OdfFormatWriter - convert pptx->odp

This commit is contained in:
ElenaSubbotina
2017-03-29 13:06:41 +03:00
parent 8525a1e9f0
commit e26cf3bf39
36 changed files with 4209 additions and 3697 deletions

View File

@ -36,7 +36,6 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/timer.hpp>
#include <iostream>
#include <string>
@ -109,6 +108,7 @@ std::wstring DetectTypeDocument(const std::wstring & pathOOX)
(res = strContentTypes.find(ppsmFormatLine))>0 || (res = strContentTypes.find(potmFormatLine))>0 ||
(res = strContentTypes.find(ppsxFormatLine)) >0 )
{
sRes = L"presentation";
}
delete []pBuffer;
@ -124,7 +124,6 @@ int _tmain(int argc, _TCHAR* argv[])
if (argc < 3) return 0;
HRESULT hr = S_OK;
boost::timer t1;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argv[2];
@ -154,7 +153,5 @@ int _tmain(int argc, _TCHAR* argv[])
NSDirectory::DeleteDirectory(dstTempPath);
////////////////////////////////////////////////////////////////////////
std::cout << "\n\nTime : " << t1.elapsed() << "\n";
return 0;
}

View File

@ -195,7 +195,7 @@
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DONT_WRITE_EMBEDDED_FONTS"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
@ -449,6 +449,14 @@
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\FontProcessor.cpp"
>
</File>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinReader\Readers.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>

View File

@ -44,7 +44,7 @@
// shapetypeHeptagon,
// shapetypeNonIsoscelesTrapezoid,
// shapetypePie,
// shapetypePieWedge,
//+ shapetypePieWedge,
//+ shapetypePlaque,
// shapetypePlaqueTabs,
// shapetypeSquareTabs,
@ -324,7 +324,7 @@ public:
}
};
class oox_shape_Gear6 : public oox_shape
class oox_shape_Gear6 : public oox_shape
{
public:
oox_shape_Gear6()
@ -411,7 +411,7 @@ public:
/////////////////////////////////////////////////////////
}
};
class oox_shape_Gear9 : public oox_shape
class oox_shape_Gear9 : public oox_shape
{
public:
oox_shape_Gear9()
@ -758,4 +758,31 @@ public:
/////////////////////////////////////////////////////////
}
};
class oox_shape_PieWedge : public oox_shape
{
public:
oox_shape_PieWedge()
{
odf_type_name =L"ooxml-PieWedge";
enhanced_path = L"M 0 ?f7 G ?f8 ?f9 ?f10 ?f11 L ?f4 ?f7 Z N";
text_areas = L"?f2 ?f3 ?f4 ?f7";
view_box = L"0 0 0 0";
add(L"f0", L"logwidth*cos(pi*(13500000)/10800000)");
add(L"f1", L"logheight*sin(pi*(13500000)/10800000)");
add(L"f2", L"logwidth+?f0 -0");
add(L"f3", L"logheight+?f1 -0");
add(L"f4", L"logwidth");
add(L"f5", L"logheight/2");
add(L"f6", L"logwidth/2");
add(L"f7", L"logheight");
add(L"f8", L"logwidth");
add(L"f9", L"logheight");
add(L"f10", L"(10800000)/60000.0");
add(L"f11", L"(5400000)/60000.0");
/////////////////////////////////////////////////////////
}
};
}

View File

@ -0,0 +1,125 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "draw_page.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include "office_elements_create.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
using namespace odf_types;
namespace odf_writer {
void draw_page_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:id", draw_id_);
CP_APPLY_ATTR(L"draw:name", draw_name_);
CP_APPLY_ATTR(L"draw:style-name", draw_style_name_);
CP_APPLY_ATTR(L"presentation:presentation-page-layout-name", page_layout_name_);
CP_APPLY_ATTR(L"draw:master-page-name", master_page_name_);
CP_APPLY_ATTR(L"presentation:use-date-time-name", use_date_time_name_);
CP_APPLY_ATTR(L"presentation:use-footer-name", use_footer_name_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_page::ns = L"draw";
const wchar_t * draw_page::name = L"page";
void draw_page::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"anim", L"par")
CP_CREATE_ELEMENT(animation_);
else
CP_CREATE_ELEMENT(content_);
}
void draw_page::add_child_element( const office_element_ptr & child_element)
{
ElementType type = child_element->get_type();
if(type == typeAnimPar)
animation_ = child_element;
else
content_.push_back(child_element);
}
void draw_page::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_page_attr_.add_attributes(Attributes);
}
void draw_page::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
for (int i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * presentation_footer_decl::ns = L"presentation";
const wchar_t * presentation_footer_decl::name = L"footer-decl";
void presentation_footer_decl::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"presentation:name", presentation_name_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * presentation_date_time_decl::ns = L"presentation";
const wchar_t * presentation_date_time_decl::name = L"date-time-decl";
void presentation_date_time_decl::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"presentation:name", presentation_name_);
CP_APPLY_ATTR(L"presentation:source", presentation_source_);
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
}
}
}

View File

@ -0,0 +1,137 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements.h"
#include "office_elements_create.h"
#include "presentationclass.h"
namespace cpdoccore {
namespace odf_writer {
class draw_page_attr
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_id_;
_CP_OPT(std::wstring) draw_style_name_;
_CP_OPT(std::wstring) page_layout_name_;
_CP_OPT(std::wstring) master_page_name_;
_CP_OPT(std::wstring) use_footer_name_;
_CP_OPT(std::wstring) use_date_time_name_;
};
class draw_page : public office_element_impl<draw_page>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeDrawPage;
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);
void add_attributes( const xml::attributes_wc_ptr & Attributes );
office_element_ptr_array content_;
office_element_ptr animation_;
draw_page_attr draw_page_attr_;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_page);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//presentation:footer-decl
class presentation_footer_decl : public office_element_impl<presentation_footer_decl>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationFooterDecl;
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){}
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(std::wstring) presentation_name_;
std::wstring text_;
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_footer_decl);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//presentation:date-time-decl
class presentation_date_time_decl : public office_element_impl<presentation_date_time_decl>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationDateTimeDecl;
CPDOCCORE_DEFINE_VISITABLE();
_CP_OPT(std::wstring) presentation_name_;
_CP_OPT(std::wstring) presentation_source_;
_CP_OPT(std::wstring) style_data_style_name_;
std::wstring text_;
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){}
void add_attributes( const xml::attributes_wc_ptr & Attributes );
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_date_time_decl);
}
}

View File

