Commit f2df0618 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - вытерты лишние комменты, поправлены позиции геометрии в...

OdfFormatReader - вытерты лишние комменты, поправлены позиции геометрии в группах, настройки текста в data point диаграмм
parent 91b1dad7
#ifndef CPDOCCORE_COLOR_UTILS_H_
#define CPDOCCORE_COLOR_UTILS_H_
#pragma once
namespace cpdoccore {
......@@ -12,4 +11,3 @@ bool HEXStringToRGB(std::wstring const & str, int &r, int &g, int &b);
}
#endif
#ifndef _CPDOCCORE_HASH_H_
#define _CPDOCCORE_HASH_H_
#pragma once
#include "../../include/cpdoccore/CPOptional.h"
namespace boost
{
template< class T > struct hash;
template< class T > struct hash;
}
namespace cpdoccore {
......@@ -25,4 +22,3 @@ std::size_t hash_value(typename optional<T>::Type const & val)
}
#endif
#ifndef _CP_NONCOPYABLE_H_
#define _CP_NONCOPYABLE_H_
#pragma once
#include <boost/noncopyable.hpp>
......@@ -8,5 +7,3 @@ namespace cpdoccore {
typedef ::boost::noncopyable noncopyable;
} // namespace cpdoccore
#endif // #ifndef _CP_NONCOPYABLE_H_
#ifndef _CPDOCCORE_SCOPED_PTR_H_
#define _CPDOCCORE_SCOPED_PTR_H_
#pragma once
#include <boost/scoped_ptr.hpp>
namespace cpdoccore {
template <class T>
struct scoped_ptr
{
typedef ::boost::scoped_ptr<T> Type;
};
struct scoped_ptr
{
typedef ::boost::scoped_ptr<T> Type;
};
#define _CP_SCOPED_PTR(T) scoped_ptr< T >::Type
}
#endif
#ifndef _CP_SHARED_PTR_H_
#define _CP_SHARED_PTR_H_
#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
namespace cpdoccore {
/// shared_ptr, boost::shared_ptr
template <class T>
struct shared_ptr
{
typedef ::boost::shared_ptr<T> Type;
};
struct shared_ptr
{
typedef ::boost::shared_ptr<T> Type;
};
#define _CP_PTR(T) shared_ptr< T >::Type
}
#endif
......@@ -2,10 +2,7 @@
namespace cpdoccore {
// ïðåîáðàçîâàíèå ñòðîê
std::string ansi_to_utf8(const std::string & _AnsiString);
std::wstring utf8_to_utf16(const std::string & _Utf8String);
std::string utf16_to_utf8(const std::wstring & _Utf16String);
std::string ansi_to_utf8(const std::string & _AnsiString);
std::wstring utf8_to_utf16(const std::string & _Utf8String);
std::string utf16_to_utf8(const std::wstring & _Utf16String);
}
#ifndef _CP_WEAK_PTR_H_
#define _CP_WEAK_PTR_H_
#pragma once
#include <boost/weak_ptr.hpp>
namespace cpdoccore {
template <class T>
struct weak_ptr
{
typedef ::boost::weak_ptr<T> Type;
};
struct weak_ptr
{
typedef ::boost::weak_ptr<T> Type;
};
}
#endif
#ifndef _CPDOCCORE_WRITEDOCELEMENT_H_
#define _CPDOCCORE_WRITEDOCELEMENT_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
......@@ -34,5 +29,3 @@ inline write_doc_element::~write_doc_element()
}
}
#endif // #ifndef _CPDOCCORE_WRITEDOCELEMENT_H_
/*
Copyright (C) 2010, Ferruccio Barletta (ferruccio.barletta@gmail.com)
*/
#ifndef XML_WRITER_HPP
#define XML_WRITER_HPP
#pragma once
#include <string>
#include <iostream>
......@@ -299,5 +293,3 @@ typedef xml::writer::element<wchar_t> xml_element;
#define CP_XML_NODE_SIMPLE() std::wstring NS_NAME = std::wstring(ns) + std::wstring(L":") + std::wstring(name); CP_XML_NODE(NS_NAME)
}
#endif
#ifndef _CPDOCCORE_XML_ELEMENT_H_
#define _CPDOCCORE_XML_ELEMENT_H_
#pragma once
#include <string>
#include <iosfwd>
......@@ -69,6 +68,4 @@ inline std::basic_string<CharT> element<CharT>::xml_to_string() const
}
}
}
#endif
}
\ No newline at end of file
#include "../../include/cpdoccore/CPString.h"
#include "../../../DesktopEditor/common/File.h"
......
......@@ -353,8 +353,6 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
}
if (data_labels_)
data_labels_->oox_serialize(_Wostream);
bool bEmpty_dPt = true;
for (int i = 0 ; i < content_.points_.size(); i++)
......@@ -382,11 +380,20 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
shape.set( content_.points_[i].graphic_properties_, content_.points_[i].fill_);
shape.oox_serialize(CP_XML_STREAM());
}
oox_serialize_default_text(CP_XML_STREAM(), content_.points_[i].text_properties_);
if (!content_.points_[i].text_properties_.empty())
{
if (!data_labels_) data_labels_ = oox_data_labels();
data_labels_->add_dLbl(indPoint - 1, content_.points_[i].text_properties_);
}
}
}
}
if (data_labels_)
data_labels_->oox_serialize(_Wostream);
}
}
//backward (Backward) 21.2.2.12
......
......@@ -21,7 +21,7 @@ public:
~oox_chart_series(){}
void oox_serialize_common(std::wostream & _Wostream);
virtual void oox_serialize(std::wostream & _Wostream){}
virtual void oox_serialize(std::wostream & _Wostream) = 0;
_oox_chart_values values_[5]; //cat(labels), common, x, y, bubble,
int id_;
......
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_chart_shape.h"
#include "oox_drawing.h"
......
......@@ -4,6 +4,8 @@
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_data_labels.h"
#include "oox_chart_shape.h"
#include <boost/foreach.hpp>
namespace cpdoccore {
......@@ -11,7 +13,6 @@ namespace oox {
oox_data_labels::oox_data_labels()//
{
//
showBubbleSize_ = false;
showCatName_ = false;
showLeaderLines_ = false;
......@@ -20,12 +21,55 @@ oox_data_labels::oox_data_labels()//
showSerName_ = false;
showVal_ = false;
}
void oox_data_labels::add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties)
{
dLbls_.insert(std::pair<int, std::vector<odf_reader::_property>>(ind, text_properties));
}
void oox_data_labels::oox_serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"c:dLbls")
{
for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); it++)
{
CP_XML_NODE(L"c:dLbl")
{
CP_XML_NODE(L"c:idx")
{
CP_XML_ATTR(L"val", it->first);
}
oox_serialize_default_text(CP_XML_STREAM(), it->second);
CP_XML_NODE(L"c:showLegendKey")
{
CP_XML_ATTR(L"val", showLegendKey_);
}
CP_XML_NODE(L"c:showVal")
{
CP_XML_ATTR(L"val", showVal_);
}
CP_XML_NODE(L"c:showCatName")
{
CP_XML_ATTR(L"val", showCatName_);
}
CP_XML_NODE(L"c:showSerName")
{
CP_XML_ATTR(L"val", showSerName_);
}
CP_XML_NODE(L"c:showPercent")
{
CP_XML_ATTR(L"val", showPercent_);
}
CP_XML_NODE(L"c:showBubbleSize")
{
CP_XML_ATTR(L"val", showBubbleSize_);
}
}
}
CP_XML_NODE(L"c:showLegendKey")
{
CP_XML_ATTR(L"val", showLegendKey_);
......
#pragma once
#include <iosfwd>
#include <map>
#include <vector>
#include <boost/noncopyable.hpp>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/xml/attributes.h>
namespace cpdoccore {
namespace oox {
......@@ -26,16 +28,20 @@ public:
void set_showSerName (bool Val){showSerName_ = Val;}
void set_showVal (bool Val){showVal_ = Val;}
void add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties);
private:
bool showBubbleSize_;// (Show Bubble Size) 21.2.2.178
bool showCatName_;// (Show Category Name) 21.2.2.179
bool showLeaderLines_;// (Show Leader Lines) 21.2.2.183
bool showLegendKey_;// (Show Legend Key) 21.2.2.184
bool showPercent_;// (Show Percent) 21.2.2.187
bool showSerName_;// (Show Series Name) 21.2.2.188
bool showVal_;// (Show Value) 21.2.2.189
bool showBubbleSize_; // (Show Bubble Size) 21.2.2.178
bool showCatName_; // (Show Category Name) 21.2.2.179
bool showLeaderLines_; // (Show Leader Lines) 21.2.2.183
bool showLegendKey_; // (Show Legend Key) 21.2.2.184
bool showPercent_; // (Show Percent) 21.2.2.187
bool showSerName_; // (Show Series Name) 21.2.2.188
bool showVal_; // (Show Value) 21.2.2.189
std::map<int, std::vector<odf_reader::_property>> dLbls_;
//delete (Delete) 21.2.2.40
......
......@@ -77,13 +77,13 @@ private:
odf_reader::styles_container * local_styles_ptr_;
void write_rPr(std::wostream & strm);
void write_pPr(std::wostream & strm);
void write_t(std::wostream & strm);
void write_rPr (std::wostream & strm);
void write_pPr (std::wostream & strm);
void write_t (std::wostream & strm);
std::wstring dump_paragraph();
void dump_run();
void dump_field();
std::wstring dump_paragraph();
void dump_run();
void dump_field();
size_t paragraphs_cout_; //???? ?
......@@ -94,8 +94,8 @@ private:
std::wstring paragraph_style_name_;
std::wstring span_style_name_;
std::wstring base_style_name_;
odf_types::style_family::type base_style_family_;//Presentation Or SpreadSheet
std::wstring base_style_name_;
odf_types::style_family::type base_style_family_;//Presentation Or SpreadSheet
/////////////lists////////////
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
......@@ -330,13 +330,13 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
int level = list_style_stack_.size()-1;
odf_reader::paragraph_format_properties paragraph_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_,odf_types::style_family::Paragraph);
ApplyListProperties (paragraph_properties_,level);//
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_,odf_types::style_family::Paragraph);
ApplyListProperties (paragraph_properties_,level);//
paragraph_properties_.pptx_convert(pptx_context_);
const std::wstring & paragraphAttr = get_styles_context().paragraph_attr().str();
const std::wstring & paragraphAttr = get_styles_context().paragraph_attr().str();
const std::wstring & paragraphNodes = get_styles_context().paragraph_nodes().str();
if (level < 0 && paragraphAttr.length() <1 && paragraphNodes.length()<1) return;
......
......@@ -132,6 +132,8 @@ void xlsx_drawing_context::clear()
impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.name_ = L"";
impl_->object_description_.anchor_ = L"";
impl_->object_description_.anchor_x_ = 0;
impl_->object_description_.anchor_y_ = 0;
impl_->object_description_.clipping_string_ = L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->object_description_.use_image_replace_ = false;
......@@ -189,8 +191,8 @@ void xlsx_drawing_context::end_group()
if (group_rect.x > objct_rect.x) group_rect.x = objct_rect.x;
if (group_rect.y > objct_rect.y) group_rect.y = objct_rect.y;
if (group_rect.cx < objct_rect.cx + objct_rect.x) group_rect.cx = objct_rect.cx + group_rect.x;
if (group_rect.cy < objct_rect.cy + objct_rect.y) group_rect.cy = objct_rect.cy + group_rect.y;
if (group_rect.cx < objct_rect.cx + objct_rect.x) group_rect.cx = objct_rect.cx + objct_rect.x;
if (group_rect.cy < objct_rect.cy + objct_rect.y) group_rect.cy = objct_rect.cy + objct_rect.y;
}
else
impl_->groups_.pop_back();
......@@ -223,8 +225,8 @@ void xlsx_drawing_context::end_drawing()
if (group_rect.x > objct_rect.x) group_rect.x = objct_rect.x;
if (group_rect.y > objct_rect.y) group_rect.y = objct_rect.y;
if (group_rect.cx < objct_rect.cx + objct_rect.x) group_rect.cx = objct_rect.cx + group_rect.x;
if (group_rect.cy < objct_rect.cy + objct_rect.y) group_rect.cy = objct_rect.cy + group_rect.y;
if (group_rect.cx < objct_rect.cx + objct_rect.x) group_rect.cx = objct_rect.cx + objct_rect.x;
if (group_rect.cy < objct_rect.cy + objct_rect.y) group_rect.cy = objct_rect.cy + objct_rect.y;
}
}
......@@ -318,6 +320,7 @@ void xlsx_drawing_context::set_anchor(std::wstring anchor, double x_pt, double y
impl_->object_description_.anchor_x_ = x_pt;
impl_->object_description_.anchor_y_ = y_pt;
}
}
void xlsx_drawing_context::set_property(odf_reader::_property p)
{
......@@ -408,12 +411,12 @@ void xlsx_drawing_context::process_common_properties(drawing_object_description
}
void xlsx_drawing_context::process_position_properties(drawing_object_description & obj, xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to)
{
size_t last_col=0, last_row=0;
size_t column_anchor = 0, row_anchor = 0;
std::vector<std::wstring> distance;
boost::algorithm::split(distance, obj.anchor_, boost::algorithm::is_any_of(L" ."), boost::algorithm::token_compress_on);
double x=0,y=0,cx=0,cy=0;
double x = 0, y = 0, cx = 0, cy = 0;
if (obj.svg_rect_)
{
......@@ -422,31 +425,31 @@ void xlsx_drawing_context::process_position_properties(drawing_object_descriptio
cx = obj.svg_rect_->cx;
cy = obj.svg_rect_->cy;
}
to = table_metrics.calc(x + cx, y + cy);
to = table_metrics.calc(x + cx, y + cy);
from = table_metrics.calc(x, y);
if (distance.size() > 1)
if (distance.size() > 0 && !obj.anchor_.empty())
{
//
int ind_cell=distance.size()-1;
getCellAddressInv(distance[ind_cell],last_col,last_row);
int ind_cell = distance.size()-1;
getCellAddressInv(distance[ind_cell], column_anchor, row_anchor);
xlsx_table_position to_anchor = table_metrics.calc(last_col,last_row,obj.anchor_x_,obj.anchor_y_); //- :) , ...
xlsx_table_position pos_anchor = table_metrics.calc(column_anchor, row_anchor, obj.anchor_x_, obj.anchor_y_); //- :) , ...
table_metrics.update_pt(last_col,last_row, obj.anchor_x_, obj.anchor_y_);
table_metrics.update_pt(column_anchor, row_anchor, obj.anchor_x_, obj.anchor_y_);
x = obj.anchor_x_ - cx;
y = obj.anchor_y_ - cy;
to = pos_anchor;
from = table_metrics.calc(x, y);
if (obj.svg_rect_)
{
_rect r_old = obj.svg_rect_.get();
obj.svg_rect_= _rect (cx, cy, x, y);
}
to = to_anchor;
}
from = table_metrics.calc(x, y);
}
......
......@@ -24,7 +24,9 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
columns_count_ (0),
xlsx_drawing_context_ (Context->get_drawing_context_handle()),
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0)
table_column_last_width_(0.0),
in_cell(false)
{
memset(&group_row_,0,sizeof(_group_row));
}
......@@ -142,10 +144,13 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
rows_spanned_[current_table_column_ + i].set_style_id(-1);
}
}
in_cell = true;
}
void xlsx_table_state::end_cell()
{
in_cell = false;
}
......
......@@ -72,7 +72,10 @@ public:
int level;
bool collapsed;
}group_row_;
friend class xlsx_conversion_context;
private:
bool in_cell;
xlsx_conversion_context * context_;
std::wstring tableName_;
......
......@@ -12,6 +12,7 @@
#include "../odf/odfcontext.h"
#include "../odf/style_text_properties.h"
#include "../odf/style_paragraph_properties.h"
#include "../odf/calcs_styles.h"
......@@ -52,7 +53,8 @@ public:
void write_shared_strings(std::wostream & strm);
void ApplyTextProperties(std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyTextProperties (std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
......@@ -76,15 +78,16 @@ private:
std::wstring dump_text();
void write_rPr(std::wostream & strm);
void write_pPr(std::wostream & strm);
size_t paragraphs_cout_; //???? тока из за начала отсчета?
std::wstringstream text_;
std::wstringstream output_;
xlsx_shared_strings xlsx_shared_strings_;
std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится
std::wstring span_style_name_;
std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится
std::wstring span_style_name_;
};
......@@ -184,8 +187,29 @@ void xlsx_text_context::Impl::end_hyperlink(std::wstring hId)
{
hyperlink_hId = hId;
}
void xlsx_text_context::Impl::ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type)
{
std::vector<const odf_reader::style_instance *> instances;
if (local_styles_ptr_)
{
odf_reader::style_instance * defaultStyle = local_styles_ptr_->style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
}
else
{
odf_reader::style_instance * defaultStyle = styles_.style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style,odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type)
odf_reader::style_instance* styleInst = styles_.style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
}
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type)
{
std::vector<const odf_reader::style_instance *> instances;
......@@ -213,11 +237,38 @@ void xlsx_text_context::Impl::set_cell_text_properties(odf_reader::text_format_p
text_properties_cell_ = text_properties;
}
void xlsx_text_context::Impl::write_pPr (std::wostream & strm)
{
if (paragraph_style_name_.empty())return;
odf_reader::paragraph_format_properties paragraph_format_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_format_properties_ , odf_types::style_family::Paragraph);
paragraph_format_properties_.xlsx_convert(strm, in_draw);
//CP_XML_WRITER(strm)
// {
// if (in_draw)
// {
// CP_XML_NODE(L"a:pPr")
// {
// }
// }
// else
// {
// CP_XML_NODE(L"rPr")
// {
// }
// }
//}
}
void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
{
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1
&& !(hyperlink_hId.length()>0 && in_draw)
&& !(text_properties_cell_ && in_cell_content))return;
if (paragraph_style_name_.empty() && span_style_name_.empty()
&& !(!hyperlink_hId.empty() && in_draw)
&& !(text_properties_cell_ && in_cell_content))return;
odf_reader::text_format_properties_content text_properties_paragraph_;
odf_reader::text_format_properties_content text_properties_span_;
......@@ -298,11 +349,13 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
{
CP_XML_NODE(L"rPr")
{
if (sValFontFamily) {CP_XML_NODE(L"rFont") {CP_XML_ATTR(L"val", sValFontFamily.get());}}
if (dValFontSize) {CP_XML_NODE(L"sz") {CP_XML_ATTR(L"val", (int)(dValFontSize.get()));}}
if (sValFontColor) {CP_XML_NODE(L"color") {CP_XML_ATTR(L"rgb", sValFontColor.get());}}
if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_NODE(L"i") {CP_XML_ATTR(L"val", "true");}}
if ((iValFontWeight) && (iValFontWeight.get() >0)){CP_XML_NODE(L"b") {CP_XML_ATTR(L"val", "true");}}
if (sValFontFamily) {CP_XML_NODE(L"rFont") {CP_XML_ATTR(L"val", sValFontFamily.get());}}
if (dValFontSize) {CP_XML_NODE(L"sz") {CP_XML_ATTR(L"val", (int)(dValFontSize.get()));}}
if (sValFontColor) {CP_XML_NODE(L"color") {CP_XML_ATTR(L"rgb", sValFontColor.get());}}
if ((iValFontStyle) &&
(iValFontStyle.get() >0)) {CP_XML_NODE(L"i") {CP_XML_ATTR(L"val", "true");}}
if ((iValFontWeight) &&
(iValFontWeight.get() >0)) {CP_XML_NODE(L"b") {CP_XML_ATTR(L"val", "true");}}
}
}
}
......
......@@ -437,6 +437,11 @@ void xlsx_conversion_context::start_table_cell(const std::wstring & formula, siz
get_table_context().start_cell(formula, columnsSpanned, rowsSpanned);
}
bool xlsx_conversion_context::in_table_cell()
{
return get_table_context().state()->in_cell;
}
void xlsx_conversion_context::end_table_cell()
{
get_table_context().end_cell();
......
......@@ -82,6 +82,8 @@ public:
bool is_empty_row() const;
void set_current_row_height(size_t height_pt);
bool in_table_cell();
void start_table_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned);
void end_table_cell();
......
#include "abstract_xml.h"
#include "paragraph_elements.h"
......
#ifndef _CPDOCCORE_ODF_ABSTRACT_XML_H_
#define _CPDOCCORE_ODF_ABSTRACT_XML_H_
#pragma once
#include "office_elements.h"
#include "office_elements_create.h"
......@@ -35,6 +34,4 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(abstract_xml);
}
}
#endif // #ifndef _CPDOCCORE_ODF_ABSTRACT_XML_H_
}
\ No newline at end of file
......@@ -61,16 +61,15 @@ void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context)
//}
////////////////////////////////////////
std::wstring Anchor;
if (common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_)
{
Anchor = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_.get();
std::wstring Anchor = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_cell_address_.get();
const double a_x_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double a_y_pt = common_draw_attlist_.common_text_spreadsheet_shape_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt);
Context.get_drawing_context().set_anchor(Anchor, a_x_pt, a_y_pt, true);
}
////////////////////////////////////////////////
for (int i = 0; i < content_.size(); i++)
......
......@@ -188,6 +188,8 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
void xlsx_convert(std::wostream & strm, bool in_draw);
// 15.5.1 fo:line-height
_CP_OPT(odf_types::line_width) fo_line_height_; // +
......
......@@ -92,6 +92,154 @@ std::wstring process_margin(const _CP_OPT(length_or_percent) & margin, length::u
}
void paragraph_format_properties::xlsx_convert(std::wostream & strm, bool in_draw)
{
CP_XML_WRITER(strm)
{
std::wstring node_name = L"pPr";
if (in_draw) node_name = L"a:pPr";
CP_XML_NODE(node_name)
{
if (fo_text_align_)
{
std::wstring jc;
switch(fo_text_align_->get_type())
{
case text_align::Start:
case text_align::Left:
jc = L"l"; break;
case text_align::End:
case text_align::Right:
jc = L"r"; break;
case text_align::Center:
jc = L"ctr"; break;
case text_align::Justify:
jc = L"just"; break;
}
if (!jc.empty()) CP_XML_ATTR(L"algn", jc);
}
if (fo_margin_left_ || fo_margin_right_ || fo_text_indent_ )
{
// TODO auto indent
std::wstring w_left, w_right, w_firstLine;
w_left = process_margin(fo_margin_left_, length::emu, 1.);
w_right = process_margin(fo_margin_right_, length::emu, 1.);
w_firstLine = process_margin(fo_text_indent_,length::emu, 1.);
//if (w_left.empty()) w_left = L"0";
//if (w_right.empty()) w_right = L"0";
//if (w_firstLine.empty()) w_hanging = L"0";
if (!w_left.empty()) CP_XML_ATTR(L"marL", w_left);
if (!w_right.empty()) CP_XML_ATTR(L"marR", w_right);
if (!w_firstLine.empty()) CP_XML_ATTR(L"indent", w_firstLine);
}
if (style_vertical_align_)
{
std::wstring w_val;
switch(style_vertical_align_->get_type())
{
case vertical_align::Baseline: w_val = L"base";break;
case vertical_align::Top: w_val = L"t"; break;
case vertical_align::Middle: w_val = L"ctr"; break;
case vertical_align::Bottom: w_val = L"b"; break;
case vertical_align::Auto: w_val = L"auto"; break;
}
if (!w_val.empty()) CP_XML_ATTR(L"fontAlgn", w_val);
}
if (style_line_height_at_least_ || fo_line_height_ || style_line_spacing_)
{
std::wstring w_line, w_lineRule;
if (fo_line_height_)
{
if (fo_line_height_->get_type() == line_width::Percent)
{
double percent = fo_line_height_->get_percent().get_value();
w_line = boost::lexical_cast<std::wstring>( (int)( 0.5 + percent *1000. ) );
w_lineRule = L"a:spcPct";
}
//else if(fo_line_height_->get_type() == line_width::Normal)
//{
//}
else if (fo_line_height_->get_type() == line_width::PositiveLength)
{
w_line = boost::lexical_cast<std::wstring>((int)(0.5 + 100.0 * fo_line_height_->get_positive_length().get_value_unit(length::pt)));
w_lineRule = L"a:spcPts";
}
}
else if (style_line_height_at_least_)
{
w_lineRule = L"a:spcPts";
w_line = boost::lexical_cast<std::wstring>((int)(0.5 + 100.0 * style_line_height_at_least_->get_value_unit(length::pt)));
}
else if (style_line_spacing_)
{
w_lineRule = L"a:spcPts";
w_line = boost::lexical_cast<std::wstring>( (int)(0.5 + 240.0 + 100.0 * style_line_spacing_->get_value_unit(length::pt)) );
}
CP_XML_NODE(L"a:lnSpc")
{
CP_XML_NODE(w_lineRule)
{
CP_XML_ATTR(L"val",w_line);
}
}
}
if (fo_margin_top_/* || fo_margin_*/)
{
CP_XML_NODE(L"a:spcBef")
{
if (fo_margin_bottom_->get_type() == length_or_percent::Length)
{
std::wstring w_before = process_margin(fo_margin_top_, length::pt, 100.0);
CP_XML_NODE(L"a:spcPts")
{
CP_XML_ATTR(L"val",w_before);
}
}
else
{
std::wstringstream s;
s << fo_margin_top_;
CP_XML_NODE(L"a:spcPct")
{
CP_XML_ATTR(L"val", s.str());
}
}
}
}
if (fo_margin_bottom_/* || fo_margin_*/)
{
CP_XML_NODE(L"a:spcAft")
{
if (fo_margin_bottom_->get_type() == length_or_percent::Length)
{
std::wstring w_after = process_margin(fo_margin_bottom_, length::pt, 100.0);
CP_XML_NODE(L"a:spcPts")
{
CP_XML_ATTR(L"val",w_after);
}
}
else
{
std::wstringstream s;
s << fo_margin_bottom_;
CP_XML_NODE(L"a:spcPct")
{
CP_XML_ATTR(L"val", s.str());
}
}
}
}
}
}
}
void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Context)
{
std::wstringstream & _pPr = Context.get_text_context().get_styles_context().paragraph_attr();
......@@ -149,6 +297,7 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
if (!w_val.empty())
_pPr << L"fontAlgn=\"" << w_val << "\" ";
}
//if (style_writing_mode_)
//{
......
......@@ -320,12 +320,12 @@ void table_columns_and_groups::add_child_element( xml::sax * Reader, const ::std
::std::wostream & table_table_cell_content::text_to_stream(::std::wostream & _Wostream) const
{
return CP_SERIALIZE_TEXT(text_content_);
return CP_SERIALIZE_TEXT(elements_);
}
void table_table_cell_content::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context)
{
CP_CREATE_ELEMENT_SIMPLE(text_content_);
CP_CREATE_ELEMENT_SIMPLE(elements_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
......
This diff is collapsed.
......@@ -17,12 +17,10 @@ namespace cpdoccore {
namespace odf_reader {
bool table_table_cell_content::docx_convert(oox::docx_conversion_context & Context)
{
bool wasPar = false;
BOOST_FOREACH(const office_element_ptr & elm, text_content_)
BOOST_FOREACH(const office_element_ptr & elm, elements_)
{
ElementType type = elm->get_type();
......
......@@ -22,13 +22,10 @@ namespace cpdoccore {
namespace odf_reader {
bool table_table_cell_content::pptx_convert(oox::pptx_conversion_context & Context)
{
bool wasPar = false;
BOOST_FOREACH(const office_element_ptr & elm, text_content_)
BOOST_FOREACH(const office_element_ptr & elm, elements_)
{
if (elm->get_type() == typeTextP ||
elm->get_type() == typeTextH)
......
......@@ -33,9 +33,9 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
Context.get_table_context().start_cell_content();
Context.get_text_context().set_cell_text_properties(text_properties);
for (int i = 0 ; i < text_content_.size(); i++)
for (int i = 0 ; i < elements_.size(); i++)
{
text_content_[i]->xlsx_convert(Context);
elements_[i]->xlsx_convert(Context);
}
const int sharedStrId = Context.get_table_context().end_cell_content();
......@@ -152,8 +152,6 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
CP_XML_ATTR(L"customFormat", 1);
CP_XML_ATTR(L"s", Default_Cell_style_in_row_ );
}
else
CP_XML_ATTR(L"customFormat", 0);
CP_XML_STREAM();
......@@ -691,12 +689,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
xfId_last_set= Context.get_style_manager().xfId(&textFormatProperties, &parFormatProperties, &cellFormatProperties, &cellFormat, num_format,false, is_style_visible);
const int sharedStringId = table_table_cell_content_.xlsx_convert(Context, &textFormatProperties);
if (t_val == oox::XlsxCellType::str && sharedStringId >=0)
t_val = oox::XlsxCellType::s;// ,
if (sharedStringId >= 0 ||
if ( table_table_cell_content_.elements_.size() > 0 ||
!formula.empty() ||
( t_val == oox::XlsxCellType::n && !number_val.empty()) ||
( t_val == oox::XlsxCellType::b && bool_val) ||
......@@ -710,6 +703,11 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
table_table_cell_attlist_extra_.table_number_rows_spanned_ - 1 );
Context.set_current_cell_style_id(xfId_last_set);
const int sharedStringId = table_table_cell_content_.xlsx_convert(Context, &textFormatProperties);
if (t_val == oox::XlsxCellType::str && sharedStringId >=0)
t_val = oox::XlsxCellType::s;// ,
if (skip_next_cell)break;
// .
......
/// \file sax_xmllite.cpp
/// \brief SAX XmlLite
#include <string>
#include "../../../Common/DocxFormat/Source/Base/Nullable.h"
......@@ -10,7 +7,6 @@
#include "../../include/cpdoccore/xml/sax.h"
#include "sax_xmllite.h"
//#include "istream2Win32Stream.h"
namespace cpdoccore {
namespace xml {
......@@ -19,46 +15,31 @@ class saxXmlLiteReader : public sax
{
public:
saxXmlLiteReader(const wchar_t * FileName);
//saxXmlLiteReader(shared_ptr< std::istream >::Type istreamPtr);
//saxXmlLiteReader(std::istream & istreamVal);
saxXmlLiteReader();
public:
//virtual std::wstring baseURI();
virtual unsigned int depth();
// <p:abc/>, returns "abc".
virtual std::wstring nodeLocalName();
// <p:abc />, returns "p:abc".
virtual std::wstring nodeQualifiedName();
// <xyz:abc xmlns:xyz="u://1" />, it returns "xyz".
virtual std::wstring namespacePrefix();
//// Returns "u://1" for the element <xyz:abc xmlns:xyz="u://1" />.
//virtual std::wstring namespaceUri();
virtual NodeType nodeType();
virtual std::wstring value();
//virtual std::wstring attValue();
virtual unsigned int attrCount();
virtual bool attrDefault();
// <element attribute="123"></element> false
// <element attribute="123"/> - true
virtual bool isEmptyElement();
//virtual bool moveToAttrByName(const wchar_t * Name, const wchar_t * nsURI);
virtual bool moveToAttrFirst();
virtual bool moveToAttrNext();
virtual bool moveToAttrOwner();
virtual NodeType next(int Depth);
//virtual unsigned int readChunk(wchar_t * Buffer, unsigned int Size);
private:
smart_ptr< XmlUtils::CXmlLiteReader > xml_;
......@@ -152,23 +133,6 @@ std::wstring saxXmlLiteReader::namespacePrefix()
free(pName);
return sTemp;
}
//
//// Returns "u://1" for the element <xyz:abc xmlns:xyz="u://1" />.
//std::wstring saxXmlLiteReader::namespaceUri()
//{
// HRESULT hr;
// UINT size = 0;
// const wchar_t * val;
// if FAILED(hr = xml_->GetNamespaceUri(&val, &size))
// {
// throw error(error::internalErr);
// }
// if (size)
// return std::wstring(&val[0], &val[size]);
// else
// return L"";
//
//}
NodeType saxXmlLiteReader::nodeType()
{
......@@ -177,12 +141,7 @@ NodeType saxXmlLiteReader::nodeType()
XmlUtils::XmlNodeType nTempType = (XmlUtils::XmlNodeType)xmlTextReaderNodeType(xml_->getNativeReader());
return NodeTypeConvert(nTempType);
}
//std::wstring saxXmlLiteReader::nodeValue()
//{
// if (xml_.IsInit() == false) return _T("");
//
// return xml_->GetText3();
//}
std::wstring saxXmlLiteReader::value()
{
if (xml_.IsInit() == false) return _T("");
......@@ -191,8 +150,6 @@ std::wstring saxXmlLiteReader::value()
}
// <element attribute="123"></element> false
// <element attribute="123"/> - true
bool saxXmlLiteReader::isEmptyElement()
{
if (xml_.IsInit() == false) return false;
......@@ -240,22 +197,6 @@ NodeType saxXmlLiteReader::next(int Depth)
}
//unsigned int saxXmlLiteReader::readChunk(wchar_t * const Buffer, unsigned int Size)
//{
// if (xml_.IsInit() == false) return 0;
//
//
// XmlUtils::XmlNodeType nTempType = (XmlUtils::XmlNodeType)xmlTextReaderNodeType(xml_->getNativeReader());
//
// if FAILED(hr = xml_->ReadValueChunk(Buffer, Size, &readed))
// {
// throw error(error::internalErr);
// }
// return readed;
//}
//
//
////////////////
sax_ptr create_sax_xmllite(const wchar_t * FileName)
{
......
/// XmlUtils::CXmlLiteReader
#pragma once
//#include <iosfwd>
#include "../../include/cpdoccore/xml/sax.h"
#include "../../include/cpdoccore/CPSharedPtr.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment