Commit 1c720f92 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

OdfFile еще парочка пофиксеных багов

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63304 954022d7-b5bf-4e40-9824-e11837661b57
parent ac94cf1e
...@@ -245,6 +245,7 @@ void docx_conversion_context::end_document() ...@@ -245,6 +245,7 @@ void docx_conversion_context::end_document()
output_stream() << L"</w:document>"; output_stream() << L"</w:document>";
output_document_->get_word_files().set_document( package::simple_element::create(L"document.xml", document_xml_.str()) ); output_document_->get_word_files().set_document( package::simple_element::create(L"document.xml", document_xml_.str()) );
output_document_->content_type().set_media(mediaitems_);
output_document_->get_word_files().set_media( mediaitems_, applicationFonts_); output_document_->get_word_files().set_media( mediaitems_, applicationFonts_);
output_document_->get_word_files().set_headers_footers(headers_footers_); output_document_->get_word_files().set_headers_footers(headers_footers_);
output_document_->get_word_files().set_comments(comments_context_); output_document_->get_word_files().set_comments(comments_context_);
......
...@@ -14,11 +14,8 @@ docx_content_types_file::docx_content_types_file() ...@@ -14,11 +14,8 @@ docx_content_types_file::docx_content_types_file()
content_type_.add_default(L"xml", L"application/xml"); content_type_.add_default(L"xml", L"application/xml");
// //
content_type_.add_default(L"jpg", L"image/jpeg"); content_type_.add_default(L"jpg", L"image/jpeg");
content_type_.add_default(L"gif", L"image/gif");
content_type_.add_default(L"jpeg", L"image/jpeg");
content_type_.add_default(L"png", L"image/png"); content_type_.add_default(L"png", L"image/png");
content_type_.add_default(L"wmf", L"image/x-wmf"); //
content_type_.add_default(L"emf", L"image/x-emf");
content_type_.add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml"); content_type_.add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content_type_.add_override(L"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml"); content_type_.add_override(L"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml");
...@@ -28,9 +25,9 @@ docx_content_types_file::docx_content_types_file() ...@@ -28,9 +25,9 @@ docx_content_types_file::docx_content_types_file()
content_type_.add_override(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"); content_type_.add_override(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
content_type_.add_override(L"/docProps/app.xml", L"application/vnd.openxmlformats-officedocument.extended-properties+xml"); content_type_.add_override(L"/docProps/app.xml", L"application/vnd.openxmlformats-officedocument.extended-properties+xml");
content_type_.add_override(L"/docProps/core.xml", L"application/vnd.openxmlformats-package.core-properties+xml"); content_type_.add_override(L"/docProps/core.xml", L"application/vnd.openxmlformats-package.core-properties+xml");
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
word_files::word_files() word_files::word_files()
......
...@@ -132,10 +132,11 @@ public: ...@@ -132,10 +132,11 @@ public:
docx_document(); docx_document();
public: public:
virtual void write(const std::wstring & RootPath);
word_files & get_word_files() { return word_files_; } word_files & get_word_files() { return word_files_; }
virtual content_types_file & content_type() { return content_type_; } virtual content_types_file & content_type() { return content_type_; }
virtual void write(const std::wstring & RootPath);
private: private:
docx_content_types_file content_type_; docx_content_types_file content_type_;
word_files word_files_; word_files word_files_;
......
...@@ -8,6 +8,39 @@ ...@@ -8,6 +8,39 @@
#include "../../DesktopEditor/fontengine/FontManager.h" #include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h" #include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include <gdiplus.h>
#elif defined(__linux__)
#include "X11/Xlib.h"
#endif
double getSystemDPI()
{
#if defined (_WIN32) || defined(_WIN64)
HDC screen = GetDC(0);
int dpiX = GetDeviceCaps (screen, LOGPIXELSX);
int dpiY = GetDeviceCaps (screen, LOGPIXELSY);
ReleaseDC (0, screen);
return dpiX;
#elif defined (__linux__)
Display *dpy = XOpenDisplay (NULL);;
double xres = ((((double) DisplayWidth (dpy, 0)) * 25.4) / ((double) DisplayWidthMM(dpy, 0)));
double yres = ((((double) DisplayHeight(dpy, 0)) * 25.4) / ((double) DisplayHeightMM(dpy, 0)));
XCloseDisplay (dpy);
return xres;
#else
return 96.;
#endif
}
namespace cpdoccore { namespace cpdoccore {
namespace utils { namespace utils {
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
class CApplicationFonts; class CApplicationFonts;
double getSystemDPI();
namespace cpdoccore { namespace cpdoccore {
namespace utils { namespace utils {
......
...@@ -50,6 +50,8 @@ std::wstring static get_default_file_name(mediaitems::Type type) ...@@ -50,6 +50,8 @@ std::wstring static get_default_file_name(mediaitems::Type type)
return L"image"; return L"image";
case mediaitems::typeChart: case mediaitems::typeChart:
return L"chart"; return L"chart";
case mediaitems::typeMedia:
return L"media";
default: default:
return L""; return L"";
} }
...@@ -110,6 +112,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool ...@@ -110,6 +112,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
number= count_image+1; number= count_image+1;
else if ( type == typeShape) else if ( type == typeShape)
number= count_shape+1; number= count_shape+1;
else if ( type == typeMedia)
number= count_media+1;
else else
number= items_.size()+1; number= items_.size()+1;
......
...@@ -11,7 +11,7 @@ class rels; ...@@ -11,7 +11,7 @@ class rels;
class mediaitems class mediaitems
{ {
public: public:
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment}; enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia};
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket) mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{ {
...@@ -19,6 +19,8 @@ public: ...@@ -19,6 +19,8 @@ public:
count_shape =0; count_shape =0;
count_image =0; count_image =0;
count_tables =0; count_tables =0;
count_media =0;
} }
struct item struct item
...@@ -43,6 +45,7 @@ public: ...@@ -43,6 +45,7 @@ public:
size_t count_charts; size_t count_charts;
size_t count_image; size_t count_image;
size_t count_media;
size_t count_shape; size_t count_shape;
size_t count_tables; size_t count_tables;
......
...@@ -28,6 +28,24 @@ static void ConvertSvmToImage(std::wstring &file_svm, std::wstring &file_png, CA ...@@ -28,6 +28,24 @@ static void ConvertSvmToImage(std::wstring &file_svm, std::wstring &file_png, CA
} }
} }
static std::wstring get_mime_type(const std::wstring & extension)
{
if (L"eps" == extension) return L"image/x-eps";
if (L"wmf" == extension) return L"image/x-wmf";
if (L"emf" == extension) return L"image/x-emf";
if (L"gif" == extension) return L"image/x-gif";
if (L"png" == extension) return L"image/x-png";
if (L"jpg" == extension) return L"image/x-jpeg";
if (L"jpeg" == extension) return L"image/x-jpeg";
if (L"tiff" == extension) return L"image/x-tiff";
if (L"pdf" == extension) return L"application/pdf";
if (L"wav" == extension) return L"audio/wav";
if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
return L"";
}
content_types_file::content_types_file() : filename_(L"[Content_Types].xml") content_types_file::content_types_file() : filename_(L"[Content_Types].xml")
{} {}
...@@ -41,6 +59,32 @@ void content_types_file::write(const std::wstring & RootPath) ...@@ -41,6 +59,32 @@ void content_types_file::write(const std::wstring & RootPath)
elm.write(RootPath); elm.write(RootPath);
} }
bool content_types_file::add_or_find_default(const std::wstring & extension)
{
for (int i = 0 ; i < content_type_.get_default().size(); i++)
{
if (content_type_.get_default()[i].extension() == extension)
return true;
}
content_type_.add_default(extension, get_mime_type(extension));
return true;
}
void content_types_file::set_media(mediaitems & _Mediaitems)
{
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() )
{
if (item.type == mediaitems::typeImage || item.type == mediaitems::typeMedia)
{
int n = item.outputName.rfind(L".");
if (n > 0)
{
add_or_find_default(item.outputName.substr(n+1, item.outputName.length() - n));
}
}
}
}
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
simple_element::simple_element(const std::wstring & FileName, const std::wstring & Content) : file_name_(FileName) simple_element::simple_element(const std::wstring & FileName, const std::wstring & Content) : file_name_(FileName)
......
...@@ -51,6 +51,8 @@ public: ...@@ -51,6 +51,8 @@ public:
content_types_file(); content_types_file();
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
content_type & get_content_type() { return content_type_; } content_type & get_content_type() { return content_type_; }
bool add_or_find_default(const std::wstring & extension);
void set_media(mediaitems & _Mediaitems);
protected: protected:
content_type content_type_; content_type content_type_;
......
...@@ -277,6 +277,7 @@ void pptx_conversion_context::end_document() ...@@ -277,6 +277,7 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().set_presentation(presentation_); output_document_->get_ppt_files().set_presentation(presentation_);
output_document_->content_type().set_media(get_mediaitems());
output_document_->get_ppt_files().set_media(get_mediaitems(), applicationFonts_); output_document_->get_ppt_files().set_media(get_mediaitems(), applicationFonts_);
output_document_->get_ppt_files().set_authors_comments(authors_comments_); output_document_->get_ppt_files().set_authors_comments(authors_comments_);
......
...@@ -109,7 +109,7 @@ private: ...@@ -109,7 +109,7 @@ private:
package::pptx_document * output_document_; package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_; odf_reader::odf_document * odf_document_;
CApplicationFonts *applicationFonts_; CApplicationFonts * applicationFonts_;
pptx_slide_context pptx_slide_context_; pptx_slide_context pptx_slide_context_;
pptx_text_context pptx_text_context_; pptx_text_context pptx_text_context_;
......
...@@ -19,10 +19,7 @@ pptx_content_types_file::pptx_content_types_file() ...@@ -19,10 +19,7 @@ pptx_content_types_file::pptx_content_types_file()
content_type_.add_default(L"xml", L"application/xml"); content_type_.add_default(L"xml", L"application/xml");
content_type_.add_default(L"jpg", L"image/jpeg"); content_type_.add_default(L"jpg", L"image/jpeg");
content_type_.add_default(L"gif", L"image/gif");
content_type_.add_default(L"jpeg", L"image/jpeg");
content_type_.add_default(L"png", L"image/png"); content_type_.add_default(L"png", L"image/png");
content_type_.add_default(L"wmf", L"image/x-wmf");
content_type_.add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml"); content_type_.add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
......
...@@ -18,10 +18,7 @@ xlsx_content_types_file::xlsx_content_types_file() ...@@ -18,10 +18,7 @@ xlsx_content_types_file::xlsx_content_types_file()
content_type_.add_default(L"xml", L"application/xml"); content_type_.add_default(L"xml", L"application/xml");
content_type_.add_default(L"jpg", L"image/jpeg"); content_type_.add_default(L"jpg", L"image/jpeg");
content_type_.add_default(L"gif", L"image/gif");
content_type_.add_default(L"jpeg", L"image/jpeg");
content_type_.add_default(L"png", L"image/png"); content_type_.add_default(L"png", L"image/png");
content_type_.add_default(L"wmf", L"image/x-wmf");
content_type_.add_default(L"vml", L"application/vnd.openxmlformats-officedocument.vmlDrawing"); content_type_.add_default(L"vml", L"application/vnd.openxmlformats-officedocument.vmlDrawing");
......
...@@ -198,6 +198,8 @@ void xlsx_conversion_context::end_document() ...@@ -198,6 +198,8 @@ void xlsx_conversion_context::end_document()
} }
output_document_->get_xl_files().set_workbook( package::simple_element::create(L"workbook.xml", strm_workbook.str()) ); output_document_->get_xl_files().set_workbook( package::simple_element::create(L"workbook.xml", strm_workbook.str()) );
output_document_->content_type().set_media(get_mediaitems());
output_document_->get_xl_files().set_media(get_mediaitems(), applicationFonts_); output_document_->get_xl_files().set_media(get_mediaitems(), applicationFonts_);
package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content()); package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content());
...@@ -482,7 +484,7 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize() ...@@ -482,7 +484,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., 0, applicationFonts_); maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, getSystemDPI(), 0, applicationFonts_);
} }
return maxDigitSize_; return maxDigitSize_;
} }
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#pragma comment(lib, "gdiplus.lib") #pragma comment(lib, "gdiplus.lib")
#endif #endif
extern double getSystemDPI();
namespace _image_file_ namespace _image_file_
{ {
bool GetResolution(const wchar_t* fileName, int & Width, int &Height) bool GetResolution(const wchar_t* fileName, int & Width, int &Height)
...@@ -104,7 +106,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c ...@@ -104,7 +106,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
} }
if (Points_pt.size()>3)// .. if (Points_pt.size()>3)// ..
{ {
float dpi_ = 96.;//getDefaultDpi(); float dpi_ = getSystemDPI();
clip_rect[0] = dpi_ * Points_pt[3].get_value_unit(length::inch); clip_rect[0] = dpi_ * Points_pt[3].get_value_unit(length::inch);
clip_rect[1] = dpi_ * Points_pt[0].get_value_unit(length::inch); clip_rect[1] = dpi_ * Points_pt[0].get_value_unit(length::inch);
clip_rect[2] = dpi_ * Points_pt[1].get_value_unit(length::inch); clip_rect[2] = dpi_ * Points_pt[1].get_value_unit(length::inch);
......
...@@ -293,7 +293,9 @@ void text_list_level_style_number::docx_convert(oox::docx_conversion_context & C ...@@ -293,7 +293,9 @@ void text_list_level_style_number::docx_convert(oox::docx_conversion_context & C
CP_XML_NODE(L"w:suff") CP_XML_NODE(L"w:suff")
{ {
if ((labelAlignment) && (labelAlignment->text_label_followed_by_)) if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
{
CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get()); CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get());
}
else else
CP_XML_ATTR(L"w:val",L"tab"); CP_XML_ATTR(L"w:val",L"tab");
} }
...@@ -500,7 +502,9 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C ...@@ -500,7 +502,9 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C
CP_XML_NODE(L"w:suff") CP_XML_NODE(L"w:suff")
{ {
if ((labelAlignment) && (labelAlignment->text_label_followed_by_)) if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
{
CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get() ); CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get() );
}
else else
CP_XML_ATTR(L"w:val",L"tab"); CP_XML_ATTR(L"w:val",L"tab");
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "../docx/xlsx_cell_format.h" #include "../docx/xlsx_cell_format.h"
#include "../formulasconvert/formulasconvert.h" #include "../formulasconvert/formulasconvert.h"
extern double getSystemDPI();
namespace cpdoccore { namespace cpdoccore {
using namespace odf_types; using namespace odf_types;
...@@ -413,7 +415,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -413,7 +415,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
in_width = 0.0; in_width = 0.0;
} }
const double pixDpi = in_width * 96./*getDefaultDpi()*/; const double pixDpi = in_width * getSystemDPI();
width = pixToSize(pixDpi, Context.getMaxDigitSize().first); width = pixToSize(pixDpi, Context.getMaxDigitSize().first);
//const double width = cmToChars(prop->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::cm)); //const double width = cmToChars(prop->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::cm));
......
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