@ -228,8 +228,6 @@ namespace odf_writer
}
}
void object_files::set_content(content_content_ptr & _content)
{
content_.set_content(_content);

View File

@ -189,6 +189,11 @@ void odf_conversion_context::start_text()
create_object();
create_element(L"office", L"text", objects_.back().content, this, true);
}
void odf_conversion_context::start_presentation()
{
create_object();
create_element(L"office", L"presentation", objects_.back().content, this, true);
}
void odf_conversion_context::create_object()
{
_object obj;
@ -220,6 +225,10 @@ void odf_conversion_context::end_spreadsheet()
{
end_object();
}
void odf_conversion_context::end_presentation()
{
end_object();
}
void odf_conversion_context::end_object()
{
current_object_ = 0;//main
@ -227,6 +236,11 @@ void odf_conversion_context::end_object()
office_element_ptr & odf_conversion_context::get_current_object_element()
{
if (objects_.empty())
{
create_object();
}
return objects_[current_object_].content;
}

View File

@ -115,6 +115,9 @@ public:
void start_text();
void end_text();
void start_presentation();
void end_presentation();
void create_object();
void end_object();

View File

@ -1797,9 +1797,8 @@ void odf_drawing_context::set_textarea_wrap(bool Val)
impl_->current_graphic_properties->content().fo_wrap_option_ = wrap_option(wrap_option::NoWrap);
}
void odf_drawing_context::set_textarea_font(_CP_OPT(std::wstring) & latin, _CP_OPT(std::wstring) & cs, _CP_OPT(std::wstring) & ea)
void odf_drawing_context::set_textarea_font(std::wstring & latin, std::wstring & cs, std::wstring & ea)
{
if (!latin && !cs && !ea)return;
if (impl_->current_drawing_state_.elements_.empty())return;
if (!impl_->current_text_properties)
@ -1813,9 +1812,9 @@ void odf_drawing_context::set_textarea_font(_CP_OPT(std::wstring) & latin, _CP_O
if (!impl_->current_text_properties) return;
if (ea) impl_->current_text_properties->content().fo_font_family_ = *ea;
if (cs) impl_->current_text_properties->content().style_font_family_complex_= *cs;
if (latin) impl_->current_text_properties->content().style_font_family_asian_ = *latin;
if (!ea.empty()) impl_->current_text_properties->content().fo_font_family_ = ea;
if (!cs.empty()) impl_->current_text_properties->content().style_font_family_complex_= cs;
if (!latin.empty()) impl_->current_text_properties->content().style_font_family_asian_ = latin;
}
void odf_drawing_context::set_textarea_fontcolor(std::wstring hexColor)

View File

@ -203,7 +203,7 @@ public:
void set_textarea_writing_mode (int mode);
void set_textarea_wrap (bool val);
void set_textarea_fontcolor (std::wstring hexColor);
void set_textarea_font (_CP_OPT(std::wstring) & latin, _CP_OPT(std::wstring) & cs, _CP_OPT(std::wstring) & ea);
void set_textarea_font (std::wstring & latin, std::wstring & cs, std::wstring & ea);
//////////////////////////////////////////////////////////////////////////////////////
void start_gradient_style ();
void set_gradient_type (odf_types::gradient_style::type style);

View File

@ -0,0 +1,123 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <boost/algorithm/string.hpp>
#include "../utils.h"
#include "odp_conversion_context.h"
#include "office_presentation.h"
#include "styles.h"
#include "style_table_properties.h"
#include "odf_text_context.h"
#include "paragraph_elements.h"
#include "odf_settings_context.h"
namespace cpdoccore {
using namespace odf_types;
namespace odf_writer {
odp_conversion_context::odp_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context (PresentationDocument, outputDocument), slide_context_(*this)
//, current_text_context_(NULL)
{
}
void odp_conversion_context::start_document()
{
start_presentation();
root_presentation_ = dynamic_cast<office_presentation*>(get_current_object_element().get());
}
void odp_conversion_context::end_document()
{
odf_conversion_context::end_document();
}
void odp_conversion_context::start_slide()
{
create_element(L"draw", L"page", root_presentation_->pages_, this);
slide_context_.start_page(root_presentation_->pages_.back());
drawing_context()->set_styles_context(styles_context());
page_layout_context()->set_styles_context(styles_context());
//page_layout_context()->add_master_page(L"");
//current_table().set_table_master_page(page_layout_context()->last_master() ?
// page_layout_context()->last_master()->get_name() : L"");
}
void odp_conversion_context::end_slide()
{
slide_context_.end_page();
//
//styles_context()->reset_defaults();
}
void odp_conversion_context::start_text_context()
{
current_text_context_ = new odf_text_context(this);
}
void odp_conversion_context::end_text_context()
{
if (current_text_context_)
delete current_text_context_;
current_text_context_ = NULL;
}
void odp_conversion_context::start_drawings()
{
}
void odp_conversion_context::end_drawings()
{
current_slide().drawing_context()->clear();
}
void odp_conversion_context::start_image(const std::wstring & image_file_name)
{
std::wstring odf_ref_name ;
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage,odf_ref_name);
current_slide().drawing_context()->start_image(odf_ref_name);
}
}
}

View File

@ -0,0 +1,78 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "odf_conversion_context.h"
#include "odp_slide_context.h"
namespace cpdoccore {
namespace odf_writer {
class office_presentation;
class odf_text_context;
class odp_conversion_context : public odf_conversion_context
{
public:
odp_conversion_context(package::odf_document * outputDocument);
virtual void start_document();
virtual void end_document();
void start_slide();
void end_slide();
///////////////////////////////////////////////////////
odp_page_state & current_slide() { return slide_context_.state();}
/////////////////////////////////////////////////////
virtual void start_text_context();
virtual void end_text_context();
virtual odf_drawing_context * drawing_context() {return current_slide().drawing_context();}
virtual odf_text_context * text_context() {return current_text_context_;}
void start_drawings();
void end_drawings();
virtual void start_image(const std::wstring & image_file_name);
private:
odp_slide_context slide_context_;
odf_text_context* current_text_context_;
office_presentation* root_presentation_;
};
}
}

View File

@ -0,0 +1,101 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "logging.h"
#include <boost/algorithm/string.hpp>
#include <boost/date_time.hpp>
#include "odp_page_state.h"
#include "odf_text_context.h"
#include "odp_conversion_context.h"
#include "draw_page.h"
#include "office_annotation.h"
#include "styles.h"
#include "style_table_properties.h"
#include "style_text_properties.h"
#include "style_paragraph_properties.h"
#include "style_graphic_properties.h"
namespace cpdoccore {
using namespace odf_types;
namespace odf_writer {
///////////////////////////////////////////////////////////////
odp_page_state::odp_page_state(odf_conversion_context * Context, office_element_ptr & elm)
: context_(Context), drawing_context_(Context)
{
draw_page_ = elm;
}
void odp_page_state::set_page_name(std::wstring name)
{
office_page_name_ = name;
draw_page* page = dynamic_cast<draw_page*>(draw_page_.get());
if (page == NULL)return;
page->draw_page_attr_.draw_name_ = name;
}
void odp_page_state::set_page_master_page(std::wstring name)
{
if (!office_page_style_)return;
office_page_style_->style_master_page_name_ = name;
}
void odp_page_state::set_page_style(office_element_ptr & elm)
{
office_page_style_ = dynamic_cast<style*>(elm.get());
if (!office_page_style_)return;
draw_page* page = dynamic_cast<draw_page*>(draw_page_.get());
if (page == NULL)return;
page->draw_page_attr_.draw_style_name_ = office_page_style_->style_name_;
//потом в принципе и по имени можно будет связать(найти)
}
void odp_page_state::add_child_element( const office_element_ptr & child_element)
{
draw_page_->add_child_element(child_element);
}
}
}

View File

@ -0,0 +1,105 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <string>
#include <vector>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include"../../../Common/DocxFormat/Source/XML/Utils.h"
#include "odf_drawing_context.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf_types
{
class color;
}
namespace odf_writer {
class odp_conversion_context;
class odf_text_context;
//class table_table;
class style;
struct odp_element_state
{
office_element_ptr elm;
short repeated;
std::wstring style_name;
office_element_ptr style_elm;
};
class odp_page_state
{
public:
odp_page_state(odf_conversion_context * Context, office_element_ptr & elm);
void set_page_name(std::wstring name);
void set_page_style(office_element_ptr & _style);
void set_page_master_page(std::wstring name);
void add_child_element( const office_element_ptr & child_element);
///////////////////////////////
odf_drawing_context * drawing_context(){return &drawing_context_;}
std::wstring office_page_name_;
office_element_ptr draw_page_;
private:
odf_conversion_context * context_;
style* office_page_style_;
odf_drawing_context drawing_context_;
friend class odp_slide_context;
};
}
}

View File

@ -0,0 +1,82 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "odp_slide_context.h"
//#include "table.h"
#include "odp_conversion_context.h"
#include "logging.h"
#include <iostream>
namespace cpdoccore {
using namespace odf_types;
namespace odf_writer {
odp_slide_context::odp_slide_context(odp_conversion_context & Context): context_(Context)
{
}
odp_page_state & odp_slide_context::state()
{
return page_state_list_.back();
}
void odp_slide_context::start_page(office_element_ptr & elm)
{
page_state_list_.push_back( odp_page_state(&context_, elm) );
std::wstring style_name_new = L"ta" + boost::lexical_cast<std::wstring>(page_state_list_.size());
office_element_ptr & style = context_.styles_context()->add_or_find(style_name_new, style_family::DrawingPage, true);
style->create_child_element(L"style", L"drawing-page-properties");
state().set_page_style(style);
//для свойств страницы, а не таблицы - нужно создать master-page c page layout и связать по имени со стилем таблицы
//причем здесь, т.к. с другой стороны это ВСЕ еще свойства листа. то есть совйства листа разделить на свйства страницы и таблицы ..
//todooo
//????
}
void odp_slide_context::end_page()
{
state().drawing_context()->finalize(state().draw_page_);
}
}
}

View File

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

View File

@ -0,0 +1,94 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "office_presentation.h"
#include "draw_page.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include "office_elements_create.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace odf_writer {
// office:presentation
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * office_presentation::ns = L"office";
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)
{
ElementType type = child_element->get_type();
if (type == typePresentationDateTimeDecl)
{
date_time_decls_.push_back(child_element);
}
else if ( type == typePresentationFooterDecl)
{
footer_decls_.push_back(child_element);
}
else if ( type == typeDrawPage)
{
pages_.push_back(child_element);
}
}
void office_presentation::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
for (int i = 0; i < pages_.size(); i++)
{
pages_[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
}

View File

@ -0,0 +1,71 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <iosfwd>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf_writer {
// office:presentation
class office_presentation : public office_element_impl<office_presentation>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficePresentation;
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 date_time_decls_;
office_element_ptr_array footer_decls_;
office_element_ptr_array pages_;
};
CP_REGISTER_OFFICE_ELEMENT2(office_presentation);
}
}

View File

@ -79,6 +79,8 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
case SimpleTypes::shapetypePlaque: return boost::make_shared<oox_shape_Plaque>();
case SimpleTypes::shapetypeDoubleWave: return boost::make_shared<oox_shape_DoubleWave>();
case SimpleTypes::shapetypePieWedge: return boost::make_shared<oox_shape_PieWedge>();
//case (2001 + SimpleTypes::textshapetypeTextArchDown):

File diff suppressed because it is too large Load Diff

View File

