Compare commits

..

83 Commits

Author SHA1 Message Date
cc06effd5e Merge remote-tracking branch 'origin/hotfix/v5.2.8' into develop 2019-01-16 16:48:51 +03:00
abd50ecec6 . 2019-01-16 16:08:17 +03:00
36faf5f2fd x2t - fix build 2019-01-16 15:48:55 +03:00
9168dbf06c x2t - version up. 2.4.562 2019-01-16 13:57:19 +03:00
94beedb1ec Merge remote-tracking branch 'origin/hotfix/v5.2.8' into develop 2019-01-16 13:42:46 +03:00
10f8c60ea1 x2t - fix bug #40124 2019-01-16 13:29:44 +03:00
8b5baeb929 x2t - fix same user files 2019-01-16 13:06:02 +03:00
864dac5eec XlsFormatReader - fix bug #40178 2019-01-16 13:05:22 +03:00
a2d085a191 v5.2.7 2019-01-15 14:46:05 +03:00
102db77f55 [ios][x2t] fixed build 2019-01-11 14:50:28 +03:00
0181cf493f Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2019-01-09 15:22:40 +03:00
25f20877df OdfFormat - fix users file (add new text field) 2019-01-09 15:20:08 +03:00
37889217cd Add v8 files to .gitignore 2019-01-09 14:10:25 +03:00
89d6a7ec7e Makefile refactoring 2019-01-09 14:09:16 +03:00
310b8605f0 . 2019-01-09 13:01:11 +03:00
c515c2bf00 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2019-01-09 11:37:53 +03:00
bea475a3cd . 2019-01-09 11:36:57 +03:00
a2454e78d4 [android][x2t] fix build script 2019-01-09 10:31:17 +03:00
c0bb704ed9 [x2t] Fix for 1b49f53f03 2018-12-27 15:37:34 +03:00
1b49f53f03 [x2t] For bug 40124 2018-12-27 12:50:48 +03:00
abbbda090d Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-26 14:30:50 +03:00
38e82f0414 PptFormatReader - fix bug #40116 2018-12-25 17:49:46 +03:00
25574aff48 PptFormatReader - fix bug #40115 2018-12-25 16:21:44 +03:00
f4d9901576 [ios] Math in menu 2018-12-25 15:48:54 +03:00
ebaa8b9769 add rpath to x2t 2018-12-24 12:59:48 +03:00
855442c1c9 . 2018-12-23 15:38:42 +03:00
30008873fe OdfFormatReader - fix after testing 2018-12-22 19:22:55 +03:00
8d247dfb6e OdfFormatReader - fix bug #40106, ... 2018-12-22 15:21:34 +03:00
a9f32fd7d0 Remove v8 object files from core.zip 2018-12-21 14:29:50 +03:00
c727f0cba8 Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-21 13:08:59 +03:00
181f613893 OdfFormatReader - fix bug #39979 2018-12-20 19:30:45 +03:00
8c4d1cde6c . 2018-12-20 15:18:14 +03:00
6e515a1ee5 . 2018-12-19 19:19:17 +03:00
3532d4088d OdfFormat - fix after testing 2018-12-19 18:03:24 +03:00
eec7ab20fd XlsFormat - fix bug #40065 2018-12-19 18:02:40 +03:00
8b568ddefb Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-19 13:24:09 +03:00
708c07c072 x2t - version upt - 2.4.560 2018-12-19 13:21:34 +03:00
c7524a2509 OdfFormatReader - fix after testing 2018-12-19 13:09:08 +03:00
90240caa0b Download correct (MacOS) 2018-12-19 10:19:15 +03:00
f8098f1237 No latin symbols in url 2018-12-18 18:52:08 +03:00
760dfbf0d7 OdfFormatReader - fix after testing 2018-12-18 14:25:33 +03:00
784f57dea4 Revert "Merge branch 'hotfix/v5.2.5' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.5"
This reverts commit e280dcbb27, reversing
changes made to 097559c25e.
2018-12-17 12:33:52 +03:00
e280dcbb27 Merge branch 'hotfix/v5.2.5' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.5 2018-12-17 12:31:52 +03:00
3953fd1add [ios][x2t] fixed build 2018-12-14 14:43:05 +03:00
30986e3c36 Fix buld crash 2018-12-14 14:09:43 +03:00
6eb596080c x2t - verison up - 2.4.558 2018-12-14 14:09:32 +03:00
b45d705e2b OdfFormatReader - fix #39976 2018-12-14 14:09:22 +03:00
21dffa628d OdfFormatReader - fix bug #39976 2018-12-14 14:09:12 +03:00
1b949a978b OdfFormatReader - fix bug #39983 2018-12-14 14:09:03 +03:00
17e140debf XlsFormatReader - fix bug #39961 2018-12-14 14:08:54 +03:00
6452e9956e OdfFormat - fix users files 2018-12-14 14:08:45 +03:00
f8ad532f77 Merge pull request #129 from ONLYOFFICE/feature/pdfUtfBOM
Feature/pdf utf bom
2018-12-14 14:06:56 +03:00
e05551e679 x2t - DocxFormat - fix bug #39935 2018-12-14 14:02:22 +03:00
850959f791 PptFormatReader -fix bug #39929 2018-12-14 14:02:06 +03:00
d0661e871d Merge pull request #128 from ONLYOFFICE/hotfix/v5.2.5
Hotfix/v5.2.5
2018-12-14 13:40:59 +03:00
ec173776ea Merge branch 'develop' into hotfix/v5.2.5 2018-12-14 13:40:47 +03:00
0a3b9fb8e9 Fix buld crash 2018-12-14 12:34:41 +03:00
097559c25e x2t - verison up - 2.4.558 2018-12-13 18:58:00 +03:00
6a571ba1c9 OdfFormatReader - fix #39976 2018-12-13 14:09:17 +03:00
c4a46114a2 Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-13 12:15:05 +03:00
724335bdda OdfFormatReader - fix bug #39976 2018-12-12 18:12:14 +03:00
7e85df3cc5 OdfFormatReader - fix bug #39983 2018-12-12 17:32:39 +03:00
326cfbde93 XlsFormatReader - fix bug #39961 2018-12-12 15:18:57 +03:00
5df8901b59 OdfFormat - fix users files 2018-12-11 20:03:56 +03:00
9c24fa2ff1 Merge pull request #127 from ONLYOFFICE/feature/pdfUtfBOM
Feature/pdf utf bom
2018-12-11 18:26:56 +03:00
82dca18ebc Correct coding to Utf16 2018-12-11 18:08:25 +03:00
86d97d050d x2t - DocxFormat - fix bug #39935 2018-12-11 18:03:16 +03:00
a6ab10d585 PptFormatReader -fix bug #39929 2018-12-11 18:00:32 +03:00
2b8efdd9b1 v5.2.4 2018-12-11 16:07:08 +03:00
1022754391 clang build fix 2018-12-11 15:38:29 +03:00
2c10457a63 . 2018-12-08 17:22:58 +03:00
e0630979c5 . 2018-12-06 13:09:12 +03:00
8bc8b7cf58 . 2018-12-05 15:43:01 +03:00
14f4364962 . 2018-12-05 14:38:22 +03:00
9de3cb016f . 2018-12-03 16:56:41 +03:00
f12cd8ff8f [ios][x2t] fixed build 2018-12-03 16:25:12 +03:00
436015b5d2 DocFormatReader - write strict writeProtection; DocxFormatReader - read ecma & strict writeProtection 2018-12-03 16:05:36 +03:00
c078df93c9 . 2018-12-03 13:17:35 +03:00
e5e8e01490 Xls/XlsxFormat - protection verify 2018-12-02 14:19:47 +03:00
4fcc3b4f41 DocFormatReader - convert writeProtect 2018-12-02 12:57:41 +03:00
ce44e50d0e OdfFormatReader - protection sheets 2018-11-29 19:01:54 +03:00
143590f17b XlsxFormat - sheet protection, ... 2018-11-29 11:25:22 +03:00
abb7a85337 [android][x2t] fix build script 2018-11-28 15:37:24 +03:00
446 changed files with 6162 additions and 3335 deletions

3
.gitignore vendored
View File

@ -18,6 +18,9 @@ Common/3dParty/curl/win_32
Common/3dParty/curl/linux_64
Common/3dParty/curl/linux_32
Common/3dParty/curl/mac_64
Common/3dParty/v8/.cipd
Common/3dParty/v8/.gclient
Common/3dParty/v8/.gclient_entries
Common/3dParty/v8/v8
Common/3dParty/v8/depot_tools
Common/3dParty/v8/win_64

View File

@ -32,9 +32,38 @@
#include "SettingsMapping.h"
#include "../../OfficeCryptReader/source/CryptTransform.h"
namespace DocFileFormat
{
std::string DecodeBase64(const std::string & value)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
std::wstring EncodeBase64(const std::string & value)
{
int nLength = 0;
char *pData = NULL;
std::string result;
NSFile::CBase64Converter::Encode((BYTE*)value.c_str(), value.length(), pData, nLength, NSBase64::B64_BASE64_FLAG_NOCRLF);
if (pData)
{
result = std::string(pData, nLength);
delete []pData; pData = NULL;
}
return std::wstring(result.begin(), result.end());
}
SettingsMapping::SettingsMapping (ConversionContext* ctx): PropertiesMapping(&m_oXmlWriter)
{
_ctx = ctx;
@ -49,11 +78,39 @@ namespace DocFileFormat
//start w:settings
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
//write namespaces
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( L"", TRUE, FALSE );
if (_ctx->_doc->FIB->m_FibBase.fWriteReservation)
{
m_oXmlWriter.WriteNodeBegin( L"w:writeProtection", TRUE );
WideString* passw = static_cast<WideString*>(_ctx->_doc->AssocNames->operator[]( 17 ));
if (passw && false == passw->empty())
{
CRYPT::_ecmaWriteProtectData data;
CRYPT::ECMAWriteProtect protect;
protect.SetCryptData(data);
protect.SetPassword(*passw);
protect.Generate();
protect.GetCryptData(data);
//m_oXmlWriter.WriteAttribute ( L"w:cryptProviderType", L"rsaAES");
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmSid", 14); //sha-512
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmType", L"typeAny");
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmClass", L"hash");
//m_oXmlWriter.WriteAttribute ( L"w:cryptSpinCount", data.spinCount);
//m_oXmlWriter.WriteAttribute ( L"w:hash", EncodeBase64(data.hashValue));
//m_oXmlWriter.WriteAttribute ( L"w:salt", EncodeBase64(data.saltValue));
m_oXmlWriter.WriteAttribute ( L"w:algorithmName", L"SHA-512");
m_oXmlWriter.WriteAttribute ( L"w:spinCount", data.spinCount);
m_oXmlWriter.WriteAttribute ( L"w:hashValue", EncodeBase64(data.hashValue));
m_oXmlWriter.WriteAttribute ( L"w:saltValue", EncodeBase64(data.saltValue));
}
m_oXmlWriter.WriteNodeEnd( L"", TRUE, TRUE );
}
//zoom
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved > 0 ? dop->wScaleSaved : 100 ) );

View File

@ -88,6 +88,7 @@ namespace DocFileFormat
friend class VMLPictureMapping;
friend class OpenXmlPackage;
friend class TextboxMapping;
friend class SettingsMapping;
public:

View File

@ -3232,6 +3232,11 @@ public:
NSBinPptxRW::CXmlWriter xmlWriter;
pTheme->toXmlWriter(&xmlWriter);
m_oFileWriter.m_oTheme.m_sContent = xmlWriter.GetXmlString();
if ((m_oFileWriter.m_pDrawingConverter) && (m_oFileWriter.m_pDrawingConverter->m_pTheme))
{
*m_oFileWriter.m_pDrawingConverter->m_pTheme = pTheme;
}
}
else
res = c_oSerConstants::ReadUnknown;

View File

@ -18,7 +18,8 @@ DEFINES += UNICODE \
_UNICODE \
SOLUTION_ASCOFFICEDOCXFILE2 \
#DISABLE_FILE_DOWNLOADER \
DONT_WRITE_EMBEDDED_FONTS
DONT_WRITE_EMBEDDED_FONTS \
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML
SOURCES += \

View File

@ -383,6 +383,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML,
SOLUTION_ASCOFFICEDOCXFILE2,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
@ -415,6 +416,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML,
SOLUTION_ASCOFFICEDOCXFILE2,
DONT_WRITE_EMBEDDED_FONTS,
MAC,

View File

