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
......@@ -208,7 +208,7 @@ void docx_conversion_context::dump_notes(rels & Rels) const
std::wstring docx_conversion_context::add_mediaitem(const std::wstring & uri, mediaitems::Type type, bool & isInternal, std::wstring & ref)
{
return mediaitems_.add_or_find(uri, type, isInternal, ref);
return mediaitems_.add_or_find(uri, type, isInternal, ref);
}
void docx_conversion_context::start_document()
......@@ -245,6 +245,7 @@ void docx_conversion_context::end_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_->content_type().set_media(mediaitems_);
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_comments(comments_context_);
......
......@@ -522,9 +522,9 @@ private:
boost::shared_ptr<streams_man> streams_man_;
package::docx_document * output_document_;
odf_reader::odf_document * odf_document_;
CApplicationFonts * applicationFonts_;
package::docx_document * output_document_;
odf_reader::odf_document * odf_document_;
CApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_;
......
......@@ -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"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"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"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml");
......@@ -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"/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");
}
////////////////////////////////////////////////////////////////////////////////////////
word_files::word_files()
......
......@@ -132,15 +132,16 @@ public:
docx_document();
public:
virtual void write(const std::wstring & RootPath);
word_files & get_word_files() { return word_files_; }
virtual content_types_file & content_type() { return content_type_; }
word_files & get_word_files() { return word_files_; }
virtual content_types_file & content_type() { return content_type_; }
virtual void write(const std::wstring & RootPath);
private:
docx_content_types_file content_type_;
word_files word_files_;
rels_files rels_files_;
docProps_files docProps_files_;
docx_content_types_file content_type_;
word_files word_files_;
rels_files rels_files_;
docProps_files docProps_files_;
};
}
......
......@@ -8,6 +8,39 @@
#include "../../DesktopEditor/fontengine/FontManager.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 utils {
......
......@@ -5,6 +5,10 @@
class CApplicationFonts;
double getSystemDPI();
namespace cpdoccore {
namespace utils {
......
......@@ -50,6 +50,8 @@ std::wstring static get_default_file_name(mediaitems::Type type)
return L"image";
case mediaitems::typeChart:
return L"chart";
case mediaitems::typeMedia:
return L"media";
default:
return L"";
}
......@@ -110,6 +112,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
number= count_image+1;
else if ( type == typeShape)
number= count_shape+1;
else if ( type == typeMedia)
number= count_media+1;
else
number= items_.size()+1;
......
......@@ -11,7 +11,7 @@ class rels;
class mediaitems
{
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)
{
......@@ -19,6 +19,8 @@ public:
count_shape =0;
count_image =0;
count_tables =0;
count_media =0;
}
struct item
......@@ -43,6 +45,7 @@ public:
size_t count_charts;
size_t count_image;
size_t count_media;
size_t count_shape;
size_t count_tables;
......
......@@ -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")
{}
......@@ -41,6 +59,32 @@ void content_types_file::write(const std::wstring & 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)
......
......@@ -51,6 +51,8 @@ public:
content_types_file();
virtual void write(const std::wstring & RootPath);
content_type & get_content_type() { return content_type_; }
bool add_or_find_default(const std::wstring & extension);
void set_media(mediaitems & _Mediaitems);
protected:
content_type content_type_;
......
......@@ -277,6 +277,7 @@ void pptx_conversion_context::end_document()
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_authors_comments(authors_comments_);
......
......@@ -107,9 +107,9 @@ private:
void create_new_slideLayout(int id);
void create_new_slideMaster(int id);
package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_;
CApplicationFonts *applicationFonts_;
package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_;
CApplicationFonts * applicationFonts_;
pptx_slide_context pptx_slide_context_;
pptx_text_context pptx_text_context_;
......@@ -123,8 +123,8 @@ private:
std::vector<pptx_xml_slideLayout_ptr> slideLayouts_;
std::vector<pptx_xml_theme_ptr> themes_;
pptx_xml_authors_comments_ptr authors_comments_;
pptx_xml_presentation presentation_;
pptx_xml_authors_comments_ptr authors_comments_;
pptx_xml_presentation presentation_;
std::wstring current_master_page_name_;
std::wstring current_layout_page_name_;
......
......@@ -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"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"wmf", L"image/x-wmf");
content_type_.add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
......
......@@ -185,27 +185,27 @@ public:
void set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments);
private:
rels_files rels_files_;
rels_files rels_files_;
slides_files slides_files_;
slideLayouts_files slideLayouts_files_;
slideMasters_files slideMasters_files_;
slides_files slides_files_;
slideLayouts_files slideLayouts_files_;
slideMasters_files slideMasters_files_;
ppt_themes_files themes_files_;
ppt_themes_files themes_files_;
ppt_charts_files charts_files_;
//slides_files notesSlides_files_;
//slides_files notesMasters_files_;
//slides_files handoutMasters_files_;
ppt_charts_files charts_files_;
//slides_files notesSlides_files_;
//slides_files notesMasters_files_;
//slides_files handoutMasters_files_;
element_ptr authors_comments_;
element_ptr authors_comments_;
element_ptr presentation_;
element_ptr presentation_;
element_ptr tableStyles_;
element_ptr tableStyles_;
element_ptr comments_;
element_ptr media_;
element_ptr comments_;
element_ptr media_;
};
/// \class xlsx_document
......
......@@ -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"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"wmf", L"image/x-wmf");
content_type_.add_default(L"vml", L"application/vnd.openxmlformats-officedocument.vmlDrawing");
......
......@@ -184,9 +184,9 @@ public:
private:
xlsx_content_types_file content_type_;
xl_files xl_files_;
docProps_files docProps_files_;
rels_files rels_files_;
xl_files xl_files_;
docProps_files docProps_files_;
rels_files rels_files_;
};
......
......@@ -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_->content_type().set_media(get_mediaitems());
output_document_->get_xl_files().set_media(get_mediaitems(), applicationFonts_);
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()
else
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_;
}
......
......@@ -28,6 +28,8 @@
#pragma comment(lib, "gdiplus.lib")
#endif
extern double getSystemDPI();
namespace _image_file_
{
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
}
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[1] = dpi_ * Points_pt[0].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
CP_XML_NODE(L"w:suff")
{
if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
{
CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get());
}
else
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
CP_XML_NODE(L"w:suff")
{
if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
{
CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get() );
}
else
CP_XML_ATTR(L"w:val",L"tab");
}
......
......@@ -19,6 +19,8 @@
#include "../docx/xlsx_cell_format.h"
#include "../formulasconvert/formulasconvert.h"
extern double getSystemDPI();
namespace cpdoccore {
using namespace odf_types;
......@@ -413,7 +415,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
in_width = 0.0;
}
const double pixDpi = in_width * 96./*getDefaultDpi()*/;
const double pixDpi = in_width * getSystemDPI();
width = pixToSize(pixDpi, Context.getMaxDigitSize().first);
//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