@ -69,64 +69,15 @@ namespace cpdoccore
namespace OOX
{
class WritingElement;
class CTheme;
class IFileContainer;
class File;
namespace Drawing
{
class CDiagrammParts;
class CPresetTextShape;
class CShape;
class CLockedCanvas;
//class CObject;
class CPicture;
class CChart;
class CGraphic;
//class CDiagrammParts;
//class CPresetTextShape;
class CInline;
class CAnchor;
class CNonVisualDrawingProps;
class CShapeProperties;
class CGroupShapeProperties;
class CCustomGeometry2D;
class CPresetGeometry2D;
class CBlipFillProperties;
class CGradientFillProperties;
class CPatternFillProperties;
class CSolidColorFillProperties;
class CPath2D;
class CPath2DLineTo;
class CPath2DMoveTo;
class CPath2DArcTo;
class CPath2DQuadBezierTo;
class CPath2DCubicBezierTo;
class CPath2DClose;
class CHslColor;
class CSchemeColor;
class CScRgbColor;
class CSRgbColor;
class CSystemColor;
class CPresetColor;
class CLineProperties;
class CTextBodyProperties;
class CParagraph;
class CParagraphProperty;
class CRun;
class CRunProperty;
class CLineSpacing;
class CColor;
class CShapeStyle;
class CStyleMatrixReference;
class CEffectList;
class COuterShadowEffect;
class CInnerShadowEffect;
class CFontReference;
class CFontCollection;
namespace Colors
{
class CColorTransform;
}
}
namespace Spreadsheet
{
@ -309,12 +260,19 @@ namespace SimpleTypes
}
namespace PPTX
{
class Theme;
namespace Logic
{
class SpTreeElem;
class GraphicFrame;
class SpTree;
class Shape;
class Pic;
class Table;
class SmartArt;
class ChartRec;
class SpPr;
class Xfrm;
class ShapeStyle;
class PrstTxWarp;
class PrstGeom;
@ -324,6 +282,8 @@ namespace PPTX
class SolidFill;
class PattFill;
class EffectLst;
class FontRef;
class StyleRef;
class Ln;
class Path2D;
class PathBase;
@ -336,6 +296,7 @@ namespace PPTX
class CNvSpPr;
class NvPr;
class Paragraph;
class TxBody;
class TextParagraphPr;
class TextSpacing;
class RunProperties;
@ -344,9 +305,12 @@ namespace PPTX
class Br;
class MathParaWrapper;
class NvGraphicFramePr;
class Table;
class ChartRec;
class SmartArt;
class LineTo;
class MoveTo;
class ArcTo;
class QuadBezTo;
class CubicBezTo;
class Close;
}
}
@ -358,7 +322,7 @@ public:
virtual void convertDocument() = 0;
virtual void write(const std::wstring & path) = 0;
OoxConverter(const ProgressCallback* CallBack = NULL){ oox_current_child_document_spreadsheet = NULL;
OoxConverter(const ProgressCallback* CallBack = NULL){
oox_current_child_document = NULL;
pCallBack = CallBack;
@ -377,67 +341,25 @@ public:
//.......................................................................................................................
virtual cpdoccore::odf_writer::odf_conversion_context *odf_context() = 0;
virtual OOX::CTheme *oox_theme() = 0;
virtual PPTX::Theme *oox_theme() = 0;
virtual std::wstring find_link_by_id(std::wstring sId, int t) = 0;
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId) = 0;
OOX::Spreadsheet::IFileContainer *oox_current_child_document_spreadsheet;
OOX::IFileContainer *oox_current_child_document;
void convert (double oox_font_size, _CP_OPT(cpdoccore::odf_types::font_size) & odf_font_size);
bool convert (int indexSchemeColor, BYTE& ucA, BYTE& ucG, BYTE& ucB, BYTE& ucR);
bool convert (std::wstring sSchemeColor, DWORD & argb);
//.......................................................................................................................
void convert(OOX::WritingElement *oox_unknown);
//.drawing......................................................................................................................
void convert(OOX::Drawing::CDiagrammParts *oox_diagramm);
void convert(OOX::Drawing::CLockedCanvas *oox_canvas);
void convert(OOX::Drawing::CShape *oox_shape);
void convert(OOX::Drawing::CNonVisualDrawingProps *oox_cnvPr);
void convert(OOX::Drawing::CShapeProperties *oox_spPr, OOX::Drawing::CShapeStyle* oox_sp_style = NULL);
void convert(OOX::Drawing::CGroupShapeProperties *oox_groupSpPr);
void convert(OOX::Drawing::CTextBodyProperties *oox_bodyPr);
void convert(OOX::Drawing::CCustomGeometry2D *oox_cust_geom);
void convert(OOX::Drawing::CPresetGeometry2D *oox_prst_geom);
int convert(OOX::Drawing::CPresetTextShape *oox_text_preset);
void convert(OOX::Drawing::CLineProperties *oox_line_prop, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CGradientFillProperties *oox_grad_fill , std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CPatternFillProperties *oox_pattern_fill, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fill , std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CEffectList *oox_effect_list, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::COuterShadowEffect *oox_shadow, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CInnerShadowEffect *oox_shadow, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CFontCollection *style_font, std::wstring *change_sheme_color = NULL);
void convert(OOX::Drawing::CFontReference *style_font_ref);
void convert(OOX::Drawing::CStyleMatrixReference *style_matrix_ref);
void convert(OOX::Drawing::CPath2D *oox_geom_path);
void convert(OOX::Drawing::CPath2DLineTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DMoveTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DArcTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DQuadBezierTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DCubicBezierTo *oox_geom_path);
void convert(OOX::Drawing::CPath2DClose *oox_geom_path);
void convert(OOX::Drawing::CColor *oox_color, std::wstring & hexColor , _CP_OPT(double) &opacity);
void convert(OOX::Drawing::CSchemeColor *oox_ShemeClr, std::wstring & hexString, _CP_OPT(double) &opacity);
void convert(OOX::Drawing::Colors::CColorTransform *oox_ScrgbClr, std::wstring & hexString, _CP_OPT(double) &opacity);
void convert(OOX::Drawing::CSolidColorFillProperties *oox_solid_fill,std::wstring & hexColor , _CP_OPT(double) &opacity);
void convert(OOX::Drawing::CParagraph *oox_paragraph);
void convert(OOX::Drawing::CParagraphProperty *oox_paragraph_pr, cpdoccore::odf_writer::style_paragraph_properties * paragraph_properties);
void convert(OOX::Drawing::CRun *oox_run);
void convert(OOX::Drawing::CRunProperty *oox_run_pr, cpdoccore::odf_writer::style_text_properties * text_properties);
void convert(OOX::Drawing::CLineSpacing *oox_spacing, cpdoccore::odf_types::length_or_percent & length_or_percent);
//drawingML & pptx................................................................................................................................
void convert(PPTX::Logic::SpTreeElem *oox_element);
void convert(PPTX::Logic::GraphicFrame *oox_graphicFrame);
void convert(PPTX::Logic::SpTree *oox_shape_tree);
void convert(PPTX::Logic::Shape *oox_shape);
void convert(PPTX::Logic::Pic *oox_pic);
void convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle* oox_sp_style = NULL);
void convert(PPTX::Logic::TextSpacing *oox_spacing, cpdoccore::odf_types::length_or_percent & length_or_percent);
void convert(PPTX::Logic::Xfrm *oox_xfrm);
int convert(PPTX::Logic::PrstTxWarp *oox_text_preset);
void convert(PPTX::Logic::PrstGeom *oox_geom);
void convert(PPTX::Logic::CustGeom *oox_geom);
@ -447,10 +369,12 @@ public:
void convert(PPTX::Logic::PattFill *oox_fill);
void convert(PPTX::Logic::EffectLst *oox_effect_lst);
void convert(PPTX::Logic::Ln *oox_line);
void convert(PPTX::Logic::FontRef *oox_fontRef);
void convert(PPTX::Logic::StyleRef *oox_styleRef);
void convert(PPTX::Logic::Path2D *oox_path2D);
void convert(PPTX::Logic::PathBase *oox_path);
void convert(PPTX::Logic::BodyPr *oox_bodyPr);
void convert(PPTX::Logic::UniFill *oox_fill, PPTX::Logic::ShapeStyle* oox_sp_style = NULL);
void convert(PPTX::Logic::UniFill *oox_fill, PPTX::Logic::ShapeStyle* oox_style = NULL);
void convert(PPTX::Logic::UniColor *color, std::wstring & hexString, _CP_OPT(double) & opacity);
void convert(PPTX::Logic::NvSpPr *oox_nvSpPr);
void convert(PPTX::Logic::CNvPr *oox_cnvPr);
@ -462,11 +386,18 @@ public:
void convert(PPTX::Logic::Run *oox_run);
void convert(PPTX::Logic::Fld *oox_fld);
void convert(PPTX::Logic::Br *oox_br);
void convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeStyle* oox_style = NULL);
void convert(PPTX::Logic::MathParaWrapper *oox_math);
void convert(PPTX::Logic::NvGraphicFramePr *oox_framePr);
void convert(PPTX::Logic::ChartRec *oox_chart);
void convert(PPTX::Logic::SmartArt *oox_smart_art);
void convert(PPTX::Logic::Table *oox_table);
void convert(PPTX::Logic::LineTo *oox_geom_path);
void convert(PPTX::Logic::MoveTo *oox_geom_path);
void convert(PPTX::Logic::ArcTo *oox_geom_path);
void convert(PPTX::Logic::QuadBezTo *oox_geom_path);
void convert(PPTX::Logic::CubicBezTo *oox_geom_path);
void convert(PPTX::Logic::Close *oox_geom_path);
//.chart............................................................................................................................
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title);

View File

@ -35,6 +35,7 @@
#include "../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Logic/Pict.h"
#include "VmlShapeTypes2Oox.h"
@ -94,7 +95,7 @@ odf_writer::odf_conversion_context* DocxConverter::odf_context()
{
return odt_context;
}
OOX::CTheme* DocxConverter::oox_theme()
PPTX::Theme* DocxConverter::oox_theme()
{
if (docx_document)
return docx_document->GetTheme();
@ -109,8 +110,6 @@ NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
smart_ptr<OOX::File> oFile;
if (oox_doc)
{
if (oox_current_child_document_spreadsheet)
oFile = oox_current_child_document_spreadsheet->Find(sId);
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else
@ -128,25 +127,6 @@ std::wstring DocxConverter::find_link_by_id (std::wstring sId, int type)
std::wstring ref;
if (ref.empty() && oox_current_child_document_spreadsheet)
{
smart_ptr<OOX::File> oFile = oox_current_child_document_spreadsheet->Find(sId);
if (oFile.IsInit())
{
if (type==1 && OOX::FileTypes::Image == oFile->type())
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
if (type==2 && oFile.IsInit() && OOX::FileTypes::HyperLink == oFile->type())
{
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
ref = pHyperlink->Uri().GetPath();
}
}
}
if (ref.empty() && oox_current_child_document)
{
smart_ptr<OOX::File> oFile = oox_current_child_document->Find(sId);
@ -326,41 +306,40 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CDrawing* pDrawing= static_cast<OOX::Logic::CDrawing*>(oox_unknown);
convert(pDrawing);
}break;
case OOX::et_c_chart:
{
OOX::Drawing::CChart* pChart = static_cast<OOX::Drawing::CChart*>(oox_unknown);
convert(pChart);
}break;
case OOX::et_w_Shape:
{
OOX::Logic::CShape* pShape = static_cast<OOX::Logic::CShape*>(oox_unknown);
convert(pShape);
}break;
case OOX::et_w_pict:
{
OOX::Logic::CPicture* pPic = static_cast<OOX::Logic::CPicture*>(oox_unknown);
convert(pPic);
}break;
case OOX::et_w_object:
{
OOX::Logic::CObject* pObj = static_cast<OOX::Logic::CObject*>(oox_unknown);
convert(pObj);
}break;
//case OOX::et_c_chart:
//{
// PPTX::Logic::ChartRec* pChart = static_cast<PPTX::Logic::ChartRec*>(oox_unknown);
// convert(pChart);
//}break;
//case OOX::et_w_Shape:
//{
// OOX::Logic::CShape* pShape = static_cast<OOX::Logic::CShape*>(oox_unknown);
// convert(pShape);
//}break;
//case OOX::et_w_pict:
//{
// OOX::Logic::CPicture* pPic = static_cast<OOX::Logic::CPicture*>(oox_unknown);
// convert(pPic);
//}break;
//case OOX::et_w_object:
//{
// OOX::Logic::CObject* pObj = static_cast<OOX::Logic::CObject*>(oox_unknown);
// convert(pObj);
//}break;
case OOX::et_pic_pic:
case OOX::et_pic:
case OOX::et_p_pic:
{
OOX::Drawing::CPicture* pPic = static_cast<OOX::Drawing::CPicture*>(oox_unknown);
PPTX::Logic::Pic* pPic = static_cast<PPTX::Logic::Pic*>(oox_unknown);
convert(pPic);
}break;
case OOX::et_w_GroupShape:
case OOX::et_p_ShapeTree:
{
OOX::Logic::CGroupShape* pGroupShape= static_cast<OOX::Logic::CGroupShape*>(oox_unknown);
PPTX::Logic::SpTree* pGroupShape= static_cast<PPTX::Logic::SpTree*>(oox_unknown);
convert(pGroupShape);
}break;
case OOX::et_w_LockedCanvas:
{
OOX::Logic::CLockedCanvas* pLockedCanvas= static_cast<OOX::Logic::CLockedCanvas*>(oox_unknown);
convert(pLockedCanvas);
}break;
case OOX::et_w_commentRangeEnd:
{
OOX::Logic::CCommentRangeEnd* pCommEnd = static_cast<OOX::Logic::CCommentRangeEnd*>(oox_unknown);
@ -1201,14 +1180,14 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
if (oox_paragraph_pr->m_oTextAlignment.IsInit() && oox_paragraph_pr->m_oTextAlignment->m_oVal.IsInit())
{
switch(oox_paragraph_pr->m_oTextAlignment->m_oVal->GetValue())
{
//case SimpleTypes::textalignAuto :
//case SimpleTypes::textalignBaseLine :
//case SimpleTypes::textalignBottom :
//case SimpleTypes::textalignCenter :
//case SimpleTypes::textalignTop :
}
//switch(oox_paragraph_pr->m_oTextAlignment->m_oVal->GetValue())
//{
////case SimpleTypes::textalignAuto :
////case SimpleTypes::textalignBaseLine :
////case SimpleTypes::textalignBottom :
////case SimpleTypes::textalignCenter :
////case SimpleTypes::textalignTop :
//}
}
//if (oox_paragraph_pr->m_oWordWrap.IsInit()) odt_context->set_word_wrap(oox_paragraph_pr->m_oWordWrap->ToBool());
@ -2256,7 +2235,7 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
if (oox_font_theme == NULL) return;
OOX::CTheme * docx_theme= docx_document->GetTheme();
PPTX::Theme * docx_theme= docx_document->GetTheme();
if (docx_theme == NULL) return;
std::wstring font;
@ -2265,47 +2244,29 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
case SimpleTypes::themeMajorAscii:
case SimpleTypes::themeMajorHAnsi :
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace.IsInit())
{
font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace->GetValue();
if (font.length() > 0) odf_font_name = font;
}
font = docx_theme->themeElements.fontScheme.majorFont.latin.typeface;
if (font.length() > 0) odf_font_name = font;
break;
case SimpleTypes::themeMajorBidi:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace.IsInit())
{
font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace->GetValue();
if (font.length() > 0) odf_font_name = font;
}
font = docx_theme->themeElements.fontScheme.majorFont.cs.typeface;
if (font.length() > 0) odf_font_name = font;
break;
case SimpleTypes::themeMajorEastAsia:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace.IsInit())
{
font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace->GetValue();
if (font.length() > 0) odf_font_name = font;
}
font = docx_theme->themeElements.fontScheme.majorFont.ea.typeface;
if (font.length() > 0) odf_font_name = font;
break;
case SimpleTypes::themeMinorAscii:
case SimpleTypes::themeMinorHAnsi:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace.IsInit())
{
font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace->GetValue();
if (font.length() > 0) odf_font_name = font;
}
font = docx_theme->themeElements.fontScheme.minorFont.latin.typeface;
if (font.length() > 0) odf_font_name = font;
break;
case SimpleTypes::themeMinorBidi:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace.IsInit())
{
font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace->GetValue();
if (font.length() > 0) odf_font_name = font;
}
font = docx_theme->themeElements.fontScheme.minorFont.cs.typeface;
if (font.length() > 0) odf_font_name = font;
break;
case SimpleTypes::themeMinorEastAsia:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace.IsInit())
{
font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace->GetValue();
if (font.length() > 0) odf_font_name = font;
}
font = docx_theme->themeElements.fontScheme.minorFont.ea.typeface;
if (font.length() > 0) odf_font_name = font;
break;
}
@ -2736,7 +2697,8 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
odf_context()->drawing_context()->set_z_order(id);
}
OoxConverter::convert(oox_anchor->m_oDocPr.GetPointer());
convert(oox_anchor->m_oGraphic.GetPointer());
convert(&oox_anchor->m_oGraphic);
odf_context()->drawing_context()->check_anchor();
}
@ -2768,246 +2730,7 @@ void DocxConverter::convert(OOX::Drawing::CInline *oox_inline)
odt_context->drawing_context()->set_vertical_pos(1);//middle
OoxConverter::convert(oox_inline->m_oDocPr.GetPointer());
convert(oox_inline->m_oGraphic.GetPointer());
}
void DocxConverter::convert(OOX::Drawing::CGraphic *oox_graphic)
{
if (oox_graphic == NULL)return;
for (unsigned int i = 0 ; i < oox_graphic->m_arrItems.size(); i++)
{
convert(oox_graphic->m_arrItems[i]);
}
}
void DocxConverter::convert(OOX::Drawing::CPicture * oox_picture)
{
if (!oox_picture)return;
odt_context->drawing_context()->start_drawing();
std::wstring pathImage;
double Width=0, Height = 0;
if (oox_picture->m_oBlipFill.m_oBlip.IsInit())
{
std::wstring sID = oox_picture->m_oBlipFill.m_oBlip->m_oEmbed.GetValue();
pathImage = find_link_by_id(sID,1);
if (pathImage.empty())
{
sID = oox_picture->m_oBlipFill.m_oBlip->m_oLink.GetValue();
//???
}
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
}
odt_context->start_image(pathImage);
{
if (oox_picture->m_oBlipFill.m_oTile.IsInit())
{
odt_context->drawing_context()->set_image_style_repeat(2);
}
if (oox_picture->m_oBlipFill.m_oStretch.IsInit())
{
odt_context->drawing_context()->set_image_style_repeat(1);
}
if (oox_picture->m_oBlipFill.m_oSrcRect.IsInit() && Width >0 && Height >0)
{
odt_context->drawing_context()->set_image_client_rect_inch(
oox_picture->m_oBlipFill.m_oSrcRect->m_oL.GetValue() * Width/100. /currentSystemDPI,
oox_picture->m_oBlipFill.m_oSrcRect->m_oT.GetValue() * Height/100./currentSystemDPI,
oox_picture->m_oBlipFill.m_oSrcRect->m_oR.GetValue() * Width/100. /currentSystemDPI,
oox_picture->m_oBlipFill.m_oSrcRect->m_oB.GetValue() * Height/100./currentSystemDPI);
}
OoxConverter::convert(&oox_picture->m_oNvPicPr.m_oCNvPr);
//oox_picture->m_oNvPicPr.m_oCNvPicPr
//oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks
{
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoChangeAspect)
//{
//}
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoCrop))
//{
//}
//if (oox_picture->m_oNvPicPr.m_oCNvPicPr.m_oPicLocks->m_oNoResize)
//{
//}
}
//m_oExtLst
OoxConverter::convert(&oox_picture->m_oSpPr, NULL);
}
odt_context->drawing_context()->end_image();
odt_context->drawing_context()->end_drawing();
}
void DocxConverter::convert(OOX::Drawing::CChart * oox_chart)
{
if (oox_chart == NULL)return;
if (oox_chart->m_oRId.IsInit())
{
smart_ptr<OOX::File> oFile;
if (oox_current_child_document)
oFile = oox_current_child_document->Find(oox_chart->m_oRId->GetValue());
else
oFile = docx_document->GetDocument()->Find(oox_chart->m_oRId->GetValue());
if (oFile.IsInit() && OOX::FileTypes::Chart == oFile->type())
{
OOX::Spreadsheet::CChartSpace* pChart = (OOX::Spreadsheet::CChartSpace*)oFile.operator->();
if (pChart)
{
odt_context->drawing_context()->start_drawing();
odt_context->drawing_context()->start_object(odf_context()->get_next_name_object());
_CP_OPT(double) width, height;
odt_context->drawing_context()->get_size(width, height);
OoxConverter::convert(pChart->m_oChartSpace.m_oSpPr.GetPointer());
oox_current_child_document_spreadsheet = dynamic_cast<OOX::Spreadsheet::IFileContainer*>(pChart);
odf_context()->start_chart();
odf_context()->chart_context()->set_chart_size(width, height);
OoxConverter::convert(&pChart->m_oChartSpace);
odf_context()->end_chart();
oox_current_child_document_spreadsheet = NULL;
odt_context->drawing_context()->end_object();
odt_context->drawing_context()->end_drawing();
}
}
}
}
void DocxConverter::convert(OOX::Logic::CGroupShape *oox_group_shape)
{
if (oox_group_shape == NULL)return;
if (oox_group_shape->m_arrItems.size() < 1) return;
odt_context->drawing_context()->start_group();
if (oox_group_shape->m_oCNvPr.IsInit())
{
if (oox_group_shape->m_oCNvPr->m_sName.IsInit())
odt_context->drawing_context()->set_group_name(*oox_group_shape->m_oCNvPr->m_sName);
if (oox_group_shape->m_oCNvPr->m_oId.IsInit())
odt_context->drawing_context()->set_group_z_order(oox_group_shape->m_oCNvPr->m_oId->GetValue());
}
OoxConverter::convert(oox_group_shape->m_oGroupSpPr.GetPointer());
for (unsigned int i=0; i < oox_group_shape->m_arrItems.size(); i++)
{
convert(oox_group_shape->m_arrItems[i]);
}
odt_context->drawing_context()->end_group();
}
void DocxConverter::convert(OOX::Logic::CLockedCanvas *oox_canvas)
{
if (oox_canvas== NULL)return;
odf_context()->drawing_context()->start_group();
_CP_OPT(double) x, y , ch_x , ch_y ;
odf_context()->drawing_context()->set_group_position(x, y, ch_x, ch_y);
for (unsigned int i=0; i < oox_canvas->m_arrItems.size(); i++)
{
convert(oox_canvas->m_arrItems[i]);
}
odf_context()->drawing_context()->end_group();
}
void DocxConverter::convert(OOX::Logic::CShape *oox_shape)
{
if (oox_shape == NULL)return;
if (!oox_shape->m_oSpPr.IsInit()) return;
odt_context->drawing_context()->start_drawing();
int type = -1;
if (oox_shape->m_oSpPr->m_oCustGeom.IsInit())
{
type = 1000;//6???
}
if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
{
OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
type =(geometry->m_oPrst.GetValue());
}
if (oox_shape->m_oCNvSpPr.IsInit() && oox_shape->m_oCNvSpPr->m_otxBox.GetValue() == 1) type = 2000; //textBox
if (type == SimpleTypes::shapetypeRect && oox_shape->m_oTxBody.IsInit() && oox_shape->m_oTxBodyProperties.IsInit() /*&&
oox_shape->m_oTxBodyProperties->m_eAutoFitType == OOX::Drawing::textautofitShape*/)
{ // ваще то тут обычный прямоугольник, но в него не вставишь таблицы, ...
//второй вариант таблицы ВСЕГДА оборачивать фреймами.
//надо тогда хотя бы сделать определялку где мы находимся - в drawing_context или нет - причем пофиг на уровень вложенности
//todoo
type = 2000;
}
if ((type == 2000 || type == SimpleTypes::shapetypeRect ) && oox_shape->m_oTxBodyProperties.IsInit()
&& oox_shape->m_oTxBodyProperties->m_oPrstTxWrap.IsInit())
{
if (oox_shape->m_oTxBodyProperties->m_oFromWordArt.ToBool())
{
int wordart_type = OoxConverter::convert(oox_shape->m_oTxBodyProperties->m_oPrstTxWrap.GetPointer());
if (wordart_type >=0)type = wordart_type;
}
}
if (type < 0)return;
/////////////////////////////////////////////////////////////////////////////////
odt_context->drawing_context()->start_shape(type);
OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//имя, описалово, номер ...
OoxConverter::convert(oox_shape->m_oCNvPr.GetPointer());
//заблокированности
OoxConverter::convert(oox_shape->m_oCNvSpPr.GetPointer());
if (oox_shape->m_oCNvConnSpPr.IsInit())
{
OoxConverter::convert(oox_shape->m_oCNvConnSpPr.GetPointer());
//частенько приплывает из стиля заполенение объекта .. а он то одномерный :)
odf_context()->drawing_context()->start_area_properties();
odf_context()->drawing_context()->set_no_fill();
odf_context()->drawing_context()->end_area_properties();
}
if (oox_shape->m_oTxBody.IsInit() && oox_shape->m_oTxBody->m_oTxtbxContent.IsInit())
{
odt_context->start_text_context();
for (unsigned int i=0 ; i < oox_shape->m_oTxBody->m_oTxtbxContent->m_arrItems.size();i++)
{
convert(oox_shape->m_oTxBody->m_oTxtbxContent->m_arrItems[i]);
}
odt_context->drawing_context()->set_text( odt_context->text_context());
//наложим внешние настройки для текста
OoxConverter::convert(oox_shape->m_oTxBodyProperties.GetPointer());
if (oox_shape->m_oShapeStyle.IsInit() && oox_shape->m_oShapeStyle->m_oFontRef.getType() == OOX::et_a_fontRef)
{
OoxConverter::convert(&oox_shape->m_oShapeStyle->m_oFontRef);
}
odt_context->end_text_context();
}
odt_context->drawing_context()->end_shape();
odt_context->drawing_context()->end_drawing();
convert(&oox_inline->m_oGraphic);
}
void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
@ -3017,62 +2740,18 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
{
odf_color = boost::none;
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
bool result = false;
if(color && color->GetValue() == SimpleTypes::hexcolorRGB)//easy, faster,realy !!
{
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
ucR = color->Get_R();
ucB = color->Get_B();
ucG = color->Get_G();
ucA = color->Get_A();
result = true;
}
if(theme_color && result == false)
{
OOX::CTheme * docx_theme= docx_document->GetTheme();
int theme_ind = theme_color->GetValue();
switch(theme_ind)
{
case SimpleTypes::themecolorLight1:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oLt1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorLight2:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oLt2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorDark1:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oDk1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorDark2:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oDk2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent1:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oAccent1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent2:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oAccent2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent3:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oAccent3.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent4:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oAccent4.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent5:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oAccent5.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorAccent6:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oAccent6.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorFollowedHyperlink:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oFolHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::themecolorHyperlink:
result = docx_theme->m_oThemeElements.m_oClrScheme.m_oHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
}
if (result == true && theme_tint)
{
OOX::Drawing::CHslColor col;
col.SetRGBA(ucR, ucG, ucB);
double dH, dS, dL;
col.GetHSL(dH, dS,dL);
dL = dL * theme_tint->GetValue()/255. + (1 - theme_tint->GetValue()/255.);
col.SetHSL(dH, dS,dL);
col.GetRGBA(ucR, ucG, ucB,ucA);
}
}
if (result == true)
{
SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR,ucG,ucB);
SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR, ucG, ucB);
if ((oRgbColor) && (oRgbColor->GetValue() == SimpleTypes::hexcolorRGB ))
{
@ -3080,6 +2759,24 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
odf_color = odf_types::color(strColor);
delete oRgbColor;
result = true;
}
}
if(theme_color && result == false)
{
PPTX::Theme * docx_theme= docx_document->GetTheme();
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_theme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
if (pFind != docx_theme->themeElements.clrScheme.Scheme.end())
{
PPTX::Logic::UniColor & color = pFind->second;
DWORD argb = color.GetARGB();
std::wstring strColor = XmlUtils::IntToString(argb & 0x00FFFFFF, L"#%06X");
odf_color = odf_types::color(strColor);
}
}
}

View File

@ -68,8 +68,9 @@ namespace OOX
class CText;
class CAlternateContent;
class CDrawing;
class CGroupShape;
class CShape;
// class CGroupShape;
// class CShape;
class CControl;
class CPicture;
class CObject;
class CPBdr;
@ -146,7 +147,7 @@ namespace Oox2Odf
virtual void write(const std::wstring & path);
virtual odf_writer::odf_conversion_context *odf_context();
virtual OOX::CTheme *oox_theme();
virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t);
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId);
@ -214,17 +215,11 @@ namespace Oox2Odf
void convert(OOX::Logic::CAlternateContent *oox_alt_content);
void convert(OOX::Logic::CDrawing *oox_drawing);
void convert(OOX::Logic::CGroupShape *oox_group_shape);
void convert(OOX::Logic::CShape *oox_shape);
void convert(OOX::Logic::CPicture *oox_picture);
void convert(OOX::Logic::CLockedCanvas *oox_canvas);
void convert(OOX::Logic::CPicture *oox_pict);
void convert(OOX::Logic::CObject *oox_obj);
void convert(OOX::Drawing::CAnchor *oox_anchor);
void convert(OOX::Drawing::CInline *oox_inline);
void convert(OOX::Drawing::CGraphic *oox_graphic);
void convert(OOX::Drawing::CChart *oox_chart);
void convert(OOX::Drawing::CPicture *oox_picture);
void convert(SimpleTypes::CTheme<> *oox_font_theme,_CP_OPT(std::wstring) & odf_font_name);
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf_types::color) & odf_color);

View File

@ -0,0 +1,268 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "PptxConverter.h"
#include "../utils.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Folder.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Presentation.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h"
#include <boost/lexical_cast.hpp>
#include "../OdfFormat/odp_conversion_context.h"
#include "../OdfFormat/odf_text_context.h"
#include "../OdfFormat/odf_drawing_context.h"
#include "../OdfFormat/styles.h"
#include "../OdfFormat/style_table_properties.h"
#include "../OdfFormat/style_text_properties.h"
#include "../OdfFormat/style_paragraph_properties.h"
#include "../OdfFormat/style_graphic_properties.h"
#include "../OdfFormat/styles_list.h"
using namespace cpdoccore;
namespace Oox2Odf
{
PptxConverter::PptxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{
const OOX::CPath oox_path(std::wstring(path.c_str()));
pptx_document = new PPTX::Folder();
if (!pptx_document->isValid(oox_path.GetPath())) // true ???
{
delete pptx_document;
return;
}
pptx_document->read(oox_path.GetPath() + FILE_SEPARATOR_STR, NULL);
smart_ptr<PPTX::Presentation> presentation_ptr = pptx_document->Get(OOX::Presentation::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>();
if (!presentation_ptr.is_init())
{
delete pptx_document;
return;
}
presentation = presentation_ptr.operator->();
output_document = new odf_writer::package::odf_document(L"presentation");
odp_context = new odf_writer::odp_conversion_context(output_document);
current_slide = NULL;
current_theme = NULL;
pCallBack = CallBack;
if (UpdateProgress(290000))return;
}
PptxConverter::~PptxConverter()
{
current_slide = NULL;
current_theme = NULL;
presentation = NULL;
if (odp_context) delete odp_context; odp_context = NULL;
if (pptx_document) delete pptx_document; pptx_document = NULL;
if (output_document) delete output_document; output_document = NULL;
}
void PptxConverter::write(const std::wstring & path)
{
if (!output_document)return;
output_document->write(path);
if (UpdateProgress(1000000))return;
}
odf_writer::odf_conversion_context* PptxConverter::odf_context()
{
return odp_context;
}
PPTX::Theme* PptxConverter::oox_theme()
{
return current_theme;
}
NSCommon::smart_ptr<OOX::File> PptxConverter::find_file_by_id(std::wstring sId)
{
smart_ptr<OOX::File> oFile;
if (pptx_document)
{
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else if (current_slide)
oFile = current_slide->Find(sId);
else
oFile = pptx_document->Find(sId);
}
return oFile;
}
std::wstring PptxConverter::find_link_by_id (std::wstring sId, int type)
{
std::wstring ref;
if (ref.empty() && oox_current_child_document)
{
smart_ptr<OOX::File> oFile = oox_current_child_document->Find(sId);
if (oFile.IsInit())
{
if (type==1 && OOX::FileTypes::Image == oFile->type())
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
if (type==2 && oFile.IsInit() && OOX::FileTypes::HyperLink == oFile->type())
{
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
ref = pHyperlink->Uri().GetPath();
}
}
}
smart_ptr<OOX::File> oFile = current_slide ? current_slide->Find(sId) : pptx_document->Find(sId);
if (ref.empty() && oFile.IsInit())
{
if (type==1 && OOX::FileTypes::Image == oFile->type())
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
if (type == 2 && OOX::FileTypes::HyperLink == oFile->type())
{
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
ref = pHyperlink->Uri().GetPath();
}
}
return ref;
}
void PptxConverter::convertDocument()
{
if (!pptx_document) return;
if (!odp_context) return;
odp_context->start_document();
if (UpdateProgress(300000))return;
//convert_settings();
convert_slides();
if (UpdateProgress(800000))return;
//удалим уже ненужный документ pptx
delete pptx_document; pptx_document = NULL;
odp_context->end_document();
if (UpdateProgress(850000))return;
}
void PptxConverter::convert_slides()
{
for (size_t i = 0; i < presentation->sldIdLst.size(); ++i)
{
std::wstring rId = presentation->sldIdLst[i].rid.get();
smart_ptr<PPTX::Slide> slide = ((*presentation)[rId]).smart_dynamic_cast<PPTX::Slide>();
if (slide.IsInit() == false)
{
continue;// странное ... слайд 38 в FY10_September_Partner_Call.pptx
}
current_slide = slide.operator->();
current_theme = slide->theme.operator->();
//smart_ptr<SlideLayout> Layout;
//smart_ptr<SlideMaster> Master;
odp_context->start_slide();
convert(slide->cSld.GetPointer());
//nullable_bool show;
//nullable_bool showMasterPhAnim;
//nullable_bool showMasterSp;
//nullable<Logic::ClrMapOvr> clrMapOvr;
//nullable<Logic::CSld> cSld;
//nullable<Logic::Transition> transition;
//nullable<Logic::Timing> timing;
//smart_ptr<NotesSlide> Note;
//smart_ptr<Theme> theme;
//smart_ptr<OOX::CVmlDrawing> Vml;
//smart_ptr<TableStyles> tableStyles_;
//smart_ptr<PPTX::Comments> comments;
odp_context->end_slide();
}
}
void PptxConverter::convert(OOX::WritingElement *oox_unknown)
{
if (oox_unknown == NULL)return;
switch(oox_unknown->getType())
{
default:
{
OoxConverter::convert(oox_unknown);
}break;
}
}
void PptxConverter::convert(PPTX::Logic::CSld *slide)
{
if (slide == NULL) return;
if (slide->attrName.IsInit())
odp_context->current_slide().set_page_name(slide->attrName.get());
for (size_t i = 0 ; i < slide->spTree.SpTreeElems.size(); i++)
{
convert(slide->spTree.SpTreeElems[i].GetElem().operator->());
}
//nullable<Bg> bg;
//nullable<Controls> controls;
}
}

View File

@ -0,0 +1,111 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Converter.h"
#include <boost/foreach.hpp>
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPOptional.h>
#include "../../../Common/DocxFormat/Source/Common/SimpleTypes_Word.h"
namespace OOX
{
class CTheme;
}
namespace PPTX
{
class Presentation;
class Folder;
namespace Logic
{
class CSld;
class Transition;
class Timing;
}
}
namespace cpdoccore
{
namespace odf_writer
{
namespace package
{
class odf_document;
}
class ods_conversion_context;
class odf_conversion_context;
class odt_conversion_context;
class odp_conversion_context;
}
}
using namespace cpdoccore;
namespace Oox2Odf
{
class PptxConverter : public OoxConverter
{
public:
PptxConverter(const std::wstring & path, const ProgressCallback* ffCallBack);
~PptxConverter();
virtual void convertDocument();
virtual void write(const std::wstring & path);
virtual odf_writer::odf_conversion_context *odf_context();
virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t);
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id (std::wstring sId);
void convert(OOX::WritingElement *oox_unknown);
void convert(PPTX::Logic::CSld *slide);
private:
PPTX::Folder *pptx_document;
PPTX::Presentation *presentation;
cpdoccore::odf_writer::package::odf_document *output_document;
PPTX::Theme *current_theme;
OOX::IFileContainer *current_slide;
odf_writer::odp_conversion_context *odp_context;
void convert_slides ();
//--------------------------------------------------------------------------------
};
}

View File