@ -64,7 +64,7 @@ public:
std::wstring convert_conditional_formula(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
static void replace_cells_range(std::wstring& expr);
static void replace_cells_range(std::wstring& expr, bool bSelect = true);
static void replace_semicolons(std::wstring& expr);
static void replace_vertical(std::wstring& expr);
@ -183,7 +183,7 @@ public:
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::table_name_ = L"";
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSelect)
{
if ((0 == expr.find(L"KAVYCHKA")) && (expr.length() - 8 == expr.rfind(L"KAVYCHKA") ))
return;
@ -195,7 +195,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
if (b)
{
boost::wregex re1(L"(\\$?\\w+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
boost::wregex re1(L"(\\$?[^\']+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
@ -204,7 +204,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
std::wstring res = boost::regex_replace(
workstr,
re1,
&replace_cells_range_formater1,
bSelect ? &replace_cells_range_formater1 : &replace_cells_range_formater2,
boost::match_default | boost::format_all);
expr = res;
@ -263,18 +263,43 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
{
const size_t sz = what.size();
if (sz > 2)
if (sz > 3)
{
std::wstring s;
std::wstring sheet = what[1].matched ? what[1].str() : L"";
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
{
return c1;
}
else if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
{
table_name_ = sheet + L".$A$1";
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"");
}
return s;
}
else
{
const std::wstring c1 = what[1].str();
const std::wstring c2 = what[2].str();
const std::wstring s = std::wstring(L"[.") + c1 + (c2.empty() ? L"" : (L":." + c2) ) + std::wstring(L"]");
const std::wstring s = std::wstring(L".") + c1 + (c2.empty() ? L"" : (L":." + c2) );
return s;
}
return L"";
return L"";
}
void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
@ -309,7 +334,7 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
{
std::wstring &d = distance[i];
replace_cells_range(d);
replace_cells_range(d, false);
oox_replace_tmp_back(d);

View File

@ -332,6 +332,7 @@ enum ElementType
typeTableTableRowGroup,
typeTableTableRowNoGroup,
typeTableTableSource,
typeTableTableProtection,
typeTableDataPilotTables,
typeTableDataPilotTable,
@ -454,6 +455,7 @@ enum ElementType
typeDrawPolyline,
typeDrawRegularPolyline,
typeDrawPath,
typeDrawContourPath,
typeDrawCircle,
typeDrawg,
typeDrawPageThumbnail,

View File

@ -43,7 +43,7 @@
#include <boost/variant.hpp>
#include <boost/lexical_cast.hpp>
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace cpdoccore
{

View File

@ -131,6 +131,7 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
last_dump_page_properties_ (true),
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
@ -155,12 +156,9 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
odf_document_ (OdfDocument)
{
streams_man_ = streams_man::create(temp_stream_);
applicationFonts_ = NSFonts::NSApplication::Create();
}
docx_conversion_context::~docx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void docx_conversion_context::set_output_document(package::docx_document * document)
{
@ -168,8 +166,7 @@ void docx_conversion_context::set_output_document(package::docx_document * docum
}
void docx_conversion_context::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_)
applicationFonts_->InitializeFromFolder(pathFonts);
mediaitems_.set_font_directory(pathFonts);
}
std::wstring styles_map::get(const std::wstring & Name, odf_types::style_family::type Type)
{
@ -686,7 +683,7 @@ void docx_conversion_context::end_document()
output_document_->get_word_files().set_document ( package::simple_element::create(L"document.xml", document_xml_.str()) );
output_document_->get_word_files().set_settings ( package::simple_element::create(L"settings.xml", dump_settings_document()));
output_document_->get_word_files().set_media ( mediaitems_, applicationFonts_);
output_document_->get_word_files().set_media ( mediaitems_);
output_document_->get_word_files().set_comments ( comments_context_);
output_document_->get_word_files().set_headers_footers( headers_footers_);
@ -1429,14 +1426,22 @@ void docx_conversion_context::next_dump_page_properties(bool val)
if (process_headers_footers_ && val) return;
next_dump_page_properties_ = val;
if (val)
last_dump_page_properties(true);
}
bool docx_conversion_context::is_next_dump_page_properties()
{
return next_dump_page_properties_;
}
void docx_conversion_context::last_dump_page_properties(bool val)
{
last_dump_page_properties_ = val;
}
bool docx_conversion_context::is_last_dump_page_properties()
{
return last_dump_page_properties_;
}
void docx_conversion_context::start_text_list_style(const std::wstring & StyleName)
{
text_list_style_name_ = StyleName;

View File

@ -47,8 +47,6 @@
#include "hyperlinks.h"
#include "mediaitems.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace odf_types
@ -190,14 +188,14 @@ public:
}
void set_position_child_group(_INT32 x, _INT32 y)
{
if (groups_.size() < 1) return;
if (groups_.empty()) return;
if (groups_.back().x > x) groups_.back().x = x;
if (groups_.back().y > y) groups_.back().y = y;
}
void set_size_child_group(_INT32 cx, _INT32 cy)
{
if (groups_.size() < 1) return;
if (groups_.empty()) return;
if (groups_.back().cx < cx) groups_.back().cx = cx;
if (groups_.back().cy < cy) groups_.back().cy = cy;
@ -205,7 +203,7 @@ public:
void get_position_group(_INT32 & x, _INT32 & y)
{
x = y = 0;
if (groups_.size() < 1) return;
if (groups_.empty()) return;
x = groups_.back().x;
y = groups_.back().y;
@ -213,7 +211,7 @@ public:
void get_size_group(_INT32 & cx, _INT32 & cy)
{
cx = cy = 0;
if (groups_.size() < 1) return;
if (groups_.empty()) return;
cx = groups_.back().cx;
cy = groups_.back().cy;
@ -795,12 +793,12 @@ public:
bool next_dump_page_properties_;
bool next_dump_section_;
bool last_dump_page_properties_;
odf_reader::odf_document * root()
odf_reader::odf_document *root()
{
return odf_document_;
}
void start_document ();
void end_document ();
@ -865,6 +863,8 @@ public:
void next_dump_page_properties (bool val);
bool is_next_dump_page_properties ();
void last_dump_page_properties (bool val);
bool is_last_dump_page_properties ();
void set_master_page_name(const std::wstring & MasterPageName);
const std::wstring & get_master_page_name() const;
@ -1000,7 +1000,6 @@ private:
package::docx_document * output_document_;
odf_reader::odf_document * odf_document_;
NSFonts::IApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_;

View File

@ -147,11 +147,11 @@ void word_files::update_rels(docx_conversion_context & Context)
Context.dump_notes (rels_files_.get_rel_file()->get_rels());
}
void word_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
void word_files::set_media(mediaitems & _Mediaitems)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
}
if (_Mediaitems.count_object > 0)
{

View File

@ -40,8 +40,6 @@
#include "docx_content_type.h"
#include "oox_package.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace oox {
@ -139,7 +137,7 @@ public:
void set_numbering (element_ptr Element);
void set_settings (element_ptr Element);
bool has_numbering ();
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void set_media (mediaitems & mediaitems_);
void set_headers_footers(headers_footers & HeadersFooters);
void set_notes (notes_context & notesContext);
void set_comments (comments_context & commentsContext);

View File

@ -73,7 +73,8 @@ struct drawing_object_description
_oox_fill fill_;
bool in_group_;
bool lined_;
bool connector_;
int shape_type_; //default - frame
std::vector<drawing_object_description> child_objects_;

View File

@ -36,7 +36,7 @@
#include <float.h>
#include "../../DesktopEditor/graphics/pro/Fonts.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace utils {

View File

@ -41,6 +41,7 @@
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace oox {
@ -74,7 +75,32 @@ mediaitems::item::item( std::wstring const & _href,
count_add = 1;
count_used = 0;
}
mediaitems::mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
applicationFonts_ = NSFonts::NSApplication::Create();
}
mediaitems::~mediaitems()
{
if (applicationFonts_)
delete applicationFonts_;
}
void mediaitems::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_)
applicationFonts_->InitializeFromFolder(pathFonts);
}
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal)
{
std::wstring ref;
@ -126,8 +152,8 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (sExt.empty())
{
int n = uri.find(L"ObjectReplacements");
if (n >= 0)
size_t n = uri.find(L"ObjectReplacements");
if (n != std::wstring::npos)
{
if (!isInternal) return L"";
@ -138,14 +164,16 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (sExt.empty())
{
//то что есть ..
int n = uri.rfind(L".");
if (n > 0)
sExt = uri.substr(n);
size_t n = uri.rfind(L".");
if (n != std::wstring::npos)
sExt = XmlUtils::GetLower(uri.substr(n));
}
}
if (type == typeOleObject && sExt.empty())
sExt = L".bin";
else if ( type == typeChart)
sExt = L".xml";
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
}
@ -167,7 +195,7 @@ std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
if (!sExt.empty()) sExt = std::wstring(L".") + sExt;
}
return sExt;
return XmlUtils::GetLower(sExt);
}
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
@ -214,8 +242,6 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id;
for (size_t i = 0 ; i < items_.size(); i++)
@ -242,8 +268,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
}
else if ( type == typeImage)
{
int n_svm = outputPath.rfind (L".svm");
if ( n_svm >= 0 )
size_t n_svm = outputPath.rfind (L".svm");
if ( n_svm != std::wstring::npos )
{
outputPath = outputPath.substr(0, n_svm) + L".png";
}

View File

@ -33,7 +33,12 @@
#include "oox_rels.h"
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace NSFonts
{
class IApplicationFonts;
}
namespace cpdoccore {
namespace oox {
@ -41,20 +46,8 @@ namespace oox {
class mediaitems
{
public:
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
}
mediaitems(const std::wstring & odfPacket);
virtual ~mediaitems();
struct item
{
@ -87,6 +80,9 @@ public:
size_t count_activeX;
size_t count_control;
void set_font_directory(std::wstring pathFonts);
NSFonts::IApplicationFonts *applicationFonts() {return applicationFonts_;}
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
@ -147,6 +143,7 @@ private:
items_array items_;
std::wstring odf_packet_;
NSFonts::IApplicationFonts *applicationFonts_;
};
}

View File

@ -109,7 +109,13 @@ static const std::wstring _ooxShapeType[]=
L"polygon",
L"roundRect",
L"bentConnector3",
L"curvedConnector3"
L"curvedConnector3",
L"",//3-D shape
L"",
L"polyline",
L"cube",
L"ellipse", //sphere
L""
};
@ -250,15 +256,15 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
{
values.clear();
}
//else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
//{
// names.push_back(L"vf");
//}
//else if (std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
//{
// names.push_back(L"hf");
// names.push_back(L"vf");
//}
else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
{
names.push_back(L"hf");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"hexagon"))
{
names.push_back(L"adj");
@ -424,7 +430,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
shapeGeomPreset = L"rect";
}
}
else if (sub_type <= 12 && sub_type >= 0)
else if (sub_type <= 16 && sub_type >= 0)
{
shapeGeomPreset = _ooxShapeType[sub_type]; //odf -> oox
}
@ -434,7 +440,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
CP_XML_WRITER(strm)
{
if (sub_type == 6 || sub_type == 8)
if (sub_type == 6 || sub_type == 8 || sub_type == 14)
{
CP_XML_NODE(L"a:custGeom")
{
@ -493,7 +499,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
}
}
}
if (bWordArt)
if (bWordArt || lined)
{
_oox_fill no_fill;
oox_serialize_fill(strm, no_fill);
@ -518,29 +524,16 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
_CP_OPT(double) dSkewY;
odf_reader::GetProperty(additional, L"svg:skewY", dSkewY);
_CP_OPT(double) dRotateAngle;
if (dRotate || dSkewX || dSkewY)
{
double tmp=0;
if (dRotate)tmp += *dRotate;
//if (dSkewX)tmp += *dSkewX;
//if (dSkewY)tmp += (*dSkewY) + 3.1415926;
dRotateAngle = tmp;
}
CP_XML_NODE(xfrm)
{
if (dRotateAngle)
if (dRotate)
{
double d =360 - dRotateAngle.get() * 180. / 3.14159265358979323846;
d *= 60000; //60 000 per 1 gr - 19.5.5 oox
CP_XML_ATTR(L"rot", (int)d);
double d = 360 - dRotate.get() * 180. / 3.14159265358979323846;
CP_XML_ATTR(L"rot", (int)( d * 60000) ); //60 000 per 1 gr - 19.5.5 oox
}
_CP_OPT(bool)bVal;
if (odf_reader::GetProperty(additional,L"flipH", bVal))
if (odf_reader::GetProperty(additional, L"flipH", bVal))
CP_XML_ATTR(L"flipH", bVal.get());
if (odf_reader::GetProperty(additional,L"flipV", bVal))

View File

@ -83,13 +83,15 @@ namespace oox {
class _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object"), extExternal(false)
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), lined(false), connector(false), name(L"object"), extExternal(false)
{
}
RelsType type;
bool inGroup;
size_t id;
bool lined;
bool connector;
std::wstring name;
int sub_type; //odf

View File

@ -194,6 +194,14 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons
{
CP_XML_NODE(ns + L":grayscl");
}
if (val.bitmap->luminance || val.bitmap->contrast)
{
CP_XML_NODE(ns + L":lum")
{
if (val.bitmap->luminance) CP_XML_ATTR2(L"bright", (int)(*val.bitmap->luminance * 1000));
if (val.bitmap->contrast) CP_XML_ATTR2(L"contrast", (int)(*val.bitmap->contrast * 1000));
}
}
}
if (val.bitmap->bCrop)
{

View File

@ -70,12 +70,15 @@ namespace oox {
bool bStretch;
bool bCrop;
bool bTile;
bool bGrayscale;
double cropRect[4];//0-left, 1 -top, 2- right, 3 - bottom
_CP_OPT(int) dpi;
_CP_OPT(bool) rotate;
bool bGrayscale;
_CP_OPT(double) luminance;
_CP_OPT(double) contrast;
};
/////////////////////////////////////////////////////////
class oox_hatch_fill;

View File

@ -79,14 +79,15 @@ static std::wstring get_mime_type(const std::wstring & extension)
else if (L"wav" == extension) return L"audio/wav";
else if (L"mp3" == extension) return L"audio/mpeg";
else if (L"wma" == extension) return L"audio/x-ms-wma";
else if (L"m4a" == extension) return L"audio/unknown";
else if (L"m4a" == extension) return L"audio/m4a";
else if (L"avi" == extension) return L"video/x-msvideo";
else if (L"wmv" == extension) return L"video/x-ms-wmv";
else if (L"mov" == extension) return L"video/unknown";
else if (L"mp4" == extension) return L"video/unknown";
else if (L"m4v" == extension) return L"video/unknown";
else if (L"mkv" == extension) return L"video/unknown";
else if (L"mov" == extension) return L"video/mov";
else if (L"mp4" == extension) return L"video/mp4";
else if (L"m4v" == extension) return L"video/m4v";
else if (L"mkv" == extension) return L"video/mkv";
else if (L"webm" == extension) return L"video/webm";
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
else if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

View File

@ -42,7 +42,7 @@ namespace oox {
struct _pptx_comment
{
size_t x_, y_;
int x_, y_;
int author_id_;
int idx_;

View File

@ -45,8 +45,6 @@
#include "pptx_default_serializes.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace odf_reader
@ -72,13 +70,10 @@ pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odf
,last_idx_placeHolder (1)
,last_uniq_big_id (1)
{
applicationFonts_ = NSFonts::NSApplication::Create();
}
pptx_conversion_context::~pptx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void pptx_conversion_context::set_output_document(package::pptx_document * document)
@ -88,8 +83,7 @@ void pptx_conversion_context::set_output_document(package::pptx_document * docum
void pptx_conversion_context::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_ )
applicationFonts_->InitializeFromFolder(pathFonts);
pptx_slide_context_.get_mediaitems().set_font_directory(pathFonts);
}
void pptx_conversion_context::process_layouts()
@ -333,7 +327,7 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().set_presentation (presentation_);
output_document_->get_ppt_files().set_comments (comments);
output_document_->get_ppt_files().set_authors_comments (authors_comments_);
output_document_->get_ppt_files().set_media (get_mediaitems(), applicationFonts_);
output_document_->get_ppt_files().set_media (get_mediaitems());
output_document_->get_content_types_file().set_media(get_mediaitems());
}

View File

@ -157,7 +157,6 @@ private:
package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_;
NSFonts::IApplicationFonts * applicationFonts_;
pptx_slide_context pptx_slide_context_;
pptx_text_context pptx_text_context_;

View File

@ -254,7 +254,65 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
}
} // CP_XML_WRITER
}
void pptx_serialize_connector(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:cxnSp")
{
CP_XML_NODE(L"p:nvCxnSpPr")
{
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"id", val.id);//числовое значение val.rId
CP_XML_ATTR(L"name", val.name);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"p:cNvCxnSpPr")//non visual properies (собственно тока 1 там)
{
if (val.sub_type == 1 || val.sub_type == 2)CP_XML_ATTR(L"txBox", 1);
CP_XML_NODE(L"a:spLocks")
{
CP_XML_ATTR(L"noGrp", 1);
}
}
CP_XML_NODE(L"p:nvPr")
{
if (val.place_holder_type_.length()>0)
{
CP_XML_NODE(L"p:ph")
{
CP_XML_ATTR(L"type",val.place_holder_type_);
if (val.place_holder_idx_ > 0) CP_XML_ATTR(L"idx", val.place_holder_idx_);
if (val.place_holder_type_ == L"dt") { CP_XML_ATTR(L"sz", L"half"); }
if (val.place_holder_type_ == L"ftr") { CP_XML_ATTR(L"sz", L"quarter"); }
if (val.place_holder_type_ == L"sldNum"){ CP_XML_ATTR(L"sz", L"quarter"); }
}
}
}
}
CP_XML_NODE(L"p:spPr")
{
_CP_OPT(bool) bNoRect;
odf_reader::GetProperty(val.additional,L"no_rect",bNoRect);
if (!bNoRect)
{
if (val.cx != 0 || val.cy != 0) //layout
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
}
val.serialize_shape(CP_XML_STREAM());
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
}
pptx_serialize_text(CP_XML_STREAM(), val);
}
} // CP_XML_WRITER
}
void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
@ -381,7 +439,10 @@ void _pptx_drawing::serialize(std::wostream & strm)
{
if (type == typeShape)
{
pptx_serialize_shape(strm, *this);
//if (connector) only for ms prst connectors, but not custom!!
// pptx_serialize_connector(strm, *this);
//else
pptx_serialize_shape(strm, *this);
}
else if (type == typeImage)
{

View File

@ -509,11 +509,11 @@ void ppt_files::add_notesMaster(slide_content_ptr slide)
{
notesMaster_files_.add_slide(slide);
}
void ppt_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
void ppt_files::set_media(mediaitems & _Mediaitems)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
}
if (_Mediaitems.count_object > 0)
{

View File

@ -217,7 +217,7 @@ public:
void add_notes (slide_content_ptr sheet);
void add_notesMaster(slide_content_ptr sheet);
void set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void set_media(mediaitems & _Mediaitems);
void add_charts(chart_content_ptr chart);
void add_theme (pptx_xml_theme_ptr theme);

View File

@ -147,11 +147,13 @@ void pptx_slide_context::Impl::process_drawings()
{
for (size_t i = 0; i < objects_.size(); i++)
{
_pptx_drawing drawing =_pptx_drawing();
_pptx_drawing drawing = _pptx_drawing();
drawing.type = objects_[i].type_;
drawing.name = objects_[i].name_;
drawing.id = next_rId();
drawing.type = objects_[i].type_;
drawing.name = objects_[i].name_;
drawing.id = next_rId();
drawing.lined = objects_[i].lined_;
drawing.connector = objects_[i].connector_;
process_common_properties(objects_[i], drawing);
@ -228,6 +230,8 @@ void pptx_slide_context::default_set()
impl_->object_description_.clipping_string_= L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->object_description_.connector_ = false;
impl_->object_description_.lined_ = false;
impl_->object_description_.hlinks_.clear();
impl_->object_description_.action_.clear();
@ -263,21 +267,20 @@ void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt
impl_->object_description_.svg_rect_ = _rect(width_pt, height_pt, x_pt, y_pt);
}
void pptx_slide_context::set_rotate(double angle)
void pptx_slide_context::set_rotate(double angle, bool translate)
{
set_property(odf_reader::_property(L"svg:rotate",angle));
set_property(odf_reader::_property(L"svg:rotate", angle));
if (impl_->object_description_.svg_rect_)
if (impl_->object_description_.svg_rect_ && translate)
{
//вращение в open office от центральной точки
_rect r = impl_->object_description_.svg_rect_.get();
//r.x_-=r.width_;
//r.y_-=r.height_;
impl_->object_description_.svg_rect_= r;
_rect &r = impl_->object_description_.svg_rect_.get();
double new_x = (r.cx / 2 * cos(-angle) - r.cy / 2 * sin(-angle) ) - r.cx / 2;
double new_y = (r.cx / 2 * sin(-angle) + r.cy / 2 * cos(-angle) ) - r.cy / 2;
r.x += new_x;
r.y += new_y;
}
}
void pptx_slide_context::set_translate(double x_pt, double y_pt)
{
if (impl_->object_description_.svg_rect_)
@ -321,12 +324,18 @@ void pptx_slide_context::set_clipping(const std::wstring & str)
{
impl_->object_description_.clipping_string_= str;
}
void pptx_slide_context::set_fill(_oox_fill & fill)
{
impl_->object_description_.fill_= fill;
}
void pptx_slide_context::set_is_line_shape(bool val)
{
impl_->object_description_.lined_ = val;
}
void pptx_slide_context::set_is_connector_shape(bool val)
{
impl_->object_description_.connector_ = val;
}
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & href)
{
++hlinks_size_;
@ -472,8 +481,8 @@ void pptx_slide_context::set_media_param(std::wstring name, std::wstring value)
void pptx_slide_context::set_image(const std::wstring & path)
{
int pos_replaicement = path.find(L"ObjectReplacements");
if (pos_replaicement >= 0)
size_t pos_replaicement = path.find(L"ObjectReplacements");
if (pos_replaicement != std::wstring::npos)
{
if (path.length() - (pos_replaicement + 18) < 2)
return; //object without image
@ -486,7 +495,7 @@ void pptx_slide_context::set_image(const std::wstring & path)
}
else if (impl_->use_image_replacement_)
{
impl_->object_description_.fill_.type = 2;
impl_->object_description_.fill_.type = 2;
impl_->object_description_.fill_.bitmap = oox::oox_bitmap_fill::create();
impl_->object_description_.fill_.bitmap->xlink_href_ = path;
impl_->object_description_.fill_.bitmap->bStretch = true;
@ -538,10 +547,13 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent, sColorMode;
_CP_OPT(std::wstring) sTextContent, sColorMode;
_CP_OPT(double) dLuminance, dContrast;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
@ -550,11 +562,11 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
}
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL);
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, get_mediaitems().applicationFonts());
drawing.fill.bitmap->bStretch = true;
if ((sColorMode) && (*sColorMode == L"greyscale"))
drawing.fill.bitmap->bGrayscale = true;
drawing.fill.bitmap->luminance = true;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;/// это ссылка на выходной внешний объект
@ -632,25 +644,29 @@ void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _
}
void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _pptx_drawing & drawing)
{
std::wstring ref;
bool isMediaInternal = true;
std::wstring ref, ref_image;
bool isMediaInternal = true, isMediaInternal_image = true;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
if (drawing.fill.bitmap)
if (!drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.fill.bitmap->xlink_href_ = L"zero.png";
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
}
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
}
void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _pptx_drawing & drawing)
{
std::wstring ref;
bool isMediaInternal = true;
std::wstring ref, ref_image;
bool isMediaInternal = true, isMediaInternal_image = true;
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
@ -658,26 +674,27 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
drawing.extId = L"ext" + drawing.objectId;
drawing.extExternal = !isMediaInternal;
if (!drawing.fill.bitmap)
{
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.fill.bitmap->xlink_href_ = L"zero.png";
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
}
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
add_additional_rels( isMediaInternal, drawing.extId, ref, typeMedia);
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
}
void pptx_slide_context::Impl::process_common_properties(drawing_object_description & pic, _pptx_drawing & drawing)
{
if (pic.svg_rect_)
{
int val;
//todooo непонятки с отрицательными значениями
int val = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if ( val >= 0) drawing.x = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if ( val >= 0 ) drawing.y = val;
drawing.x = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
drawing.y = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
val = (int)(0.5 + odf_types::length(pic.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if ( val >=0 ) drawing.cx = val;

View File

@ -59,11 +59,11 @@ public:
void set_transitionAction (bool val);
void set_transitionSpeed (std::wstring val);
///////////////////////////////////////////////////////////////////////////////////////////
void set_rect (double width_pt, double height_pt, double x_pt, double y_pt);
void set_rect (double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate (double x_pt, double y_pt);
void set_scale (double cx_pt, double cy_pt);
void set_rotate (double angle);
void set_rotate (double angle, bool translate = false);
void set_name (std::wstring const & name);
void set_anchor (std::wstring anchor, double x_pt, double y_pt);
@ -72,6 +72,9 @@ public:
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_is_line_shape(bool val);
void set_is_connector_shape(bool val);
void set_placeHolder_type (std::wstring typeHolder);
void set_placeHolder_idx (int idx);

View File

@ -99,7 +99,6 @@ private:
odf_reader::odf_read_context & odf_context_ ;
std::wstring hyperlink_hId;
bool in_span;
bool in_paragraph;
@ -275,7 +274,7 @@ void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name, std::
void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_properties & propertiesOut, int Level)
{
if (Level <0)return;
if (Level < 0)return;
if (list_style_stack_.empty())return;
odf_reader::style_list_level_properties *list_properties= NULL;
@ -362,7 +361,7 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{
get_styles_context().start();
int level = list_style_stack_.size()-1;
int level = list_style_stack_.size() - 1;
odf_reader::paragraph_format_properties paragraph_properties_;
@ -643,7 +642,7 @@ void pptx_text_context::Impl::start_list_item(bool restart)
void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Continue)
{
if (paragraphs_cout_ > 0 && in_paragraph)
if (paragraphs_cout_ > 0 && ( in_paragraph || list_style_stack_.empty()))
{
dump_paragraph();
}

View File

@ -162,7 +162,7 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
}
CP_XML_NODE(L"xdr:cNvSpPr")//non visual properies (собственно тока 1 там)
{
if (val.sub_type==1)CP_XML_ATTR(L"txBox", 1);
if (val.sub_type == 1)CP_XML_ATTR(L"txBox", 1);
}
} // xdr:nv_Pr
CP_XML_NODE(L"xdr:spPr")
@ -171,11 +171,7 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
val.serialize_shape(CP_XML_STREAM());
bool draw_always = false;
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
draw_always = true;
oox_serialize_ln(CP_XML_STREAM(),val.additional, draw_always);
oox_serialize_ln(CP_XML_STREAM(),val.additional, val.lined);
} // xdr:spPr
xlsx_serialize_text(CP_XML_STREAM(), val);

View File

@ -53,8 +53,7 @@ namespace oox {
class xlsx_drawing_context_handle::Impl
{
public:
Impl(mediaitems & items)
: items_(items), next_rId_(1), next_drawing_id_(1)
Impl(mediaitems & items) : items_(items), next_rId_(1), next_drawing_id_(1)
{
}
@ -162,6 +161,8 @@ void xlsx_drawing_context::clear()
{
impl_->object_description_.type_ = typeUnknown;
impl_->object_description_.in_group_ = false;
impl_->object_description_.lined_ = false;
impl_->object_description_.connector_ = false;
impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.name_ = L"";
impl_->object_description_.anchor_ = L"";
@ -360,17 +361,18 @@ void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
}
}
void xlsx_drawing_context::set_rotate(double angle)
void xlsx_drawing_context::set_rotate(double angle, bool translate)
{
set_property(odf_reader::_property(L"svg:rotate", angle));
if (impl_->object_description_.svg_rect_)
if (impl_->object_description_.svg_rect_ && translate)
{
_rect & r = impl_->object_description_.svg_rect_.get();
_rect &r = impl_->object_description_.svg_rect_.get();
double new_x = (r.cx / 2 * cos(-angle) - r.cy / 2 * sin(-angle) ) - r.cx / 2;
double new_y = (r.cx / 2 * sin(-angle) + r.cy / 2 * cos(-angle) ) - r.cy / 2;
//r.x -= r.width_/2;
//r.y -= r.height_/2;
r.x += new_x;
r.y += new_y;
}
}
void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt)
@ -543,6 +545,8 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
@ -551,7 +555,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
}
std::wstring fileName = odf_packet_path_ + FILE_SEPARATOR_STR + obj.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL/*applicationFonts_*/);
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, impl_->get_mediaitems().applicationFonts());
drawing.fill.bitmap->bStretch = true;
if ((sColorMode) && (*sColorMode == L"greyscale"))
@ -673,11 +677,13 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
_xlsx_drawing drawing =_xlsx_drawing();
drawing.type = obj.type_;
drawing.name = obj.name_;
drawing.fill = obj.fill_;
drawing.inGroup = obj.in_group_;
drawing.id = impl_->next_rId();
drawing.type = obj.type_;
drawing.name = obj.name_;
drawing.fill = obj.fill_;
drawing.inGroup = obj.in_group_;
drawing.id = impl_->next_rId();
drawing.lined = obj.lined_;
drawing.connector = obj.connector_;
drawing.sub_type = obj.shape_type_;
@ -741,6 +747,14 @@ void xlsx_drawing_context::set_link(std::wstring link, RelsType typeRels)
void xlsx_drawing_context::end_action()
{
}
void xlsx_drawing_context::set_is_line_shape(bool val)
{
impl_->object_description_.lined_ = val;
}
void xlsx_drawing_context::set_is_connector_shape(bool val)
{
impl_->object_description_.connector_ = val;
}
}

View File

