Commit 4374c122 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

OdfFileReader linux build (complete)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62905 954022d7-b5bf-4e40-9824-e11837661b57
parent 7fb61117
......@@ -22,6 +22,7 @@ DEFINES += UNICODE \
INCLUDEPATH += /usr/include/libxml2
INCLUDEPATH += ../include
INCLUDEPATH += ../../../ServerComponents/DesktopEditor/freetype-2.5.2/include
SOURCES += \
../formulasconvert/formulasconvert_odf.cpp \
......
#include <windows.h>
#include "../../DesktopEditor/common/Types.h"
#include <string>
struct ProgressCallback;
HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation, const ProgressCallback* CallBack);
\ No newline at end of file
HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation, const ProgressCallback* CallBack);
#include "measuredigits.h"
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#include <atlbase.h>
#include <boost/lexical_cast.hpp>
#include <logging.h>
#import "../../../Redist/ASCGraphics.dll" rename_namespace("ASCGraphics")
#include <float.h>
#include "../../DesktopEditor/fontengine/FontManager.h"
namespace cpdoccore {
namespace utils {
......@@ -18,72 +17,57 @@ namespace
class MeasureError : public Error {};
}
std::pair<float,float> GetMaxDigitSizePixelsImpl(const wchar_t * fontName, float fontSize, float dpi, long fontStyle)
std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CFontManager *pFontManager)
{
ATL::CComPtr<ASCGraphics::IASCFontManager> fontMan;
HRESULT hr;
try
{
if (FAILED(hr = fontMan.CoCreateInstance(__uuidof(ASCGraphics::CASCFontManager))))
throw;
if (pFontManager == NULL) return std::pair<float, float>(7.f,8.f);
if (S_OK != (hr = fontMan->Initialize(L"")))
throw;
}
catch(...)
{
return std::pair<float,float>(7,8);
}
HRESULT hr = S_OK;
if (S_OK != (hr = fontMan->LoadFontByName(fontName, fontSize, fontStyle, dpi, dpi )))
if (S_OK != (hr = pFontManager->LoadFontByName(fontName, fontSize, fontStyle, dpi, dpi )))
{
if (S_OK != (hr = fontMan->LoadFontByName(L"Arial", fontSize, fontStyle, dpi, dpi )))
if (S_OK != (hr = pFontManager->LoadFontByName(L"Arial", fontSize, fontStyle, dpi, dpi )))
{
return std::pair<float,float>(7,8);
return std::pair<float, float>(7,8);
}
}
float maxWidth = 0;
float maxHeight = 0;
float maxHeight = 0;
for (int i = 0; i <= 9; ++i)
{
if (S_OK != (hr = fontMan->LoadString2( boost::lexical_cast<std::wstring>(i).c_str(), 0, 0)))
return std::pair<float,float>(7,8);
if (S_OK != (hr = pFontManager->LoadString2( boost::lexical_cast<std::wstring>(i).c_str(), 0, 0)))
return std::pair<float, float>(7,8);
float x, y, width, height;
TBBox box;
try
{
hr = fontMan->MeasureString(&x, &y, &width, &height);
box = pFontManager->MeasureString();
}catch(...)
{
return std::pair<float,float>(7,8);
return std::pair<float, float>(7,8);
}
if (width> maxWidth)
maxWidth = width;
if (height>maxHeight)
maxHeight = height;
if (box.fMaxX - box.fMinX > maxWidth) maxWidth = box.fMaxX - box.fMinX;
if (box.fMaxY - box.fMinY > maxHeight) maxHeight = box.fMaxY - box.fMinY;
}
return std::pair<float,float>(maxWidth,maxHeight);
return std::pair<float, float>(maxWidth,maxHeight);
}
std::pair<float,float> GetMaxDigitSizePixels(const wchar_t * fontName, float fontSize, float dpi, long fontStyle)
std::pair<float, float> GetMaxDigitSizePixels(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CFontManager *pFontManager)
{
try
{
_CP_LOG(info) << "[info] : GetMaxDigitSizePixels...";
std::pair<float,float> val = GetMaxDigitSizePixelsImpl(fontName, fontSize, dpi, fontStyle);
std::pair<float, float> val = GetMaxDigitSizePixelsImpl(fontName, fontSize, dpi, fontStyle, pFontManager);
_CP_LOG(info) << "ok" << std::endl;
return val;
}
catch(...)
{
// TODO: default value!
return std::pair<float,float>(7,8);
return std::pair<float, float>(7,8);
}
}
......
#ifndef _CPDOCCORE_MEASURE_DIGITS_H_
#define _CPDOCCORE_MEASURE_DIGITS_H_
#pragma once
#include <utility>
#include <string>
class CFontManager;
namespace cpdoccore {
namespace utils {
std::pair<float,float> GetMaxDigitSizePixels(const wchar_t * fontName, float fontSize, float dpi = 96.0, long fontStyle = 0);
std::pair<float, float> GetMaxDigitSizePixels(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CFontManager *pFontManager);
}
}
#endif
......@@ -216,7 +216,8 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
if (content_.regression_curve_.line_properties_.size()>0)
{
std::wstring typeTrendline= L"log"; //"exp" | "linear" | "log" | "movingAvg" | "poly" | "power"
shape.set(content_.regression_curve_.line_properties_,_oox_fill());
_oox_fill oox_fill;
shape.set(content_.regression_curve_.line_properties_, oox_fill);
_CP_OPT(int) iType;
odf::GetProperty(content_.properties_, L"regression-type",iType); // none, linear, logarithmic, exponential, power
......@@ -249,7 +250,8 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
}
shape.set( content_.regression_curve_.line_properties_,_oox_fill());
_oox_fill oox_fill;
shape.set( content_.regression_curve_.line_properties_, oox_fill);
shape.oox_serialize(CP_XML_STREAM());
......
......@@ -28,41 +28,40 @@ static const std::wstring _ooxShapeType[]=
namespace cpdoccore {
namespace oox {
struct _hlink_desc
{
std::wstring hId;
std::wstring hRef;
bool object;
};
struct _oox_drawing
{
_oox_drawing():type(mediaitems::typeUnknown),id(0),x(0),y(0),cx(0),cy(0),sub_type(0),name(L"object")
{
}
mediaitems::Type type;
struct _hlink_desc
{
std::wstring hId;
std::wstring hRef;
bool object;
};
struct _oox_drawing
{
_oox_drawing():type(mediaitems::typeUnknown),id(0),x(0),y(0),cx(0),cy(0),sub_type(0),name(L"object")
{
}
mediaitems::Type type;
size_t id;
std::wstring name;
size_t id;
size_t x, y;
size_t cx, cy;
_oox_fill fill;
std::wstring name;
int sub_type;
std::wstring chartId;
std::vector<_hlink_desc> hlinks;
std::vector<odf::_property> additional;
size_t x, y;
size_t cx, cy;
friend void oox_serialize_xfrm( std::wostream & _Wostream, _oox_drawing const & val,std::wstring name_space = L"a");
friend void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val);
friend void oox_serialize_ln (std::wostream & _Wostream, const std::vector<odf::_property> & val);
friend void oox_serialize_hlink (std::wostream & _Wostream, const std::vector<_hlink_desc> & val);
friend void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property> & val);
_oox_fill fill;
};
int sub_type;
std::wstring chartId;
std::vector<_hlink_desc> hlinks;
std::vector<odf::_property> additional;
};
void oox_serialize_xfrm( std::wostream & _Wostream, _oox_drawing const & val,std::wstring name_space = L"a");
void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val);
void oox_serialize_ln (std::wostream & _Wostream, const std::vector<odf::_property> & val);
void oox_serialize_hlink (std::wostream & _Wostream, const std::vector<_hlink_desc> & val);
void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property> & val);
}
}
......@@ -96,9 +96,6 @@ namespace oox {
_CP_OPT(double) opacity;
int type;
friend void oox_serialize_fill(std::wostream & strm, const _oox_fill & val);
friend void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
friend void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::percent) opacity);
void clear()
{
......@@ -112,6 +109,9 @@ namespace oox {
}
};
void oox_serialize_fill(std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf::percent) opacity);
}
}
}
\ No newline at end of file
......@@ -388,7 +388,7 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
dump_run();//last
std::wstring & str_run = run_.str();
std::wstring str_run = run_.str();
if (str_run.length() > 0 || paragraph_style_name_.length() > 0)
{
......@@ -413,7 +413,10 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
return paragraph_.str();
}
#include <Objbase.h>
#if defined (_WIN32) || defined (_WIN64)
#include <Objbase.h>
#endif
void pptx_text_context::Impl::dump_field()
{
if (field_type_ == none) return;
......@@ -426,44 +429,57 @@ void pptx_text_context::Impl::dump_field()
std::wstring string_id;
std::wstring string_type;
GUID new_id;
#if defined (_WIN32) || defined (_WIN64)
GUID new_id;
CoCreateGuid(&new_id);
wchar_t str[100]={};
StringFromGUID2(new_id,str,100);
string_id = str;
#endif
switch (field_type_)
{
case page_number:
{
string_type = L"slidenum";
// string_id = L"{5CC2A059-B141-45A7-B910-B096D6D06820}";
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{5CC2A059-B141-45A7-B910-B096D6D06820}";
#endif
// content = L"#";
}
break;
case date:
{
string_type = L"datetime1";
// string_id = L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}";
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"01.01.2000");
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}";
#endif
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"01.01.2000");
}
break;
case time:
{
string_type = L"datetime11";
// string_id = L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}";
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"00:00:00");
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}";
#endif
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"00:00:00");
}
break;
case datetime:
{
string_type = L"datetime1";
// string_id = L"{A9EA0FE8-FEF9-4B2F-BC9D-19DDCDB4AB9B}";
}
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{A9EA0FE8-FEF9-4B2F-BC9D-19DDCDB4AB9B}";
#endif
}break;
}
if (string_type.length()>0)
{
CP_XML_ATTR(L"id", string_id);
CP_XML_ATTR(L"id", string_id);
CP_XML_ATTR(L"type", string_type);
CP_XML_NODE(L"a:t")
{
......@@ -538,7 +554,7 @@ std::wstring pptx_text_context::Impl::end_object()
{
dump_paragraph(/*true*/);
std::wstring & str_paragraph = paragraph_.str();
std::wstring str_paragraph = paragraph_.str();
std::wstringstream str_output;
......
......@@ -20,50 +20,50 @@ class style_table_cell_properties;
namespace cpdoccore {
namespace oox {
struct xlsx_border_edge
{
xlsx_border_edge()
{}
xlsx_border_edge(std::wstring _style, xlsx_color _color = xlsx_color()) : style(_style), color(_color)
{}
_CP_OPT(std::wstring) style; // attribute
_CP_OPT(xlsx_color) color; // element
_CP_OPT(int) width; //
bool operator == (const xlsx_border_edge & rVal) const;
bool operator != (const xlsx_border_edge & rVal) const;
friend std::size_t hash_value(xlsx_border_edge const & val);
};
struct xlsx_border
{
_CP_OPT(bool) diagonalUp;
_CP_OPT(bool) diagonalDown;
_CP_OPT(bool) outline; // default true
_CP_OPT(xlsx_border_edge) left;
_CP_OPT(xlsx_border_edge) right;
_CP_OPT(xlsx_border_edge) top;
_CP_OPT(xlsx_border_edge) bottom;
_CP_OPT(xlsx_border_edge) diagonal;
_CP_OPT(xlsx_border_edge) vertical;
_CP_OPT(xlsx_border_edge) horizontal;
std::size_t index;
bool operator == (const xlsx_border & rVal) const;
bool operator != (const xlsx_border & rVal) const;
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_border const & border);
friend bool is_default(xlsx_border_edge const & borderEdge);
friend bool is_default(_CP_OPT(xlsx_border_edge) const & borderEdge);
friend bool is_default(xlsx_border const & border);
friend std::size_t hash_value(xlsx_border const & val);
};
struct xlsx_border_edge
{
xlsx_border_edge()
{}
xlsx_border_edge(std::wstring _style, xlsx_color _color = xlsx_color()) : style(_style), color(_color)
{}
_CP_OPT(std::wstring) style; // attribute
_CP_OPT(xlsx_color) color; // element
_CP_OPT(int) width; //
bool operator == (const xlsx_border_edge & rVal) const;
bool operator != (const xlsx_border_edge & rVal) const;
friend std::size_t hash_value(xlsx_border_edge const & val);
};
struct xlsx_border
{
_CP_OPT(bool) diagonalUp;
_CP_OPT(bool) diagonalDown;
_CP_OPT(bool) outline; // default true
_CP_OPT(xlsx_border_edge) left;
_CP_OPT(xlsx_border_edge) right;
_CP_OPT(xlsx_border_edge) top;
_CP_OPT(xlsx_border_edge) bottom;
_CP_OPT(xlsx_border_edge) diagonal;
_CP_OPT(xlsx_border_edge) vertical;
_CP_OPT(xlsx_border_edge) horizontal;
std::size_t index;
bool operator == (const xlsx_border & rVal) const;
bool operator != (const xlsx_border & rVal) const;
friend bool is_default(xlsx_border_edge const & borderEdge);
friend bool is_default(_CP_OPT(xlsx_border_edge) const & borderEdge);
friend bool is_default(xlsx_border const & border);
friend std::size_t hash_value(xlsx_border const & val);
};
void xlsx_serialize(std::wostream & _Wostream, xlsx_border const & border);
}
}
......@@ -162,7 +162,7 @@ public:
}
};
void xlsx_serialize(std::wostream & _Wostream) const
void xlsx_serialize(std::wostream & _Wostream)
{
std::vector<xlsx_border> inst_array;
......@@ -178,9 +178,9 @@ public:
CP_XML_NODE(L"borders")
{
CP_XML_ATTR(L"count", inst_array.size());
BOOST_FOREACH(const xlsx_border & border, inst_array)
BOOST_FOREACH( xlsx_border & border, inst_array)
{
::cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), border);
cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), border);
}
}
}
......@@ -206,7 +206,7 @@ size_t xlsx_borders::borderId(const odf::style_table_cell_properties_attlist * c
return impl_->borderId(cellProp, is_default);
}
void xlsx_borders::xlsx_serialize(std::wostream & _Wostream) const
void xlsx_borders::xlsx_serialize(std::wostream & _Wostream)
{
return impl_->xlsx_serialize(_Wostream);
}
......@@ -219,10 +219,11 @@ xlsx_borders::~xlsx_borders()
{
}
void xlsx_serialize(std::wostream & _Wostream, const xlsx_borders & borders)
void xlsx_serialize(std::wostream & _Wostream, xlsx_borders & borders)
{
return borders.xlsx_serialize(_Wostream);
}
}
}
......
......@@ -14,24 +14,25 @@ class style_table_cell_properties_attlist;
namespace cpdoccore {
namespace oox {
class xlsx_borders
{
public:
xlsx_borders();
~xlsx_borders();
size_t size() const;
size_t borderId(const odf::style_table_cell_properties_attlist * cellProp);
size_t borderId(const odf::style_table_cell_properties_attlist * cellProp, bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const;
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_borders & borders);
};
class xlsx_borders
{
public:
xlsx_borders();
~xlsx_borders();
size_t size() const;
size_t borderId(const odf::style_table_cell_properties_attlist * cellProp);
size_t borderId(const odf::style_table_cell_properties_attlist * cellProp, bool & is_default);
void xlsx_serialize(std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, xlsx_borders & borders);
}
}
......
......@@ -10,14 +10,15 @@
namespace cpdoccore {
namespace oox {
struct xlsx_cell_style
{
_CP_OPT(std::wstring) name;
_CP_OPT(unsigned int) xfId;
_CP_OPT(unsigned int) builtinId;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_cell_style & cell_style);
};
struct xlsx_cell_style
{
_CP_OPT(std::wstring) name;
_CP_OPT(unsigned int) xfId;
_CP_OPT(unsigned int) builtinId;
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_cell_style & cell_style);
}
}
......
......@@ -66,9 +66,9 @@ void xlsx_defined_names::add(std::wstring const & name, std::wstring const & ref
return impl_->add(name, ref);
}
void xlsx_serialize(std::wostream & _Wostream, xlsx_defined_names const & val)
void xlsx_defined_names::xlsx_serialize(std::wostream & _Wostream)
{
return val.impl_->xlsx_serialize(_Wostream);
return impl_->xlsx_serialize(_Wostream);
}
}
......
......@@ -9,22 +9,23 @@
namespace cpdoccore {
namespace oox {
class xlsx_defined_names
{
public:
xlsx_defined_names();
~xlsx_defined_names();
public:
void add(std::wstring const & name, std::wstring const & ref);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_defined_names const & val);
};
class xlsx_defined_names
{
public:
xlsx_defined_names();
~xlsx_defined_names();
public:
void add(std::wstring const & name, std::wstring const & ref);
void xlsx_serialize(std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}
......
......@@ -7,40 +7,40 @@
namespace cpdoccore {
namespace oox {
struct xlsx_patternFill
{
_CP_OPT(xlsx_color) fgColor;
_CP_OPT(xlsx_color) bgColor;
_CP_OPT(std::wstring) patternType;
bool operator == (const xlsx_patternFill & rVal) const;
bool operator != (const xlsx_patternFill & rVal) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_patternFill & patternFill);
friend std::size_t hash_value(xlsx_patternFill const & val);
};
struct xlsx_gradientFill
{
bool operator == (const xlsx_gradientFill & rVal) const;
bool operator != (const xlsx_gradientFill & rVal) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_gradientFill & gradientFill);
friend std::size_t hash_value(xlsx_gradientFill const & val);
};
struct xlsx_fill
{
_CP_OPT(xlsx_patternFill) patternFill;
_CP_OPT(xlsx_gradientFill) gradientFill;
std::size_t index;
bool bDefault;
bool operator == (const xlsx_fill & rVal) const;
bool operator != (const xlsx_fill & rVal) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_fill & fill);
friend std::size_t hash_value(xlsx_fill const & val);
};
struct xlsx_patternFill
{
_CP_OPT(xlsx_color) fgColor;
_CP_OPT(xlsx_color) bgColor;
_CP_OPT(std::wstring) patternType;
bool operator == (const xlsx_patternFill & rVal) const;
bool operator != (const xlsx_patternFill & rVal) const;
friend std::size_t hash_value(xlsx_patternFill const & val);
};
struct xlsx_gradientFill
{
bool operator == (const xlsx_gradientFill & rVal) const;
bool operator != (const xlsx_gradientFill & rVal) const;
friend std::size_t hash_value(xlsx_gradientFill const & val);
};
struct xlsx_fill
{
_CP_OPT(xlsx_patternFill) patternFill;
_CP_OPT(xlsx_gradientFill) gradientFill;
std::size_t index;
bool bDefault;
bool operator == (const xlsx_fill & rVal) const;
bool operator != (const xlsx_fill & rVal) const;
friend std::size_t hash_value(xlsx_fill const & val);
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_gradientFill & gradientFill);
void xlsx_serialize(std::wostream & _Wostream, const xlsx_patternFill & patternFill);
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fill & fill);
}
}
......@@ -157,7 +157,7 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const
CP_XML_ATTR(L"count", inst_array.size());
BOOST_FOREACH(const xlsx_fill & f, inst_array)
{
::cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), f);
cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), f);
}
}
}
......
......@@ -9,9 +9,9 @@
namespace cpdoccore {
namespace odf {
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
}
......@@ -19,29 +19,29 @@ class style_table_cell_properties_attlist;
namespace cpdoccore {
namespace oox {
class xlsx_fills
{
public:
xlsx_fills();
~xlsx_fills();
public:
size_t size() const;
size_t fillId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp,
const odf::style_table_cell_properties_attlist * cellProp, bool default_set);
size_t fillId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp,
const odf::style_table_cell_properties_attlist * cellProp, bool default_set,bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
class xlsx_fills
{
public:
xlsx_fills();
~xlsx_fills();
public:
size_t size() const;
size_t fillId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp,
const odf::style_table_cell_properties_attlist * cellProp, bool default_set);
size_t fillId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp,
const odf::style_table_cell_properties_attlist * cellProp, bool default_set,bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const;
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills);
}
}
......@@ -12,86 +12,84 @@
namespace cpdoccore {
namespace oox {
enum xlsx_vertAlign
{
vertAlignBaseline,
vertAlignSubscript,
vertAlignSuperscript
};
enum xlsx_vertAlign
{
vertAlignBaseline,
vertAlignSubscript,
vertAlignSuperscript
};
enum XlsxFontFamily
{
XFAMILY_EMPTY = -1,
XFAMILY_NOTAPPLICABLE = 0,
XFAMILY_ROMAN = 1,
XFAMILY_SWISS = 2,
XFAMILY_MODERN = 3,
XFAMILY_SCRIPT = 4,
XFAMILY_DECORATIVE = 5
};
enum XlsxFontFamily
{
XFAMILY_EMPTY = -1,
XFAMILY_NOTAPPLICABLE = 0,
XFAMILY_ROMAN = 1,
XFAMILY_SWISS = 2,
XFAMILY_MODERN = 3,
XFAMILY_SCRIPT = 4,
XFAMILY_DECORATIVE = 5
};
enum XlsxUnderline
{
XUNDERLINE_NONE,
XUNDERLINE_SINGLE,
XUNDERLINE_DOUBLE,
XUNDERLINE_SINGLE_ACCOUNTING,
XUNDERLINE_DOUBLE_ACCOUNTING
};
enum XlsxUnderline
{
XUNDERLINE_NONE,
XUNDERLINE_SINGLE,
XUNDERLINE_DOUBLE,
XUNDERLINE_SINGLE_ACCOUNTING,
XUNDERLINE_DOUBLE_ACCOUNTING
};
/// \struct xlsx_font
struct xlsx_font
{
_CP_OPT(bool) bold;
_CP_OPT(unsigned int) charset;
_CP_OPT(xlsx_color) color;
_CP_OPT(bool) condense;
_CP_OPT(bool) extend;
_CP_OPT(XlsxFontFamily) family;
_CP_OPT(bool) i; ///< italic
_CP_OPT(std::wstring) name;
_CP_OPT(bool) outline;
_CP_OPT(std::wstring) scheme;
_CP_OPT(bool) shadow;
_CP_OPT(bool) strike;
_CP_OPT(double) sz;
_CP_OPT(XlsxUnderline) u;
_CP_OPT(xlsx_vertAlign) vertAlign;
enum XlsxFontCharset
{
XCHARSET_EMPTY = -1,
XCHARSET_CHARSET_ANSI = 0,
XCHARSET_DEFAULT = 1,
XCHARSET_SYMBOL = 2,
XCHARSET_MAC = 77,
XCHARSET_SHIFTJIS = 128,
XCHARSET_HANGEUL = 129,
XCHARSET_JOHAB = 130,
XCHARSET_GB2312 = 134,
XCHARSET_CHINESEBIG5 = 136,
XCHARSET_GREEK = 161,
XCHARSET_TURKISH = 162,
XCHARSET_VIETNAMESE = 163,
XCHARSET_HEBREW = 177,
XCHARSET_ARABIC = 178,
XCHARSET_BALTIC = 186,
XCHARSET_RUSSIAN = 204,
XCHARSET_THAI = 222,
XCHARSET_EASTEUROPE = 238,
XCHARSET_OEM = 255
};
mutable std::size_t index;
struct xlsx_font
{
_CP_OPT(bool) bold;
_CP_OPT(unsigned int) charset;
_CP_OPT(xlsx_color) color;
_CP_OPT(bool) condense;
_CP_OPT(bool) extend;
_CP_OPT(XlsxFontFamily) family;
_CP_OPT(bool) i; ///< italic
_CP_OPT(std::wstring) name;
_CP_OPT(bool) outline;
_CP_OPT(std::wstring) scheme;
_CP_OPT(bool) shadow;
_CP_OPT(bool) strike;
_CP_OPT(double) sz;
_CP_OPT(XlsxUnderline) u;
_CP_OPT(xlsx_vertAlign) vertAlign;
bool operator == (const xlsx_font & rVal) const;
bool operator != (const xlsx_font & rVal) const;
mutable std::size_t index;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font);
friend std::size_t hash_value(xlsx_font const & val);
};
enum XlsxFontCharset
{
XCHARSET_EMPTY = -1,
XCHARSET_CHARSET_ANSI = 0,
XCHARSET_DEFAULT = 1,
XCHARSET_SYMBOL = 2,
XCHARSET_MAC = 77,
XCHARSET_SHIFTJIS = 128,
XCHARSET_HANGEUL = 129,
XCHARSET_JOHAB = 130,
XCHARSET_GB2312 = 134,
XCHARSET_CHINESEBIG5 = 136,
XCHARSET_GREEK = 161,
XCHARSET_TURKISH = 162,
XCHARSET_VIETNAMESE = 163,
XCHARSET_HEBREW = 177,
XCHARSET_ARABIC = 178,
XCHARSET_BALTIC = 186,
XCHARSET_RUSSIAN = 204,
XCHARSET_THAI = 222,
XCHARSET_EASTEUROPE = 238,
XCHARSET_OEM = 255
};
bool operator == (const xlsx_font & rVal) const;
bool operator != (const xlsx_font & rVal) const;
friend std::size_t hash_value(xlsx_font const & val);
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font);
}
}
......
......@@ -6,9 +6,9 @@
namespace cpdoccore {
namespace odf {
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
}
......@@ -16,31 +16,29 @@ class style_table_cell_properties_attlist;
namespace cpdoccore {
namespace oox {
struct xlsx_font;
struct xlsx_font;
/// \class xlsx_fonts
class xlsx_fonts
{
public:
xlsx_fonts();
~xlsx_fonts();
class xlsx_fonts
{
public:
xlsx_fonts();
~xlsx_fonts();
public:
size_t size() const;
size_t fontId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp,
const odf::style_table_cell_properties_attlist * cellProp);
const xlsx_font & getFont(size_t id) const;
public:
size_t size() const;
size_t fontId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp,
const odf::style_table_cell_properties_attlist * cellProp);
const xlsx_font & getFont(size_t id) const;
void xlsx_serialize(std::wostream & _Wostream) const;
void xlsx_serialize(std::wostream & _Wostream) const;
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_fonts const & fonts);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, xlsx_fonts const & fonts);
}
......
......@@ -9,20 +9,21 @@
namespace cpdoccore {
namespace oox {
class xlsx_num_fmts
{
public:
xlsx_num_fmts();
~xlsx_num_fmts();
public:
size_t num_format_id(const std::wstring & format_code);
void xlsx_serialize(std::wostream & _Wostream) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_num_fmts & numFmts);
private:
struct Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
class xlsx_num_fmts
{
public:
xlsx_num_fmts();
~xlsx_num_fmts();
public:
size_t num_format_id(const std::wstring & format_code);
void xlsx_serialize(std::wostream & _Wostream) const;
private:
struct Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_num_fmts & numFmts);
}
}
......
......@@ -195,10 +195,10 @@ void xlsx_style_manager::Impl::xlsx_serialize(std::wostream & _Wostream)
{
_Wostream << L"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">";
::cpdoccore::oox::xlsx_serialize(_Wostream, numFmts_);
::cpdoccore::oox::xlsx_serialize(_Wostream, fonts_);
::cpdoccore::oox::xlsx_serialize(_Wostream, fills_);
::cpdoccore::oox::xlsx_serialize(_Wostream, borders_);
cpdoccore::oox::xlsx_serialize(_Wostream, numFmts_);
cpdoccore::oox::xlsx_serialize(_Wostream, fonts_);
cpdoccore::oox::xlsx_serialize(_Wostream, fills_);
cpdoccore::oox::xlsx_serialize(_Wostream, borders_);
xlsx_serialize_xf(_Wostream, cellStyleXfs_, L"cellStyleXfs");
......@@ -211,13 +211,13 @@ void xlsx_style_manager::Impl::xlsx_serialize(std::wostream & _Wostream)
namespace
{
struct compare_xlsx_xf
{
bool operator() (xlsx_xf const & x1, xlsx_xf const & x2)
struct compare_xlsx_xf
{
return x1.index < x2.index;
}
};
bool operator() (xlsx_xf const & x1, xlsx_xf const & x2)
{
return x1.index < x2.index;
}
};
}
void xlsx_style_manager::Impl::xlsx_serialize_xf(std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName)
......@@ -234,7 +234,7 @@ void xlsx_style_manager::Impl::xlsx_serialize_xf(std::wostream & _Wostream, cons
_Wostream << L"<" << nodeName << L" count=\"" << xfs_.size() << L"\">";
BOOST_FOREACH(const xlsx_xf & xfRecord, xfs_)
{
::cpdoccore::oox::xlsx_serialize(_Wostream, xfRecord);
cpdoccore::oox::xlsx_serialize(_Wostream, xfRecord);
}
_Wostream << L"</" << nodeName << L">";
}
......
......@@ -12,37 +12,36 @@
namespace cpdoccore {
namespace oox {
struct xlsx_xf;
typedef _CP_PTR(xlsx_xf) xlsx_xf_ptr;
/// \struct xlsx_x
/// xf (18.8.45)
struct xlsx_xf
{
_CP_OPT(bool) applyAlignment;
_CP_OPT(bool) applyBorder;
_CP_OPT(bool) applyFill;
_CP_OPT(bool) applyFont;
_CP_OPT(bool) applyNumberForm;
_CP_OPT(bool) applyProtection;
_CP_OPT(unsigned int) borderId;
_CP_OPT(unsigned int) fillId;
_CP_OPT(unsigned int) fontId;
_CP_OPT(unsigned int) numFmtId;
_CP_OPT(bool) pivotButton;
_CP_OPT(bool) quotePrefix;
_CP_OPT(unsigned int) xfId;
_CP_OPT(xlsx_alignment) alignment;
_CP_OPT(xlsx_protection) protection;
mutable std::size_t index;
bool operator == (const xlsx_xf & rVal) const;
bool operator != (const xlsx_xf & rVal) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_xf & xf);
friend std::size_t hash_value(xlsx_xf const & val);
};
struct xlsx_xf;
typedef _CP_PTR(xlsx_xf) xlsx_xf_ptr;
struct xlsx_xf
{
_CP_OPT(bool) applyAlignment;
_CP_OPT(bool) applyBorder;
_CP_OPT(bool) applyFill;
_CP_OPT(bool) applyFont;
_CP_OPT(bool) applyNumberForm;
_CP_OPT(bool) applyProtection;
_CP_OPT(unsigned int) borderId;
_CP_OPT(unsigned int) fillId;
_CP_OPT(unsigned int) fontId;
_CP_OPT(unsigned int) numFmtId;
_CP_OPT(bool) pivotButton;
_CP_OPT(bool) quotePrefix;
_CP_OPT(unsigned int) xfId;
_CP_OPT(xlsx_alignment) alignment;
_CP_OPT(xlsx_protection) protection;
mutable std::size_t index;
bool operator == (const xlsx_xf & rVal) const;
bool operator != (const xlsx_xf & rVal) const;
friend std::size_t hash_value(xlsx_xf const & val);
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_xf & xf);
}
}
......@@ -12,6 +12,8 @@
#include "xlsx_cell_format.h"
#include "../odf/calcs_styles.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace cpdoccore {
......@@ -39,7 +41,21 @@ xlsx_conversion_context(::cpdoccore::oox::package::xlsx_document * outputDocumen
mediaitems_(odf_document_->get_folder()),
xlsx_drawing_context_handle_(mediaitems_)
{
fontsApplication_ = new CApplicationFonts();
}
xlsx_conversion_context::~xlsx_conversion_context()
{
if (fontsApplication_)
delete fontsApplication_;
}
void xlsx_conversion_context::set_font_directory(std::wstring pathFonts)
{
if (fontsApplication_ == NULL) return;
fontsApplication_->InitializeFromFolder(pathFonts);
}
void xlsx_conversion_context::start_chart(std::wstring const & name)
{
charts_.push_back(oox_chart_context::create(name));
......@@ -177,7 +193,7 @@ void xlsx_conversion_context::end_document()
CP_XML_STREAM() << workbook_content.str();
}
::cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), this->get_xlsx_defined_names());
get_xlsx_defined_names().xlsx_serialize(CP_XML_STREAM());
}
}
......@@ -466,7 +482,7 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
else
font_size =10;
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, /*getDefaultDpi()*/96.);
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, /*getDefaultDpi()*/96., 0, fontsApplication_->GenerateFontManager());
}
return maxDigitSize_;
}
......
......@@ -21,6 +21,7 @@
#include "mediaitems.h"
class CApplicationFonts;
namespace cpdoccore {
......@@ -40,8 +41,10 @@ namespace package
class xlsx_conversion_context : boost::noncopyable
{
public:
xlsx_conversion_context(::cpdoccore::oox::package::xlsx_document * outputDocument,
::cpdoccore::odf::odf_document * odfDocument);
xlsx_conversion_context(cpdoccore::oox::package::xlsx_document * outputDocument, cpdoccore::odf::odf_document * odfDocument);
~xlsx_conversion_context();
void set_font_directory(std::wstring pathFonts);
void start_document();
void end_document();
......@@ -88,14 +91,12 @@ public:
void start_table_covered_cell();
void end_table_covered_cell();
xlsx_text_context & get_text_context() { return xlsx_text_context_; }
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
int current_table_column() const;
int current_table_row() const;
void start_hyperlink(const std::wstring & styleName);
void end_hyperlink(std::wstring const & href);
std::wstring current_cell_address() const;
odf::odf_document * root()
......@@ -107,60 +108,49 @@ public:
void process_styles();
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_xml_worksheet & current_sheet();
xlsx_text_context & get_text_context() { return xlsx_text_context_; }
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_xml_worksheet & current_sheet();
oox_chart_context & current_chart();
num_format_context & get_num_format_context() { return num_format_context_; }
size_t get_default_cell_style() const { return default_style_; };
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
xlsx_table_metrics & get_table_metrics();
xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle();
xlsx_comments_context & get_comments_context();
oox_chart_context & current_chart();
num_format_context & get_num_format_context() { return num_format_context_; }
size_t get_default_cell_style() const { return default_style_; }
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
xlsx_table_metrics & get_table_metrics();
xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle();
xlsx_comments_context & get_comments_context();
xlsx_comments_context_handle & get_comments_context_handle();
mediaitems & get_mediaitems() { return mediaitems_; }
void start_hyperlink(const std::wstring & styleName);
void end_hyperlink(std::wstring const & href);
private:
void create_new_sheet(std::wstring const & name);
void dump_sheet();
private:
package::xlsx_document *output_document_;
const odf::office_element *spreadsheet_;
odf::odf_document *odf_document_;
package::xlsx_document * output_document_;
const odf::office_element * spreadsheet_;
odf::odf_document * odf_document_;
xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_;
std::wstringstream defaultOutput_;
std::vector<xlsx_xml_worksheet_ptr> sheets_;
CApplicationFonts *fontsApplication_;
std::vector<oox_chart_context_ptr> charts_;
std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_;
//xlsx_xml_workbook_ptr workbook_;
std::pair<float,float> maxDigitSize_;
xlsx_style_manager xlsx_style_;
num_format_context num_format_context_;
size_t default_style_;
xlsx_defined_names xlsx_defined_names_;
mediaitems mediaitems_;
std::wstringstream defaultOutput_;
std::pair<float,float> maxDigitSize_;
num_format_context num_format_context_;
size_t default_style_;
mediaitems mediaitems_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_;
xlsx_style_manager xlsx_style_;
xlsx_defined_names xlsx_defined_names_;
xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_;
};
......
......@@ -284,7 +284,8 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
{
CP_XML_NODE(L"a:buClr")
{
oox::oox_serialize_srgb(CP_XML_STREAM(),fo_color_->get_hex_value(),NULL);
_CP_OPT(double) opacity;
oox::oox_serialize_srgb(CP_XML_STREAM(),fo_color_->get_hex_value(), opacity);
}
}
if (fo_font_size_)
......
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