@ -87,7 +87,7 @@ odf_writer::odf_conversion_context* XlsxConverter::odf_context()
{
return ods_context;
}
OOX::CTheme* XlsxConverter::oox_theme()
PPTX::Theme* XlsxConverter::oox_theme()
{
if (xlsx_document)
return xlsx_document->GetTheme();
@ -102,8 +102,6 @@ smart_ptr<OOX::File> XlsxConverter::find_file_by_id(std::wstring sId)
oFile = xlsx_current_container->Find(sId);
else if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else if (oox_current_child_document_spreadsheet)
oFile = oox_current_child_document_spreadsheet->Find(sId);
return oFile;
}
@ -116,9 +114,9 @@ std::wstring XlsxConverter::find_link_by_id (std::wstring sId, int type)
if (ref.empty() && xlsx_current_container)
{
smart_ptr<OOX::File> oFile = xlsx_current_container->Find(sId);
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Image == oFile->type())
if (oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
{
OOX::Spreadsheet::Image* pImage = (OOX::Spreadsheet::Image*)oFile.operator->();
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
@ -126,19 +124,9 @@ std::wstring XlsxConverter::find_link_by_id (std::wstring sId, int type)
if (ref.empty() && oox_current_child_document)
{
smart_ptr<OOX::File> oFile = oox_current_child_document->Find(sId);
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Image == oFile->type())
if (oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
{
OOX::Spreadsheet::Image* pImage = (OOX::Spreadsheet::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
}
if (ref.empty() && oox_current_child_document_spreadsheet)
{
smart_ptr<OOX::File> oFile = oox_current_child_document_spreadsheet->Find(sId);
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Image == oFile->type())
{
OOX::Spreadsheet::Image* pImage = (OOX::Spreadsheet::Image*)oFile.operator->();
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
@ -338,9 +326,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
if ((pTableFile) && (pTableFile->m_oTable.IsInit()))
{
oox_current_child_document_spreadsheet = dynamic_cast<OOX::Spreadsheet::IFileContainer*>(pTableFile);
oox_current_child_document = dynamic_cast<OOX::IFileContainer*>(pTableFile);
convert(pTableFile->m_oTable.GetPointer());
oox_current_child_document_spreadsheet = NULL;
oox_current_child_document = NULL;
}
}
}
@ -562,27 +550,27 @@ void XlsxConverter::convert(OOX::Spreadsheet::WritingElement *oox_unknown)
switch(oox_unknown->getType())
{
case OOX::Spreadsheet::et_r:
case OOX::et_x_r:
{
OOX::Spreadsheet::CRun* pRun = static_cast<OOX::Spreadsheet::CRun*>(oox_unknown);
convert(pRun);
}break;
case OOX::Spreadsheet::et_t:
case OOX::et_x_t:
{
OOX::Spreadsheet::CText* pText = static_cast<OOX::Spreadsheet::CText*>(oox_unknown);
convert(pText);
}break;
case OOX::Spreadsheet::et_IconSet:
case OOX::et_x_IconSet:
{
OOX::Spreadsheet::CIconSet *pIc = static_cast<OOX::Spreadsheet::CIconSet*>(oox_unknown);
convert(pIc);
}break;
case OOX::Spreadsheet::et_DataBar:
case OOX::et_x_DataBar:
{
OOX::Spreadsheet::CDataBar *pB = static_cast<OOX::Spreadsheet::CDataBar*>(oox_unknown);
convert(pB);
}break;
case OOX::Spreadsheet::et_FormulaCF:
case OOX::et_x_FormulaCF:
{
OOX::Spreadsheet::CFormulaCF *pF = static_cast<OOX::Spreadsheet::CFormulaCF*>(oox_unknown);
convert(pF);
@ -1493,37 +1481,17 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
result = true;
}
OOX::CTheme * xlsx_theme= xlsx_document->GetTheme();
if(color->m_oThemeColor.IsInit() && xlsx_theme)
if(color->m_oThemeColor.IsInit())
{
int theme_ind = color->m_oThemeColor->GetValue();
switch(theme_ind)
{
case SimpleTypes::Spreadsheet::themecolorLight1:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oLt1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorLight2:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oLt2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorDark1:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oDk1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorDark2:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oDk2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorAccent1:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent1.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorAccent2:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent2.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorAccent3:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent3.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorAccent4:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent4.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorAccent5:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent5.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorAccent6:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oAccent6.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorFollowedHyperlink:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oFolHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
case SimpleTypes::Spreadsheet::themecolorHyperlink:
result = xlsx_theme->m_oThemeElements.m_oClrScheme.m_oHlink.tryGetRgb(ucR, ucG, ucB, ucA); break;
}
std::wstring sColor = color->m_oThemeColor->ToString();
DWORD argb = 0;
result = OoxConverter::convert(sColor, argb) ;
ucR = (argb & 0x0000FF);
ucB = (argb & 0x00FF00) >> 8;
ucG = (argb & 0xFF0000) >> 16;
ucA = argb >> 24;
}
if(color->m_oIndexed.IsInit())
{
@ -1724,6 +1692,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
{
if (!oox_anchor) return;
if (oox_anchor->m_bShapeOle) return;
//////////////////
if (oox_anchor->m_oFrom.IsInit() || oox_anchor->m_oTo.IsInit())
{
@ -1747,34 +1718,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
if (oox_anchor->m_oExt.IsInit())
{
}
//собственно
if (oox_anchor->m_oPicture.IsInit())
{
convert(oox_anchor->m_oPicture.GetPointer());
}
else if (oox_anchor->m_oShape.IsInit())
{
convert(oox_anchor->m_oShape.GetPointer());
}
else if (oox_anchor->m_oConnShape.IsInit())
{
convert(oox_anchor->m_oConnShape.GetPointer());
}
else if (oox_anchor->m_oGroupShape.IsInit())
{
convert(oox_anchor->m_oGroupShape.GetPointer());
}
else if (oox_anchor->m_oGraphicFrame.IsInit())
{
OoxConverter::convert(oox_anchor->m_oGraphicFrame.GetPointer());
}
OoxConverter::convert(oox_anchor->m_oElement.GetPointer());
}
void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing)
{
if (!oox_drawing)return;
xlsx_current_container = dynamic_cast<OOX::Spreadsheet::IFileContainer*>(oox_drawing);
xlsx_current_container = dynamic_cast<OOX::IFileContainer*>(oox_drawing);
for (unsigned int dr = 0 ; dr < oox_drawing->m_arrItems.size(); dr++)
{
@ -1797,236 +1748,236 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFromTo* oox_from_to, oox_table_po
if (oox_from_to->m_oColOff.IsInit()) pos->col_off = oox_from_to->m_oColOff->GetValue();//pt
}
void XlsxConverter::convert(OOX::Spreadsheet::CGroupShape* oox_group_shape)
{
if (!oox_group_shape)return;
if (oox_group_shape->m_arrItems.size() < 1) return;
ods_context->drawing_context()->start_group();
if (oox_group_shape->m_oNvGroupSpPr.IsInit())
{
if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr.IsInit())
{
if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit())
ods_context->drawing_context()->set_group_name(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName);
if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit())
ods_context->drawing_context()->set_group_z_order(oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue());
}
}
OoxConverter::convert(oox_group_shape->m_oGroupSpPr.GetPointer());
for (unsigned int i=0; i < oox_group_shape->m_arrItems.size(); i++)
{
switch(oox_group_shape->m_arrItems[i]->getType())
{
case OOX::Spreadsheet::et_Shape:
{
OOX::Spreadsheet::CShape* item = static_cast<OOX::Spreadsheet::CShape*>(oox_group_shape->m_arrItems[i]);
convert(item);
}break;
case OOX::Spreadsheet::et_ConnShape:
{
OOX::Spreadsheet::CConnShape* item = static_cast<OOX::Spreadsheet::CConnShape*>(oox_group_shape->m_arrItems[i]);
convert(item);
}break;
case OOX::Spreadsheet::et_GroupShape:
{
OOX::Spreadsheet::CGroupShape* item = static_cast<OOX::Spreadsheet::CGroupShape*>(oox_group_shape->m_arrItems[i]);
convert(item);
}break;
case OOX::Spreadsheet::et_Pic:
{
OOX::Spreadsheet::CPic* item = static_cast<OOX::Spreadsheet::CPic*>(oox_group_shape->m_arrItems[i]);
convert(item);
}break;
}
}
ods_context->drawing_context()->end_group();
}
void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape)
{
if (!oox_shape)return;
if (!oox_shape->m_oSpPr.IsInit()) return;
ods_context->drawing_context()->start_drawing();
int type = -1;
if (oox_shape->m_oSpPr->m_oCustGeom.IsInit())
{
type = 1000;//6???
}
if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
{
OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
type =(geometry->m_oPrst.GetValue());
}
if ((oox_shape->m_oNvSpPr.IsInit()) && (oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit()))
{
if (oox_shape->m_oNvSpPr->m_oCNvSpPr->m_otxBox.GetValue() == 1)
type = 2000; //textBox
}
if (type < 0)return;
/////////////////////////////////////////////////////////////////////////////////
if (type == 2000) ods_context->drawing_context()->start_text_box();
else ods_context->drawing_context()->start_shape(type);
{
OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
if (oox_shape->m_oNvSpPr.IsInit())
{
OoxConverter::convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); //имя, описалово, номер ...
convert(oox_shape->m_oNvSpPr->m_oCNvSpPr.GetPointer()); //заблокированности ... todooo
}
if (oox_shape->m_oShapeStyle.IsInit())
{
//доп эффекты
}
if (oox_shape->m_oTxBody.IsInit())
{
ods_context->start_text_context();
OoxConverter::convert(oox_shape->m_oTxBody->m_oBodyPr.GetPointer());
for (unsigned int i=0 ; i < oox_shape->m_oTxBody->m_arrItems.size();i++)
{
OoxConverter::convert(oox_shape->m_oTxBody->m_arrItems[i]);
}
ods_context->drawing_context()->set_text( ods_context->text_context());
ods_context->end_text_context();
}
}
if (type == 2000)ods_context->drawing_context()->end_text_box();
else ods_context->drawing_context()->end_shape();
ods_context->drawing_context()->end_drawing();
}
void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape)
{
if (!oox_shape)return;
if (!oox_shape->m_oSpPr.IsInit()) return;
ods_context->drawing_context()->start_drawing();
int type = -1;
if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom)
{
type = 1000;//?????
}
else if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypePreset)
{
if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
{
OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
type = (int)(geometry->m_oPrst.GetValue());
}
}
if (type < 0)return;
//////////////////////////////////////////////////////////////////////////////
ods_context->drawing_context()->start_shape(type);
{
OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//частенько приплывает из стиля заполенение объекта .. а он то одномерный :)
odf_context()->drawing_context()->start_area_properties();
odf_context()->drawing_context()->set_no_fill();
odf_context()->drawing_context()->end_area_properties();
if (oox_shape->m_oNvConnSpPr.IsInit())
{
if (oox_shape->m_oNvConnSpPr->m_oCNvPr.IsInit())
{
OoxConverter::convert(oox_shape->m_oNvConnSpPr->m_oCNvPr.GetPointer());
}
if (oox_shape->m_oNvConnSpPr->m_oCNvConnSpPr.IsInit())
{
}
}
//avLst
}
ods_context->drawing_context()->end_shape();
ods_context->drawing_context()->end_drawing();
}
void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture)
{
if (!oox_picture)return;
if (!oox_picture->m_oBlipFill.IsInit()) return; // невeрная структура оох
ods_context->drawing_context()->start_drawing();
std::wstring pathImage;
double Width=0, Height = 0;
if (oox_picture->m_oBlipFill->m_oBlip.IsInit())
{
std::wstring sID = oox_picture->m_oBlipFill->m_oBlip->m_oEmbed.GetValue();
pathImage = find_link_by_id(sID,1);
if (pathImage.empty())
{
sID = oox_picture->m_oBlipFill->m_oBlip->m_oLink.GetValue();
//???
}
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
}
ods_context->start_image(pathImage);
{
if (oox_picture->m_oBlipFill->m_oTile.IsInit())
{
ods_context->drawing_context()->set_image_style_repeat(2);
}
if (oox_picture->m_oBlipFill->m_oStretch.IsInit())
{
ods_context->drawing_context()->set_image_style_repeat(1);
}
if (oox_picture->m_oBlipFill->m_oSrcRect.IsInit() && Width >0 && Height >0)
{
ods_context->drawing_context()->set_image_client_rect_inch(
oox_picture->m_oBlipFill->m_oSrcRect->m_oL.GetValue()/100. * Width / currentSystemDPI ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oT.GetValue()/100. * Height / currentSystemDPI ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oR.GetValue()/100. * Width / currentSystemDPI ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oB.GetValue()/100. * Height / currentSystemDPI );
}
if (oox_picture->m_oNvPicPr.IsInit())
{
OoxConverter::convert(oox_picture->m_oNvPicPr->m_oCNvPr.GetPointer());
if (oox_picture->m_oNvPicPr->m_oCNvPicPr.IsInit())
{
if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks.IsInit())
{
//if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoChangeAspect)
//{
//}
//if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoCrop))
//{
//}
//if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoResize)
//{
//}
}
//m_oExtLst
}
}
OoxConverter::convert(oox_picture->m_oSpPr.GetPointer(), oox_picture->m_oShapeStyle.GetPointer());
}
ods_context->drawing_context()->end_image();
ods_context->drawing_context()->end_drawing();
}
//void XlsxConverter::convert(OOX::Spreadsheet::CGroupShape* oox_group_shape)
//{
// if (!oox_group_shape)return;
// if (oox_group_shape->m_arrItems.size() < 1) return;
//
// ods_context->drawing_context()->start_group();
//
// if (oox_group_shape->m_oNvGroupSpPr.IsInit())
// {
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr.IsInit())
// {
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit())
// ods_context->drawing_context()->set_group_name(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName);
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit())
// ods_context->drawing_context()->set_group_z_order(oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue());
// }
// }
//
// OoxConverter::convert(oox_group_shape->m_oGroupSpPr.GetPointer());
//
// for (unsigned int i=0; i < oox_group_shape->m_arrItems.size(); i++)
// {
// switch(oox_group_shape->m_arrItems[i]->getType())
// {
// case OOX::et_x_Shape:
// {
// OOX::Spreadsheet::CShape* item = static_cast<OOX::Spreadsheet::CShape*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// case OOX::et_x_ConnShape:
// {
// OOX::Spreadsheet::CConnShape* item = static_cast<OOX::Spreadsheet::CConnShape*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// case OOX::et_x_GroupShape:
// {
// OOX::Spreadsheet::CGroupShape* item = static_cast<OOX::Spreadsheet::CGroupShape*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// case OOX::et_x_Pic:
// {
// OOX::Spreadsheet::CPic* item = static_cast<OOX::Spreadsheet::CPic*>(oox_group_shape->m_arrItems[i]);
// convert(item);
// }break;
// }
// }
// ods_context->drawing_context()->end_group();
//}
//
//void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape)
//{
// if (!oox_shape)return;
// if (!oox_shape->m_oSpPr.IsInit()) return;
//
// ods_context->drawing_context()->start_drawing();
//
// int type = -1;
// if (oox_shape->m_oSpPr->m_oCustGeom.IsInit())
// {
// type = 1000;//6???
// }
// if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
// {
// OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
// type =(geometry->m_oPrst.GetValue());
// }
//
// if ((oox_shape->m_oNvSpPr.IsInit()) && (oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit()))
// {
// if (oox_shape->m_oNvSpPr->m_oCNvSpPr->m_otxBox.GetValue() == 1)
// type = 2000; //textBox
// }
//
// if (type < 0)return;
///////////////////////////////////////////////////////////////////////////////////
// if (type == 2000) ods_context->drawing_context()->start_text_box();
// else ods_context->drawing_context()->start_shape(type);
//
// {
// OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//
// if (oox_shape->m_oNvSpPr.IsInit())
// {
// OoxConverter::convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); //имя, описалово, номер ...
// convert(oox_shape->m_oNvSpPr->m_oCNvSpPr.GetPointer()); //заблокированности ... todooo
// }
// if (oox_shape->m_oShapeStyle.IsInit())
// {
// //доп эффекты
//
// }
// if (oox_shape->m_oTxBody.IsInit())
// {
// ods_context->start_text_context();
// OoxConverter::convert(oox_shape->m_oTxBody->m_oBodyPr.GetPointer());
//
// for (unsigned int i=0 ; i < oox_shape->m_oTxBody->m_arrItems.size();i++)
// {
// OoxConverter::convert(oox_shape->m_oTxBody->m_arrItems[i]);
// }
// ods_context->drawing_context()->set_text( ods_context->text_context());
// ods_context->end_text_context();
//
// }
// }
// if (type == 2000)ods_context->drawing_context()->end_text_box();
// else ods_context->drawing_context()->end_shape();
//
// ods_context->drawing_context()->end_drawing();
//
//}
//
//void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape)
//{
// if (!oox_shape)return;
// if (!oox_shape->m_oSpPr.IsInit()) return;
//
// ods_context->drawing_context()->start_drawing();
//
// int type = -1;
// if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom)
// {
// type = 1000;//?????
// }
// else if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypePreset)
// {
// if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
// {
// OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
// type = (int)(geometry->m_oPrst.GetValue());
// }
// }
// if (type < 0)return;
////////////////////////////////////////////////////////////////////////////////
// ods_context->drawing_context()->start_shape(type);
// {
// OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//
// //частенько приплывает из стиля заполенение объекта .. а он то одномерный :)
// odf_context()->drawing_context()->start_area_properties();
// odf_context()->drawing_context()->set_no_fill();
// odf_context()->drawing_context()->end_area_properties();
//
// if (oox_shape->m_oNvConnSpPr.IsInit())
// {
// if (oox_shape->m_oNvConnSpPr->m_oCNvPr.IsInit())
// {
// OoxConverter::convert(oox_shape->m_oNvConnSpPr->m_oCNvPr.GetPointer());
// }
//
// if (oox_shape->m_oNvConnSpPr->m_oCNvConnSpPr.IsInit())
// {
// }
// }
// //avLst
// }
// ods_context->drawing_context()->end_shape();
// ods_context->drawing_context()->end_drawing();
//}
//
//
//void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture)
//{
// if (!oox_picture)return;
// if (!oox_picture->m_oBlipFill.IsInit()) return; // невeрная структура оох
//
// ods_context->drawing_context()->start_drawing();
//
// std::wstring pathImage;
// double Width=0, Height = 0;
//
// if (oox_picture->m_oBlipFill->m_oBlip.IsInit())
// {
// std::wstring sID = oox_picture->m_oBlipFill->m_oBlip->m_oEmbed.GetValue();
// pathImage = find_link_by_id(sID,1);
//
// if (pathImage.empty())
// {
// sID = oox_picture->m_oBlipFill->m_oBlip->m_oLink.GetValue();
// //???
// }
// _graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
// }
// ods_context->start_image(pathImage);
// {
// if (oox_picture->m_oBlipFill->m_oTile.IsInit())
// {
// ods_context->drawing_context()->set_image_style_repeat(2);
// }
// if (oox_picture->m_oBlipFill->m_oStretch.IsInit())
// {
// ods_context->drawing_context()->set_image_style_repeat(1);
// }
// if (oox_picture->m_oBlipFill->m_oSrcRect.IsInit() && Width >0 && Height >0)
// {
// ods_context->drawing_context()->set_image_client_rect_inch(
// oox_picture->m_oBlipFill->m_oSrcRect->m_oL.GetValue()/100. * Width / currentSystemDPI ,
// oox_picture->m_oBlipFill->m_oSrcRect->m_oT.GetValue()/100. * Height / currentSystemDPI ,
// oox_picture->m_oBlipFill->m_oSrcRect->m_oR.GetValue()/100. * Width / currentSystemDPI ,
// oox_picture->m_oBlipFill->m_oSrcRect->m_oB.GetValue()/100. * Height / currentSystemDPI );
// }
// if (oox_picture->m_oNvPicPr.IsInit())
// {
// OoxConverter::convert(oox_picture->m_oNvPicPr->m_oCNvPr.GetPointer());
//
// if (oox_picture->m_oNvPicPr->m_oCNvPicPr.IsInit())
// {
// if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks.IsInit())
// {
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoChangeAspect)
// //{
// //}
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoCrop))
// //{
// //}
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoResize)
// //{
// //}
// }
// //m_oExtLst
// }
// }
//
// OoxConverter::convert(oox_picture->m_oSpPr.GetPointer(), oox_picture->m_oShapeStyle.GetPointer());
//
// }
// ods_context->drawing_context()->end_image();
// ods_context->drawing_context()->end_drawing();
//}
//
void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt)
{
if (!oox_cond_fmt)return;
@ -2086,8 +2037,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColorScale *oox_cond_colorscale)
{
if (!oox_cond_colorscale->m_arrItems[i])continue;
OOX::Spreadsheet::EElementType type = oox_cond_colorscale->m_arrItems[i]->getType();
if (type == OOX::Spreadsheet::et_ConditionalFormatValueObject)
OOX::EElementType type = oox_cond_colorscale->m_arrItems[i]->getType();
if (type == OOX::et_x_ConditionalFormatValueObject)
{
convert(oox_cond_colorscale->m_arrItems[i]);
}

View File

@ -72,13 +72,7 @@ namespace OOX
class CCellAnchor;
class CDrawing;
class CFromTo;
class CPic;
class CShape;
class CConnShape;
class CGroupShape;
class CCommentItem;
class CGraphicFrame;
class CGraphicChart;
class CDefinedName;
class CConditionalFormatting;
class CConditionalFormattingRule;
@ -137,14 +131,14 @@ namespace Oox2Odf
virtual void write(const std::wstring & path);
virtual odf_writer::odf_conversion_context *odf_context();
virtual OOX::CTheme *oox_theme();
virtual PPTX::Theme *oox_theme();
virtual std::wstring find_link_by_id (std::wstring sId, int t);
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId);
void convert(OOX::Spreadsheet::WritingElement *oox_unknown);
private:
OOX::Spreadsheet::CXlsx *xlsx_document;
OOX::Spreadsheet::IFileContainer *xlsx_current_container;
OOX::IFileContainer *xlsx_current_container;
odf_writer::ods_conversion_context *ods_context;
@ -196,11 +190,6 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CFromTo *oox_from_to, oox_table_position * pos);
void convert(OOX::Spreadsheet::CPic *oox_picture);
void convert(OOX::Spreadsheet::CShape *oox_shape);
void convert(OOX::Spreadsheet::CConnShape *oox_conn_shape);
void convert(OOX::Spreadsheet::CGroupShape *oox_group_shape);
void convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt);
void convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_cond_rule);
void convert(OOX::Spreadsheet::CAutofilter *oox_filter);