@ -103,13 +103,16 @@ public:
void set_translate (double x_pt, double y_pt);
void set_scale (double cx_pt, double cy_pt);
void set_rotate (double angle);
void set_rotate (double angle, bool translate = false);
void set_anchor (std::wstring anchor, double x_pt, double y_pt, bool group = false);
void set_property (odf_reader::_property p);
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_is_line_shape(bool val);
void set_is_connector_shape(bool val);
std::vector<odf_reader::_property> & get_properties();
std::wstring add_hyperlink(std::wstring const & ref);

View File

@ -41,8 +41,9 @@ namespace oox {
class xlsx_xml_worksheet::Impl
{
public:
Impl(std::wstring const & name) : name_(name){}
Impl(std::wstring const & name, bool hidden) : name_(name), hidden_(hidden) {}
std::wstring name_;
bool hidden_;
std::wstringstream cols_;
std::wstringstream sheetFormat_;
@ -60,6 +61,7 @@ public:
std::wstringstream ole_objects_;
std::wstringstream page_props_;
std::wstringstream controls_;
std::wstringstream protection_;
rels sheet_rels_;
@ -77,14 +79,18 @@ std::wstring xlsx_xml_worksheet::name() const
{
return impl_->name_;
}
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name)
bool xlsx_xml_worksheet::hidden() const
{
return boost::make_shared<xlsx_xml_worksheet>(name);
return impl_->hidden_;
}
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name)
: impl_(new xlsx_xml_worksheet::Impl(name))
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name, bool hidden)
{
return boost::make_shared<xlsx_xml_worksheet>(name, hidden);
}
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name, bool hidden)
: impl_(new xlsx_xml_worksheet::Impl(name, hidden))
{
}
@ -156,6 +162,10 @@ std::wostream & xlsx_xml_worksheet::dataValidations()
{
return impl_->dataValidations_;
}
std::wostream & xlsx_xml_worksheet::protection()
{
return impl_->protection_;
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::sheet_rels()
{
@ -184,6 +194,10 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_STREAM() << impl_->sheetData_.str();
}
if (!impl_->protection_.str().empty())
{
CP_XML_STREAM() << impl_->protection_.str();
}
//оказывается порядок нахождения элементов важен !!! (для office 2010)
//объединенные ячейки раньше чем гиперлинки !!!
@ -203,7 +217,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->hyperlinks_.str();
}
}
if (!impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();

View File

@ -47,10 +47,11 @@ typedef _CP_PTR(xlsx_xml_worksheet) xlsx_xml_worksheet_ptr;
class xlsx_xml_worksheet: noncopyable
{
public:
xlsx_xml_worksheet(std::wstring const & name);
xlsx_xml_worksheet(std::wstring const & name, bool hidden);
~xlsx_xml_worksheet();
std::wstring name() const;
bool hidden() const;
std::wostream & cols();
std::wostream & sheetFormat();
@ -68,6 +69,7 @@ public:
std::wostream & ole_objects();
std::wostream & page_properties();
std::wostream & controls();
std::wostream & protection();
rels & sheet_rels(); //hyperlink, background image, external, media ...
@ -81,7 +83,7 @@ public:
std::pair<std::wstring, std::wstring> get_vml_drawing_link() const;
std::pair<std::wstring, std::wstring> get_comments_link() const;
static xlsx_xml_worksheet_ptr create(std::wstring const & name);
static xlsx_xml_worksheet_ptr create(std::wstring const & name, bool hidden);
private:
class Impl;

View File

@ -298,11 +298,11 @@ void xl_files::add_sheet(sheet_content_ptr sheet)
sheets_files_.add_sheet(sheet);
}
void xl_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
void xl_files::set_media(mediaitems & _Mediaitems)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
}
if (_Mediaitems.count_object > 0)

View File

@ -284,7 +284,7 @@ public:
void set_sharedStrings (element_ptr Element);
void set_connections (element_ptr Element);
void add_sheet (sheet_content_ptr sheet);
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void set_media (mediaitems & _Mediaitems);
void set_drawings (element_ptr Element);
void set_vml_drawings (element_ptr Element);
void set_comments (element_ptr Element);

View File

@ -44,6 +44,7 @@
#include "../formulasconvert/formulasconvert.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
namespace cpdoccore {
namespace oox {
@ -134,9 +135,10 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false),
bEndTable_(false),
bRTL_(false)
bEndTable(false),
bRTL(false),
bHidden(false),
bProtected(false)
{
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = context_->root()->odf_context().styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
@ -144,10 +146,17 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
if ((tableStyle) && (tableStyle->content()))
table_prop = tableStyle->content()->get_style_table_properties();
if ((table_prop) && (table_prop->content().common_writing_mode_attlist_.style_writing_mode_))
if (table_prop)
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
bRTL_ = true;
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_)
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
bRTL = true;
}
if ((table_prop->content().table_display_) && (false == table_prop->content().table_display_))
{
bHidden = true;
}
}
}
@ -162,7 +171,27 @@ void xlsx_table_state::start_column(unsigned int repeated, const std::wstring &
void xlsx_table_state::set_rtl(bool val)
{
bRTL_ = val;
bRTL = val;
}
void xlsx_table_state::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
bProtected = val;
protect_key = key;
size_t pos = algorithm.find(L"#");
if (pos != std::wstring::npos)
{
protect_key_algorithm = algorithm.substr(pos + 1);
}
//test
//CRYPT::odfWriteProtect protect;
//protect.SetProtectKey(DecodeBase64(protect_key));
//protect.SetPassword(L"123");
//bool res = protect.Verify();
}
unsigned int xlsx_table_state::columns_count() const
@ -389,6 +418,21 @@ void xlsx_table_state::serialize_background (std::wostream & strm)
}
}
}
void xlsx_table_state::serialize_protection (std::wostream & strm)
{
if (!bProtected) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"sheetProtection")
{
CP_XML_ATTR(L"sheet", 1);
CP_XML_ATTR(L"objects", 1);
CP_XML_ATTR(L"scenarios", 1);
//convert protection odf->ooxml impossible without password !!!
}
}
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
@ -437,7 +481,7 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
CP_XML_ATTR(L"workbookViewId", 0);
if (bRTL_)
if (bRTL)
CP_XML_ATTR(L"rightToLeft", 1);
std::wstring s_col, s_row;

View File

@ -32,6 +32,7 @@
#pragma once
#include <vector>
#include <map>
#include "xlsx_row_spanned.h"
#include "xlsx_merge_cells.h"
@ -76,10 +77,6 @@ public:
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
size_t row_header;
size_t start_column_header;
size_t end_column_header;
std::vector<std::wstring> header_values;
void set_header(size_t row, size_t col1, size_t col2)
@ -96,12 +93,29 @@ public:
while (col - start_column_header + 1 >= header_values.size())
header_values.push_back(L"");
header_values[col - start_column_header] = value;
std::map<std::wstring, int>::iterator pFind = map_unique_header_values.find(value);
if (pFind == map_unique_header_values.end())
{
map_unique_header_values.insert(std::make_pair(value, 1));
header_values[col - start_column_header] = value;
}
else
{
pFind->second++;
header_values[col - start_column_header] = value + std::to_wstring(pFind->second);
}
}
bool in_header(size_t col, size_t row)
{
return (row_header == row && (col >= start_column_header && col <= end_column_header));
}
private:
size_t row_header;
size_t start_column_header;
size_t end_column_header;
std::map<std::wstring, int> map_unique_header_values;
};
class xlsx_table_state
@ -112,7 +126,8 @@ public:
std::wstring current_style() const { return table_style_; }
void set_rtl(bool val);
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
@ -122,8 +137,8 @@ public:
void add_empty_row(int count);
void set_end_table(){ bEndTable_ = true; }
bool get_end_table(){ return bEndTable_; }
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
@ -168,12 +183,14 @@ public:
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
std::wstring get_table_name() const { return tableName_; }
int get_table_id() const { return tableId_; }
bool get_table_hidden() const { return bHidden; }
struct _group_row
{
@ -187,10 +204,15 @@ public:
friend class xlsx_table_context;
private:
bool bRTL_;
bool bEndTable_;
xlsx_conversion_context * context_;
bool bProtected;
std::wstring protect_key;
std::wstring protect_key_algorithm;
bool bRTL;
bool bEndTable;
bool bHidden;
std::wstring tableName_;
int tableId_;
std::wstring tableBackground_;

View File

@ -204,17 +204,19 @@ xlsx_text_context_(textContext)
{
}
void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName, int id)
void xlsx_table_context::start_table(const std::wstring & tableName, const std::wstring & tableStyleName, int id)
{
xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName, id);
xlsx_table_states_.push_back( state);
}
void xlsx_table_context::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
xlsx_table_states_.back()->set_protection(val, key, algorithm);
}
void xlsx_table_context::end_table()
{
//xlsx_table_states_.pop_back();
}
}
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
{
state()->start_cell(columnsSpanned, rowsSpanned);
@ -336,6 +338,38 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
{
if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
// из за дебелизма мсофис которому ОБЯЗАТЕЛЬНО нужно прописывать имена колонок таблицы (и они должны быть еще
// прописаны и в самих данных таблицы !!
int i = xlsx_data_ranges_[it->second]->header_values.size() - 1;
for (; i >= 0; i--)
{
if (false == xlsx_data_ranges_[it->second]->header_values[i].empty())
{
break;
}
}
if (i == -1)
{
xlsx_data_ranges_[it->second]->bTablePart = false;
continue;
}
else
{
size_t erase = xlsx_data_ranges_[it->second]->header_values.size() - 1 - i;
if (erase > 0)
{
xlsx_data_ranges_[it->second]->header_values.erase(xlsx_data_ranges_[it->second]->header_values.begin() + i + 1, xlsx_data_ranges_[it->second]->header_values.end());
xlsx_data_ranges_[it->second]->cell_end.first -= erase;
std::wstring ref1 = getCellAddress(xlsx_data_ranges_[it->second]->cell_start.first, xlsx_data_ranges_[it->second]->cell_start.second);
std::wstring ref2 = getCellAddress(xlsx_data_ranges_[it->second]->cell_end.first, xlsx_data_ranges_[it->second]->cell_end.second);
xlsx_data_ranges_[it->second]->ref = ref1 + L":" + ref2;
}
}
//--------------------------------------------------------
size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
std::wstring rId = L"tprtId" + std::to_wstring(id);
@ -349,10 +383,10 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
}
}
Rels.add( relationship(rId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", ref));
//--------------------------------------------------------
std::wstringstream strm;
CP_XML_WRITER(strm)
{
{
CP_XML_NODE(L"table")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
@ -451,6 +485,10 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
}
}
}
void xlsx_table_context::serialize_protection(std::wostream & _Wostream)
{
return state()->serialize_protection(_Wostream);
}
void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
{
return state()->serialize_conditionalFormatting(_Wostream);

View File

@ -48,7 +48,8 @@ class xlsx_table_context
public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void start_table(const std::wstring &tableName, const std::wstring & tableStyleName, int id);
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void end_table();
void start_cell(const std::wstring & formula,
@ -94,6 +95,7 @@ public:
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_data_validation (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();

View File

@ -45,7 +45,6 @@
#include "../odf/odfcontext.h"
#include "../odf/calcs_styles.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
@ -76,7 +75,6 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
mediaitems_ (odf_document_->get_folder()),
xlsx_drawing_context_handle_(mediaitems_)
{
applicationFonts_ = NSFonts::NSApplication::Create();
}
std::unordered_map<std::wstring, int> xlsx_conversion_context::mapExternalLink_;
@ -88,15 +86,11 @@ void xlsx_conversion_context::set_output_document (package::xlsx_document * docu
xlsx_conversion_context::~xlsx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void xlsx_conversion_context::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_ == NULL) return;
applicationFonts_->InitializeFromFolder(pathFonts);
mediaitems_.set_font_directory(pathFonts);
}
void xlsx_conversion_context::start_chart(std::wstring name)
@ -184,7 +178,7 @@ void xlsx_conversion_context::end_document()
{
CP_XML_ATTR(L"name", sheet->name()); // office 2010 ! ограничение на длину имени !!!
CP_XML_ATTR(L"sheetId", i + 1);
CP_XML_ATTR(L"state", L"visible");
CP_XML_ATTR(L"state", sheet->hidden() ? L"hidden" : L"visible");
CP_XML_ATTR(L"r:id", id);
}
}
@ -327,7 +321,7 @@ void xlsx_conversion_context::end_document()
output_document_->get_xl_files().set_workbook( package::simple_element::create(L"workbook.xml", strm_workbook.str()) );
output_document_->get_content_types_file().set_media(get_mediaitems());
output_document_->get_xl_files().set_media(get_mediaitems(), applicationFonts_);
output_document_->get_xl_files().set_media(get_mediaitems());
package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content());
output_document_->get_xl_files().set_drawings(drawings);
@ -432,15 +426,12 @@ int xlsx_conversion_context::find_sheet_by_name(std::wstring tableName)
}
return -1;
}
void xlsx_conversion_context::create_new_sheet(std::wstring const & name)
{
sheets_.push_back(xlsx_xml_worksheet::create(name));
}
bool xlsx_conversion_context::start_table(std::wstring tableName, std::wstring tableStyleName)
{
create_new_sheet(tableName);
get_table_context().start_table(tableName, tableStyleName, sheets_.size() - 1);
sheets_.push_back(xlsx_xml_worksheet::create(tableName, get_table_context().state()->get_table_hidden()));
current_sheet().cols() << L"<cols>";
return true;
}
@ -481,7 +472,8 @@ void xlsx_conversion_context::end_table()
get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
get_table_context().serialize_data_validation (current_sheet().dataValidations());
get_table_context().serialize_protection (current_sheet().protection());
get_drawing_context().set_odf_packet_path (root()->get_folder());
get_drawing_context().process_objects (get_table_metrics());
@ -738,7 +730,7 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
else
font_size =10;
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, applicationFonts_);
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, mediaitems_.applicationFonts());
}
return maxDigitSize_;
}

View File

@ -56,11 +56,6 @@
#include "mediaitems.h"
namespace NSFonts
{
class IApplicationFonts;
}
namespace cpdoccore {
namespace odf_reader
@ -203,8 +198,6 @@ public:
static std::unordered_map<std::wstring, int> mapExternalLink_;
std::map<std::wstring, int> mapUsedNames_;
private:
void create_new_sheet (std::wstring const & name);
void serialize_bookViews(std::wostream & strm);
void serialize_calcPr (std::wostream & strm);
@ -212,8 +205,6 @@ private:
const odf_reader::office_element *spreadsheet_;
odf_reader::odf_document *odf_document_;
NSFonts::IApplicationFonts *applicationFonts_;
std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_;
std::vector<std::wstring> table_parts_;

View File

@ -510,7 +510,7 @@ public:
_CP_OPT(std::wstring) draw_id_;
_CP_OPT(std::wstring) draw_layer_;
_CP_OPT(std::wstring) draw_transform_;
_CP_OPT(int) draw_z_index_;
_CP_OPT(unsigned int) draw_z_index_;
_CP_OPT(std::wstring) drawooo_display_;
};

View File

@ -139,13 +139,6 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"mso-spt18" ,L"irregularSeal1" ,0 ,0 ,0 },
{L"mso-spt19" ,L"rect" ,0 ,0 ,0 },
{L"mso-spt24" ,L"textBox" ,0 ,0 ,0 },
{L"mso-spt25" ,L"" ,0 ,0 ,0 },
{L"mso-spt26" ,L"" ,0 ,0 ,0 },
{L"mso-spt27" ,L"" ,0 ,0 ,0 },
{L"mso-spt28" ,L"" ,0 ,0 ,0 },
{L"mso-spt29" ,L"" ,0 ,0 ,0 },
{L"mso-spt30" ,L"" ,0 ,0 ,0 },
{L"mso-spt31" ,L"" ,0 ,0 ,0 },
{L"mso-spt32" ,L"straightConnector1" ,0 ,0 ,0 },
{L"mso-spt33" ,L"bentConnector2" ,0 ,0 ,0 },
{L"mso-spt34" ,L"bentConnector3" ,0 ,0 ,0 },
@ -181,10 +174,10 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"mso-spt107" ,L"ellipseRibbon" ,0 ,0 ,0 },
{L"mso-spt108" ,L"ellipseRibbon2" ,0 ,0 ,0 },
{L"mso-spt129" ,L"flowChartMagneticDrum" ,0 ,0 ,0 },
{L"mso-spt167" ,L"rect" ,0 ,0 ,0 },
{L"mso-spt178" ,L"" ,0 ,0 ,0 },
{L"mso-spt179" ,L"" ,0 ,0 ,0 },
{L"mso-spt180" ,L"" ,0 ,0 ,0 },
{L"mso-spt178" ,L"callout1" ,0 ,0 ,0 },
{L"mso-spt179" ,L"callout2" ,0 ,0 ,0 },
{L"mso-spt180" ,L"callout3" ,0 ,0 ,0 },
{L"mso-spt182" ,L"leftRightUpArrow" ,0 ,0 ,0 },
{L"mso-spt188" ,L"flowChartPunchedTape",0 ,0 ,0 },
{L"mso-spt189" ,L"actionButtonBlank" ,0 ,0 ,0 },
@ -299,6 +292,13 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"fontwork-slant-up" ,L"textSlantUp" ,0 ,0 ,0 },
{L"fontwork-slant-down" ,L"textSlantDown" ,0 ,0 ,0 },
{L"mso-spt25" ,L"textPlain" ,0 ,0 ,0 },//
{L"mso-spt26" ,L"textPlain" ,0 ,0 ,0 },
{L"mso-spt27" ,L"textCurveDown" ,0 ,0 ,0 },
{L"mso-spt28" ,L"textWave1" ,0 ,0 ,0 },
{L"mso-spt29" ,L"textRingInside" ,0 ,0 ,0 },
{L"mso-spt30" ,L"textPlain" ,0 ,0 ,0 },
{L"mso-spt31" ,L"textRingOutside" ,0 ,0 ,0 },
{L"mso-spt142" ,L"textRingInside" ,0 ,0 ,0 },
{L"mso-spt143" ,L"textRingOutside" ,0 ,0 ,0 },
{L"mso-spt157" ,L"textWave2" ,0 ,0 ,0 },
@ -310,7 +310,8 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"mso-spt163" ,L"textDeflateBottom" ,0 ,0 ,0 },
{L"mso-spt164" ,L"textInflateTop" ,0 ,0 ,0 },
{L"mso-spt165" ,L"textDeflateTop" ,0 ,0 ,0 },
{L"mso-spt166" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
{L"mso-spt166" ,L"textDeflateInflate" ,0 ,0 ,0 },
{L"mso-spt167" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
{L"mso-spt174" ,L"textCanUp" ,0 ,0 ,0 },
{L"mso-spt175" ,L"textCanDown" ,0 ,0 ,0 },
{L"mso-spt188" ,L"textDoubleWave1" ,0 ,0 ,0 },

View File

@ -60,6 +60,10 @@ std::wostream & operator << (std::wostream & _Wostream, const marker_style & _Va
std::wstring marker_style::parse(const std::wstring & Str)
{
if (Str.empty())
{
return L"none";
}
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);

View File

@ -58,13 +58,11 @@ namespace _image_file_
{
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts* appFonts)
{
if (!appFonts) return false;
CBgraFrame image;
MetaFile::IMetaFile* meta_file = MetaFile::Create(appFonts);
bool bRet = false;
if ( meta_file->LoadFromFile(fileName))
if ( appFonts && meta_file->LoadFromFile(fileName))
{
double dX = 0, dY = 0, dW = 0, dH = 0;
meta_file->GetBounds(&dX, &dY, &dW, &dH);
@ -83,6 +81,18 @@ namespace _image_file_
RELEASEOBJECT(meta_file);
return bRet;
}
void GenerateZeroImage(const std::wstring & fileName)
{
NSFile::CFileBinary file;
if (file.CreateFileW(fileName))
{
BYTE pData[149] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x03, 0x00, 0x00, 0x01, 0x5f, 0xcc, 0x04, 0x2d, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x06, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x67, 0xb9, 0xcf, 0x00, 0x00, 0x00, 0x02, 0x74, 0x52, 0x4e, 0x53, 0xff, 0x00, 0xe5, 0xb7, 0x30, 0x4a, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x12, 0x74, 0x00, 0x00, 0x12, 0x74, 0x01, 0xde, 0x66, 0x1f, 0x78, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xa3, 0xda, 0x3d, 0x94, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
file.WriteFile(pData, 149);
file.CloseFile();
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace cpdoccore {
@ -101,11 +111,11 @@ int get_value_emu(double pt)
{
return static_cast<int>((pt* 360000 * 2.54) / 72);
}
bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts)
bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts *appFonts)
{
memset(clip_rect, 0, 4*sizeof(double));
if (strClipping.length() <1 || fileName.length()<1)return false;
if (strClipping.empty() || fileName.empty()) return false;
//<top>, <right>, <bottom>, <left> - http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html#clip
@ -114,7 +124,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
std::vector<std::wstring> Points;
std::vector<length> Points_pt;
boost::algorithm::split(Points,strClipping, boost::algorithm::is_any_of(L" ,"), boost::algorithm::token_compress_on);
boost::algorithm::split(Points, strClipping, boost::algorithm::is_any_of(L" ,"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < Points.size(); i++)
{
@ -125,9 +135,9 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
if (!bEnableCrop) return false;
int fileWidth=0,fileHeight=0;
int fileWidth = 0,fileHeight = 0;
if (!_image_file_::GetResolution(fileName.data(), fileWidth, fileHeight, appFonts) || fileWidth<1 || fileHeight<1) return false;
if (!_image_file_::GetResolution(fileName.data(), fileWidth, fileHeight, appFonts) || fileWidth < 1 || fileHeight < 1) return false;
if (Points_pt.size() > 3)//если другое количество точек .. попозже
{
@ -143,7 +153,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
clip_rect[1] = clip_rect[1]*100/fileHeight;
clip_rect[3] = clip_rect[3]*100/fileHeight;
if (clip_rect[0]<0.01 && clip_rect[1]<0.01 && clip_rect[2]<0.01 && clip_rect[3]<0.01)
if (clip_rect[0] < 0.01 && clip_rect[1] < 0.01 && clip_rect[2] < 0.01 && clip_rect[3] < 0.01)
return false;
return true;
}
@ -609,7 +619,7 @@ void parse_string_to_points(std::wstring str, std::vector<length> & Points)
}
}
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
void docx_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
{
std::vector<std::wstring> transforms;
@ -678,10 +688,10 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
std::vector<std::wstring> transform;
boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
if (transform.size()>1)//тока с аргументами
if (transform.size() > 1)//тока с аргументами
{
int res=0;
if ((res = transform[0].find(L"translate"))>=0)//перемещение
size_t res=0;
if ((res = transform[0].find(L"translate")) != std::wstring::npos)//перемещение
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
@ -695,7 +705,7 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
Context.get_drawing_context().set_translate(x_pt,y_pt);
}
}
else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
else if ((res = transform[0].find(L"scale")) != std::wstring::npos)//масштабирование
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
@ -708,19 +718,19 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
Context.get_drawing_context().set_scale(x_pt,y_pt);
}
}
else if ((res = transform[0].find(L"rotate"))>=0)//вращение
else if ((res = transform[0].find(L"rotate")) != std::wstring::npos)//вращение
{
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]));
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]), true);
}
else if ((res = transform[0].find(L"skewX"))>=0)//сдвиг
else if ((res = transform[0].find(L"skewX")) != std::wstring::npos)//сдвиг
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:skewX",angle));
Context.get_drawing_context().set_property(_property(L"svg:skewX", angle));
}
else if ((res = transform[0].find(L"skewY"))>=0)//сдвиг
else if ((res = transform[0].find(L"skewY")) != std::wstring::npos)//сдвиг
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:skewY",angle));
Context.get_drawing_context().set_property(_property(L"svg:skewY", angle));
}
}
}
@ -738,49 +748,50 @@ void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_con
std::vector<std::wstring> transform;
boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
if (transform.size()>1)//тока с аргументами
if (transform.size() > 1)//тока с аргументами
{
int res=0;
if ((res = transform[0].find(L"translate"))>=0)//перемещение
size_t res = 0;
if ((res = transform[0].find(L"translate")) != std::wstring::npos)//перемещение
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
if (Points.size()>0)
if (false == Points.empty())
{
double x_pt = Points[0].get_value_unit(length::pt);
double y_pt = 0;
if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть
Context.get_slide_context().set_translate(x_pt,y_pt);
Context.get_slide_context().set_translate(x_pt, y_pt);
}
}
else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
else if ((res = transform[0].find(L"scale")) != std::wstring::npos)//масштабирование
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
if (Points.size()>0)
if (false == Points.empty())
{
double x_pt = Points[0].get_value_unit(length::pt);
double y_pt = x_pt;
if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть
Context.get_slide_context().set_scale(x_pt,y_pt);
Context.get_slide_context().set_scale(x_pt, y_pt);
}
}
else if ((res = transform[0].find(L"rotate"))>=0)//вращение
else if ((res = transform[0].find(L"rotate")) != std::wstring::npos)//вращение
{
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]));
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]), true);
}
else if ((res = transform[0].find(L"skewX"))>=0)//вращение
else if ((res = transform[0].find(L"skewX")) != std::wstring::npos)//вращение
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_slide_context().set_property(_property(L"svg:skewX",angle));
Context.get_slide_context().set_property(_property(L"svg:skewX", angle));
}
else if ((res = transform[0].find(L"skewY"))>=0)//вращение
else if ((res = transform[0].find(L"skewY")) != std::wstring::npos)//вращение
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_slide_context().set_property(_property(L"svg:skewY",angle));
Context.get_slide_context().set_property(_property(L"svg:skewY", angle));
}
}
}

