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 \ ...@@ -22,6 +22,7 @@ DEFINES += UNICODE \
INCLUDEPATH += /usr/include/libxml2 INCLUDEPATH += /usr/include/libxml2
INCLUDEPATH += ../include INCLUDEPATH += ../include
INCLUDEPATH += ../../../ServerComponents/DesktopEditor/freetype-2.5.2/include
SOURCES += \ SOURCES += \
../formulasconvert/formulasconvert_odf.cpp \ ../formulasconvert/formulasconvert_odf.cpp \
......
#include <windows.h>
#include "../../DesktopEditor/common/Types.h"
#include <string> #include <string>
struct ProgressCallback; struct ProgressCallback;
......
#include "measuredigits.h"
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#include <atlbase.h>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <logging.h> #include <logging.h>
#import "../../../Redist/ASCGraphics.dll" rename_namespace("ASCGraphics")
#include <float.h>
#include "../../DesktopEditor/fontengine/FontManager.h"
namespace cpdoccore { namespace cpdoccore {
namespace utils { namespace utils {
...@@ -18,29 +17,17 @@ namespace ...@@ -18,29 +17,17 @@ namespace
class MeasureError : public Error {}; 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; if (pFontManager == NULL) return std::pair<float, float>(7.f,8.f);
HRESULT hr;
try HRESULT hr = S_OK;
{
if (FAILED(hr = fontMan.CoCreateInstance(__uuidof(ASCGraphics::CASCFontManager))))
throw;
if (S_OK != (hr = fontMan->Initialize(L""))) if (S_OK != (hr = pFontManager->LoadFontByName(fontName, fontSize, fontStyle, dpi, dpi )))
throw;
}
catch(...)
{ {
return std::pair<float,float>(7,8); if (S_OK != (hr = pFontManager->LoadFontByName(L"Arial", fontSize, fontStyle, dpi, dpi )))
}
if (S_OK != (hr = fontMan->LoadFontByName(fontName, fontSize, fontStyle, dpi, dpi )))
{ {
if (S_OK != (hr = fontMan->LoadFontByName(L"Arial", fontSize, fontStyle, dpi, dpi ))) return std::pair<float, float>(7,8);
{
return std::pair<float,float>(7,8);
} }
} }
...@@ -48,42 +35,39 @@ std::pair<float,float> GetMaxDigitSizePixelsImpl(const wchar_t * fontName, float ...@@ -48,42 +35,39 @@ std::pair<float,float> GetMaxDigitSizePixelsImpl(const wchar_t * fontName, float
float maxHeight = 0; float maxHeight = 0;
for (int i = 0; i <= 9; ++i) for (int i = 0; i <= 9; ++i)
{ {
if (S_OK != (hr = fontMan->LoadString2( boost::lexical_cast<std::wstring>(i).c_str(), 0, 0))) if (S_OK != (hr = pFontManager->LoadString2( boost::lexical_cast<std::wstring>(i).c_str(), 0, 0)))
return std::pair<float,float>(7,8); return std::pair<float, float>(7,8);
float x, y, width, height; TBBox box;
try try
{ {
hr = fontMan->MeasureString(&x, &y, &width, &height); box = pFontManager->MeasureString();
}catch(...) }catch(...)
{ {
return std::pair<float,float>(7,8); return std::pair<float, float>(7,8);
} }
if (box.fMaxX - box.fMinX > maxWidth) maxWidth = box.fMaxX - box.fMinX;
if (width> maxWidth) if (box.fMaxY - box.fMinY > maxHeight) maxHeight = box.fMaxY - box.fMinY;
maxWidth = width;
if (height>maxHeight)
maxHeight = height;
} }
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 try
{ {
_CP_LOG(info) << "[info] : GetMaxDigitSizePixels..."; _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; _CP_LOG(info) << "ok" << std::endl;
return val; return val;
} }
catch(...) catch(...)
{ {
// TODO: default value! // TODO: default value!
return std::pair<float,float>(7,8); return std::pair<float, float>(7,8);
} }
} }
......
#ifndef _CPDOCCORE_MEASURE_DIGITS_H_ #pragma once
#define _CPDOCCORE_MEASURE_DIGITS_H_
#include <utility>
#include <string>
class CFontManager;
namespace cpdoccore { namespace cpdoccore {
namespace utils { 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) ...@@ -216,7 +216,8 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
if (content_.regression_curve_.line_properties_.size()>0) if (content_.regression_curve_.line_properties_.size()>0)
{ {
std::wstring typeTrendline= L"log"; //"exp" | "linear" | "log" | "movingAvg" | "poly" | "power" 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; _CP_OPT(int) iType;
odf::GetProperty(content_.properties_, L"regression-type",iType); // none, linear, logarithmic, exponential, power 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) ...@@ -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()); shape.oox_serialize(CP_XML_STREAM());
......
...@@ -28,14 +28,14 @@ static const std::wstring _ooxShapeType[]= ...@@ -28,14 +28,14 @@ static const std::wstring _ooxShapeType[]=
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct _hlink_desc struct _hlink_desc
{ {
std::wstring hId; std::wstring hId;
std::wstring hRef; std::wstring hRef;
bool object; bool object;
}; };
struct _oox_drawing struct _oox_drawing
{ {
_oox_drawing():type(mediaitems::typeUnknown),id(0),x(0),y(0),cx(0),cy(0),sub_type(0),name(L"object") _oox_drawing():type(mediaitems::typeUnknown),id(0),x(0),y(0),cx(0),cy(0),sub_type(0),name(L"object")
{ {
} }
...@@ -57,12 +57,11 @@ struct _oox_drawing ...@@ -57,12 +57,11 @@ struct _oox_drawing
std::vector<odf::_property> additional; std::vector<odf::_property> additional;
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); void oox_serialize_xfrm( std::wostream & _Wostream, _oox_drawing const & val,std::wstring name_space = L"a");
friend void oox_serialize_ln (std::wostream & _Wostream, const std::vector<odf::_property> & val); void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val);
friend void oox_serialize_hlink (std::wostream & _Wostream, const std::vector<_hlink_desc> & val); void oox_serialize_ln (std::wostream & _Wostream, const std::vector<odf::_property> & val);
friend void oox_serialize_bodyPr(std::wostream & strm, 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 { ...@@ -96,9 +96,6 @@ namespace oox {
_CP_OPT(double) opacity; _CP_OPT(double) opacity;
int type; 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() void clear()
{ {
...@@ -112,6 +109,9 @@ namespace oox { ...@@ -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);
} }
} }
...@@ -388,7 +388,7 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/) ...@@ -388,7 +388,7 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
dump_run();//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) if (str_run.length() > 0 || paragraph_style_name_.length() > 0)
{ {
...@@ -413,7 +413,10 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/) ...@@ -413,7 +413,10 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
return paragraph_.str(); return paragraph_.str();
} }
#include <Objbase.h> #if defined (_WIN32) || defined (_WIN64)
#include <Objbase.h>
#endif
void pptx_text_context::Impl::dump_field() void pptx_text_context::Impl::dump_field()
{ {
if (field_type_ == none) return; if (field_type_ == none) return;
...@@ -426,40 +429,53 @@ void pptx_text_context::Impl::dump_field() ...@@ -426,40 +429,53 @@ void pptx_text_context::Impl::dump_field()
std::wstring string_id; std::wstring string_id;
std::wstring string_type; std::wstring string_type;
#if defined (_WIN32) || defined (_WIN64)
GUID new_id; GUID new_id;
CoCreateGuid(&new_id); CoCreateGuid(&new_id);
wchar_t str[100]={}; wchar_t str[100]={};
StringFromGUID2(new_id,str,100); StringFromGUID2(new_id,str,100);
string_id = str; string_id = str;
#endif
switch (field_type_) switch (field_type_)
{ {
case page_number: case page_number:
{ {
string_type = L"slidenum"; 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"#"; // content = L"#";
} }
break; break;
case date: case date:
{ {
string_type = L"datetime1"; string_type = L"datetime1";
// string_id = L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}";
#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"); if (content.length()<1)content = xml::utils::replace_text_to_xml(L"01.01.2000");
} }
break; break;
case time: case time:
{ {
string_type = L"datetime11"; string_type = L"datetime11";
// string_id = L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}";
#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"); if (content.length()<1)content = xml::utils::replace_text_to_xml(L"00:00:00");
} }
break; break;
case datetime: case datetime:
{ {
string_type = L"datetime1"; 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) if (string_type.length()>0)
{ {
...@@ -538,7 +554,7 @@ std::wstring pptx_text_context::Impl::end_object() ...@@ -538,7 +554,7 @@ std::wstring pptx_text_context::Impl::end_object()
{ {
dump_paragraph(/*true*/); dump_paragraph(/*true*/);
std::wstring & str_paragraph = paragraph_.str(); std::wstring str_paragraph = paragraph_.str();
std::wstringstream str_output; std::wstringstream str_output;
......
...@@ -20,8 +20,8 @@ class style_table_cell_properties; ...@@ -20,8 +20,8 @@ class style_table_cell_properties;
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct xlsx_border_edge struct xlsx_border_edge
{ {
xlsx_border_edge() xlsx_border_edge()
{} {}
...@@ -35,10 +35,10 @@ struct xlsx_border_edge ...@@ -35,10 +35,10 @@ struct xlsx_border_edge
bool operator == (const xlsx_border_edge & rVal) const; bool operator == (const xlsx_border_edge & rVal) const;
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); friend std::size_t hash_value(xlsx_border_edge const & val);
}; };
struct xlsx_border struct xlsx_border
{ {
_CP_OPT(bool) diagonalUp; _CP_OPT(bool) diagonalUp;
_CP_OPT(bool) diagonalDown; _CP_OPT(bool) diagonalDown;
_CP_OPT(bool) outline; // default true _CP_OPT(bool) outline; // default true
...@@ -56,14 +56,14 @@ struct xlsx_border ...@@ -56,14 +56,14 @@ struct xlsx_border
bool operator == (const xlsx_border & rVal) const; bool operator == (const xlsx_border & rVal) const;
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(xlsx_border_edge const & borderEdge);
friend bool is_default(_CP_OPT(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 bool is_default(xlsx_border const & border);
friend std::size_t hash_value(xlsx_border const & val); 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: ...@@ -162,7 +162,7 @@ public:
} }
}; };
void xlsx_serialize(std::wostream & _Wostream) const void xlsx_serialize(std::wostream & _Wostream)
{ {
std::vector<xlsx_border> inst_array; std::vector<xlsx_border> inst_array;
...@@ -178,9 +178,9 @@ public: ...@@ -178,9 +178,9 @@ public:
CP_XML_NODE(L"borders") CP_XML_NODE(L"borders")
{ {
CP_XML_ATTR(L"count", inst_array.size()); 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 ...@@ -206,7 +206,7 @@ size_t xlsx_borders::borderId(const odf::style_table_cell_properties_attlist * c
return impl_->borderId(cellProp, is_default); 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); return impl_->xlsx_serialize(_Wostream);
} }
...@@ -219,10 +219,11 @@ xlsx_borders::~xlsx_borders() ...@@ -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); return borders.xlsx_serialize(_Wostream);
} }
} }
} }
......
...@@ -14,9 +14,9 @@ class style_table_cell_properties_attlist; ...@@ -14,9 +14,9 @@ class style_table_cell_properties_attlist;
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class xlsx_borders class xlsx_borders
{ {
public: public:
xlsx_borders(); xlsx_borders();
~xlsx_borders(); ~xlsx_borders();
...@@ -24,14 +24,15 @@ public: ...@@ -24,14 +24,15 @@ public:
size_t borderId(const odf::style_table_cell_properties_attlist * cellProp); 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); size_t borderId(const odf::style_table_cell_properties_attlist * cellProp, bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const; void xlsx_serialize(std::wostream & _Wostream);
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_borders & borders); };
};
void xlsx_serialize(std::wostream & _Wostream, xlsx_borders & borders);
} }
} }
......
...@@ -10,14 +10,15 @@ ...@@ -10,14 +10,15 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct xlsx_cell_style struct xlsx_cell_style
{ {
_CP_OPT(std::wstring) name; _CP_OPT(std::wstring) name;
_CP_OPT(unsigned int) xfId; _CP_OPT(unsigned int) xfId;
_CP_OPT(unsigned int) builtinId; _CP_OPT(unsigned int) builtinId;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_cell_style & cell_style); };
};
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 ...@@ -66,9 +66,9 @@ void xlsx_defined_names::add(std::wstring const & name, std::wstring const & ref
return impl_->add(name, 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 @@ ...@@ -9,22 +9,23 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class xlsx_defined_names class xlsx_defined_names
{ {
public: public:
xlsx_defined_names(); xlsx_defined_names();
~xlsx_defined_names(); ~xlsx_defined_names();
public: public:
void add(std::wstring const & name, std::wstring const & ref); void add(std::wstring const & name, std::wstring const & ref);
void xlsx_serialize(std::wostream & _Wostream);
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_defined_names const & val);
}; };
} }
} }
......
...@@ -7,29 +7,26 @@ ...@@ -7,29 +7,26 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct xlsx_patternFill struct xlsx_patternFill
{ {
_CP_OPT(xlsx_color) fgColor; _CP_OPT(xlsx_color) fgColor;
_CP_OPT(xlsx_color) bgColor; _CP_OPT(xlsx_color) bgColor;
_CP_OPT(std::wstring) patternType; _CP_OPT(std::wstring) patternType;
bool operator == (const xlsx_patternFill & rVal) const; bool operator == (const xlsx_patternFill & rVal) const;
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); friend std::size_t hash_value(xlsx_patternFill const & val);
}; };
struct xlsx_gradientFill
struct xlsx_gradientFill {
{
bool operator == (const xlsx_gradientFill & rVal) const; bool operator == (const xlsx_gradientFill & rVal) const;
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); friend std::size_t hash_value(xlsx_gradientFill const & val);
}; };
struct xlsx_fill struct xlsx_fill
{ {
_CP_OPT(xlsx_patternFill) patternFill; _CP_OPT(xlsx_patternFill) patternFill;
_CP_OPT(xlsx_gradientFill) gradientFill; _CP_OPT(xlsx_gradientFill) gradientFill;
...@@ -38,9 +35,12 @@ struct xlsx_fill ...@@ -38,9 +35,12 @@ struct xlsx_fill
bool operator == (const xlsx_fill & rVal) const; bool operator == (const xlsx_fill & rVal) const;
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); 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 ...@@ -157,7 +157,7 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const
CP_XML_ATTR(L"count", inst_array.size()); CP_XML_ATTR(L"count", inst_array.size());
BOOST_FOREACH(const xlsx_fill & f, inst_array) 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 @@ ...@@ -9,9 +9,9 @@
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
class text_format_properties_content; class text_format_properties_content;
class paragraph_format_properties; class paragraph_format_properties;
class style_table_cell_properties_attlist; class style_table_cell_properties_attlist;
} }
} }
...@@ -19,12 +19,12 @@ class style_table_cell_properties_attlist; ...@@ -19,12 +19,12 @@ class style_table_cell_properties_attlist;
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class xlsx_fills class xlsx_fills
{ {
public: public:
xlsx_fills(); xlsx_fills();
~xlsx_fills(); ~xlsx_fills();
public: public:
size_t size() const; size_t size() const;
size_t fillId(const odf::text_format_properties_content * textProp, size_t fillId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp, const odf::paragraph_format_properties * parProp,
...@@ -35,13 +35,13 @@ public: ...@@ -35,13 +35,13 @@ public:
const odf::style_table_cell_properties_attlist * cellProp, bool default_set,bool & is_default); const odf::style_table_cell_properties_attlist * cellProp, bool default_set,bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const; void xlsx_serialize(std::wostream & _Wostream) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills);
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
}; };
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills);
} }
} }
...@@ -12,15 +12,15 @@ ...@@ -12,15 +12,15 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
enum xlsx_vertAlign enum xlsx_vertAlign
{ {
vertAlignBaseline, vertAlignBaseline,
vertAlignSubscript, vertAlignSubscript,
vertAlignSuperscript vertAlignSuperscript
}; };
enum XlsxFontFamily enum XlsxFontFamily
{ {
XFAMILY_EMPTY = -1, XFAMILY_EMPTY = -1,
XFAMILY_NOTAPPLICABLE = 0, XFAMILY_NOTAPPLICABLE = 0,
XFAMILY_ROMAN = 1, XFAMILY_ROMAN = 1,
...@@ -28,20 +28,43 @@ enum XlsxFontFamily ...@@ -28,20 +28,43 @@ enum XlsxFontFamily
XFAMILY_MODERN = 3, XFAMILY_MODERN = 3,
XFAMILY_SCRIPT = 4, XFAMILY_SCRIPT = 4,
XFAMILY_DECORATIVE = 5 XFAMILY_DECORATIVE = 5
}; };
enum XlsxUnderline enum XlsxUnderline
{ {
XUNDERLINE_NONE, XUNDERLINE_NONE,
XUNDERLINE_SINGLE, XUNDERLINE_SINGLE,
XUNDERLINE_DOUBLE, XUNDERLINE_DOUBLE,
XUNDERLINE_SINGLE_ACCOUNTING, XUNDERLINE_SINGLE_ACCOUNTING,
XUNDERLINE_DOUBLE_ACCOUNTING XUNDERLINE_DOUBLE_ACCOUNTING
}; };
/// \struct xlsx_font enum XlsxFontCharset
struct xlsx_font {
{ 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
};
struct xlsx_font
{
_CP_OPT(bool) bold; _CP_OPT(bool) bold;
_CP_OPT(unsigned int) charset; _CP_OPT(unsigned int) charset;
_CP_OPT(xlsx_color) color; _CP_OPT(xlsx_color) color;
...@@ -63,35 +86,10 @@ struct xlsx_font ...@@ -63,35 +86,10 @@ struct xlsx_font
bool operator == (const xlsx_font & rVal) const; bool operator == (const xlsx_font & rVal) const;
bool operator != (const xlsx_font & rVal) const; bool operator != (const xlsx_font & rVal) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font);
friend std::size_t hash_value(xlsx_font const & val); 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
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font);
} }
} }
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
class text_format_properties_content; class text_format_properties_content;
class paragraph_format_properties; class paragraph_format_properties;
class style_table_cell_properties_attlist; class style_table_cell_properties_attlist;
} }
} }
...@@ -16,16 +16,15 @@ class style_table_cell_properties_attlist; ...@@ -16,16 +16,15 @@ class style_table_cell_properties_attlist;
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct xlsx_font; struct xlsx_font;
/// \class xlsx_fonts class xlsx_fonts
class xlsx_fonts {
{ public:
public:
xlsx_fonts(); xlsx_fonts();
~xlsx_fonts(); ~xlsx_fonts();
public: public:
size_t size() const; size_t size() const;
size_t fontId(const odf::text_format_properties_content * textProp, size_t fontId(const odf::text_format_properties_content * textProp,
const odf::paragraph_format_properties * parProp, const odf::paragraph_format_properties * parProp,
...@@ -34,13 +33,12 @@ public: ...@@ -34,13 +33,12 @@ public:
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:
private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
}; };
void xlsx_serialize(std::wostream & _Wostream, xlsx_fonts const & fonts);
} }
......
...@@ -9,20 +9,21 @@ ...@@ -9,20 +9,21 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class xlsx_num_fmts class xlsx_num_fmts
{ {
public: public:
xlsx_num_fmts(); xlsx_num_fmts();
~xlsx_num_fmts(); ~xlsx_num_fmts();
public: public:
size_t num_format_id(const std::wstring & format_code); size_t num_format_id(const std::wstring & format_code);
void xlsx_serialize(std::wostream & _Wostream) const; void xlsx_serialize(std::wostream & _Wostream) const;
friend void xlsx_serialize(std::wostream & _Wostream, const xlsx_num_fmts & numFmts);
private: private:
struct Impl; struct Impl;
_CP_SCOPED_PTR(Impl) 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) ...@@ -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\">"; _Wostream << L"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">";
::cpdoccore::oox::xlsx_serialize(_Wostream, numFmts_); cpdoccore::oox::xlsx_serialize(_Wostream, numFmts_);
::cpdoccore::oox::xlsx_serialize(_Wostream, fonts_); cpdoccore::oox::xlsx_serialize(_Wostream, fonts_);
::cpdoccore::oox::xlsx_serialize(_Wostream, fills_); cpdoccore::oox::xlsx_serialize(_Wostream, fills_);
::cpdoccore::oox::xlsx_serialize(_Wostream, borders_); cpdoccore::oox::xlsx_serialize(_Wostream, borders_);
xlsx_serialize_xf(_Wostream, cellStyleXfs_, L"cellStyleXfs"); xlsx_serialize_xf(_Wostream, cellStyleXfs_, L"cellStyleXfs");
...@@ -211,13 +211,13 @@ void xlsx_style_manager::Impl::xlsx_serialize(std::wostream & _Wostream) ...@@ -211,13 +211,13 @@ void xlsx_style_manager::Impl::xlsx_serialize(std::wostream & _Wostream)
namespace namespace
{ {
struct compare_xlsx_xf struct compare_xlsx_xf
{ {
bool operator() (xlsx_xf const & x1, xlsx_xf const & x2) bool operator() (xlsx_xf const & x1, xlsx_xf const & x2)
{ {
return x1.index < x2.index; 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) 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 ...@@ -234,7 +234,7 @@ void xlsx_style_manager::Impl::xlsx_serialize_xf(std::wostream & _Wostream, cons
_Wostream << L"<" << nodeName << L" count=\"" << xfs_.size() << L"\">"; _Wostream << L"<" << nodeName << L" count=\"" << xfs_.size() << L"\">";
BOOST_FOREACH(const xlsx_xf & xfRecord, xfs_) BOOST_FOREACH(const xlsx_xf & xfRecord, xfs_)
{ {
::cpdoccore::oox::xlsx_serialize(_Wostream, xfRecord); cpdoccore::oox::xlsx_serialize(_Wostream, xfRecord);
} }
_Wostream << L"</" << nodeName << L">"; _Wostream << L"</" << nodeName << L">";
} }
......
...@@ -12,13 +12,11 @@ ...@@ -12,13 +12,11 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
struct xlsx_xf; struct xlsx_xf;
typedef _CP_PTR(xlsx_xf) xlsx_xf_ptr; typedef _CP_PTR(xlsx_xf) xlsx_xf_ptr;
/// \struct xlsx_x struct xlsx_xf
/// xf (18.8.45) {
struct xlsx_xf
{
_CP_OPT(bool) applyAlignment; _CP_OPT(bool) applyAlignment;
_CP_OPT(bool) applyBorder; _CP_OPT(bool) applyBorder;
_CP_OPT(bool) applyFill; _CP_OPT(bool) applyFill;
...@@ -40,9 +38,10 @@ struct xlsx_xf ...@@ -40,9 +38,10 @@ struct xlsx_xf
bool operator == (const xlsx_xf & rVal) const; bool operator == (const xlsx_xf & rVal) const;
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); friend std::size_t hash_value(xlsx_xf const & val);
}; };
void xlsx_serialize(std::wostream & _Wostream, const xlsx_xf & xf);
} }
} }
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "xlsx_cell_format.h" #include "xlsx_cell_format.h"
#include "../odf/calcs_styles.h" #include "../odf/calcs_styles.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace cpdoccore { namespace cpdoccore {
...@@ -39,7 +41,21 @@ xlsx_conversion_context(::cpdoccore::oox::package::xlsx_document * outputDocumen ...@@ -39,7 +41,21 @@ xlsx_conversion_context(::cpdoccore::oox::package::xlsx_document * outputDocumen
mediaitems_(odf_document_->get_folder()), mediaitems_(odf_document_->get_folder()),
xlsx_drawing_context_handle_(mediaitems_) 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) void xlsx_conversion_context::start_chart(std::wstring const & name)
{ {
charts_.push_back(oox_chart_context::create(name)); charts_.push_back(oox_chart_context::create(name));
...@@ -177,7 +193,7 @@ void xlsx_conversion_context::end_document() ...@@ -177,7 +193,7 @@ void xlsx_conversion_context::end_document()
CP_XML_STREAM() << workbook_content.str(); 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() ...@@ -466,7 +482,7 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
else else
font_size =10; 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_; return maxDigitSize_;
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "mediaitems.h" #include "mediaitems.h"
class CApplicationFonts;
namespace cpdoccore { namespace cpdoccore {
...@@ -40,8 +41,10 @@ namespace package ...@@ -40,8 +41,10 @@ namespace package
class xlsx_conversion_context : boost::noncopyable class xlsx_conversion_context : boost::noncopyable
{ {
public: public:
xlsx_conversion_context(::cpdoccore::oox::package::xlsx_document * outputDocument, xlsx_conversion_context(cpdoccore::oox::package::xlsx_document * outputDocument, cpdoccore::odf::odf_document * odfDocument);
::cpdoccore::odf::odf_document * odfDocument); ~xlsx_conversion_context();
void set_font_directory(std::wstring pathFonts);
void start_document(); void start_document();
void end_document(); void end_document();
...@@ -88,14 +91,12 @@ public: ...@@ -88,14 +91,12 @@ public:
void start_table_covered_cell(); void start_table_covered_cell();
void end_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_column() const;
int current_table_row() 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; std::wstring current_cell_address() const;
odf::odf_document * root() odf::odf_document * root()
...@@ -107,58 +108,47 @@ public: ...@@ -107,58 +108,47 @@ public:
void process_styles(); void process_styles();
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_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_xml_worksheet & current_sheet(); xlsx_xml_worksheet & current_sheet();
oox_chart_context & current_chart(); oox_chart_context & current_chart();
num_format_context & get_num_format_context() { return num_format_context_; } num_format_context & get_num_format_context() { return num_format_context_; }
size_t get_default_cell_style() const { return default_style_; }
size_t get_default_cell_style() const { return default_style_; };
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; } xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
xlsx_table_metrics & get_table_metrics(); xlsx_table_metrics & get_table_metrics();
xlsx_drawing_context & get_drawing_context(); xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle(); xlsx_drawing_context_handle & get_drawing_context_handle();
xlsx_comments_context & get_comments_context(); xlsx_comments_context & get_comments_context();
xlsx_comments_context_handle & get_comments_context_handle(); xlsx_comments_context_handle & get_comments_context_handle();
mediaitems & get_mediaitems() { return mediaitems_; } mediaitems & get_mediaitems() { return mediaitems_; }
void start_hyperlink(const std::wstring & styleName);
void end_hyperlink(std::wstring const & href);
private: private:
void create_new_sheet(std::wstring const & name); void create_new_sheet(std::wstring const & name);
void dump_sheet(); void dump_sheet();
private: package::xlsx_document *output_document_;
const odf::office_element *spreadsheet_;
odf::odf_document *odf_document_;
package::xlsx_document * output_document_; CApplicationFonts *fontsApplication_;
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_; std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_; std::vector<oox_chart_context_ptr> charts_;
//xlsx_xml_workbook_ptr workbook_; std::wstringstream defaultOutput_;
std::pair<float,float> maxDigitSize_; std::pair<float,float> maxDigitSize_;
xlsx_style_manager xlsx_style_;
num_format_context num_format_context_; num_format_context num_format_context_;
size_t default_style_; size_t default_style_;
xlsx_defined_names xlsx_defined_names_;
mediaitems mediaitems_; mediaitems mediaitems_;
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_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_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 ...@@ -284,7 +284,8 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
{ {
CP_XML_NODE(L"a:buClr") 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_) 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