View File

@ -345,6 +345,14 @@
RelativePath="..\OdfFormat\draw_frame.h"
>
</File>
<File
RelativePath="..\OdfFormat\draw_page.cpp"
>
</File>
<File
RelativePath="..\OdfFormat\draw_page.h"
>
</File>
<File
RelativePath="..\OdfFormat\draw_shapes.cpp"
>
@ -385,6 +393,14 @@
RelativePath="..\OdfFormat\office_chart.h"
>
</File>
<File
RelativePath="..\OdfFormat\office_presentation.cpp"
>
</File>
<File
RelativePath="..\OdfFormat\office_presentation.h"
>
</File>
<File
RelativePath="..\OdfFormat\office_settings.cpp"
>
@ -697,6 +713,30 @@
<Filter
Name="odf presentation"
>
<File
RelativePath="..\OdfFormat\odp_conversion_context.cpp"
>
</File>
<File
RelativePath="..\OdfFormat\odp_conversion_context.h"
>
</File>
<File
RelativePath="..\OdfFormat\odp_page_state.cpp"
>
</File>
<File
RelativePath="..\OdfFormat\odp_page_state.h"
>
</File>
<File
RelativePath="..\OdfFormat\odp_slide_context.cpp"
>
</File>
<File
RelativePath="..\OdfFormat\odp_slide_context.h"
>
</File>
</Filter>
<Filter
Name="odf common"

View File

@ -171,7 +171,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../ASCOfficeOdfFile/include;../../../ASCOfficeOdfFile/src/odf/datatypes"
PreprocessorDefinitions="NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;BUILD_CONFIG_FULL_VERSION"
PreprocessorDefinitions="NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;BUILD_CONFIG_FULL_VERSION;DONT_WRITE_EMBEDDED_FONTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -278,7 +278,7 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\Oox2OdfConverter\ConvertDiagram.cpp"
RelativePath="..\Oox2OdfConverter\ConvertDrawing.cpp"
>
</File>
<File
@ -297,6 +297,10 @@
RelativePath="..\Oox2OdfConverter\DocxConverter.cpp"
>
</File>
<File
RelativePath="..\Oox2OdfConverter\PptxConverter.cpp"
>
</File>
<File
RelativePath="..\Oox2OdfConverter\XlsxConverter.cpp"
>
@ -315,6 +319,10 @@
RelativePath="..\Oox2OdfConverter\DocxConverter.h"
>
</File>
<File
RelativePath="..\Oox2OdfConverter\PptxConverter.h"
>
</File>
<File
RelativePath="..\Oox2OdfConverter\VmlShapeTypes2Oox.h"
>