View File

@ -52,7 +52,8 @@
namespace _image_file_
{
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts * appFonts);
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts *appFonts);
void GenerateZeroImage(const std::wstring & fileName);
}
namespace cpdoccore {
@ -74,7 +75,7 @@ void Compute_GraphicFill(const odf_types::common_draw_fill_attlist & props,
const office_element_ptr & style_image, styles_lite_container &styles, oox::_oox_fill & fill, bool txbx = false);
typedef double double_4[4];
bool parse_clipping(std::wstring strClipping,std::wstring fileName,double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts);
bool parse_clipping(std::wstring strClipping, std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts *appFonts);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class draw_a : public office_element_impl<draw_a>
{
@ -110,10 +111,9 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_a);
void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
void docx_convert_transforms(std::wstring transformStr, std::vector<odf_reader::_property> & additional);
void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_context & Context);
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional);
//void docx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
}
}

View File

@ -30,8 +30,6 @@
*
*/
#include "draw_frame.h"
#include <ostream>
#include <sstream>
#include <string>
@ -42,6 +40,8 @@
#include <xml/attributes.h>
#include <odf/odf_document.h>
#include "draw_common.h"
#include "serialize_elements.h"
#include "style_graphic_properties.h"
#include "odfcontext.h"
@ -154,6 +154,75 @@ void draw_g::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_g::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
if (content_.empty()) return;
draw_g *group = dynamic_cast<draw_g*> (content_.back().get());
draw_frame *frame = dynamic_cast<draw_frame*> (content_.back().get());
draw_shape *shape = dynamic_cast<draw_shape*> (content_.back().get());
if (group)
{
int x = 0, y = 0, cx = 0, cy = 0;
if (group->common_draw_attlists_.position_.svg_x_ && group->common_draw_attlists_.position_.svg_y_)
{
x = get_value_emu(group->common_draw_attlists_.position_.svg_x_);
y = get_value_emu(group->common_draw_attlists_.position_.svg_y_);
}
else
{
x = group->position_child_x1;
y = group->position_child_y1;
}
if (group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ &&
group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
{
cx = get_value_emu(group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
cy = get_value_emu(group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
}
else
{
cx = group->position_child_x2 - group->position_child_x1;
cy = group->position_child_y2 - group->position_child_y1;
}
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
}
else if (frame)
{
int x = 0, y = 0, cx = 0, cy = 0;
x = get_value_emu(frame->common_draw_attlists_.position_.svg_x_);
y = get_value_emu(frame->common_draw_attlists_.position_.svg_y_);
cx = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
cy = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
}
else if (shape)
{
int x = 0, y = 0, cx = 0, cy = 0;
x = get_value_emu(shape->common_draw_attlists_.position_.svg_x_);
y = get_value_emu(shape->common_draw_attlists_.position_.svg_y_);
cx = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
cy = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
}
}
std::wostream & draw_g::text_to_stream(std::wostream & _Wostream) const
@ -303,6 +372,8 @@ void draw_object_ole::detectObject(const std::wstring &fileName, std::wstring &p
POLE::Storage *storage = new POLE::Storage(fileName.c_str());
if ((storage) && (storage->open(false, false) == true))
{
rels = oox::typeOleObject;
std::wstring prog;
POLE::Stream* pStream = new POLE::Stream(storage, L"CompObj");
if ((pStream) && (pStream->size() > 28))

View File

@ -209,6 +209,8 @@ public:
static const ElementType type = typeDrawG;
CPDOCCORE_DEFINE_VISITABLE();
draw_g() : position_child_x1(0x7fffffff), position_child_y1(0x7fffffff), position_child_x2(0x7fffffff), position_child_y2(0x7fffffff) {}
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void docx_convert(oox::docx_conversion_context & Context);
@ -220,6 +222,12 @@ public:
office_element_ptr_array content_;
int position_child_x1;
int position_child_y1;
int position_child_x2;
int position_child_y2;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);

View File

@ -574,11 +574,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
const graphic_format_properties & graphicProperties,
const std::vector<odf_reader::_property> & additional)
{
// TODO : recursive result!!!
const _CP_OPT(anchor_type) anchor =
attlists_.shape_with_text_and_styles_.
common_text_anchor_attlist_.
type_;
const _CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
//todooo пока не ясно как привязать к определеной странице в документе ...
//const _CP_OPT(unsigned int) anchor_page_number =
@ -589,6 +585,15 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
_CP_OPT(vertical_rel) styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
_CP_OPT(vertical_pos) styleVerticallPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
if (!styleVerticalRel && anchor)
{
switch(anchor->get_type())
{
case anchor_type::Paragraph: styleVerticalRel = vertical_rel::Paragraph; break;
case anchor_type::Page: styleVerticalRel = vertical_rel::Page; break;
}
}
_CP_OPT(double) dVal;
GetProperty(additional, L"svg:translate_y", dVal);
@ -817,14 +822,31 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
}
_CP_OPT(run_through) styleRunThrough = graphicProperties.style_run_through_;
_CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
drawing->styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
drawing->styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
drawing->styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
drawing->styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
_CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
if (!drawing->styleVerticalRel && anchor)
{
switch(anchor->get_type())
{
case anchor_type::Paragraph: drawing->styleVerticalRel = vertical_rel::Paragraph; break;
case anchor_type::Page: drawing->styleVerticalRel = vertical_rel::Page; break;
case anchor_type::Char: drawing->styleVerticalRel = vertical_rel::Char; break;
}
}
if (!drawing->styleHorizontalRel && anchor)
{
switch(anchor->get_type())
{
case anchor_type::Paragraph: drawing->styleHorizontalRel = horizontal_rel::Paragraph; break;
case anchor_type::Page: drawing->styleHorizontalRel = horizontal_rel::Page; break;
case anchor_type::Char: drawing->styleHorizontalRel = horizontal_rel::Char; break;
}
}
int level_drawing = Context.get_drawing_context().get_current_level();
if (drawing->parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
@ -834,7 +856,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
if (attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_)
{
std::wstring transformStr = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_.get();
oox_convert_transforms(transformStr, drawing->additional);
docx_convert_transforms(transformStr, drawing->additional);
}
if (!drawing->isInline)
{
@ -852,7 +874,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
if (!drawing->styleWrap)
drawing->styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
_CP_OPT(int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
_CP_OPT(unsigned int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
if (zIndex)//порядок отрисовки объектов
{
@ -887,7 +909,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
}
drawing->number_wrapped_paragraphs = graphicProperties.style_number_wrapped_paragraphs_.
get_value_or( integer_or_nolimit( integer_or_nolimit::NoLimit) ).get_value();
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV< 0)
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV < 0)
{
drawing->posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
}
@ -936,14 +958,41 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
drawing->cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
drawing->cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
_CP_OPT(double) dVal;
GetProperty(drawing->additional, L"svg:rotate", dVal);
if (dVal)
{
double new_x = (drawing->cx / 2 * cos(-(*dVal)) - drawing->cy / 2 * sin(-(*dVal)) ) - drawing->cx / 2;
double new_y = (drawing->cx / 2 * sin(-(*dVal)) + drawing->cy / 2 * cos(-(*dVal)) ) - drawing->cy / 2;
drawing->x += new_x;
drawing->y += new_y;
}
GetProperty(drawing->additional, L"svg:scale_x",dVal);
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
GetProperty(drawing->additional, L"svg:scale_y",dVal);
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
GetProperty(drawing->additional, L"svg:translate_x", dVal);
if (dVal)
{
drawing->x += get_value_emu(dVal.get());
}
GetProperty(drawing->additional, L"svg:translate_y", dVal);
if (dVal)
{
drawing->y += get_value_emu(dVal.get());
}
if (drawing->cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
{
drawing->cx = -drawing->cx;
drawing->additional.push_back(_property(L"fit-to-size", true));
}
if (drawing->cy < 0)
drawing->cy = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////
if ((drawing->styleWrap) && (drawing->styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
{
@ -988,40 +1037,13 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
//}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
_CP_OPT(double) dVal;
GetProperty(drawing->additional, L"svg:scale_x",dVal);
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
GetProperty(drawing->additional, L"svg:scale_y",dVal);
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
GetProperty(drawing->additional, L"svg:translate_x", dVal);
if (dVal)
{
int val = get_value_emu(dVal.get());
drawing->x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
}
GetProperty(drawing->additional,L"svg:translate_y", dVal);
if (dVal)
{
int val = get_value_emu(dVal.get());
drawing->y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
}
if (drawing->inGroup && drawing->type != oox::typeGroupShape)
{
Context.get_drawing_context().set_position_child_group (drawing->x, drawing->y);
Context.get_drawing_context().set_size_child_group (drawing->cx + drawing->x, drawing->cy + drawing->y);
// ваще то тут "несовсем" всерно ... нужно сначала все стартовые позиции добавить ..
_INT32 x_group_offset, y_group_offset;
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
drawing->x -= x_group_offset;
drawing->y -= y_group_offset;
}
}
@ -1030,17 +1052,17 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
//--------------------------------------------------------------------------------------------------
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
drawing.lined = lined_shape_;
drawing.connector = connector_;
drawing.sub_type = sub_type_;
drawing.additional = additional_;//сюда могут добавиться свойства ...
if (drawing.sub_type != 5 &&
drawing.sub_type != 11 &&
drawing.sub_type != 12 )//line, connectors
if (drawing.lined == false)
{
drawing.additional.push_back(_property(L"text-content", Context.get_drawing_context().get_text_stream_shape()));
}
@ -1121,7 +1143,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
return;
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
int pos_replaicement = href.find(L"ObjectReplacements");
size_t pos_replaicement = href.find(L"ObjectReplacements");
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
if (!frame)
@ -1130,7 +1152,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
if (pos_replaicement >= 0)
if (pos_replaicement != std::wstring::npos)
{
if (!Context.get_drawing_context().get_use_image_replace())
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
@ -1192,10 +1214,18 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
std::wstring strRectClip = properties->fo_clip_.get();
strRectClip = strRectClip.substr(5, strRectClip.length() - 6);
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + href;
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + xlink_attlist_.href_.get_value_or(L"");
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
}
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, Context.get_mediaitems().applicationFonts());
}
if (properties->common_draw_fill_attlist_.draw_luminance_)
{
drawing->fill.bitmap->luminance = properties->common_draw_fill_attlist_.draw_luminance_->get_value();
}
if (properties->common_draw_fill_attlist_.draw_contrast_)
{
drawing->fill.bitmap->contrast = properties->common_draw_fill_attlist_.draw_contrast_->get_value();
}
}
}
@ -1349,9 +1379,18 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
Context.reset_context_state();
if (position_child_x1 != 0x7fffffff && position_child_y1 != 0x7fffffff )
{
Context.get_drawing_context().set_position_child_group (position_child_x1, position_child_y1);
if (position_child_x2 != 0x7fffffff && position_child_y2 != 0x7fffffff )
{
Context.get_drawing_context().set_size_child_group (position_child_x2 - position_child_x1, position_child_y2 - position_child_y1);
}
}
for (size_t i = 0; i < content_.size(); i++)
{
ElementType type = content_[i]->get_type();
content_[i]->docx_convert(Context);
}
drawing.content_group_ = temp_stream.str();
@ -1362,18 +1401,11 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
//--------------------------------------------------
Context.get_drawing_context().get_size_group (drawing.cx , drawing.cy);
Context.get_drawing_context().get_position_group(drawing.x , drawing.y);
drawing.cx -= drawing.x;
drawing.cy -= drawing.y;
Context.get_drawing_context().stop_group();
if (drawing.inGroup)
{
Context.get_drawing_context().set_position_child_group (drawing.x, drawing.y);
Context.get_drawing_context().set_size_child_group (drawing.cx + drawing.x, drawing.cy + drawing.y);
// ваще то тут "несовсем" верно ... нужно сначала все стартовые позиции добавить ..
_INT32 x_group_offset, y_group_offset;
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
@ -1645,7 +1677,7 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
if (!drawing) return;
std::wstring extension;
detectObject(href, drawing->objectProgId, extension, drawing->type);
detectObject(objectPath, drawing->objectProgId, extension, drawing->type);
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);

View File

@ -88,7 +88,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
common_shape_draw_attlist &common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_;
common_presentation_attlist &common_presentation_attlist_= common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
const int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const unsigned int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -115,7 +115,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
if (common_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.draw_transform_.get();
pptx_convert_transforms(transformStr,Context);
pptx_convert_transforms(transformStr, Context);
}
////////////////////////////////////////
std::wstring Anchor;
@ -125,7 +125,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
const double a_x_pt = common_draw_attlists_.shape_with_text_and_styles_.common_shape_table_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double a_y_pt = common_draw_attlists_.shape_with_text_and_styles_.common_shape_table_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt);
Context.get_slide_context().set_anchor(Anchor,a_x_pt,a_y_pt);
Context.get_slide_context().set_anchor(Anchor, a_x_pt, a_y_pt);
}
//////////////////////////////////////////////
std::vector<const odf_reader::style_instance *> instances;
@ -162,7 +162,13 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
Context.root()->odf_context().drawStyles(), fill);
if (properties.fo_clip_)
{
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_slide_context().set_clipping(strRectClip.substr(5, strRectClip.length() - 6));
}
Context.get_slide_context().set_fill(fill);
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_left", Compute_BorderWidth(properties, sideLeft)));
@ -170,11 +176,6 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight)));
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom)));
if (properties.fo_clip_)
{
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_slide_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
}
if (common_presentation_attlist_.presentation_class_)
{
Context.get_slide_context().set_placeHolder_type(common_presentation_attlist_.presentation_class_->get_type_ms());
@ -221,7 +222,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
}
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_slide_context().set_property(_property(L"text-content", text_content_));
}

View File

@ -73,8 +73,8 @@ void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context)
{
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
//////////////////////////////////////////////////////////////////////////
Context.get_drawing_context().start_group( name);
@ -118,7 +118,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
{
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring styleName = common_draw_attlist_.common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -144,7 +144,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
if (common_draw_attlist_.common_shape_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.common_shape_draw_attlist_.draw_transform_.get();
xlsx_convert_transforms(transformStr,Context);
xlsx_convert_transforms(transformStr, Context);
}
////////////////////////////////////////
std::wstring Anchor;
@ -179,14 +179,14 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight)));
Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom)));
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
if (properties.fo_clip_)
{
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_drawing_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
Context.get_drawing_context().set_clipping(strRectClip.substr(5, strRectClip.length() - 6));
}
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill);
oox_drawing_ = oox_drawing_ptr(new oox::_xlsx_drawing());
@ -228,7 +228,7 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
}
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
}

View File

@ -174,6 +174,7 @@ void draw_line::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_shape::add_attributes(Attributes);
sub_type_ = 5;
lined_shape_ = true;
}
void draw_line::reset_svg_attributes()
{
@ -256,8 +257,11 @@ void draw_path::reset_svg_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false);
bool bClosed = false;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false, bClosed);
if (!bClosed) lined_shape_ = true;
for (size_t i = 0; i < o_Polyline_cm.size(); i++)
{
::svg_path::_polyline & poly = o_Polyline_cm[i];
@ -275,7 +279,7 @@ void draw_path::reset_svg_path()
}
o_Polyline_pt.push_back(poly);
}
if (o_Polyline_pt.size()>0)
if (false == o_Polyline_pt.empty())
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
@ -291,18 +295,24 @@ void draw_polygon_attlist::add_attributes( const xml::attributes_wc_ptr & Attrib
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
//-------------------------------------------------------------------------------------------
// draw:polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_polygon::ns = L"draw";
const wchar_t * draw_polygon::name = L"polygon";
//-------------------------------------------------------------------------------------------
// draw:contour-polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_contour_polygon::ns = L"draw";
const wchar_t * draw_contour_polygon::name = L"contour-polygon";
//-------------------------------------------------------------------------------------------
// draw:contour-path
//-------------------------------------------------------------------------------------------
const wchar_t * draw_contour_path::ns = L"draw";
const wchar_t * draw_contour_path::name = L"contour-path";
//-------------------------------------------------------------------------------------------
// draw:polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_polygon::ns = L"draw";
const wchar_t * draw_polygon::name = L"polygon";
void draw_polygon::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_polygon_attlist_.add_attributes(Attributes);
@ -322,7 +332,7 @@ void draw_polygon::reset_polygon_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polygon_attlist_.draw_points_.get(),false, true);
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polygon_attlist_.draw_points_.get(), false, true);
for (size_t ind = 0 ; ind < o_Polyline_cm.size(); ind++)
{
@ -341,12 +351,12 @@ void draw_polygon::reset_polygon_path()
}
o_Polyline_pt.push_back(poly);
}
if (o_Polyline_pt.size()>0)
if (false == o_Polyline_pt.empty())
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
::svg_path::oox_serialize(output_, o_Polyline_pt);
additional_.push_back(odf_reader::_property(L"custom_path",output_.str()));
additional_.push_back(odf_reader::_property(L"custom_path", output_.str()));
}
}
}
@ -368,7 +378,8 @@ void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_polyline_attlist_.add_attributes(Attributes);
draw_shape::add_attributes(Attributes);
sub_type_ = 8;
sub_type_ = 14;
lined_shape_ = true;
}
void draw_polyline::reset_polyline_path()
@ -382,7 +393,7 @@ void draw_polyline::reset_polyline_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, true);
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, false);
_CP_OPT(double) start_x, start_y;
@ -407,7 +418,7 @@ void draw_polyline::reset_polyline_path()
}
o_Polyline_pt.push_back(poly);
}
if (o_Polyline_pt.size()>0)
if (false == o_Polyline_pt.empty())
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
@ -481,6 +492,8 @@ void draw_enhanced_geometry_attlist::add_attributes( const xml::attributes_wc_pt
CP_APPLY_ATTR(L"draw:enhanced-path" , draw_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:enhanced-path" , drawooo_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:sub-view-size" , drawooo_sub_view_size_);
CP_APPLY_ATTR(L"draw:mirror-horizontal" , draw_mirror_horizontal_);
CP_APPLY_ATTR(L"draw:mirror-vertical" , draw_mirror_vertical_);
}
//-------------------------------------------------------------------------------------------
// draw:enhanced_geometry
@ -490,7 +503,7 @@ const wchar_t * draw_enhanced_geometry::name = L"enhanced-geometry";
void draw_enhanced_geometry::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_enhanced_geometry_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
@ -514,20 +527,20 @@ void draw_enhanced_geometry::add_child_element( xml::sax * Reader, const std::ws
}
void draw_enhanced_geometry::find_draw_type_oox()
{
word_art_ = false;
bOoxType_ = false;
word_art_ = false;
bOoxType_ = false;
if (draw_enhanced_geometry_attlist_.draw_text_path_ &&
*draw_enhanced_geometry_attlist_.draw_text_path_ == true)
if (attlist_.draw_text_path_ &&
*attlist_.draw_text_path_ == true)
{
draw_type_oox_index_ = 0;
word_art_ = true;
sub_type_ = 1;
}
if (draw_enhanced_geometry_attlist_.draw_type_)
if (attlist_.draw_type_)
{
std::wstring odf_type = draw_enhanced_geometry_attlist_.draw_type_.get();
std::wstring odf_type = attlist_.draw_type_.get();
if (word_art_)
{
@ -550,7 +563,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
if (pos == std::wstring::npos)
{
for (long i = 0; i< count; i++)
for (long i = 0; i < count; i++)
{
if (_OO_OOX_custom_shapes[i].odf_reader == odf_type)
{
@ -650,7 +663,8 @@ void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_shape::add_attributes(Attributes);
sub_type_ = 10; //коннектор - линия, если ломаная (ниже определяется) - то путь
lined_shape_ = true;
connector_ = true;
}
void draw_connector::reset_svg_path()
{
@ -661,7 +675,10 @@ void draw_connector::reset_svg_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false);
bool bClosed = false;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false, bClosed);
if (!bClosed) lined_shape_ = true;
double x1=common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::emu);
double y1=common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::emu);
@ -716,13 +733,22 @@ const wchar_t * dr3d_extrude::name = L"extrude";
void dr3d_extrude::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"svg:d", svg_d_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
draw_path::add_attributes(Attributes);
//sub_type_ = ??
}
void dr3d_extrude::reset_svg_path()
{
if (!svg_d_) return;
//-------------------------------------------------------------------------------------------
// dr3d:rotate
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_rotate::ns = L"dr3d";
const wchar_t * dr3d_rotate::name = L"rotate";
void dr3d_rotate::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_path::add_attributes(Attributes);
//sub_type_ = ??
}
//-------------------------------------------------------------------------------------------
// dr3d:light
@ -738,6 +764,38 @@ void dr3d_light::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"dr3d:enabled", dr3d_enabled_);
}
//-------------------------------------------------------------------------------------------
// dr3d:cube
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_cube::ns = L"dr3d";
const wchar_t * dr3d_cube::name = L"cube";
void dr3d_cube::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_shape::add_attributes(Attributes);
CP_APPLY_ATTR(L"dr3d:max-edge", dr3d_max_edge_);
CP_APPLY_ATTR(L"dr3d:min-edge", dr3d_min_edge_);
CP_APPLY_ATTR(L"dr3d:transform", dr3d_transform_);
sub_type_ = 15;
}
//-------------------------------------------------------------------------------------------
// dr3d:sphere
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_sphere::ns = L"dr3d";
const wchar_t * dr3d_sphere::name = L"sphere";
void dr3d_sphere::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_shape::add_attributes(Attributes);
CP_APPLY_ATTR(L"dr3d:size", dr3d_size_); //vector3D
CP_APPLY_ATTR(L"dr3d:center", dr3d_center_); //vector3D
CP_APPLY_ATTR(L"dr3d:transform",dr3d_transform_);
sub_type_ = 16;
}
//-------------------------------------------------------------------------------------------
// draw:control
//-------------------------------------------------------------------------------------------
const wchar_t * draw_control::ns = L"draw";

View File

@ -63,7 +63,7 @@ public:
static const ElementType type = typeDrawShape;
static const xml::NodeType xml_type = xml::typeElement;
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1) {}
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1), lined_shape_(false), connector_(false){}
CPDOCCORE_DEFINE_VISITABLE();
friend class odf_document;
@ -93,6 +93,8 @@ public:
int sub_type_;
std::vector<odf_reader::_property> additional_;
int idx_in_owner;
bool lined_shape_;
bool connector_;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -285,7 +287,7 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_polygon);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------------------------------
//draw:contour-polygon
class draw_contour_polygon : public draw_polygon
{
@ -297,9 +299,21 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_polygon);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------------------------------
//draw:contour-path
class draw_contour_path : public draw_path
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDrawContourPath;
static const xml::NodeType xml_type = xml::typeElement;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_path);
//-----------------------------------------------------------------------------------------------------
class draw_polyline_attlist
{
public:
@ -441,6 +455,8 @@ public:
_CP_OPT(std::wstring) draw_enhanced_path_;
_CP_OPT(std::wstring) drawooo_enhanced_path_;
_CP_OPT(std::wstring) drawooo_sub_view_size_;
_CP_OPT(bool) draw_mirror_horizontal_;
_CP_OPT(bool) draw_mirror_vertical_;
};
/////////////////////////////////////////////////////////////////////////
class draw_enhanced_geometry : public office_element_impl<draw_enhanced_geometry>
@ -462,7 +478,7 @@ public:
void find_draw_type_oox();
draw_enhanced_geometry_attlist draw_enhanced_geometry_attlist_;
draw_enhanced_geometry_attlist attlist_;
_CP_OPT(int) sub_type_;
_CP_OPT(int) draw_type_oox_index_;
@ -572,9 +588,9 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_scene);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------------------------------
class dr3d_extrude : public office_element_impl<dr3d_extrude>
class dr3d_extrude : public draw_path
{
public:
static const wchar_t * ns;
@ -586,19 +602,31 @@ public:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) svg_d_;
_CP_OPT(std::wstring) svg_viewbox_;
void reset_svg_path();
//virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
//virtual void docx_convert(oox::docx_conversion_context & Context);
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_extrude);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------------------------------
class dr3d_rotate : public draw_path
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dRotate;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
//virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
//virtual void docx_convert(oox::docx_conversion_context & Context);
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_rotate);
//------------------------------------------------------------------------------------------------------------
class dr3d_light : public office_element_impl<dr3d_light>
{
public:
@ -615,13 +643,61 @@ public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_diffuse_color_;
_CP_OPT(std::wstring) dr3d_direction_;
_CP_OPT(std::wstring) dr3d_specular_;
_CP_OPT(odf_types::Bool)dr3d_enabled_;
_CP_OPT(std::wstring) dr3d_diffuse_color_;
_CP_OPT(std::wstring) dr3d_direction_;
_CP_OPT(odf_types::Bool) dr3d_specular_;
_CP_OPT(odf_types::Bool) dr3d_enabled_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_light);
//------------------------------------------------------------------------------------------------------------
class dr3d_cube : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dCube;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_max_edge_;
_CP_OPT(std::wstring) dr3d_min_edge_;
_CP_OPT(std::wstring) dr3d_transform_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_cube);
//------------------------------------------------------------------------------------------------------------
class dr3d_sphere : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dSphere;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_size_; //vector3D
_CP_OPT(std::wstring) dr3d_center_; //vector3D
_CP_OPT(std::wstring) dr3d_transform_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_sphere);
//----------------------------------------------------------------------------------------------
class draw_control : public draw_shape
{

View File

@ -288,6 +288,14 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
bool set_shape = false;
if (attlist_.draw_mirror_horizontal_)
{
shape->additional_.push_back(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
}
if (attlist_.draw_mirror_vertical_)
{
shape->additional_.push_back(_property(L"flipV", *attlist_.draw_mirror_vertical_));
}
if (draw_type_oox_index_)
{
shape->additional_.push_back(_property(L"oox-geom-index", draw_type_oox_index_.get()));
@ -305,25 +313,27 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
set_shape = true;
}
std::wstring odf_path; //общая часть - объединить ...
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (attlist_.drawooo_enhanced_path_)
odf_path = attlist_.drawooo_enhanced_path_.get();
else if (attlist_.draw_enhanced_path_)
odf_path = attlist_.draw_enhanced_path_.get();
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
bool res = false;
bool bClosed = false;
try
{
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
}
catch(...)
{
res = false;
}
//if (!bClosed) lined_shape_ = true;
if (!o_Polyline.empty() && res )
{
@ -337,10 +347,10 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
int w = 0;
int h = 0;
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
if (attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
@ -373,10 +383,10 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
}
}
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
if (attlist_.draw_modifiers_)
{
if (bOoxType_)
shape->additional_.push_back(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
shape->additional_.push_back(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
else
{
}
@ -401,12 +411,15 @@ void dr3d_scene::docx_convert(oox::docx_conversion_context & Context)
//...
draw_shape::docx_convert(Context);
}
void dr3d_extrude::docx_convert(oox::docx_conversion_context & Context)
void dr3d_light::docx_convert(oox::docx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::docx_convert(oox::docx_conversion_context & Context)
void dr3d_cube::docx_convert(oox::docx_conversion_context & Context)
{
}
void dr3d_sphere::docx_convert(oox::docx_conversion_context & Context)
{
}

View File

@ -68,7 +68,7 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
common_shape_draw_attlist &common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_;
common_presentation_attlist &common_presentation_attlist_= common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
const int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const unsigned int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -92,8 +92,7 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
if (common_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.draw_transform_.get();
pptx_convert_transforms(transformStr,Context);
//oox_convert_transforms(transformStr, additional_);
pptx_convert_transforms(transformStr, Context);
}
////////////////////////////////////////
std::wstring Anchor;
@ -148,6 +147,9 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
paragraph_format_properties paragraph_properties = calc_paragraph_properties_content(textStyleInst);
}
///////////////////////////////////////////////////////////////////////////////////////
Context.get_slide_context().set_is_line_shape(lined_shape_);
Context.get_slide_context().set_is_connector_shape(connector_);
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
@ -230,6 +232,7 @@ void draw_path::pptx_convert(oox::pptx_conversion_context & Context)
}
void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
{
//closed shape
reset_polygon_path();
///////////////////////////////////////////////////////////////////////
Context.get_slide_context().start_shape(sub_type_);
@ -238,9 +241,9 @@ void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
{
//line
reset_polyline_path();
///////////////////////////////////////////////////////////////////////
Context.get_slide_context().start_shape(sub_type_);
@ -249,6 +252,17 @@ void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
//void dr3d_rotate::pptx_convert(oox::pptx_conversion_context & Context)
//{
// //closed shape
// reset_polygon_path();
/////////////////////////////////////////////////////////////////////////
// Context.get_slide_context().start_shape(sub_type_);
//
// common_pptx_convert(Context);
//
// Context.get_slide_context().end_shape();
//}
void draw_custom_shape::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_);
@ -326,6 +340,14 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
bool set_shape = false;
if (attlist_.draw_mirror_horizontal_)
{
Context.get_slide_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
}
if (attlist_.draw_mirror_vertical_)
{
Context.get_slide_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
}
if (draw_type_oox_index_)
{
Context.get_slide_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));
@ -343,25 +365,27 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
}
std::wstring odf_path;
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (attlist_.drawooo_enhanced_path_)
odf_path = attlist_.drawooo_enhanced_path_.get();
else if (attlist_.draw_enhanced_path_)
odf_path = attlist_.draw_enhanced_path_.get();
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
bool res = false;
bool bClosed =false;
try
{
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
}
catch(...)
{
res = false;
}
//if (!bClosed) lined_shape_ = true;
if (o_Polyline.size() > 1 && res )
{
@ -372,10 +396,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
set_shape = true;
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
if (attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
@ -396,10 +420,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
}
}
}
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
if (attlist_.draw_modifiers_)
{
if (bOoxType_)
Context.get_slide_context().set_property(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
Context.get_slide_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
else
{
}
@ -426,15 +450,18 @@ void dr3d_scene::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
void dr3d_extrude::pptx_convert(oox::pptx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::pptx_convert(oox::pptx_conversion_context & Context)
{
}
void dr3d_cube::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_); //reset type
}
void dr3d_sphere::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_); //reset type
}
}
}

View File

@ -71,7 +71,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring styleName = common_draw_attlist_.common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -96,8 +96,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
if (common_draw_attlist_.common_shape_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.common_shape_draw_attlist_.draw_transform_.get();
xlsx_convert_transforms(transformStr,Context);
//oox_convert_transforms(transformStr, additional_);
xlsx_convert_transforms(transformStr, Context);
}
////////////////////////////////////////
std::wstring Anchor;
@ -130,6 +129,8 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().set_property(additional_[i]);
}
Context.get_drawing_context().set_is_line_shape(lined_shape_);
Context.get_drawing_context().set_is_connector_shape(connector_);
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
@ -275,6 +276,14 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
{
find_draw_type_oox();
if (attlist_.draw_mirror_horizontal_)
{
Context.get_drawing_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
}
if (attlist_.draw_mirror_vertical_)
{
Context.get_drawing_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
}
if (draw_type_oox_index_)
{
Context.get_drawing_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));
@ -290,25 +299,27 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
}
std::wstring odf_path;
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (attlist_.drawooo_enhanced_path_)
odf_path = attlist_.drawooo_enhanced_path_.get();
else if (attlist_.draw_enhanced_path_)
odf_path = attlist_.draw_enhanced_path_.get();
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
bool res = false;
bool bClosed = false;
try
{
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
}
catch(...)
{
res = false;
}
//if (!bClosed) lined_shape_ = true;
if (o_Polyline.size() > 1 && res )
{
@ -317,10 +328,10 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
::svg_path::oox_serialize(output_, o_Polyline);
Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path", output_.str()));
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
if (attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
@ -345,10 +356,10 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
draw_type_oox_index_ = 0;
}
}
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
if (attlist_.draw_modifiers_)
{
if (bOoxType_)
Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
else
{
}
@ -365,14 +376,18 @@ void dr3d_scene::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
}
void dr3d_extrude::xlsx_convert(oox::xlsx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
void dr3d_cube::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().start_shape(sub_type_); //reset type
}
void dr3d_sphere::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().start_shape(sub_type_); //reset type
}
void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
{

View File

@ -332,22 +332,6 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
}
return result;
}
std::string DecodeBase64(const std::wstring & value1)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
std::string value(value1.begin(), value1.end());
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
bool odf_document::Impl::decrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, office_element_ptr element, int file_size )
{
manifest_encryption_data* encryption_data = dynamic_cast<manifest_encryption_data*>(element.get());
@ -988,6 +972,28 @@ void odf_document::Impl::parse_styles(office_element *element)
continue;
context_->Templates().add(L"table:" + style->get_text_style_name(), elm);
}
for (size_t i = 0; i < docStyles->draw_styles_.draw_marker_.size(); i++)
{
office_element_ptr & elm = docStyles->draw_styles_.draw_marker_[i];
draw_marker * style = dynamic_cast<draw_marker *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"marker:" + style->get_style_name(), elm);
}
for (size_t i = 0; i < docStyles->draw_styles_.draw_stroke_dash_.size(); i++)
{
office_element_ptr & elm = docStyles->draw_styles_.draw_stroke_dash_[i];
draw_stroke_dash * style = dynamic_cast<draw_stroke_dash *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"stroke_dash:" + style->get_style_name(), elm);
}
}
while(0); // end parse styles

View File

@ -35,7 +35,23 @@
namespace cpdoccore {
using namespace odf_types;
std::string DecodeBase64(const std::wstring & value1)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
std::string value(value1.begin(), value1.end());
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
namespace odf_reader {
style_instance::style_instance(

View File

@ -44,6 +44,9 @@
#include <iosfwd>
namespace cpdoccore {
std::string DecodeBase64(const std::wstring & value);
namespace odf_reader {
class styles_container;

View File

@ -268,7 +268,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
}
id_idx = Context.add_author_comments(author);
Context.get_comments_context().start_comment(x, y,id_idx.first,id_idx.second);//author & idx (uniq number for author
Context.get_comments_context().start_comment(x, y, id_idx.first, id_idx.second);//author & idx (uniq number for author
Context.get_text_context().start_comment_content();
for (size_t i = 0; i < content_.size(); i++)//текст + текстовый стиль

View File

@ -151,7 +151,10 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
{
if (page_layout_instance *lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{
Context.next_dump_page_properties(true);
if (Context.is_last_dump_page_properties())
{
Context.next_dump_page_properties(true);
}
lastPageLayout->docx_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();

View File

@ -129,6 +129,16 @@ void office_text::add_child_element( xml::sax * Reader, const std::wstring & Ns,
else if (is_text_content(Ns, Name))
{
CP_CREATE_ELEMENT(content_);
if (!first_element_style_name && (content_.back()->get_type() == typeTextP ||
content_.back()->get_type() == typeTextH))
{//bus-modern_l.ott
if (content_.back()->element_style_name)
first_element_style_name = content_.back()->element_style_name;
else
first_element_style_name = L""; //default
}
}
else
CP_NOT_APPLICABLE_ELM();
@ -155,6 +165,26 @@ void office_text::docx_convert(oox::docx_conversion_context & Context)
//forms_->docx_convert(Context);
Context.start_office_text();
if ((first_element_style_name) && (!first_element_style_name->empty()))
{
std::wstring text___ = *first_element_style_name;
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(text___);
if (masterPageName)
{
std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(*masterPageName);
if (false == masterPageNameLayout.empty())
{
Context.set_master_page_name(*masterPageName); //проверка на то что тема действительно существует????
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
}
}
}
for (size_t i = 0; i < content_.size(); i++)
{
if (content_[i]->element_style_name)

View File

@ -70,6 +70,8 @@ private:
//office_element_ptr forms_; -> content
office_element_ptr_array content_;
_CP_OPT(std::wstring) first_element_style_name;
};
CP_REGISTER_OFFICE_ELEMENT2(office_text);
//----------------------------------------------------------------------------------------------------

View File

@ -1320,6 +1320,67 @@ void sequence::pptx_convert(oox::pptx_conversion_context & Context)
text_[i]->pptx_convert(Context);
}
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * expression::ns = L"text";
const wchar_t * expression::name = L"expression";
void expression::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
office_value_.add_attributes(Attributes);
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"text:formula", text_formula_);
}
std::wostream & expression::text_to_stream(std::wostream & _Wostream) const
{
_Wostream << xml::utils::replace_text_to_xml( text_ );
return _Wostream;
}
void expression::add_text(const std::wstring & Text)
{
text_ = Text;
}
void expression::docx_convert(oox::docx_conversion_context & Context)
{//???
std::wostream & strm = Context.output_stream();
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"></w:fldChar></w:r>";
strm << L"<w:r><w:instrText>FORMTEXT</w:instrText></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
strm << L"<w:r><w:t>" << text_ << L"</w:t></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * text_input::ns = L"text";
const wchar_t * text_input::name = L"text-input";
void text_input::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:description", text_description_);
}
std::wostream & text_input::text_to_stream(std::wostream & _Wostream) const
{
_Wostream << xml::utils::replace_text_to_xml( text_ );
return _Wostream;
}
void text_input::add_text(const std::wstring & Text)
{
text_ = Text;
}
void text_input::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & strm = Context.output_stream();
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"></w:fldChar></w:r>";
strm << L"<w:r><w:instrText>FORMTEXT</w:instrText></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
strm << L"<w:r><w:t>" << text_ << L"</w:t></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
//-------------------------------------------------------------------------------------------------------------------
const wchar_t * text_drop_down::ns = L"text";
const wchar_t * text_drop_down::name = L"drop-down";

View File

@ -875,6 +875,58 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(sequence);
//-------------------------------------------------------------------------------------------------------------------
// text:expression
//-------------------------------------------------------------------------------------------------------------------
class expression: public paragraph_content_element<expression>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextExpression;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
_CP_OPT(std::wstring) style_data_style_name_;
_CP_OPT(std::wstring) text_display_;
_CP_OPT(std::wstring) text_formula_;
odf_types::common_value_and_type_attlist office_value_;
std::wstring text_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(expression);
//-------------------------------------------------------------------------------------------------------------------
// text:text-input
//-------------------------------------------------------------------------------------------------------------------
class text_input: public paragraph_content_element<text_input>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextTextInput;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
_CP_OPT(std::wstring) text_description_;
std::wstring text_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(text_input);
//-------------------------------------------------------------------------------------------------------------------
// text:sequence_ref
//-------------------------------------------------------------------------------------------------------------------
class sequence_ref : public paragraph_content_element<sequence_ref>

View File

@ -169,7 +169,7 @@ public:
virtual void visit(const table_table& val)
{
if (visit_table(val.table_table_attlist_.table_name_.get_value_or(L"")))
if (visit_table(val.attlist_.table_name_.get_value_or(L"")))
{
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_, stop_);
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_, stop_);

View File

@ -108,11 +108,26 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
if (draw_stroke_) properties.push_back(_property(L"stroke", draw_stroke_->get_type() ));
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_->get_hex_value() ));
if (draw_stroke_dash_) properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
if (draw_stroke_dash_)
{
if (!draw_stroke_dash_->empty())
properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
}
if (svg_stroke_width_) properties.push_back(_property(L"stroke-width", svg_stroke_width_->get_length().get_value_unit(odf_types::length::pt) ));
if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_->get_percent().get_value()));
if (draw_marker_start_) properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
if (draw_marker_end_) properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
if (draw_marker_start_)
{
properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
}
if (draw_marker_end_)
{
//const std::wstring style_name = draw_marker_end_->get();
//if (!style_name.empty())
////if (office_element_ptr style = styles.find_by_style_name(style_name))
//{
properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
//}
}
if (draw_textarea_horizontal_align_)properties.push_back(_property(L"textarea-horizontal_align",draw_textarea_horizontal_align_->get_type() ));
if (draw_textarea_vertical_align_) properties.push_back(_property(L"textarea-vertical_align", draw_textarea_vertical_align_->get_type() ));
@ -126,6 +141,14 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
{
properties.push_back(_property(L"color-mode", *common_draw_fill_attlist_.draw_color_mode_));
}
if (common_draw_fill_attlist_.draw_luminance_)
{
properties.push_back(_property(L"luminance", common_draw_fill_attlist_.draw_luminance_->get_value()));
}
if (common_draw_fill_attlist_.draw_contrast_)
{
properties.push_back(_property(L"contrast", common_draw_fill_attlist_.draw_contrast_->get_value()));
}
if (common_padding_attlist_.fo_padding_)
{
properties.push_back(_property(L"text-padding-left", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));

View File

@ -344,14 +344,14 @@ void style_table_row_properties_attlist::docx_convert(oox::docx_conversion_conte
if (style_row_height_)
{
int val = (int)( 0.5 + 20.0 *style_row_height_->get_value_unit(length::pt) );
int val = (int)( 0.5 + 20.0 * style_row_height_->get_value_unit(length::pt) );
if (val < 0)
val = 0;
strm << L"<w:trHeight w:hRule=\"exact\" w:val=\"" << val << L"\" />";
}
else if (style_min_row_height_)
{
int val = (int)( 0.5 + 20.0 *style_min_row_height_->get_value_unit(length::pt) );
int val = (int)( 0.5 + 20.0 * style_min_row_height_->get_value_unit(length::pt) );
if (val < 0)
val = 0;
strm << L"<w:trHeight w:hRule=\"atLeast\" w:val=\"" << val << L"\" />";

View File

@ -529,7 +529,18 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_cs));}
}
}
if ((fo_background_color_) && (fo_background_color_->get_type() == odf_types::background_color::Enabled ))
{
std::wstring strRGB = fo_background_color_->get_color().get_hex_value(); //auto ... не нужно
if (!strRGB.empty())
{
CP_XML_NODE(L"a:highlight")
{
CP_XML_NODE(L"a:srgbClr") {CP_XML_ATTR(L"val", strRGB);}
}
}
}
if (!hlink.empty())
{
CP_XML_NODE(L"a:hlinkClick")

View File

@ -329,7 +329,44 @@ void draw_fill_image::add_child_element( xml::sax * Reader, const std::wstring &
{
CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------
const wchar_t * draw_marker::ns = L"draw";
const wchar_t * draw_marker::name = L"marker";
void draw_marker::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name" , draw_name_);
CP_APPLY_ATTR(L"draw:display-name" , draw_display_name_);
CP_APPLY_ATTR(L"svg:d" , svg_d_);
CP_APPLY_ATTR(L"svg:viewBox" , svg_viewBox_);
}
void draw_marker::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
//----------------------------------------------------------------------------------------
const wchar_t * draw_stroke_dash::ns = L"draw";
const wchar_t * draw_stroke_dash::name = L"stroke-dash";
void draw_stroke_dash::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name" , draw_name_);
CP_APPLY_ATTR(L"draw:display-name" , draw_display_name_);
CP_APPLY_ATTR(L"draw:distance" , draw_distance_);
CP_APPLY_ATTR(L"draw:dots1-length" , draw_dots1_length_);
CP_APPLY_ATTR(L"draw:dots2-length" , draw_dots2_length_);
CP_APPLY_ATTR(L"draw:dots1" , draw_dots1_);
CP_APPLY_ATTR(L"draw:dots2" , draw_dots2_);
CP_APPLY_ATTR(L"draw:style" , draw_style_);//"square"
}
void draw_stroke_dash::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
//----------------------------------------------------------------------------------------
const wchar_t * draw_gradient::ns = L"draw";
const wchar_t * draw_gradient::name = L"gradient";

View File

@ -119,8 +119,7 @@ private:
};
// default_style
/// style:default-style
// style:default-style
class default_style : public office_element_impl<default_style>
{
public:
@ -147,10 +146,69 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(default_style);
//-------------------------------------------------------------------------------------------------
// draw:marker
class draw_marker : public office_element_impl<draw_marker>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawMarker;
CPDOCCORE_DEFINE_VISITABLE();
/////////////////////////////////////////////////////////////////////////////////////////////////
// style_draw_gradient
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(std::wstring) svg_d_;
_CP_OPT(std::wstring) svg_viewBox_;
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
friend class odf_document;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_marker);
//-------------------------------------------------------------------------------------------------
// draw:stroke-dash
class draw_stroke_dash : public office_element_impl<draw_stroke_dash>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawStrokeDash;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(odf_types::length_or_percent) draw_distance_;
_CP_OPT(odf_types::length_or_percent) draw_dots1_length_;
_CP_OPT(odf_types::length_or_percent) draw_dots2_length_;
_CP_OPT(int) draw_dots1_;
_CP_OPT(int) draw_dots2_;
_CP_OPT(std::wstring) draw_style_; //rect or round:
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
friend class odf_document;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_stroke_dash);
//-------------------------------------------------------------------------------------------------
// draw:gradient
class draw_gradient : public office_element_impl<draw_gradient>
{
public:
@ -189,7 +247,7 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_gradient);
/////////////////////////////////////////////////////////////////////////////////////////////////
// style_draw_hatch
// draw:hatch
class draw_hatch : public office_element_impl<draw_hatch>
{
public:
@ -355,8 +413,8 @@ public:
office_element_ptr_array draw_opacity_;
office_element_ptr_array draw_hatch_;
office_element_ptr_array draw_marker_; // < TODO
office_element_ptr_array draw_stroke_dash_; // < TODO
office_element_ptr_array draw_marker_;
office_element_ptr_array draw_stroke_dash_;
office_element_ptr_array svg_linearGradient_; // < TODO
office_element_ptr_array svg_radialGradient_; // < TODO

View File

@ -185,12 +185,11 @@ namespace svg_path
return bUseRelativeCoordinates ? cLowerCaseCommand : cUpperCaseCommand;
}
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ)
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ, bool & bIsClosed)
{
Polyline.clear();
const int nLen(rSvgDStatement.length());
int nPos(0);
bool bIsClosed(false);
double nLastX( 0.0 );
double nLastY( 0.0 );
@ -200,6 +199,8 @@ namespace svg_path
_polyline aCurrPoly;
bIsClosed = false;
// skip initial whitespace
skipSpaces(nPos, rSvgDStatement, nLen);

View File

@ -58,7 +58,7 @@ namespace svg_path
};
bool parseVml(std::vector<_polyline> & Polyline, const std::wstring & path);
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ);
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool & bIsClosed);
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool closed);
}

View File

@ -57,6 +57,8 @@ void table_table_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
CP_APPLY_ATTR(L"table:protected", table_protected_, false);
CP_APPLY_ATTR(L"table:protection-key", table_protection_key_);
CP_APPLY_ATTR(L"table:protection-key-digest-algorithm", table_protection_key_digest_algorithm_);
CP_APPLY_ATTR(L"table:print", table_print_, true);
CP_APPLY_ATTR(L"table:print-ranges", table_print_ranges_);
@ -134,7 +136,23 @@ void table_table_source::add_child_element( xml::sax * Reader, const std::wstrin
{
CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:table-protection
const wchar_t * table_table_protection::ns = L"loext"; //?? table odf 1.3
const wchar_t * table_table_protection::name = L"table-protection";
void table_table_protection::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"loext:select-protected-cells", select_protected_cells);
CP_APPLY_ATTR(L"loext:select-unprotected-cells",select_unprotected_cells);
CP_APPLY_ATTR(L"loext:insert-columns", insert_columns);
CP_APPLY_ATTR(L"loext:insert-rows", insert_rows);
CP_APPLY_ATTR(L"loext:delete-columns", delete_columns);
CP_APPLY_ATTR(L"loext:delete-rows", delete_rows);
//CP_APPLY_ATTR(L"loext:format-columns", format_columns);
//CP_APPLY_ATTR(L"loext:format-rows", format_rows);
//CP_APPLY_ATTR(L"loext:format-cells", format_cells);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:table
const wchar_t * table_table::ns = L"table";
@ -144,7 +162,7 @@ void table_table::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"table:style-name", element_style_name);
table_table_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
}
void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -172,9 +190,13 @@ void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns,
else if CP_CHECK_NAME(L"table", L"shapes")
{
CP_CREATE_ELEMENT(table_shapes_);
}
else if ( L"table-protection" == Name) //ns = loext or table
{
CP_CREATE_ELEMENT(table_protection_);
}
else if ( CP_CHECK_NAME(L"table", L"named-expressions") ||
CP_CHECK_NAME(L"table", L"named-range") ) //???
CP_CHECK_NAME(L"table", L"named-range") )
{
CP_CREATE_ELEMENT(table_named_);
}

View File

@ -61,15 +61,17 @@ public:
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
bool table_protected_; // default false
bool table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
bool table_print_; // default true
_CP_OPT(std::wstring) table_protection_key_digest_algorithm_;
bool table_print_; // default true
_CP_OPT(std::wstring) table_print_ranges_;
bool table_use_first_row_styles_; // default false;
bool table_use_banding_rows_styles_; //defualt false;
bool table_use_first_column_styles_; //defualt false;
bool table_use_banding_columns_styles_; //defualt false;
bool table_use_banding_rows_styles_; // defualt false;
bool table_use_first_column_styles_; // defualt false;
bool table_use_banding_columns_styles_; // defualt false;
friend class table_table;
};
@ -617,6 +619,38 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_row_group);
class table_table_protection : public office_element_impl<table_table_protection>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableTableProtection;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) {}
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
virtual void pptx_convert(oox::pptx_conversion_context & Context) {}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
public:
_CP_OPT(bool) select_protected_cells;
_CP_OPT(bool) select_unprotected_cells;
_CP_OPT(bool) insert_columns;
_CP_OPT(bool) insert_rows;
_CP_OPT(bool) delete_columns;
_CP_OPT(bool) delete_rows;
//_CP_OPT(bool) format_columns; //???
//_CP_OPT(bool) format_rows;
//_CP_OPT(bool) format_cells;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_protection);
class table_table : public office_element_impl<table_table>
{
public:
@ -636,7 +670,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
table_table_attlist table_table_attlist_;
table_table_attlist attlist_;
office_element_ptr table_protection_;
table_columns_and_groups table_columns_and_groups_;
table_rows_and_groups table_rows_and_groups_;

View File

@ -72,8 +72,9 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
const style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name( styleName , style_family::TableRow,Context.process_headers_footers_);
style_table_cell_properties* cell_props = NULL;
style_table_row_properties* row_props = NULL;
style_table_cell_properties *cell_props = NULL;
style_table_row_properties *row_props = NULL;
if (inst && inst->content())
{
cell_props = inst->content()->get_style_table_cell_properties(true);
@ -89,8 +90,32 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
{
_Wostream << L"<w:tr>";
_Wostream << L"<w:trPr>";
_Wostream << L"<w:cantSplit w:val=\"false\" />";
_Wostream << L"<w:trPr>";
bool bCantSplit = false;
if (row_props)
{
if (row_props->attlist_.fo_keep_together_ && row_props->attlist_.fo_keep_together_->get_type() == keep_together::Always)
{
_Wostream << L"<w:cantSplit w:val=\"true\"/>";
}
if (row_props->attlist_.style_row_height_)
{
int val = (int)( 0.5 + 20.0 * row_props->attlist_.style_row_height_->get_value_unit(length::pt) );
if (val < 0)
val = 0;
_Wostream << L"<w:trHeight w:val=\"" << val << L"\" w:hRule=\"exact\"/>";
}
else if (row_props->attlist_.style_min_row_height_)
{
int val = (int)( 0.5 + 20.0 * row_props->attlist_.style_min_row_height_->get_value_unit(length::pt) );
if (val < 0)
val = 0;
_Wostream << L"<w:trHeight w:val=\"" << val << L"\" w:hRule=\"atLeast\"/>";
}
}
if (cell_props)
cell_props->docx_convert(Context);
@ -171,10 +196,10 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
}
}
bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false);
bool sub_table = attlist_.table_is_sub_table_.get_value_or(false);
//todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло)
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
_Wostream << L"<w:tbl>";

View File

@ -83,14 +83,14 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context)
style_table_row_properties_attlist & row_attlist = inst->content()->get_style_table_row_properties()->attlist_;
if (row_attlist.style_row_height_)
{
height = (int)( 0.5 +row_attlist.style_row_height_->get_value_unit(length::emu) );
height = (int)( 0.5 + row_attlist.style_row_height_->get_value_unit(length::emu) );
}
else if (row_attlist.style_min_row_height_)
{
height = (int)( 0.5 + row_attlist.style_min_row_height_->get_value_unit(length::emu));
}
}
if (height<1) height = 100000;
if (height < 1) height = 100000;
_Wostream << L"<a:tr h=\"" << height << L"\">";
@ -159,13 +159,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_table();
//////////////////////////////////////////////////////////////////
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
Context.get_table_context().start_table(tableStyleName);
if (table_table_attlist_.table_template_name_)
if (attlist_.table_template_name_)
{
std::wstring name = L"table:" + table_table_attlist_.table_template_name_.get() ;
std::wstring name = L"table:" + attlist_.table_template_name_.get() ;
if (office_element_ptr style = Context.root()->odf_context().Templates().find_by_style_name(name))
{
if (table_table_template* template_ = dynamic_cast<table_table_template *>(style.get()))
@ -184,13 +184,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
_Wostream << L"<a:tbl>";
_Wostream << L"<a:tblPr";
if (table_table_attlist_.table_use_banding_rows_styles_)
if (attlist_.table_use_banding_rows_styles_)
_Wostream << L" bandRow=\"1\"";
if (table_table_attlist_.table_use_first_row_styles_)
if (attlist_.table_use_first_row_styles_)
_Wostream << L" firstRow=\"1\"";
if (table_table_attlist_.table_use_banding_columns_styles_)
if (attlist_.table_use_banding_columns_styles_)
_Wostream << L" bandCol=\"1\"";
if (table_table_attlist_.table_use_first_column_styles_)
if (attlist_.table_use_first_column_styles_)
_Wostream << L" firstCol=\"1\"";
_Wostream << ">";

View File

@ -319,8 +319,8 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context)
void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = table_table_attlist_.table_name_.get_value_or(L"");
const std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = attlist_.table_name_.get_value_or(L"");
_CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl;
@ -340,6 +340,16 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
}
Context.start_table(tableName, tableStyleName);
if (attlist_.table_protected_)
{
Context.get_table_context().set_protection(true, attlist_.table_protection_key_.get_value_or(L""),
attlist_.table_protection_key_digest_algorithm_.get_value_or(L""));
table_table_protection* prot = dynamic_cast<table_table_protection*>( table_protection_.get() );
if (prot)
{
}
}
table_columns_and_groups_.xlsx_convert(Context);
// check last rows for equal style and empties - collapsed
@ -433,6 +443,8 @@ namespace {
double pixToSize(double pixels, double maxDigitSize)
{
if (pixels < 8) pixels = 8; //УВЕДОМЛЕНИЕ О ПРИБЫТИИ ИНОСТРАННОГО ГРАЖДАНИНА.ods
return (int(( pixels /*/ 0.75*/ - 5)/ maxDigitSize * 100. + 0.5)) /100. * 0.9; // * 9525. * 72.0 / (360000.0 * 2.54);
}
double cmToChars (double cm)
@ -762,10 +774,10 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
double s;
if (oox::parseTime(tv, h, m, s))
{
boost::int64_t intTime = (boost::int64_t)oox::convertTime(h, m, s);
if (intTime > 0)
double dTime = oox::convertTime(h, m, s);
if (dTime >= 0)
{
number_val = boost::lexical_cast<std::wstring>(intTime);
number_val = boost::lexical_cast<std::wstring>(dTime);
}
else
{

View File

@ -308,7 +308,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
}
}
}
if (next_section_/* || next_end_section_*/)
if (next_section_/* || next_end_section_*/)//remove in text::section
{
Context.get_section_context().get().is_dump_ = true;
is_empty = false;
@ -675,6 +675,7 @@ void section::add_child_element( xml::sax * Reader, const std::wstring & Ns, con
void section::docx_convert(oox::docx_conversion_context & Context)
{
bool bAddSection = false;
if ( false == Context.get_drawing_state_content())
{
std::wstring current_page_properties = Context.get_page_properties();
@ -682,6 +683,8 @@ void section::docx_convert(oox::docx_conversion_context & Context)
Context.get_section_context().add_section (section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties);
Context.add_page_properties(current_page_properties);
bAddSection = true;
}
else
{
@ -729,6 +732,11 @@ void section::docx_convert(oox::docx_conversion_context & Context)
}
content_[i]->docx_convert(Context);
}
if (bAddSection)
{
Context.get_section_context().get().is_dump_ = true;
Context.last_dump_page_properties(false);
}
}
// text-section-source-attr

View File

@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/freetype-2.5.2/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;__WORDSIZE=32;DONT_WRITE_EMBEDDED_FONTS"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;__WORDSIZE=32;DONT_WRITE_EMBEDDED_FONTS;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"

View File

@ -311,7 +311,10 @@ odf_drawing_context::~odf_drawing_context()
{
}
office_element_ptr & odf_drawing_context::get_current_element(){return impl_->current_level_.back();}
office_element_ptr & odf_drawing_context::get_current_element()
{
return impl_->current_level_.back();
}
void odf_drawing_context::set_styles_context(odf_style_context* styles_context)
{
@ -377,7 +380,7 @@ void odf_drawing_context::start_group()
impl_->current_group_ = impl_->group_list_.back();
if (impl_->current_level_.size()>0)
if (false == impl_->current_level_.empty())
impl_->current_level_.back()->add_child_element(group_elm);
impl_->current_level_.push_back(group_elm);
@ -482,7 +485,7 @@ void odf_drawing_context::start_drawing()
impl_->current_drawing_state_.svg_height_ = impl_->anchor_settings_.svg_height_;
}
//else
if (impl_->current_level_.size() > 0)
if (false == impl_->current_level_.empty())
{
impl_->current_drawing_state_.in_group_ = true;
}
@ -504,9 +507,7 @@ void odf_drawing_context::end_drawing_background(odf_types::common_draw_fill_att
}
void odf_drawing_context::end_drawing()
{
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
draw_base* draw = impl_->current_drawing_state_.elements_.empty() ? NULL : dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (draw)
{
if (impl_->current_drawing_state_.presentation_class_ || impl_->current_drawing_state_.presentation_placeholder_)
@ -596,7 +597,7 @@ void odf_drawing_context::end_drawing()
draw->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = impl_->current_drawing_state_.svg_width_;
}
///////////////////////////////////////////////////////
presentation_placeholder * placeholder = dynamic_cast<presentation_placeholder*>(impl_->current_drawing_state_.elements_[0].elm.get());
presentation_placeholder * placeholder = impl_->current_drawing_state_.elements_.empty() ? NULL : dynamic_cast<presentation_placeholder*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (placeholder)
{
placeholder->presentation_object_ = impl_->current_drawing_state_.presentation_class_;
@ -754,7 +755,7 @@ void odf_drawing_context::Impl::create_draw_base(int type)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
size_t level = current_level_.size();
if (current_level_.size() > 0)
if (false == current_level_.empty())
current_level_.back()->add_child_element(draw_elm);
current_level_.push_back(draw_elm);
@ -915,7 +916,7 @@ void odf_drawing_context::end_shape()
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill::none;
}
draw_path* path = dynamic_cast<draw_path*>(impl_->current_drawing_state_.elements_[0].elm.get());
draw_path* path = dynamic_cast<draw_path*>(impl_->current_level_.back().get());
if (path)
{
if (impl_->current_drawing_state_.view_box_.empty() && impl_->current_drawing_state_.svg_width_ && impl_->current_drawing_state_.svg_height_)
@ -1002,7 +1003,7 @@ void odf_drawing_context::end_shape()
}
//////////////////////////////////////////////////////////////////////////////////////////////////
draw_custom_shape* custom = dynamic_cast<draw_custom_shape*>(impl_->current_drawing_state_.elements_[0].elm.get());
draw_custom_shape* custom = dynamic_cast<draw_custom_shape*>(impl_->current_level_.back().get());
if (custom)
{
std::wstring sub_type;
@ -1069,7 +1070,7 @@ void odf_drawing_context::end_shape()
enhanced->attlist_.draw_type_ = shape_define->odf_type_name;
enhanced->attlist_.draw_text_areas_ = shape_define->text_areas;
enhanced->attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty())
@ -1223,7 +1224,7 @@ void odf_drawing_context::start_element(office_element_ptr elm, office_element_p
{
size_t level = (int)impl_->current_level_.size();
if (impl_->current_level_.size() > 0 && elm)
if (false == impl_->current_level_.empty() && elm)
impl_->current_level_.back()->add_child_element(elm);
std::wstring style_name;
@ -1853,7 +1854,7 @@ void odf_drawing_context::set_horizontal_pos(int align)
}
void odf_drawing_context::set_horizontal_pos(double offset_pt)
{
impl_->anchor_settings_.style_horizontal_pos_svg_x_ = length(length(offset_pt,length::pt).get_value_unit(length::cm),length::cm);
impl_->anchor_settings_.style_horizontal_pos_svg_x_ = length(length(offset_pt, length::pt).get_value_unit(length::cm), length::cm);
impl_->x = offset_pt;
}
void odf_drawing_context::set_default_wrap_style()
@ -1902,11 +1903,13 @@ void odf_drawing_context::set_group_position(_CP_OPT(double) x, _CP_OPT(double)
if ( !x || !y ) return;
impl_->current_group_->x = *change_x ;
impl_->current_group_->y = *change_y ;
if (change_x && impl_->current_group_->x)
impl_->current_group_->x = *change_x;
if (change_y && impl_->current_group_->y)
impl_->current_group_->y = *change_y;
impl_->current_group_->shift_x = (*x /impl_->current_group_->scale_cx - *change_x) ;
impl_->current_group_->shift_y = (*y /impl_->current_group_->scale_cy - *change_y) ;
impl_->current_group_->shift_x = (*x /impl_->current_group_->scale_cx - change_x.get_value_or(0)) ;
impl_->current_group_->shift_y = (*y /impl_->current_group_->scale_cy - change_y.get_value_or(0)) ;
}
void odf_drawing_context::set_group_size( _CP_OPT(double) cx, _CP_OPT(double) cy, _CP_OPT(double) change_cx, _CP_OPT(double) change_cy)
@ -1919,8 +1922,10 @@ void odf_drawing_context::set_group_size( _CP_OPT(double) cx, _CP_OPT(double) cy
if (change_cy && cy)
impl_->current_group_->scale_cy = *cy / *change_cy;
impl_->current_group_->cx = *change_cx;
impl_->current_group_->cy = *change_cy;
if (change_cx && impl_->current_group_->cx)
impl_->current_group_->cx = *change_cx;
if (change_cy && impl_->current_group_->cy)
impl_->current_group_->cy = *change_cy;
}
void odf_drawing_context::set_group_flip_V(bool bVal)
@ -2784,11 +2789,9 @@ void odf_drawing_context::end_text_box()
{
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_level_.back().get());
if (!draw) return;
if (!draw->draw_text_box_attlist_.fo_min_height_)
if ((draw) && (!draw->draw_text_box_attlist_.fo_min_height_))
{
draw->draw_text_box_attlist_.fo_min_height_= impl_->current_drawing_state_.svg_height_;
}
@ -2912,7 +2915,7 @@ office_element_ptr & odf_drawing_context::get_current_style_element()
}
void odf_drawing_context::set_text(odf_text_context* text_context)
{
if (text_context == NULL || impl_->current_level_.size() < 1 ) return;
if (text_context == NULL || impl_->current_level_.empty() ) return;
//if (impl_->is_presentation_ && *impl_->is_presentation_) return;
@ -3557,7 +3560,7 @@ void odf_drawing_context::set_bitmap_link(std::wstring file_path)
if (impl_->current_drawing_state_.oox_shape_preset_ == 3000)
{
if (impl_->current_level_.size() < 1) return;
if (impl_->current_level_.empty()) return;
draw_image* image = dynamic_cast<draw_image*>(impl_->current_level_.back().get());
if (image == NULL)return;

View File

@ -74,6 +74,7 @@ namespace odf_writer
count_rows = 0;
table_width = 0;
table_height = 0;
}
std::vector<odf_row_state> rows;
std::vector<odf_column_state> columns;
@ -91,6 +92,8 @@ namespace odf_writer
bool styled;
double table_width;
double table_height;
std::wstring default_cell_properties;
_CP_OPT(std::wstring) border_inside_v_;
@ -103,30 +106,34 @@ class odf_table_context::Impl
public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)
{
default_column_width = -1;
default_column_width = boost::none;
default_row_height = boost::none;
optimal_column_width = false;
}
odf_table_state & current_table() {return tables_.back();}
bool empty () {return tables_.size() >0 ? false : true; }
bool empty () {return (false == tables_.empty()) ? false : true; }
void start_table(odf_table_state & state) {tables_.push_back(state);}
void end_table()
{
if (tables_.size() > 0) tables_.pop_back();
if (false == tables_.empty()) tables_.pop_back();
default_column_width = -1; // todo .. in level ???
default_column_width = boost::none; // todo .. in level ???
default_row_height = boost::none;
default_cell_properties = L"";
optimal_column_width = false;
}
odf_style_context * styles_context() {return odf_context_->styles_context();}
odf_style_context *styles_context() {return odf_context_->styles_context();}
odf_conversion_context *odf_context_;
double default_column_width;
bool optimal_column_width;
_CP_OPT(double) default_row_height;
_CP_OPT(double) default_column_width;
bool optimal_column_width;
std::wstring default_cell_properties; // для предустановки ..
private:
@ -174,7 +181,7 @@ void odf_table_context::start_table(office_element_ptr &elm, bool styled)
state.table.style_elm = style_state->get_office_element();
state.table.style_name = style_state->get_name();
table->table_table_attlist_.table_style_name_ = state.table.style_name;
table->attlist_.table_style_name_ = state.table.style_name;
}
}
impl_->default_cell_properties = L"";
@ -226,11 +233,11 @@ void odf_table_context::start_row(office_element_ptr &elm, bool styled)
state.style_elm = style_state->get_office_element();
state.style_name = style_state->get_name();
row->table_table_row_attlist_.table_style_name_ = state.style_name;
row->attlist_.table_style_name_ = state.style_name;
}
}
if (!impl_->current_table().default_cell_properties.empty())
row->table_table_row_attlist_.table_default_cell_style_name_ = impl_->current_table().default_cell_properties;
row->attlist_.table_default_cell_style_name_ = impl_->current_table().default_cell_properties;
impl_->current_table().rows.push_back(state);
@ -252,7 +259,7 @@ void odf_table_context::end_row()
// start_cell(cell,false);
// end_cell();
//}
impl_->current_table().current_column =0;
impl_->current_table().current_column = 0;
}
@ -277,7 +284,7 @@ void odf_table_context::add_column(office_element_ptr &elm, bool styled)
{
state.style_elm = style_state->get_office_element();
state.style_name = style_state->get_name();
column->table_table_column_attlist_.table_style_name_ = state.style_name;
column->attlist_.table_style_name_ = state.style_name;
}
}
@ -312,16 +319,25 @@ void odf_table_context::set_default_cell_properties(std::wstring style_name)
{
impl_->default_cell_properties = style_name;
}
double odf_table_context::get_table_width()
_CP_OPT(double) odf_table_context::get_table_width()
{
if (impl_->empty()) return -1;
if (impl_->empty()) return boost::none;
else return impl_->current_table().table_width;
}
_CP_OPT(double) odf_table_context::get_table_height()
{
if (impl_->empty()) return boost::none;
else return impl_->current_table().table_height;
}
std::wstring odf_table_context::get_default_cell_properties()
{
if (impl_->empty()) return impl_->default_cell_properties;
else return impl_->current_table().default_cell_properties;
}
void odf_table_context::set_default_row_height(double height)
{
impl_->default_row_height = height;
}
void odf_table_context::set_default_column_width(double width)
{
impl_->default_column_width = width;
@ -347,7 +363,7 @@ void odf_table_context::set_column_optimal(bool val)
void odf_table_context::change_current_column_width(double width)
{
if (impl_->empty()) return;
if (impl_->current_table().columns.size() < 1)return;
if (impl_->current_table().columns.empty())return;
int index = impl_->current_table().current_column ;
if (index < 0) return;
@ -368,7 +384,7 @@ void odf_table_context::change_current_column_width(double width)
style_table_column_properties *properties = style_->content_.get_style_table_column_properties();
if (properties == NULL) return;
length length_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
length length_ = length(length(width, length::pt).get_value_unit(length::cm), length::cm);
if (!properties->style_table_column_properties_attlist_.style_column_width_)
properties->style_table_column_properties_attlist_.style_column_width_ = length_;
@ -383,39 +399,68 @@ void odf_table_context::change_current_column_width(double width)
void odf_table_context::set_column_width(double width)
{
if (impl_->empty()) return;
if (impl_->current_table().columns.size() < 1)return;
if (impl_->current_table().columns.empty())return;
style *style_ = dynamic_cast<style*>(impl_->current_table().columns.back().style_elm.get());
if (style_ == NULL) return;
style_table_column_properties *properties = style_->content_.get_style_table_column_properties();
if (properties == NULL) return;
style_table_column_properties *properties = style_ ? style_->content_.get_style_table_column_properties() : NULL;
if (width > 0)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
if (impl_->optimal_column_width)
if (properties)
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
if (impl_->optimal_column_width)
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
}
}
impl_->current_table().table_width += width;
}
else
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
if (impl_->default_column_width >= 0)
if (properties)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(impl_->default_column_width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);
impl_->current_table().table_width += impl_->default_column_width;
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
if (impl_->default_column_width)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(impl_->default_column_width.get(), length::pt).get_value_unit(length::cm), length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);
}
}
impl_->current_table().table_width += impl_->default_column_width.get_value_or(0);
}
}
void odf_table_context::set_row_height(double height)
{
if (impl_->empty()) return;
if (height > 0)
{
//style *style_ = dynamic_cast<odf_writer::style*>(rows_.back().style_elm.get());
//if (style_)
//{
// style_table_row_properties *properties = style_->content_.get_style_table_row_properties();
// if (properties)
// {
// //properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
// }
//}
impl_->current_table().table_height += height;
if (!impl_->default_row_height)
impl_->default_row_height = height;
}
else
{
impl_->current_table().table_height += impl_->default_row_height.get_value_or(0);
}
}
int odf_table_context::current_column ()
{
if (impl_->empty()) return 0;
@ -466,7 +511,7 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
state.style_elm = style_state->get_office_element();
state.style_name = style_state->get_name();
cell->table_table_cell_attlist_.table_style_name_ = state.style_name;
cell->attlist_.table_style_name_ = state.style_name;
}
if (!impl_->current_table().default_cell_properties.empty())
@ -498,7 +543,7 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
table_table_cell * cell = dynamic_cast<table_table_cell *>(state_row.spanned_column_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = (unsigned int)state_row.spanned_column_cell.size();
cell->attlist_extra_.table_number_columns_spanned_ = (unsigned int)state_row.spanned_column_cell.size();
state_row.spanned_column_cell.clear();
}
@ -517,7 +562,7 @@ void odf_table_context::set_cell_column_span_restart()
table_table_cell * cell = dynamic_cast<table_table_cell *>(state.spanned_column_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = sz;
cell->attlist_extra_.table_number_columns_spanned_ = sz;
}
state.spanned_column_cell.clear();
}
@ -530,7 +575,7 @@ void odf_table_context::set_cell_column_span(int spanned)
{
table_table_cell * cell = dynamic_cast<table_table_cell *>(impl_->current_table().cells.back().elm.get());
if (cell)
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned;
cell->attlist_extra_.table_number_columns_spanned_ = spanned;
}
else
{
@ -551,7 +596,7 @@ void odf_table_context::set_cell_row_span(int spanned)
{
table_table_cell * cell = dynamic_cast<table_table_cell *>(impl_->current_table().cells.back().elm.get());
if (cell)
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned;
cell->attlist_extra_.table_number_rows_spanned_ = spanned;
}
else
{
@ -574,7 +619,7 @@ void odf_table_context::set_cell_row_span_restart()
table_table_cell * cell = dynamic_cast<table_table_cell *>(state.spanned_row_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = sz;
cell->attlist_extra_.table_number_rows_spanned_ = sz;
}
state.spanned_row_cell.clear();

View File

@ -65,15 +65,17 @@ public:
void count_rows (int count);
void start_table(office_element_ptr &elm, bool styled = false);
void set_default_column_width(double width);
void set_default_column_width(double val);
void set_optimal_column_width(bool val);
void change_current_column_width(double width);
void change_current_column_width(double val);
void set_default_row_height(double val);
void end_table();
void set_default_cell_properties(std::wstring style_name);
std::wstring get_default_cell_properties();
double get_table_width();
_CP_OPT(double) get_table_width();
_CP_OPT(double) get_table_height();
void set_table_inside_v(_CP_OPT(std::wstring) border);
void set_table_inside_h(_CP_OPT(std::wstring) border);
@ -82,6 +84,7 @@ public:
_CP_OPT(std::wstring) get_table_inside_h();
void start_row(office_element_ptr &elm, bool styled = false);
void set_row_height(double val);
void end_row();
void start_cell(office_element_ptr &elm, bool styled = false);

View File

@ -507,6 +507,10 @@ bool odf_text_context::start_field(int type, const std::wstring& value)
{
create_element(L"text", L"date", elm, odf_context_);
}break;
case fieldTextInput:
{
create_element(L"text", L"text-input", elm, odf_context_);
}break;
}
if (elm)

View File

@ -53,6 +53,8 @@ namespace odf_writer
fieldPageRef,
fieldSeq,
fieldXE,
fieldTextInput,
fieldExpression,
fieldBibliography = 0xff + 1,
fieldIndex,

View File

@ -292,25 +292,25 @@ void ods_conversion_context::set_comment_rect(double l, double t, double w, doub
current_table().set_comment_rect(l,t,w,h);
}
/////////////////////////////
void ods_conversion_context::add_hyperlink(std::wstring & ref, std::wstring & link, std::wstring & display)
void ods_conversion_context::add_hyperlink(const std::wstring & ref, const std::wstring & link, const std::wstring & display, bool bLocation)
{
//////////////////////////////////////////////////////////////////
std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size()>1)
boost::algorithm::split(ref_cells, ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size() > 1)
{
//в ооx можно воткнуть на диапазон одну ссылку, в оо нельзя - ссылку вствляем, текст не меням
int start_col = -1, start_row = -1;
int end_col = -1, end_row = -1;
utils::parsing_ref (ref_cells[0], start_col, start_row);
utils::parsing_ref (ref_cells[1], end_col, end_row);
utils::parsing_ref (ref_cells[1], end_col, end_row);
for (long col = start_col; col <= end_col; col++)
{
for (long row = start_row; row <= end_row; row++)
{
current_table().add_hyperlink(ref,col,row,link);
current_table().add_hyperlink(ref, col, row, link, bLocation);
//ссылка одна, а вот отображаемый текст - разный
}
}
@ -319,7 +319,7 @@ void ods_conversion_context::add_hyperlink(std::wstring & ref, std::wstring & li
{
int col = -1, row = -1;
utils::parsing_ref (ref_cells[0], col, row);
current_table().add_hyperlink(ref,col,row,link);
current_table().add_hyperlink(ref, col, row, link, bLocation);
}
}

View File

@ -93,7 +93,7 @@ public:
void add_external_reference(const std::wstring & ref);
void add_merge_cells(const std::wstring & ref);
void add_hyperlink(std::wstring & ref, std::wstring & link, std::wstring & display);
void add_hyperlink(const std::wstring & ref, const std::wstring & link, const std::wstring & display, bool external = true);
void start_comment (int col, int row, std::wstring & author);
void set_comment_rect (double l, double t, double w, double h);

View File

@ -73,8 +73,6 @@ void ods_table_context::start_table_part(std::wstring name, std::wstring ref)
ref = table_state_list_.back().office_table_name_ + L"!" + ref;
}
std::wstring odf_range = formulas_converter.convert_named_ref(ref);
XmlUtils::replace_all( odf_range, L"[", L"");
XmlUtils::replace_all( odf_range, L"]", L"");
d_range->table_target_range_address_ = odf_range;
d_range->table_name_ = name;
@ -141,8 +139,6 @@ void ods_table_context::add_autofilter(std::wstring ref)
formulasconvert::oox2odf_converter formulas_converter;
std::wstring odf_range = formulas_converter.convert_named_ref(ref);
XmlUtils::replace_all( odf_range, L"[", L"");
XmlUtils::replace_all( odf_range, L"]", L"");
d_range->table_target_range_address_ = odf_range;
d_range->table_display_filter_buttons_= true;
@ -167,8 +163,6 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
formulasconvert::oox2odf_converter formulas_converter;
std::wstring odf_range = formulas_converter.convert_named_ref(cell_range);//todo - разделить конвертацию диапазонов/рэнжей на c [] и без
XmlUtils::replace_all( odf_range, L"[", L"");
XmlUtils::replace_all( odf_range, L"]", L"");
std::wstring odf_base_cell = formulas_converter.get_table_name() + L".$A$1";

View File

@ -169,7 +169,7 @@ void ods_table_state::set_table_name(std::wstring name)
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->table_table_attlist_.table_name_ = name;
table->attlist_.table_name_ = name;
}
void ods_table_state::set_table_master_page(std::wstring name)
@ -178,7 +178,74 @@ void ods_table_state::set_table_master_page(std::wstring name)
office_table_style_->style_master_page_name_ = name;
}
void ods_table_state::set_table_protection(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->attlist_.table_protected_ = true;
create_element(L"loext", L"table-protection", table->table_protection_, context_);
}
void ods_table_state::set_table_protection_insert_columns(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->insert_columns = Val;
}
void ods_table_state::set_table_protection_insert_rows(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->insert_rows = Val;
}
void ods_table_state::set_table_protection_delete_columns(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->delete_columns = Val;
}
void ods_table_state::set_table_protection_delete_rows(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->delete_rows = Val;
}
void ods_table_state::set_table_protection_protected_cells(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->select_protected_cells = Val;
}
void ods_table_state::set_table_protection_unprotected_cells(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->select_unprotected_cells = Val;
}
void ods_table_state::set_table_hidden(bool Val)
{
if (!office_table_style_)return;
@ -205,7 +272,7 @@ void ods_table_state::set_print_range(std::wstring range)
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->table_table_attlist_.table_print_ranges_ = range;
table->attlist_.table_print_ranges_ = range;
}
void ods_table_state::set_table_tab_color(_CP_OPT(color) & _color)
@ -227,7 +294,7 @@ void ods_table_state::set_table_style(office_element_ptr & elm)
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->table_table_attlist_.table_style_name_ = office_table_style_->style_name_;
table->attlist_.table_style_name_ = office_table_style_->style_name_;
//потом в принципе и по имени можно будет связать(найти)
@ -273,8 +340,8 @@ void ods_table_state::add_column(office_element_ptr & elm, unsigned int repeated
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
if (style_name.length()>0) column->table_table_column_attlist_.table_style_name_ = style_name;
column->table_table_column_attlist_.table_number_columns_repeated_ = repeated;
if (style_name.length()>0) column->attlist_.table_style_name_ = style_name;
column->attlist_.table_number_columns_repeated_ = repeated;
}
void ods_table_state::set_column_default_cell_style(std::wstring & style_name)
@ -284,7 +351,7 @@ void ods_table_state::set_column_default_cell_style(std::wstring & style_name)
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
column->table_table_column_attlist_.table_default_cell_style_name_ = style_name;
column->attlist_.table_default_cell_style_name_ = style_name;
columns_.back().cell_style_name = style_name;
}
@ -330,7 +397,7 @@ void ods_table_state::set_column_hidden(bool val)
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
column->table_table_column_attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
column->attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
}
void ods_table_state::set_table_dimension(int col, int row)
{
@ -370,8 +437,8 @@ void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, o
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
if (row == NULL)return;
if (style_name.length()>0) row->table_table_row_attlist_.table_style_name_ = style_name;
row->table_table_row_attlist_.table_number_rows_repeated_ = repeated;
if (style_name.length()>0) row->attlist_.table_style_name_ = style_name;
row->attlist_.table_number_rows_repeated_ = repeated;
row_default_cell_style_name_ = L"";
@ -394,14 +461,14 @@ void ods_table_state::add_row_repeated()
i--;
}
}
row->table_table_row_attlist_.table_number_rows_repeated_ = rows_.back().repeated;
row->attlist_.table_number_rows_repeated_ = rows_.back().repeated;
}
void ods_table_state::set_row_hidden(bool Val)
{
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
if (row == NULL)return;
row->table_table_row_attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
row->attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
}
void ods_table_state::set_row_optimal_height(bool val)
{
@ -496,7 +563,7 @@ void ods_table_state::set_row_default_cell_style(std::wstring & style_name)
//table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
//if (row == NULL)return;
//row->table_table_row_attlist_.table_default_cell_style_name_ = style_name;
//row->attlist_.table_default_cell_style_name_ = style_name;
}
office_element_ptr & ods_table_state::current_row_element()
@ -515,7 +582,7 @@ office_element_ptr & ods_table_state::current_cell_element()
}
ods_hyperlink_state & ods_table_state::current_hyperlink()
{
if ((cells_size_ >0 && !hyperlinks_.empty()) && (cells_.back().hyperlink_idx >= 0) )
if ((cells_size_ > 0 && !hyperlinks_.empty()) && (cells_.back().hyperlink_idx >= 0) )
{
return hyperlinks_[cells_.back().hyperlink_idx];
}
@ -536,12 +603,12 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
if (cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
{
cell->table_table_cell_attlist_.table_style_name_ = style_name;
cell->attlist_.table_style_name_ = style_name;
}
table_covered_table_cell* covered_cell = dynamic_cast<table_covered_table_cell*>(elm.get());
if (covered_cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
{
covered_cell->table_table_cell_attlist_.table_style_name_ = style_name;
covered_cell->attlist_.table_style_name_ = style_name;
}
ods_cell_state state;
@ -571,7 +638,7 @@ void ods_table_state::set_cell_format_value(office_value_type::type value_type)
common_value_and_type_attlist cell_type;
cell_type.office_value_type_ = office_value_type(value_type);
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = cell_type;
cell->attlist_.common_value_and_type_attlist_ = cell_type;
}
void ods_table_state::set_cell_type(int type)
@ -599,11 +666,11 @@ void ods_table_state::set_cell_type(int type)
}
if (cell_type)
{
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
if (!cell->attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
}
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
}
void ods_table_state::add_definded_expression(office_element_ptr & elm)
@ -616,12 +683,19 @@ void ods_table_state::add_definded_expression(office_element_ptr & elm)
if (!table_defined_expressions_)return;
table_defined_expressions_->add_child_element(elm);
}
void ods_table_state::add_hyperlink(std::wstring & ref,int col, int row, std::wstring & link)
void ods_table_state::add_hyperlink(const std::wstring & ref,int col, int row, const std::wstring & link, bool bLocation)
{
ods_hyperlink_state state;
state.row = row; state.col = col; state.ref = ref; state.bLocation = bLocation;
state.row=row; state.col =col; state.ref = ref, state.link = link;
if (state.bLocation)
{
state.link = L"#" + formulas_converter_table.convert_named_ref(link);
}
else
{
state.link = link;
}
hyperlinks_.push_back(state);
}
@ -629,7 +703,7 @@ void ods_table_state::start_comment(int col, int row, std::wstring & author)
{
ods_comment_state state;
state.row=row; state.col =col; state.author = author;
state.row = row; state.col = col; state.author = author;
create_element(L"office", L"annotation", state.elm, context_);
comments_.push_back(state);
@ -693,8 +767,8 @@ void ods_table_state::check_spanned_cells()
table_table_cell* cell_elm = dynamic_cast<table_table_cell*>(cells_[i].elm.get());
if (cell_elm == NULL)break;
cell_elm->table_table_cell_attlist_extra_.table_number_columns_spanned_ = jt->second.spanned_cols;
cell_elm->table_table_cell_attlist_extra_.table_number_rows_spanned_ = jt->second.spanned_rows;
cell_elm->attlist_extra_.table_number_columns_spanned_ = jt->second.spanned_cols;
cell_elm->attlist_extra_.table_number_rows_spanned_ = jt->second.spanned_rows;
break;
}
@ -794,8 +868,8 @@ void ods_table_state::set_cell_spanned(int spanned_cols, int spanned_rows)
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
cell->attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->attlist_extra_.table_number_rows_spanned_ = spanned_rows;
}
void ods_table_state::set_cell_formula(std::wstring & formula)
{
@ -866,7 +940,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_.table_formula_ = odfFormula;
cell->attlist_.table_formula_ = odfFormula;
cells_.back().empty = false;
}
@ -939,7 +1013,7 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
shared_formulas_.push_back(state);
cell->table_table_cell_attlist_.table_formula_ = odf_formula;
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
else
@ -975,7 +1049,7 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
boost::match_default | boost::format_all);
odf_formula = res;
}
cell->table_table_cell_attlist_.table_formula_ = odf_formula;
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
}
@ -1016,8 +1090,8 @@ void ods_table_state::set_cell_array_formula(std::wstring & formula, std::wstrin
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_extra_.table_number_matrix_columns_spanned_ = col_span;
cell->table_table_cell_attlist_extra_.table_number_matrix_rows_spanned_ = row_span;
cell->attlist_extra_.table_number_matrix_columns_spanned_ = col_span;
cell->attlist_extra_.table_number_matrix_rows_spanned_ = row_span;
}
}
@ -1100,11 +1174,11 @@ void ods_table_state::set_cell_text(odf_text_context* text_context, bool cash_va
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell)
{
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
if (!cell->attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
}
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
cells_.back().empty = false;
@ -1127,35 +1201,35 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
if (!cell->attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::Float);
cell->attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::Float);
//временно... пока нет определялки типов
}
cells_.back().empty = false;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_)
{
switch(cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type())
switch(cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type())
{
case office_value_type::String:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_string_value_ = value;
cell->attlist_.common_value_and_type_attlist_->office_string_value_ = value;
break;
case office_value_type::Boolean:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_boolean_value_ = value;
cell->attlist_.common_value_and_type_attlist_->office_boolean_value_ = value;
break;
case office_value_type::Date:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_date_value_ = utils::convert_date(value);
cell->attlist_.common_value_and_type_attlist_->office_date_value_ = utils::convert_date(value);
break;
case office_value_type::Time:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_time_value_ = utils::convert_time(value);
cell->attlist_.common_value_and_type_attlist_->office_time_value_ = utils::convert_time(value);
break;
case office_value_type::Currency:
case office_value_type::Percentage:
case office_value_type::Float:
default:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_ = value;
cell->attlist_.common_value_and_type_attlist_->office_value_ = value;
}
}
else
@ -1168,11 +1242,11 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
{
bool need_test_cach = false;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_)
{
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Float) need_test_cach = true;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Currency) need_test_cach = true;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Percentage) need_test_cach = true;
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Float) need_test_cach = true;
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Currency) need_test_cach = true;
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Percentage) need_test_cach = true;
}
try
{
@ -1186,8 +1260,8 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
{
if (need_cash)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_ = boost::none;
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::String);
cell->attlist_.common_value_and_type_attlist_->office_value_ = boost::none;
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::String);
}
}
if (need_cash)
@ -1216,7 +1290,7 @@ void ods_table_state::end_cell()
if (cells_.back().empty)
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell)cell->table_table_cell_attlist_.common_value_and_type_attlist_ = boost::none;
if (cell)cell->attlist_.common_value_and_type_attlist_ = boost::none;
}
}
@ -1315,8 +1389,8 @@ void ods_table_state::add_default_cell( unsigned int repeated)
int spanned_rows = 0, spanned_cols = 0;
if (cell && isSpannedCell(current_table_column_, current_table_row_, spanned_cols, spanned_rows))
{
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
cell->attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->attlist_extra_.table_number_rows_spanned_ = spanned_rows;
}
}
@ -1338,17 +1412,17 @@ void ods_table_state::add_default_cell( unsigned int repeated)
if (cell)
{
cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
cell->attlist_.table_number_columns_repeated_ = repeated;
if (!row_default_cell_style_name_.empty())
cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
cell->attlist_.table_style_name_ = row_default_cell_style_name_;
}
if (covered_cell)
{
covered_cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
covered_cell->attlist_.table_number_columns_repeated_ = repeated;
if (!row_default_cell_style_name_.empty())
covered_cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
covered_cell->attlist_.table_style_name_ = row_default_cell_style_name_;
current_covered_cols_ -= repeated;
}
@ -1357,7 +1431,7 @@ void ods_table_state::add_default_cell( unsigned int repeated)
///////////////////////////////////////////////////
void ods_table_state::start_conditional_formats()
{
office_element_ptr elm;
office_element_ptr elm;
create_element(L"calcext", L"conditional-formats",elm,context_);
current_level_.back()->add_child_element(elm);
@ -1370,7 +1444,7 @@ void ods_table_state::end_conditional_formats()
}
void ods_table_state::start_conditional_format(std::wstring ref)
{
office_element_ptr elm;
office_element_ptr elm;
create_element(L"calcext", L"conditional-format", elm, context_);
current_level_.back()->add_child_element(elm);

View File

@ -179,8 +179,8 @@ struct ods_element_state
struct ods_cell_state : ods_element_state
{
int col;
int row;
int col = -1;
int row = -1;
int hyperlink_idx = -1;
int comment_idx = -1;
@ -191,14 +191,16 @@ struct ods_cell_state : ods_element_state
struct ods_hyperlink_state
{
std::wstring ref;
int col;
int row;
int col = -1;
int row = -1;
std::wstring link;
bool bLocation = false;
};
struct ods_comment_state
{
int col;
int row;
int col = -1;
int row = -1;
std::wstring author;
office_element_ptr elm;
@ -253,6 +255,14 @@ public:
void set_table_tab_color(_CP_OPT(odf_types::color) & _color);
void set_table_dimension(int col, int row);
void set_print_range(std::wstring range);
void set_table_protection(bool Val);
void set_table_protection_insert_columns(bool Val);
void set_table_protection_insert_rows(bool Val);
void set_table_protection_delete_columns(bool Val);
void set_table_protection_delete_rows(bool Val);
void set_table_protection_unprotected_cells(bool Val);
void set_table_protection_protected_cells(bool Val);
void add_column(office_element_ptr & elm, unsigned int repeated ,office_element_ptr & style);
void set_column_width(double width);
@ -318,7 +328,8 @@ public:
void end_conditional_formats();
///////////////////////////////
void add_hyperlink(std::wstring & ref,int col, int row, std::wstring & link);
void add_hyperlink(const std::wstring & ref,int col, int row, const std::wstring & link, bool bLocation = false);
void add_definded_expression(office_element_ptr & elm);
void start_comment(int col, int row, std::wstring & author);

View File

@ -706,6 +706,11 @@ void odt_conversion_context::set_field_instr()
{
current_fields.back().type = fieldTime;
}
res1 = instr.find(L"FORMTEXT");
if (std::wstring::npos != res1 && current_fields.back().type == 0)
{
current_fields.back().type = fieldTextInput;
}
res1 = instr.find(L"SEQ");
if (std::wstring::npos != res1 && current_fields.back().type == 0)
{
@ -1509,7 +1514,7 @@ void odt_conversion_context::end_table_columns()
void odt_conversion_context::start_table_header_rows()
{
office_element_ptr elm;
create_element(L"table", L"table-header-rows",elm,this);
create_element(L"table", L"table-header-rows", elm, this);
text_context()->start_element(elm);
}
@ -1520,11 +1525,11 @@ void odt_conversion_context::end_table_header_rows()
void odt_conversion_context::start_table_row(bool styled)
{
office_element_ptr elm;
create_element(L"table", L"table-row",elm,this);
create_element(L"table", L"table-row", elm, this);
if (styled)
{
styles_context()->create_style(L"",odf_types::style_family::TableRow, true, false, -1);
styles_context()->create_style(L"", odf_types::style_family::TableRow, true, false, -1);
}
text_context()->start_element(elm);
@ -1556,7 +1561,7 @@ void odt_conversion_context::end_table_cell()
}
void odt_conversion_context::end_table_row()
{
for (int i=table_context()->current_column() ; i < table_context()->count_columns(); i++)
for (int i = table_context()->current_column() ; i < table_context()->count_columns(); i++)
{
add_default_cell();
}

View File

@ -232,4 +232,10 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
}
}
void oox_shape::add(std::wstring name,std::wstring frmla)
{
XmlUtils::replace_all(name, L"gd", L"f");
_equation q = {name, frmla};
equations.push_back(q);
}
}

View File

@ -68,11 +68,7 @@ namespace cpdoccore
_CP_OPT(std::wstring) r_maximum;
};
void add(std::wstring name,std::wstring frmla)
{
_equation q = {name, frmla};
equations.push_back(q);
}
void add(std::wstring name,std::wstring frmla);
std::vector<_equation> equations;
std::vector<_handle> handles;
@ -87,4 +83,4 @@ namespace cpdoccore
std::wstring odf_type_name;
};
};
};

View File

@ -814,7 +814,40 @@ void text_sequence::add_text(const std::wstring & Text)
office_element_ptr elm = text_text::create(Text) ;
text_.push_back( elm );
}
//----------------------------------------------------------------------------------
// text:sequence
//----------------------------------------------------------------------------------
const wchar_t * text_text_input::ns = L"text";
const wchar_t * text_text_input::name = L"text-input";
void text_text_input::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"text:description", text_description_);
for (size_t i = 0; i < text_.size(); i++)
{
text_[i]->text_to_stream(CP_XML_STREAM());
}
}
}
}
void text_text_input::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
void text_text_input::add_child_element( const office_element_ptr & child_element)
{
text_.push_back(child_element);
}
void text_text_input::add_text(const std::wstring & Text)
{
office_element_ptr elm = text_text::create(Text) ;
text_.push_back( elm );
}
//----------------------------------------------------------------------------------
// text:sequesheet-namence
//----------------------------------------------------------------------------------

View File

@ -689,9 +689,30 @@ public:
_CP_OPT(std::wstring) template_;
office_element_ptr_array text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_sequence);
// text:text-input
//---------------------------------------------------------------------------------------------------
class text_text_input : public office_element_impl<text_text_input>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextTextInput;
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);
virtual void add_text(const std::wstring & Text);
_CP_OPT(std::wstring) text_description_;
office_element_ptr_array text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_text_input);
// text:sheet-name
//---------------------------------------------------------------------------------------------------
class text_sheet_name : public office_element_impl<text_sheet_name>

View File

@ -50,13 +50,17 @@ using xml::xml_char_wc;
void table_table_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT( L"table:name", table_name_);
CP_XML_ATTR_OPT( L"table:style-name", table_style_name_);
CP_XML_ATTR_OPT( L"table:template-name", table_template_name_);
CP_XML_ATTR_OPT( L"table:name", table_name_);
CP_XML_ATTR_OPT( L"table:style-name", table_style_name_);
CP_XML_ATTR_OPT( L"table:template-name", table_template_name_);
if (table_protected_ && table_protected_->get())
{
CP_XML_ATTR_OPT( L"table:protected", table_protected_);
CP_XML_ATTR_OPT( L"table:protection-key", table_protection_key_);
CP_XML_ATTR_OPT( L"table:protection-digest-algorithm", table_protection_key_digest_algorithm_);
}
if (table_protected_)
CP_XML_ATTR_OPT( L"table:protection-key", table_protection_key_);
if (table_print_)
CP_XML_ATTR_OPT( L"table:print-ranges", table_print_ranges_);
}
@ -120,6 +124,28 @@ void table_table_column_attlist::serialize(CP_ATTR_NODE)
////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_table_protection::ns = L"loext"; //table ???
const wchar_t * table_table_protection::name = L"table-protection";
void table_table_protection::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR(L"loext:select-protected-cells", select_protected_cells);
CP_XML_ATTR(L"loext:select-unprotected-cells", select_unprotected_cells);
CP_XML_ATTR_OPT(L"loext:insert-columns", insert_columns);
CP_XML_ATTR_OPT(L"loext:insert-rows", insert_rows);
CP_XML_ATTR_OPT(L"loext:delete-columns", delete_columns);
CP_XML_ATTR_OPT(L"loext:delete-rows", delete_rows);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_table_source::ns = L"table";
const wchar_t * table_table_source::name = L"table-source";
@ -225,7 +251,9 @@ void table_table::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
if (table_protection_)table_protection_->serialize(CP_XML_STREAM());
if (table_shapes_)table_shapes_->serialize(CP_XML_STREAM());
@ -257,7 +285,7 @@ void table_table_column::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_column_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
}
}
}
@ -553,12 +581,12 @@ const wchar_t * table_table_cell::name = L"table-cell";
void table_table_cell::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
table_table_cell_content_.create_child_element(Ns, Name, getContext());
content_.create_child_element(Ns, Name, getContext());
}
void table_table_cell::add_child_element( const office_element_ptr & child_element)
{
table_table_cell_content_.add_child_element(child_element);
content_.add_child_element(child_element);
}
void table_table_cell::serialize(std::wostream & _Wostream)
{
@ -566,10 +594,10 @@ void table_table_cell::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_cell_attlist_.serialize(CP_GET_XML_NODE());
table_table_cell_attlist_extra_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
attlist_extra_.serialize(CP_GET_XML_NODE());
table_table_cell_content_.serialize(CP_XML_STREAM());
content_.serialize(CP_XML_STREAM());
}
}
}
@ -582,12 +610,12 @@ const wchar_t * table_covered_table_cell::name = L"covered-table-cell";
void table_covered_table_cell::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
empty_ = false;
table_table_cell_content_.create_child_element( Ns, Name, getContext());
content_.create_child_element( Ns, Name, getContext());
}
void table_covered_table_cell::add_child_element( const office_element_ptr & child_element)
{
empty_ = false;
table_table_cell_content_.add_child_element(child_element);
content_.add_child_element(child_element);
}
void table_covered_table_cell::serialize(std::wostream & _Wostream)
{
@ -595,9 +623,9 @@ void table_covered_table_cell::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_cell_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
table_table_cell_content_.serialize(CP_XML_STREAM());
content_.serialize(CP_XML_STREAM());
}
}
}
@ -632,7 +660,7 @@ void table_table_row::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_row_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < content_.size(); i++)
{

View File

@ -66,10 +66,11 @@ public:
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
_CP_OPT(std::wstring) table_protection_key_;
_CP_OPT(std::wstring) table_print_ranges_;
_CP_OPT(odf_types::Bool) table_protected_; // default false
_CP_OPT(odf_types::Bool) table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
_CP_OPT(std::wstring) table_protection_key_digest_algorithm_;
bool table_print_; // default true
@ -152,7 +153,37 @@ public:
void serialize(CP_ATTR_NODE);
};
//-----------------------------------------------------------------------------------------------------
class table_table_protection : public office_element_impl<table_table_protection>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableTableProtection;
CPDOCCORE_DEFINE_VISITABLE();
table_table_protection() : select_protected_cells(true), select_unprotected_cells(true) {}
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
virtual void add_child_element( const office_element_ptr & child_element){}
virtual void serialize(std::wostream & _Wostream);
odf_types::Bool select_protected_cells;
odf_types::Bool select_unprotected_cells;
_CP_OPT(odf_types::Bool) insert_columns;
_CP_OPT(odf_types::Bool) insert_rows;
_CP_OPT(odf_types::Bool) delete_columns;
_CP_OPT(odf_types::Bool) delete_rows;
//_CP_OPT(bool) format_columns; //???
//_CP_OPT(bool) format_rows;
//_CP_OPT(bool) format_cells;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_protection);
//-----------------------------------------------------------------------------------------------------
class table_table_source : public office_element_impl<table_table_source>
{
@ -274,7 +305,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
public:
table_table_column_attlist table_table_column_attlist_;
table_table_column_attlist attlist_;
};
@ -378,7 +409,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
table_table_row_attlist table_table_row_attlist_;
table_table_row_attlist attlist_;
office_element_ptr_array content_; // table-table-cell, table-covered-table-cell
};
@ -418,9 +449,9 @@ public:
virtual void serialize(std::wostream & _Wostream);
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_attlist_extra table_table_cell_attlist_extra_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist attlist_;
table_table_cell_attlist_extra attlist_extra_;
table_table_cell_content content_;
};
@ -445,8 +476,8 @@ public:
virtual void serialize(std::wostream & _Wostream);
bool empty_;
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist attlist_;
table_table_cell_content content_;
};
@ -616,17 +647,20 @@ public:
virtual void serialize(std::wostream & _Wostream);
table_table_attlist table_table_attlist_;
office_element_ptr table_table_source_;//table-table-source
table_table_attlist attlist_;
office_element_ptr table_table_source_;//table-table-source
office_element_ptr table_protection_;
office_element_ptr table_named_expressions_;
office_element_ptr table_conditional_formats_;
office_element_ptr table_shapes_;
table_columns_and_groups table_columns_and_groups_;//table-columns-and-groups
table_rows_and_groups table_rows_and_groups_;
//office-dde-source
//table-scenario
//office-forms
office_element_ptr table_named_expressions_;
office_element_ptr table_conditional_formats_;
office_element_ptr table_shapes_;
table_columns_and_groups table_columns_and_groups_;//table-columns-and-groups
table_rows_and_groups table_rows_and_groups_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table);

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