From 8d750adb7be31cfcb53849619f38d6019075c195 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 17 Apr 2018 19:10:48 +0300 Subject: [PATCH] x2t (not complete) --- .../DocDocxConverter/PropertiesMapping.cpp | 4 +- .../DocDocxConverter/PropertiesMapping.h | 7 +- .../DocDocxConverter/StyleSheetMapping.cpp | 4 +- .../DocDocxConverter/StyleSheetMapping.h | 4 +- .../BinReader/fontTableWriter.h | 25 +- .../DocWrapper/DocxSerializer.cpp | 2 +- .../DocWrapper/FontProcessor.cpp | 12 +- ASCOfficeDocxFile2/DocWrapper/FontProcessor.h | 8 +- .../DocWrapper/XlsxSerializer.cpp | 2 +- .../Linux/ASCOfficeDocxFile2Lib.pro | 12 +- .../src/docx/docx_conversion_context.cpp | 4 +- .../src/docx/docx_conversion_context.h | 4 +- ASCOfficeOdfFile/src/docx/docx_package.cpp | 2 +- ASCOfficeOdfFile/src/docx/docx_package.h | 4 +- ASCOfficeOdfFile/src/docx/measuredigits.cpp | 12 +- ASCOfficeOdfFile/src/docx/measuredigits.h | 7 +- ASCOfficeOdfFile/src/docx/oox_package.cpp | 18 +- ASCOfficeOdfFile/src/docx/oox_package.h | 9 +- .../src/docx/pptx_conversion_context.cpp | 4 +- .../src/docx/pptx_conversion_context.h | 7 +- ASCOfficeOdfFile/src/docx/pptx_package.cpp | 2 +- ASCOfficeOdfFile/src/docx/pptx_package.h | 7 +- ASCOfficeOdfFile/src/docx/xlsx_package.cpp | 4 +- ASCOfficeOdfFile/src/docx/xlsx_package.h | 7 +- .../src/docx/xlsxconversioncontext.cpp | 4 +- .../src/docx/xlsxconversioncontext.h | 7 +- ASCOfficeOdfFile/src/odf/draw_common.cpp | 21 +- ASCOfficeOdfFile/src/odf/draw_common.h | 8 +- ASCOfficeOdfFileW/linux/OdfFileWriterLib.pro | 4 +- .../linux/odffilewriterlib_odf.cpp | 8 + .../OdfFormat/odf_conversion_context.cpp | 4 +- .../source/OdfFormat/odf_conversion_context.h | 7 +- .../OdfFormat/ods_conversion_context.cpp | 2 +- .../OdfFormat/odt_conversion_context.cpp | 2 +- .../Oox2OdfConverter/ConvertDrawing.cpp | 7 + .../source/Oox2OdfConverter/ConvertVml.cpp | 8 + .../source/Oox2OdfConverter/Converter.cpp | 7 + .../Oox2OdfConverter/ConverterChart.cpp | 7 + .../source/Oox2OdfConverter/DocxConverter.cpp | 7 + .../source/Oox2OdfConverter/PptxConverter.cpp | 8 + .../source/Oox2OdfConverter/XlsxConverter.cpp | 8 + ASCOfficeOdfFileW/source/utils.h | 4 +- .../PPTFormatLib/PPTXWriter/ShapeWriter.h | 4 +- .../ASCOfficeDrawingConverter.cpp | 4 +- ASCOfficePPTXFile/ASCOfficeDrawingConverter.h | 5 +- .../ASCOfficePPTXFileRealization.cpp | 1 + .../Editor/Drawing/Shapes/BaseShape/Common.h | 3 + .../Editor/Drawing/TextAttributesEx.h | 7 +- ASCOfficePPTXFile/Editor/FontCutter.h | 11 +- ASCOfficePPTXFile/Editor/FontPicker.h | 28 +- ASCOfficePPTXFile/Editor/imagemanager.h | 25 +- .../PPTXFormat/Limit/BaseLimit.h | 20 +- .../PPTXFormat/Logic/Colors/SysClr.h | 2 + .../Linux/PPTXFormatLib/PPTXFormatLib.pro | 6 +- .../source/Reader/OOXShapeReader.cpp | 9 +- .../RtfFormatLib/source/RtfShape.cpp | 19 +- ASCOfficeRtfFile/RtfFormatLib/source/Utils.h | 10 +- .../XlsFormat/Logic/GlobalWorkbookInfo.cpp | 12 +- .../XlsFormat/Logic/GlobalWorkbookInfo.h | 10 +- Common/DocxFormat/Source/Base/ASCWinAPI.h | 2 +- Common/DocxFormat/Source/DocxFormat/Docx.h | 7 +- Common/DocxFormat/Source/SystemUtility/File.h | 18 +- .../Source/SystemUtility/SystemUtility.cpp | 2 +- DesktopEditor/AllFontsGen/main.cpp | 3 +- DesktopEditor/common/Directory.cpp | 2 +- DesktopEditor/common/Directory.h | 9 +- DesktopEditor/common/File.h | 20 +- DesktopEditor/common/Types.h | 5 +- DesktopEditor/doctrenderer/test/main.cpp | 2 +- .../freetype_names/FontMaps/FontMaps.cpp | 2 +- DesktopEditor/graphics/IRenderer.h | 2 +- .../graphics/MetafileToGraphicsRenderer.h | 231 +---- DesktopEditor/graphics/MetafileToRenderer.cpp | 965 ++++++++++++++++++ .../graphics/MetafileToRendererCheck.h | 83 ++ DesktopEditor/graphics/TemporaryCS.cpp | 21 + DesktopEditor/graphics/TemporaryCS.h | 13 + DesktopEditor/graphics/pro/Fonts.h | 4 + DesktopEditor/graphics/pro/graphics.pro | 1 + DesktopEditor/xml/include/xmlutils.h | 5 +- DocxRenderer/src/logic/FontManagerBase.h | 2 +- HtmlRenderer/include/ASCSVGWriter.h | 12 +- HtmlRenderer/src/ASCSVGWriter.cpp | 10 +- PdfWriter/Src/FontCidTT.cpp | 2 +- X2tConverter/build/Qt/X2tConverter.pri | 41 +- X2tConverter/src/ASCConverters.cpp | 88 +- 85 files changed, 1487 insertions(+), 535 deletions(-) create mode 100644 DesktopEditor/graphics/MetafileToRenderer.cpp create mode 100644 DesktopEditor/graphics/MetafileToRendererCheck.h diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp index 92ca4d6c6a..708a271a06 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp @@ -34,8 +34,8 @@ namespace DocFileFormat { - std::map PropertiesMapping::brcTypeMap; - OfficeCriticalSection PropertiesMapping::brcTypeMapLock; + std::map PropertiesMapping::brcTypeMap; + NSCriticalSection::CRITICAL_SECTION_SMART PropertiesMapping::brcTypeMapLock; void PropertiesMapping::init() { diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h index 1747b90490..04fde94551 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h @@ -39,8 +39,7 @@ #include "ShadingDescriptor.h" #include "SinglePropertyModifier.h" - -#include "../../OfficeUtils/src/ASCOfficeCriticalSection.h" //for linux make inside +#include "../../DesktopEditor/graphics/TemporaryCS.h" namespace DocFileFormat { @@ -75,7 +74,7 @@ namespace DocFileFormat XMLTools::CStringXmlWriter* m_pXmlWriter; - static std::map brcTypeMap; - static OfficeCriticalSection brcTypeMapLock; + static std::map brcTypeMap; + static NSCriticalSection::CRITICAL_SECTION_SMART brcTypeMapLock; }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp index 5b27957aef..b7a18fbf7d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp @@ -35,8 +35,8 @@ namespace DocFileFormat { - std::map StyleSheetMapping::m_mapStyleId; - OfficeCriticalSection StyleSheetMapping::m_mapStyleIdLock; + std::map StyleSheetMapping::m_mapStyleId; + NSCriticalSection::CRITICAL_SECTION_SMART StyleSheetMapping::m_mapStyleIdLock; StyleSheetMapping::StyleSheetMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h index 2fc3b547fc..abe4f98674 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h @@ -55,7 +55,7 @@ namespace DocFileFormat /// Generates a style id for custom style names or returns the build-in identifier for build-in styles. static std::wstring MakeStyleId( StyleSheetDescription* std ); static std::map m_mapStyleId; - static OfficeCriticalSection m_mapStyleIdLock; + static NSCriticalSection::CRITICAL_SECTION_SMART m_mapStyleIdLock; virtual ~StyleSheetMapping(); private: @@ -67,4 +67,4 @@ namespace DocFileFormat /// Writes the "NormalTable" default style void writeNormalTableStyle(); }; -} \ No newline at end of file +} diff --git a/ASCOfficeDocxFile2/BinReader/fontTableWriter.h b/ASCOfficeDocxFile2/BinReader/fontTableWriter.h index ae667a3d84..c059bd3b2b 100644 --- a/ASCOfficeDocxFile2/BinReader/fontTableWriter.h +++ b/ASCOfficeDocxFile2/BinReader/fontTableWriter.h @@ -33,8 +33,7 @@ #define FONT_TABLE_WRITER #include "../../XlsxSerializerCom/Common/Common.h" -#include "../../DesktopEditor/fontengine/FontManager.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" #include namespace Writers @@ -46,32 +45,28 @@ namespace Writers { XmlUtils::CStringWriter m_oWriter; std::wstring m_sDir; - CApplicationFonts m_oApplicationFonts; - CFontManager* m_pFontManager; + NSFonts::IApplicationFonts* m_pApplicationFonts; + NSFonts::IFontManager* m_pFontManager; public: boost::unordered_map m_mapFonts; FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir) { + m_pApplicationFonts = NSFonts::NSApplication::Create(); m_pFontManager = NULL; if(!bNoFontDir) { if(sFontDir.empty()) - m_oApplicationFonts.Initialize(); + m_pApplicationFonts->Initialize(); else - m_oApplicationFonts.InitializeFromFolder(sFontDir); - CFontList* pFontList = m_oApplicationFonts.GetList(); - if(NULL != pFontList) - { - std::wstring sDefaultFont(_T("Arial")); - pFontList->SetDefaultFont(sDefaultFont); - } - m_pFontManager = m_oApplicationFonts.GenerateFontManager(); + m_pApplicationFonts->InitializeFromFolder(sFontDir); + m_pFontManager = m_pApplicationFonts->GenerateFontManager(); } } ~FontTableWriter() { RELEASEOBJECT(m_pFontManager); + RELEASEOBJECT(m_pApplicationFonts); } void Write() @@ -116,11 +111,11 @@ namespace Writers bool bUsePanose = false; if(NULL != m_pFontManager) { - CFontSelectFormat oFontSelectFormat; + NSFonts::CFontSelectFormat oFontSelectFormat; oFontSelectFormat.wsName = new std::wstring; *oFontSelectFormat.wsName = sFontName; - CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); + NSFonts::CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); if(NULL != pFontInfo) { for (size_t i = 0; i < 10; ++i) diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp index f7eba409e0..eb429a9315 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp @@ -67,7 +67,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co COfficeFontPicker* pFontPicker = new COfficeFontPicker(); pFontPicker->Init(m_sFontDir); - CFontManager* pFontManager = pFontPicker->get_FontManager(); + NSFonts::IFontManager* pFontManager = pFontPicker->get_FontManager(); DocWrapper::FontProcessor fp; fp.setFontManager(pFontManager); diff --git a/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp b/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp index a34bf56170..29864a8f6c 100644 --- a/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp @@ -52,11 +52,11 @@ namespace DocWrapper { { } - void FontProcessor::setFontManager(CFontManager* pFontManager) + void FontProcessor::setFontManager(NSFonts::IFontManager* pFontManager) { m_pFontManager = pFontManager; } - CFontManager* FontProcessor::getFontManager() + NSFonts::IFontManager* FontProcessor::getFontManager() { return m_pFontManager; } @@ -88,7 +88,7 @@ namespace DocWrapper { std::wstring FontProcessor::getFont(const NSCommon::nullable& oScheme, const NSCommon::nullable& oRFont, const NSCommon::nullable& oCharset, const NSCommon::nullable& oFamily, PPTX::Theme* pTheme) { - CFontSelectFormat oFontSelectFormat; + NSFonts::CFontSelectFormat oFontSelectFormat; std::wstring sFontName; if(NULL != pTheme && oScheme.IsInit() && oScheme->m_oFontScheme.IsInit()) { @@ -125,7 +125,7 @@ namespace DocWrapper { } std::wstring sRes; - CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); + NSFonts::CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); if(NULL != pFontInfo) sRes = pFontInfo->m_wsFontName; else @@ -135,7 +135,7 @@ namespace DocWrapper { } void FontProcessor::addToFontMap(OOX::CFont& font) { - CFontSelectFormat oFontSelectFormat; + NSFonts::CFontSelectFormat oFontSelectFormat; std::wstring sFontName; if(font.m_sName.empty()) @@ -221,7 +221,7 @@ namespace DocWrapper { *oFontSelectFormat.ulCodeRange2 = ulCodeRange2; } - CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); + NSFonts::CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); if(NULL != pFontInfo) fontMap[sFontName] = pFontInfo->m_wsFontName; else diff --git a/ASCOfficeDocxFile2/DocWrapper/FontProcessor.h b/ASCOfficeDocxFile2/DocWrapper/FontProcessor.h index 76a94c6e46..92895dc448 100644 --- a/ASCOfficeDocxFile2/DocWrapper/FontProcessor.h +++ b/ASCOfficeDocxFile2/DocWrapper/FontProcessor.h @@ -33,7 +33,7 @@ #include -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" namespace NSCommon{ template class nullable; @@ -68,15 +68,15 @@ namespace DocWrapper { class FontProcessor { - CFontManager* m_pFontManager; + NSFonts::IFontManager* m_pFontManager; std::map fontMap; public: FontProcessor(); ~FontProcessor(); - void setFontManager(CFontManager* pFontManager); - CFontManager* getFontManager(); + void setFontManager(NSFonts::IFontManager* pFontManager); + NSFonts::IFontManager* getFontManager(); void setFontTable(OOX::CFontTable* fontTable); std::wstring getFont(const std::wstring& name); diff --git a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp index 76b89ebb86..3989b0c0cc 100644 --- a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp @@ -104,7 +104,7 @@ namespace BinXlsxRW{ { COfficeFontPicker* pFontPicker = new COfficeFontPicker(); pFontPicker->Init(m_sFontDir); - CFontManager* pFontManager = pFontPicker->get_FontManager(); + NSFonts::IFontManager* pFontManager = pFontPicker->get_FontManager(); DocWrapper::FontProcessor fp; fp.setFontManager(pFontManager); diff --git a/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro b/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro index 00114269ad..616a4246ea 100644 --- a/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro +++ b/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro @@ -16,17 +16,9 @@ include($$PWD/../../Common/3dParty/boost/boost.pri) DEFINES += UNICODE \ _UNICODE \ - USE_AVSOFFICESTUDIO_XMLUTILS \ SOLUTION_ASCOFFICEDOCXFILE2 \ - #DISABLE_FILE_DOWNLOADER \ - _USE_LIBXML2_READER_ \ - LIBXML_READER_ENABLED \ - DONT_WRITE_EMBEDDED_FONTS - - -INCLUDEPATH += \ - ../../DesktopEditor/freetype-2.5.2/include \ - ../../DesktopEditor/xml/libxml2/include \ + #DISABLE_FILE_DOWNLOADER \ + DONT_WRITE_EMBEDDED_FONTS SOURCES += \ diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp index c949b65cf5..f530f724b1 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp @@ -51,7 +51,7 @@ #include "oox_rels.h" #include "logging.h" -#include "../../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../../DesktopEditor/graphics/pro/Fonts.h" #include "../../../Common/DocxFormat/Source/XML/Utils.h" static int current_id_changes = 0; @@ -158,7 +158,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD odf_document_ (OdfDocument) { streams_man_ = streams_man::create(temp_stream_); - applicationFonts_ = new CApplicationFonts(); + applicationFonts_ = NSFonts::NSApplication::Create(); } docx_conversion_context::~docx_conversion_context() { diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h index 22399cadf5..4702db35d1 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h @@ -47,7 +47,7 @@ #include "oox_conversion_context.h" #include "oox_chart_context.h" -class CApplicationFonts; +#include "../../../DesktopEditor/graphics/pro/Fonts.h" namespace cpdoccore { @@ -758,7 +758,7 @@ private: package::docx_document * output_document_; odf_reader::odf_document * odf_document_; - CApplicationFonts * applicationFonts_; + NSFonts::IApplicationFonts * applicationFonts_; std::vector settings_properties_; diff --git a/ASCOfficeOdfFile/src/docx/docx_package.cpp b/ASCOfficeOdfFile/src/docx/docx_package.cpp index 72dfb9fa9e..81584941fb 100644 --- a/ASCOfficeOdfFile/src/docx/docx_package.cpp +++ b/ASCOfficeOdfFile/src/docx/docx_package.cpp @@ -140,7 +140,7 @@ void word_files::update_rels(docx_conversion_context & Context) Context.dump_notes (rels_files_.get_rel_file()->get_rels()); } -void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts) +void word_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts) { if (_Mediaitems.count_image + _Mediaitems.count_media > 0) { diff --git a/ASCOfficeOdfFile/src/docx/docx_package.h b/ASCOfficeOdfFile/src/docx/docx_package.h index 3ede6712ca..79545a38c8 100644 --- a/ASCOfficeOdfFile/src/docx/docx_package.h +++ b/ASCOfficeOdfFile/src/docx/docx_package.h @@ -40,7 +40,7 @@ #include "docx_content_type.h" #include "oox_package.h" -class CApplicationFonts; +#include "../../../DesktopEditor/graphics/pro/Fonts.h" namespace cpdoccore { namespace oox { @@ -130,7 +130,7 @@ public: void set_numbering (element_ptr Element); void set_settings (element_ptr Element); bool has_numbering (); - void set_media (mediaitems & _Mediaitems, CApplicationFonts *pAppFonts); + void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts); void set_headers_footers(headers_footers & HeadersFooters); void set_notes (notes_context & notesContext); void set_comments (comments_context & commentsContext); diff --git a/ASCOfficeOdfFile/src/docx/measuredigits.cpp b/ASCOfficeOdfFile/src/docx/measuredigits.cpp index 4831ebe046..9576f1b191 100644 --- a/ASCOfficeOdfFile/src/docx/measuredigits.cpp +++ b/ASCOfficeOdfFile/src/docx/measuredigits.cpp @@ -36,8 +36,7 @@ #include -#include "../../DesktopEditor/fontengine/FontManager.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" namespace cpdoccore { namespace utils { @@ -49,7 +48,7 @@ namespace class MeasureError : public Error {}; } -std::pair GetMaxDigitSizePixelsImpl(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CFontManager *pFontManager) +std::pair GetMaxDigitSizePixelsImpl(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, NSFonts::IFontManager *pFontManager) { if (pFontManager == NULL) return std::pair(7,8); @@ -102,7 +101,7 @@ std::pair GetMaxDigitSizePixelsImpl(const std::wstring & fontName, } -std::pair GetMaxDigitSizePixels(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CApplicationFonts *appFonts) +std::pair GetMaxDigitSizePixels(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, NSFonts::IApplicationFonts *appFonts) { try { @@ -110,13 +109,12 @@ std::pair GetMaxDigitSizePixels(const std::wstring & fontName, dou if (appFonts) { - CFontManager *pFontManager = appFonts->GenerateFontManager(); + NSFonts::IFontManager *pFontManager = appFonts->GenerateFontManager(); std::pair val = GetMaxDigitSizePixelsImpl(fontName, fontSize, dpi, fontStyle, pFontManager); if (pFontManager) - { - pFontManager->m_pApplication = NULL; + { delete pFontManager; } diff --git a/ASCOfficeOdfFile/src/docx/measuredigits.h b/ASCOfficeOdfFile/src/docx/measuredigits.h index d18c13b549..cf4d239910 100644 --- a/ASCOfficeOdfFile/src/docx/measuredigits.h +++ b/ASCOfficeOdfFile/src/docx/measuredigits.h @@ -34,12 +34,15 @@ #include #include -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { namespace utils { - std::pair GetMaxDigitSizePixels(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CApplicationFonts *appFonts); + std::pair GetMaxDigitSizePixels(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, NSFonts::IApplicationFonts *appFonts); } } diff --git a/ASCOfficeOdfFile/src/docx/oox_package.cpp b/ASCOfficeOdfFile/src/docx/oox_package.cpp index 95664ec43b..72335d5eea 100644 --- a/ASCOfficeOdfFile/src/docx/oox_package.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_package.cpp @@ -38,7 +38,7 @@ #include "mediaitems.h" #include "../../DesktopEditor/common/File.h" -#include "../../DesktopEditor/raster/Metafile/MetaFile.h" +#include "../../DesktopEditor/graphics/pro/Image.h" #include "../../DesktopEditor/raster/ImageFileFormatChecker.h" #include "../../Common/DocxFormat/Source/Base/Base.h" @@ -46,17 +46,19 @@ namespace cpdoccore { namespace oox { namespace package { -static void ConvertSvmToImage(std::wstring &file_svm, std::wstring &file_png, CApplicationFonts *pAppFonts) +static void ConvertSvmToImage(std::wstring &file_svm, std::wstring &file_png, NSFonts::IApplicationFonts *pAppFonts) { - MetaFile::CMetaFile oMetaFile(pAppFonts); + MetaFile::IMetaFile* pMetaFile = MetaFile::Create(pAppFonts); - if (oMetaFile.LoadFromFile(file_svm.c_str())) + if (pMetaFile->LoadFromFile(file_svm.c_str())) { double w, h, x, y; - oMetaFile.GetBounds(&x, &y, &w, &h); - oMetaFile.ConvertToRaster(file_png.c_str(), 4, w); - oMetaFile.Close(); + pMetaFile->GetBounds(&x, &y, &w, &h); + pMetaFile->ConvertToRaster(file_png.c_str(), 4, w); + pMetaFile->Close(); } + + RELEASEOBJECT(pMetaFile); } static std::wstring get_mime_type(const std::wstring & extension) @@ -331,7 +333,7 @@ void docProps_files::write(const std::wstring & RootPath) //////////// -media::media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts) : mediaitems_(_Mediaitems), appFonts_(pAppFonts) +media::media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts) : mediaitems_(_Mediaitems), appFonts_(pAppFonts) { } diff --git a/ASCOfficeOdfFile/src/docx/oox_package.h b/ASCOfficeOdfFile/src/docx/oox_package.h index f56583d3d4..409bb07e17 100644 --- a/ASCOfficeOdfFile/src/docx/oox_package.h +++ b/ASCOfficeOdfFile/src/docx/oox_package.h @@ -42,7 +42,10 @@ #include "../../../Common/DocxFormat/Source/Base/Base.h" #include "../../../DesktopEditor/common/Directory.h" -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { namespace oox { @@ -202,14 +205,14 @@ private: class media : public element { public: - media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts); + media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts); public: virtual void write(const std::wstring & RootPath); private: mediaitems & mediaitems_; - CApplicationFonts * appFonts_; + NSFonts::IApplicationFonts * appFonts_; }; diff --git a/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp index ba54a20ce5..23122b6710 100644 --- a/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp +++ b/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp @@ -45,7 +45,7 @@ #include "pptx_default_serializes.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" namespace cpdoccore { @@ -72,7 +72,7 @@ pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odf ,last_idx_placeHolder (1) ,last_uniq_big_id (1) { - applicationFonts_ = new CApplicationFonts(); + applicationFonts_ = NSFonts::NSApplication::Create(); } pptx_conversion_context::~pptx_conversion_context() diff --git a/ASCOfficeOdfFile/src/docx/pptx_conversion_context.h b/ASCOfficeOdfFile/src/docx/pptx_conversion_context.h index febd2eed39..cae0cb72f0 100644 --- a/ASCOfficeOdfFile/src/docx/pptx_conversion_context.h +++ b/ASCOfficeOdfFile/src/docx/pptx_conversion_context.h @@ -44,7 +44,10 @@ #include "mediaitems.h" -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { @@ -152,7 +155,7 @@ private: package::pptx_document * output_document_; odf_reader::odf_document * odf_document_; - CApplicationFonts * applicationFonts_; + NSFonts::IApplicationFonts * applicationFonts_; pptx_slide_context pptx_slide_context_; pptx_text_context pptx_text_context_; diff --git a/ASCOfficeOdfFile/src/docx/pptx_package.cpp b/ASCOfficeOdfFile/src/docx/pptx_package.cpp index e5ee83e8f2..ac9dd09c00 100644 --- a/ASCOfficeOdfFile/src/docx/pptx_package.cpp +++ b/ASCOfficeOdfFile/src/docx/pptx_package.cpp @@ -504,7 +504,7 @@ void ppt_files::add_notesMaster(slide_content_ptr slide) { notesMaster_files_.add_slide(slide); } -void ppt_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts) +void ppt_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts) { if (_Mediaitems.count_image + _Mediaitems.count_media > 0) { diff --git a/ASCOfficeOdfFile/src/docx/pptx_package.h b/ASCOfficeOdfFile/src/docx/pptx_package.h index d0434dd640..5448f5c50f 100644 --- a/ASCOfficeOdfFile/src/docx/pptx_package.h +++ b/ASCOfficeOdfFile/src/docx/pptx_package.h @@ -35,7 +35,10 @@ #include #include "pptx_comments.h" -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { namespace oox { @@ -214,7 +217,7 @@ public: void add_notes (slide_content_ptr sheet); void add_notesMaster(slide_content_ptr sheet); - void set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts); + void set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts); void add_charts(chart_content_ptr chart); void add_theme (pptx_xml_theme_ptr theme); diff --git a/ASCOfficeOdfFile/src/docx/xlsx_package.cpp b/ASCOfficeOdfFile/src/docx/xlsx_package.cpp index 0ba2be73ef..072fb5438b 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_package.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsx_package.cpp @@ -36,6 +36,8 @@ #include +#include "../../../DesktopEditor/common/Directory.h" + namespace cpdoccore { namespace oox { namespace package { @@ -275,7 +277,7 @@ void xl_files::add_sheet(sheet_content_ptr sheet) sheets_files_.add_sheet(sheet); } -void xl_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts) +void xl_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts) { if (_Mediaitems.count_image + _Mediaitems.count_media > 0) { diff --git a/ASCOfficeOdfFile/src/docx/xlsx_package.h b/ASCOfficeOdfFile/src/docx/xlsx_package.h index c6b05a0260..76628de9a3 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_package.h +++ b/ASCOfficeOdfFile/src/docx/xlsx_package.h @@ -38,7 +38,10 @@ #include "xlsx_drawings.h" #include "xlsx_comments.h" -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { namespace oox { @@ -222,7 +225,7 @@ public: void set_sharedStrings (element_ptr Element); void set_connections (element_ptr Element); void add_sheet (sheet_content_ptr sheet); - void set_media (mediaitems & _Mediaitems, CApplicationFonts *pAppFonts); + void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts); void set_drawings (element_ptr Element); void set_vml_drawings (element_ptr Element); void set_comments (element_ptr Element); diff --git a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp index 9963e589db..95df9d3cfc 100644 --- a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp @@ -45,7 +45,7 @@ #include "../odf/odfcontext.h" #include "../odf/calcs_styles.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" namespace cpdoccore { @@ -76,7 +76,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD mediaitems_ (odf_document_->get_folder()), xlsx_drawing_context_handle_(mediaitems_) { - applicationFonts_ = new CApplicationFonts(); + applicationFonts_ = NSFonts::NSApplication::Create(); } void xlsx_conversion_context::set_output_document (package::xlsx_document * document) diff --git a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h index 9e23dde477..ba1e1489f9 100644 --- a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h +++ b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h @@ -54,7 +54,10 @@ #include "mediaitems.h" -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { @@ -194,7 +197,7 @@ private: const odf_reader::office_element *spreadsheet_; odf_reader::odf_document *odf_document_; - CApplicationFonts *applicationFonts_; + NSFonts::IApplicationFonts *applicationFonts_; std::vector sheets_; std::vector charts_; diff --git a/ASCOfficeOdfFile/src/odf/draw_common.cpp b/ASCOfficeOdfFile/src/odf/draw_common.cpp index 24988f8bd3..0f27922f9f 100644 --- a/ASCOfficeOdfFile/src/odf/draw_common.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_common.cpp @@ -51,20 +51,21 @@ ///////////////////////////////////////////////////////////////////////////////// #include "../../../DesktopEditor/raster/BgraFrame.h" -#include "../../../DesktopEditor/raster/Metafile/MetaFile.h" +#include "../../../DesktopEditor/graphics/pro/Image.h" #include "../../../Common/DocxFormat/Source/XML/Utils.h" namespace _image_file_ { - bool GetResolution(const wchar_t* fileName, int & Width, int &Height, CApplicationFonts * appFonts) + bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts* appFonts) { CBgraFrame image; - MetaFile::CMetaFile meta_file(appFonts); + MetaFile::IMetaFile* meta_file = MetaFile::Create(appFonts); - if ( meta_file.LoadFromFile(fileName)) + bool bRet = false; + if ( meta_file->LoadFromFile(fileName)) { double dX = 0, dY = 0, dW = 0, dH = 0; - meta_file.GetBounds(&dX, &dY, &dW, &dH); + meta_file->GetBounds(&dX, &dY, &dW, &dH); Width = dW; Height = dH; @@ -74,13 +75,13 @@ namespace _image_file_ Width = image.get_Width(); Height = image.get_Height(); - return true; + bRet = true; } - - return false; + RELEASEOBJECT(meta_file); + return bRet; } -}; +} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// namespace cpdoccore { @@ -98,7 +99,7 @@ int get_value_emu(double pt) { return static_cast((pt* 360000 * 2.54) / 72); } -bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, CApplicationFonts * appFonts) +bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts) { memset(clip_rect, 0, 4*sizeof(double)); diff --git a/ASCOfficeOdfFile/src/odf/draw_common.h b/ASCOfficeOdfFile/src/odf/draw_common.h index 54d3b199a7..72de6dca46 100644 --- a/ASCOfficeOdfFile/src/odf/draw_common.h +++ b/ASCOfficeOdfFile/src/odf/draw_common.h @@ -50,11 +50,9 @@ #include "datatypes/targetframename.h" #include "datatypes/common_attlists.h" -//class CApplicationFonts; - namespace _image_file_ { - bool GetResolution(const wchar_t* fileName, int & Width, int &Height, CApplicationFonts * appFonts); + bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts * appFonts); } namespace cpdoccore { @@ -76,7 +74,7 @@ void Compute_GraphicFill(const odf_types::common_draw_fill_attlist & props, const office_element_ptr & style_image, styles_lite_container &styles, oox::_oox_fill & fill, bool txbx = false); typedef double double_4[4]; -bool parse_clipping(std::wstring strClipping,std::wstring fileName,double_4 & clip_rect, CApplicationFonts * appFonts); +bool parse_clipping(std::wstring strClipping,std::wstring fileName,double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class draw_a : public office_element_impl { @@ -118,4 +116,4 @@ void oox_convert_transforms(std::wstring transformStr,std::vector (b) ? (a) : (b)) +#endif + #include "../source/OdfFormat/calcext_elements.cpp" #include "../source/OdfFormat/draw_base.cpp" #include "../source/OdfFormat/draw_frame.cpp" diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.cpp index 61d758f6d8..1248f8ac93 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.cpp @@ -43,7 +43,7 @@ #include "style_paragraph_properties.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" namespace cpdoccore { @@ -60,7 +60,7 @@ odf_conversion_context::odf_conversion_context(_office_type_document type_, pack output_document_ = outputDocument; current_object_ = 0; - applicationFonts_ = new CApplicationFonts(); + applicationFonts_ = NSFonts::NSApplication::Create(); } odf_conversion_context::~odf_conversion_context() diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.h index 2948ff0e0f..40daed73c8 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_conversion_context.h @@ -43,7 +43,10 @@ #include "mediaitems.h" -class CApplicationFonts; +namespace NSFonts +{ + class IApplicationFonts; +} namespace cpdoccore { namespace odf_writer { @@ -87,7 +90,7 @@ public: virtual void end_document(); package::odf_document *output_document_; - CApplicationFonts *applicationFonts_; + NSFonts::IApplicationFonts *applicationFonts_; virtual odf_drawing_context * drawing_context() = 0; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp index f5e800eb7e..1cd7f58b3e 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp @@ -54,7 +54,7 @@ namespace odf_writer { namespace utils { -void calculate_size_font_symbols(_font_metrix & metrix, CApplicationFonts *appFonts) +void calculate_size_font_symbols(_font_metrix & metrix, NSFonts::IApplicationFonts *appFonts) { double appr_px = _graphics_utils_::calculate_size_symbol_asc(metrix.font_name, metrix.font_size, metrix.italic, metrix.bold, appFonts); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp index 2b71550f0b..1a942717f7 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp @@ -60,7 +60,7 @@ namespace odf_writer { namespace utils { -double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name, double font_size, CApplicationFonts *appFonts) +double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name, double font_size, NSFonts::IApplicationFonts *appFonts) { double appr_px = _graphics_utils_::calculate_size_symbol_asc(font_name, font_size, false, false, appFonts); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp index 7fc8924c5b..e9941f5186 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp @@ -29,6 +29,13 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "XlsxConverter.h" #include "PptxConverter.h" #include "DocxConverter.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp index f8bd3e7cff..30cdf3276f 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp @@ -29,6 +29,14 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "Converter.h" #include "../utils.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index 0a204f84b7..8e2a9a00c7 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -30,6 +30,13 @@ * */ +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "Oox2OdfConverter.h" #include "Converter.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp index f0dcb6e5ae..67f1d5f5a5 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp @@ -30,6 +30,13 @@ * */ +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "Converter.h" #include "../utils.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index 061ed5e025..ac52d8646d 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -29,6 +29,13 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "DocxConverter.h" #include "../utils.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp index 532e87adf9..a8d31ba523 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp @@ -29,6 +29,14 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "PptxConverter.h" #include "../utils.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index 9dfd65baed..5df88b3435 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -29,6 +29,14 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + #include "XlsxConverter.h" #include "../../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h" #include "../../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h" diff --git a/ASCOfficeOdfFileW/source/utils.h b/ASCOfficeOdfFileW/source/utils.h index 638994485b..81be1c66f0 100644 --- a/ASCOfficeOdfFileW/source/utils.h +++ b/ASCOfficeOdfFileW/source/utils.h @@ -43,8 +43,6 @@ #include "../../../DesktopEditor/raster/BgraFrame.h" #include "../../../ASCOfficeOdfFile/src/docx/measuredigits.h" -class CFontManager; - namespace _graphics_utils_ { bool static GetResolution(const wchar_t* fileName, double & Width, double &Height) //pt @@ -137,7 +135,7 @@ namespace _graphics_utils_ #endif return result; } - double static calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , CApplicationFonts *appFonts) + double static calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , NSFonts::IApplicationFonts *appFonts) { std::pair val = cpdoccore::utils::GetMaxDigitSizePixels(name, size, 96., 0 , appFonts); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h index 2dabd7e7ae..db2eb45de1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h @@ -353,7 +353,7 @@ namespace NSPresentationEditor { if (NULL == m_pFontManager) { - m_pFontManager = new CFontManager(); + m_pFontManager = NSFonts::NSFontManager::Create(); m_pFontManager->Initialize(); } @@ -375,7 +375,7 @@ namespace NSPresentationEditor public: Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter; // конвертер сложных гафических путей в простые - CFontManager* m_pFontManager; // менеджер шрифтов + NSFonts::IFontManager* m_pFontManager; // менеджер шрифтов Aggplus::CMatrix m_oBaseTransform; // матрица перерасчета координатных осей (здесь: миллиметры -> пикселы) Aggplus::CMatrix m_oTransform; // текущая матрица преобразований рендерера diff --git a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp index 7c897eef7b..c430e17dcd 100644 --- a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp +++ b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp @@ -5648,11 +5648,11 @@ smart_ptr CDrawingConverter::GetRels() { return *m_pBinaryWriter->m_pCurrentContainer; } -void CDrawingConverter::SetFontManager(CFontManager* pFontManager) +void CDrawingConverter::SetFontManager(NSFonts::IFontManager* pFontManager) { if(NULL != m_pBinaryWriter && NULL != m_pBinaryWriter->m_pCommon && NULL != m_pBinaryWriter->m_pCommon->m_pMediaManager) { m_pBinaryWriter->m_pCommon->m_pMediaManager->SetFontManager(pFontManager); } } -} \ No newline at end of file +} diff --git a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h index ef678719b5..ba7c3a51ba 100644 --- a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h +++ b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h @@ -42,8 +42,9 @@ #include #include +#include "./../DesktopEditor/graphics/pro/Fonts.h" + class IRenderer; -class CFontManager; class COfficeFontPicker; class CShape; @@ -258,7 +259,7 @@ namespace NSBinPptxRW void WriteRels (const std::wstring& sType, const std::wstring& sTarget, const std::wstring& sTargetMode, long* lId); void Registration (const std::wstring& sType, const std::wstring& oDirectory, const std::wstring& oFilename); - void SetFontManager (CFontManager* pFontManager); + void SetFontManager (NSFonts::IFontManager* pFontManager); void SetDocumentChartsCount (int val); int GetDocumentChartsCount (); diff --git a/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp b/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp index 5c6ba64f12..acfde4ad4f 100644 --- a/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp +++ b/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp @@ -34,6 +34,7 @@ #include "PPTXFormat/PPTXEvent.h" #if defined(_WIN32) || defined (_WIN64) + #include #include #include #include diff --git a/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/Common.h b/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/Common.h index a2629901e3..ab585937ba 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/Common.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/Common.h @@ -38,6 +38,9 @@ #include +#define _USE_MATH_DEFINES +#include + const double ShapeSize = 43200.0; const LONG ShapeSizeVML = 21600; const double RadKoef = M_PI/10800000.0; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h b/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h index ac051b99d1..65b581be6e 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h @@ -30,13 +30,16 @@ * */ #pragma once -#include "Structures.h" -#include "TextStructures.h" #if !defined(_WIN32) && !defined (_WIN64) #include "../../../DesktopEditor/graphics/aggplustypes.h" +#else + #include #endif +#include "Structures.h" +#include "TextStructures.h" + namespace NSPresentationEditor { class CTheme; diff --git a/ASCOfficePPTXFile/Editor/FontCutter.h b/ASCOfficePPTXFile/Editor/FontCutter.h index 8928a06202..97e305ead8 100644 --- a/ASCOfficePPTXFile/Editor/FontCutter.h +++ b/ASCOfficePPTXFile/Editor/FontCutter.h @@ -32,8 +32,9 @@ #pragma once #include "../../Common/DocxFormat/Source/SystemUtility/File.h" #include "BinReaderWriterDefines.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" #include "../../Common/Base64.h" +#include "../../DesktopEditor/common/Array.h" #include "../../Common/DocxFormat/Source/Base/Nullable.h" #include @@ -115,7 +116,7 @@ namespace NSFontCutter m_strEmbeddedFontsFolder = _T(""); } - void CheckFont(const std::wstring& strName, CFontManager* pManager) + void CheckFont(const std::wstring& strName, NSFonts::IFontManager* pManager) { std::map::const_iterator pPair = m_mapFontsEmbeddded.find(strName); if (pPair != m_mapFontsEmbeddded.end()) @@ -124,10 +125,10 @@ namespace NSFontCutter CEmbeddedFontInfo oInfo; oInfo.Name = strName; - CArray aFontInfos = pManager->GetAllStylesByFontName(strName); - for(int i = 0; i < aFontInfos.GetCount(); ++i) + std::vector aFontInfos = pManager->GetAllStylesByFontName(strName); + for(std::vector::iterator i = aFontInfos.begin(); i != aFontInfos.end(); i++) { - CFontInfo* pFontInfo = aFontInfos[i]; + NSFonts::CFontInfo* pFontInfo = *i; if(0 != pFontInfo->m_bBold && 0 != pFontInfo->m_bItalic) { oInfo.PathBoldItalic = std::wstring(pFontInfo->m_wsFontPath.c_str()); diff --git a/ASCOfficePPTXFile/Editor/FontPicker.h b/ASCOfficePPTXFile/Editor/FontPicker.h index 65a17b5628..8ea233b611 100644 --- a/ASCOfficePPTXFile/Editor/FontPicker.h +++ b/ASCOfficePPTXFile/Editor/FontPicker.h @@ -33,20 +33,16 @@ #include "../../Common/DocxFormat/Source/SystemUtility/File.h" #include "BinReaderWriterDefines.h" - #include "FontCutter.h" - -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" - namespace NSFontCutter { class CFontDstManager { public: std::map m_mapPicks; - CApplicationFonts m_oApplicationFonts; - CFontManager* m_pFontManager; + NSFonts::IApplicationFonts* m_pApplicationFonts; + NSFonts::IFontManager* m_pFontManager; std::wstring m_strFontsDir; @@ -57,6 +53,7 @@ namespace NSFontCutter public: CFontDstManager() : m_mapPicks() { + m_pApplicationFonts = NSFonts::NSApplication::Create(); m_strFontsDir = _T(""); m_pFontManager = NULL; @@ -65,21 +62,16 @@ namespace NSFontCutter ~CFontDstManager() { RELEASEOBJECT(m_pFontManager); + RELEASEOBJECT(m_pApplicationFonts); } void Init(const std::wstring& strDir) { if(strDir.empty()) - m_oApplicationFonts.Initialize(); + m_pApplicationFonts->Initialize(); else - m_oApplicationFonts.InitializeFromFolder(strDir); - CFontList* pFontList = m_oApplicationFonts.GetList(); - if(NULL != pFontList) - { - std::wstring sDefaultFont(_T("Arial")); - pFontList->SetDefaultFont(sDefaultFont); - } - m_pFontManager = m_oApplicationFonts.GenerateFontManager(); + m_pApplicationFonts->InitializeFromFolder(strDir); + m_pFontManager = m_pApplicationFonts->GenerateFontManager(); } std::wstring GetTypefacePickByName(const std::wstring& strTypeface) @@ -108,11 +100,11 @@ namespace NSFontCutter std::wstring sInputSave = sFind; - CFontSelectFormat oFontSelectFormat; + NSFonts::CFontSelectFormat oFontSelectFormat; oFontSelectFormat.wsName = new std::wstring(sFind); //oFontSelectFormat. - CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); + NSFonts::CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); std::wstring sRes = _T("Arial"); if(NULL != pFontInfo) { @@ -150,7 +142,7 @@ public: return S_OK; } - CFontManager* get_FontManager() + NSFonts::IFontManager* get_FontManager() { return m_oPicker.m_pFontManager; } diff --git a/ASCOfficePPTXFile/Editor/imagemanager.h b/ASCOfficePPTXFile/Editor/imagemanager.h index 6518dab4db..d85c780bb7 100644 --- a/ASCOfficePPTXFile/Editor/imagemanager.h +++ b/ASCOfficePPTXFile/Editor/imagemanager.h @@ -45,17 +45,19 @@ using namespace NSFontCutter; #include "../../Common/FileDownloader/FileDownloader.h" #endif +#include #include "WMFToImageConverter.h" +#include "../../HtmlRenderer/include/ASCSVGWriter.h" + #include "../../Common/MediaFormatDefine.h" #include "../../DesktopEditor/raster/ImageFileFormatChecker.h" -#include "../../DesktopEditor/raster/Metafile/MetaFile.h" +#include "../../DesktopEditor/graphics/pro/Image.h" #include "../../DesktopEditor/raster/BgraFrame.h" #include "../../DesktopEditor/graphics/Image.h" #include "../../Common/DocxFormat/Source/SystemUtility/File.h" #include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h" -#include "../../HtmlRenderer/include/ASCSVGWriter.h" -#include + namespace NSShapeImageGen { @@ -174,7 +176,7 @@ namespace NSShapeImageGen CCalculatorCRC32 m_oCRC; LONG m_lDstFormat; NSWMFToImageConverter::CImageExt m_oImageExt; - CFontManager* m_pFontManager; + NSFonts::IFontManager* m_pFontManager; CMediaManager() { @@ -312,7 +314,7 @@ namespace NSShapeImageGen return GenerateMediaID(strFile, L""); } - void SetFontManager(CFontManager* pFontManager) + void SetFontManager(NSFonts::IFontManager* pFontManager) { m_pFontManager = pFontManager; } @@ -332,7 +334,7 @@ namespace NSShapeImageGen if (20 > oFile.GetFileSize()) return false; - ULONG64 max_size = 3 * 1024 * 1024; // 4 Mb + ULONG max_size = 3 * 1024 * 1024; // 4 Mb if (max_size < oFile.GetFileSize()) return false; @@ -517,11 +519,11 @@ namespace NSShapeImageGen OOX::CPath pathSaveItem = strSaveDir + oInfo.GetPath2(); CDirectory::CopyFile(strFileName, pathSaveItem.GetPath()); - ::MetaFile::CMetaFile oMetafile(m_pFontManager->m_pApplication); - if (oMetafile.LoadFromFile(strFileName.c_str())) + ::MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pFontManager->GetApplication()); + if (pMetafile->LoadFromFile(strFileName.c_str())) { double x = 0, y = 0, w = 0, h = 0; - oMetafile.GetBounds(&x, &y, &w, &h); + pMetafile->GetBounds(&x, &y, &w, &h); double _max = (w >= h) ? w : h; double dKoef = 100000.0 / _max; @@ -533,7 +535,7 @@ namespace NSShapeImageGen oWriterSVG.SetFontManager(m_pFontManager); oWriterSVG.put_Width(WW); oWriterSVG.put_Height(HH); - oMetafile.DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH); + pMetafile->DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH); bool bIsRaster = true; oWriterSVG.IsRaster(&bIsRaster); @@ -567,7 +569,7 @@ namespace NSShapeImageGen } std::wstring strSaveItem = strSaveItemWE + L".png"; - oMetafile.ConvertToRaster(strSaveItem.c_str(), 4 /*CXIMAGE_FORMAT_PNG*/, lWidth, lHeight); + pMetafile->ConvertToRaster(strSaveItem.c_str(), 4 /*CXIMAGE_FORMAT_PNG*/, lWidth, lHeight); bool bIsSuccess = NSFile::CFileBinary::Exists(strSaveItem); if (bIsSuccess) @@ -587,6 +589,7 @@ namespace NSShapeImageGen return oInfo; } } + RELEASEOBJECT(pMetafile); } SaveImage(strFileName, oInfo, lWidth, lHeight); diff --git a/ASCOfficePPTXFile/PPTXFormat/Limit/BaseLimit.h b/ASCOfficePPTXFile/PPTXFormat/Limit/BaseLimit.h index b2ba8d1d6e..5a8389a627 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Limit/BaseLimit.h +++ b/ASCOfficePPTXFile/PPTXFormat/Limit/BaseLimit.h @@ -35,26 +35,12 @@ #include "../../../Common/DocxFormat/Source/Base/Base.h" -#if !defined(_WIN32) && !defined (_WIN64) -#include "../../../DesktopEditor/common/Types.h" -#define _USE_STRING_OPERATOR \ +#define _USE_STRING_OPERATOR \ virtual void operator=(const std::wstring& value) \ - { \ - set(value); \ + { \ + set(value); \ } -#else -#define _USE_STRING_OPERATOR \ - virtual void operator=(const std::wstring& value) \ - { \ - set(value); \ - } \ - virtual void operator=(const BSTR& value) \ - { \ - set((std::wstring)value); \ - } -#endif // #if !defined(_WIN32) && !defined (_WIN64) - namespace PPTX diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h index 1cc4454ab8..2fba29c3a9 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h @@ -37,6 +37,8 @@ #include "./../../Limit/SysClrVal.h" #include "../../../Common/DocxFormat/Source/Base/ASCWinAPI.h" // GetSysColor + + namespace PPTX { namespace Logic diff --git a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro index 569bfb0d08..a961c9d0a1 100644 --- a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro +++ b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro @@ -38,11 +38,11 @@ core_windows { } INCLUDEPATH += \ - ../../../../DesktopEditor/freetype-2.5.2/include \ ../../../../Common/ASCDocxFormat/Source/Utility \ ../../../../Common/ASCDocxFormat/Source/XML \ - ../../../../Common/ASCDocxFormat/Source \ - ../../../../DesktopEditor/xml/libxml2/include + ../../../../Common/ASCDocxFormat/Source + +LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lkernel -lgraphics core_release { SOURCES += \ diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp index 95c8d2f8b3..b7b4a9b525 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXShapeReader.cpp @@ -2141,16 +2141,17 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput { if (pOutput.eDataType == RtfPicture::dt_emf || pOutput.eDataType == RtfPicture::dt_wmf) { - MetaFile::CMetaFile meta(NULL); - if (meta.LoadFromFile(sPath.c_str())) + MetaFile::IMetaFile* meta = MetaFile::Create(NULL); + if (meta->LoadFromFile(sPath.c_str())) { double dX, dY, dW, dH; - meta.GetBounds(&dX, &dY, &dW, &dH); - meta.Close(); + meta->GetBounds(&dX, &dY, &dW, &dH); + meta->Close(); pOutput.m_nWidthGoal = (int)(dW * 15); //pixels to twip pOutput.m_nHeightGoal = (int)(dH * 15); //pixels to twip; } + RELEASEOBJECT(meta); //Запоминаем только имя pOutput.m_sPicFilename = sPath; pOutput.m_bIsCopy = false; //не удалять diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp index de5c90ca09..489a36d8ac 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfShape.cpp @@ -37,7 +37,7 @@ #include "../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/PptShape.h" #include "../../../DesktopEditor/raster/BgraFrame.h" -#include "../../../DesktopEditor/raster/Metafile/MetaFile.h" +#include "../../../DesktopEditor/graphics/pro/Image.h" bool RtfShape::GetPictureResolution(RenderParameter oRenderParameter, int & Width, int &Height) { @@ -53,16 +53,17 @@ bool RtfShape::GetPictureResolution(RenderParameter oRenderParameter, int & Widt if (fileName.empty()) return false; - CApplicationFonts appFonts; - appFonts.Initialize(); + NSFonts::IApplicationFonts* appFonts = NSFonts::NSApplication::Create(); + appFonts->Initialize(); CBgraFrame image; - MetaFile::CMetaFile meta_file(/*oRenderParameter.*/&appFonts); + MetaFile::IMetaFile* meta_file = MetaFile::Create(appFonts); - if ( meta_file.LoadFromFile(fileName.c_str())) + bool bRet = false; + if ( meta_file->LoadFromFile(fileName.c_str())) { double dX = 0, dY = 0, dW = 0, dH = 0; - meta_file.GetBounds(&dX, &dY, &dW, &dH); + meta_file->GetBounds(&dX, &dY, &dW, &dH); Width = dW; Height = dH; @@ -72,11 +73,13 @@ bool RtfShape::GetPictureResolution(RenderParameter oRenderParameter, int & Widt Width = image.get_Width(); Height = image.get_Height(); - return true; + bRet = true; } + RELEASEOBJECT(meta_file); + RELEASEOBJECT(appFonts); - return false; + return bRet; } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h b/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h index 43ed0f61aa..8f02d8fa6f 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Utils.h @@ -33,6 +33,12 @@ #include "RtfDefine.h" +#if !defined (_WIN32) && !defined (_WIN64) + #include "iconv.h" +#else + #include +#endif + #include "../../../Common/FileWriter.h" #include "../../../Common/DocxFormat/Source/XML/Utils.h" @@ -40,10 +46,6 @@ #include "UniversalConverterUtils.h" -#if !defined (_WIN32) && !defined (_WIN64) - #include "iconv.h" -#endif - #include #define BUF_SIZE 2048 diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp index 9261c15eff..438a94f0f0 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.cpp @@ -35,14 +35,13 @@ #include -#include "../../../DesktopEditor/fontengine/FontManager.h" -#include "../../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../../DesktopEditor/graphics/pro/Fonts.h" namespace XLS { -std::pair GetMaxDigitSizePixelsImpl(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, CFontManager *pFontManager) +std::pair GetMaxDigitSizePixelsImpl(const std::wstring & fontName, double fontSize, double dpi, long fontStyle, NSFonts::IFontManager *pFontManager) { if (pFontManager == NULL) return std::pair(7,8); @@ -182,7 +181,7 @@ void GlobalWorkbookInfo::GetDigitFontSizePixels() if (applicationFonts == NULL) { - applicationFonts = new CApplicationFonts(); + applicationFonts = NSFonts::NSApplication::Create(); applicationFonts->InitializeFromFolder(fontsDirectory); } @@ -199,13 +198,12 @@ void GlobalWorkbookInfo::GetDigitFontSizePixels() { if (applicationFonts) { - CFontManager *pFontManager = applicationFonts->GenerateFontManager(); + NSFonts::IFontManager *pFontManager = applicationFonts->GenerateFontManager(); std::pair val = GetMaxDigitSizePixelsImpl(fontName, fontSize, 96., 0, pFontManager); if (pFontManager) { - pFontManager->m_pApplication = NULL; delete pFontManager; } @@ -281,4 +279,4 @@ void GlobalWorkbookInfo::CalculateAnchor(int colL, int colR, int rwT, int rwB, _ } -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h index 999d686e38..2a8317d9cb 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h @@ -41,11 +41,11 @@ #include "../Crypt/Decryptor.h" -class XlsConverter; -class CApplicationFonts; +#include "../../../../DesktopEditor/graphics/pro/Fonts.h" +class XlsConverter; namespace XLS -{; +{ class BaseObject; typedef boost::shared_ptr BaseObjectPtr; @@ -155,7 +155,7 @@ public: std::vector<_sheet_info> sheets_info; std::pair defaultDigitFontSize; - CApplicationFonts *applicationFonts; + NSFonts::IApplicationFonts* applicationFonts; std::wstring fontsDirectory; std::wstring tempDirectory; @@ -180,4 +180,4 @@ public: typedef boost::shared_ptr GlobalWorkbookInfoPtr; -} // namespace XLS \ No newline at end of file +} // namespace XLS diff --git a/Common/DocxFormat/Source/Base/ASCWinAPI.h b/Common/DocxFormat/Source/Base/ASCWinAPI.h index 0470c0098d..f25c17f7ac 100644 --- a/Common/DocxFormat/Source/Base/ASCWinAPI.h +++ b/Common/DocxFormat/Source/Base/ASCWinAPI.h @@ -234,6 +234,7 @@ static DWORD GetSysColor(const int nIndex) #else + #include #ifndef COLOR_HOTLIGHT #define COLOR_HOTLIGHT 26 @@ -254,6 +255,5 @@ static DWORD GetSysColor(const int nIndex) #ifndef COLOR_MENUBAR #define COLOR_MENUBAR 30 #endif - #endif //#ifndef _WIN32 #endif // #ifndef _ASC_WIN_API diff --git a/Common/DocxFormat/Source/DocxFormat/Docx.h b/Common/DocxFormat/Source/DocxFormat/Docx.h index 28304cad27..b117a382cc 100644 --- a/Common/DocxFormat/Source/DocxFormat/Docx.h +++ b/Common/DocxFormat/Source/DocxFormat/Docx.h @@ -86,12 +86,7 @@ namespace OOX //return false; // Создаем папку -#if defined(_WIN32) || defined (_WIN64) - CreateDirectoryW( oFilePath.GetPath().c_str(), NULL ); -#else - std::string sFileParthUtf8 = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(oFilePath.GetPath()); - mkdir (sFileParthUtf8.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); -#endif + NSDirectory::CreateDirectory(oFilePath.GetPath()); OOX::CRels oRels; OOX::CContentTypes oContent; diff --git a/Common/DocxFormat/Source/SystemUtility/File.h b/Common/DocxFormat/Source/SystemUtility/File.h index fe1f45d85e..fe05acf8a0 100644 --- a/Common/DocxFormat/Source/SystemUtility/File.h +++ b/Common/DocxFormat/Source/SystemUtility/File.h @@ -32,13 +32,13 @@ #pragma once #include -#include "../../../../DesktopEditor/xml/include/xmlutils.h" -#include "../../../../DesktopEditor/common/File.h" - #include "../../../3dParty/pole/pole.h" #include "../Base/unicode_util.h" #include "../Base/Types_32.h" +#include "../../../../DesktopEditor/xml/include/xmlutils.h" +#include "../../../../DesktopEditor/common/File.h" + class CFile { private: @@ -198,7 +198,7 @@ public: { return _Open(strFileName, false, true, true); } - HRESULT SetPosition( ULONG64 nPos ) + HRESULT SetPosition( ULONG nPos ) { if (m_pFile && nPos <= (ULONG)m_lFileSize) { @@ -211,11 +211,11 @@ public: return !m_pFile ? S_FALSE : S_OK; } } - LONG64 GetPosition() + ULONG GetPosition() { - return m_lFilePosition; + return (ULONG)m_lFilePosition; } - HRESULT SkipBytes(ULONG64 nCount) + HRESULT SkipBytes(ULONG nCount) { return SetPosition(m_lFilePosition + nCount); } @@ -233,7 +233,7 @@ public: return S_OK; } - ULONG64 GetFileSize() + ULONG GetFileSize() { return m_lFileSize; } @@ -475,7 +475,7 @@ namespace CDirectory { return NSFile::CFileBinary::Remove(strFileName); } - static bool CopyFile (std::wstring strExists, std::wstring strNew) + static bool CopyFile (const std::wstring& strExists, const std::wstring& strNew) { return NSFile::CFileBinary::Copy(strExists, strNew); } diff --git a/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp b/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp index 4f97ed0564..7f5bc053e0 100644 --- a/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp +++ b/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp @@ -199,7 +199,7 @@ namespace OOX bool CSystemUtility::CreateFile(const std::wstring& strFileName) { #if defined(_WIN32) || defined (_WIN64) - HANDLE hResult = ::CreateFile(strFileName.c_str(), GENERIC_READ, 0, NULL, + HANDLE hResult = ::CreateFileW(strFileName.c_str(), GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hResult == INVALID_HANDLE_VALUE) diff --git a/DesktopEditor/AllFontsGen/main.cpp b/DesktopEditor/AllFontsGen/main.cpp index 0579b26161..f4249c9a37 100644 --- a/DesktopEditor/AllFontsGen/main.cpp +++ b/DesktopEditor/AllFontsGen/main.cpp @@ -32,8 +32,7 @@ #include #include -#include "../fontengine/ApplicationFonts.h" -#include "../graphics/GraphicsRenderer.h" +#include "../graphics/pro/Graphics.h" #include "../common/File.h" #include "../common/Directory.h" #include "../graphics/Timer.h" diff --git a/DesktopEditor/common/Directory.cpp b/DesktopEditor/common/Directory.cpp index ba27a8606c..d9a64a961a 100644 --- a/DesktopEditor/common/Directory.cpp +++ b/DesktopEditor/common/Directory.cpp @@ -52,8 +52,8 @@ #include #endif -#include "Directory.h" #include +#include "Directory.h" namespace NSDirectory { diff --git a/DesktopEditor/common/Directory.h b/DesktopEditor/common/Directory.h index 2aa649fcaa..9921a8cc86 100644 --- a/DesktopEditor/common/Directory.h +++ b/DesktopEditor/common/Directory.h @@ -29,6 +29,11 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#if defined(CreateDirectory) +#undef CreateDirectory +#endif + #ifndef _BUILD_DIRECTORY_CROSSPLATFORM_H_ #define _BUILD_DIRECTORY_CROSSPLATFORM_H_ @@ -49,10 +54,6 @@ #endif #endif -#if defined(CreateDirectory) -#undef CreateDirectory -#endif - #include "../../Common/kernel_config.h" namespace NSDirectory { diff --git a/DesktopEditor/common/File.h b/DesktopEditor/common/File.h index f322144fba..3f353fa094 100644 --- a/DesktopEditor/common/File.h +++ b/DesktopEditor/common/File.h @@ -29,6 +29,18 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ +#if defined(GetTempPath) +#undef GetTempPath +#endif + +#if defined(CreateFile) +#undef CreateFile +#endif + +#if defined(CopyFile) +#undef CopyFile +#endif + #ifndef _BUILD_FILE_CROSSPLATFORM_H_ #define _BUILD_FILE_CROSSPLATFORM_H_ @@ -45,14 +57,6 @@ #define MAX_PATH 1024 #endif -#if defined(GetTempPath) -#undef GetTempPath -#endif - -#if defined(CreateFile) -#undef CreateFile -#endif - namespace NSFile { #define WriteUtf16_WCHAR(code, p) \ diff --git a/DesktopEditor/common/Types.h b/DesktopEditor/common/Types.h index 9b010f008a..e25da42ae7 100644 --- a/DesktopEditor/common/Types.h +++ b/DesktopEditor/common/Types.h @@ -83,7 +83,7 @@ typedef T_LONG64 __int64; typedef T_ULONG64 ULONG64; typedef T_LONG64 LONG64; -typedef T_ULONG64 UINT64; +typedef T_ULONG64 UINT64; #else #ifdef __APPLE__ @@ -101,6 +101,9 @@ typedef T_ULONG64 UINT64; #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64))) typedef __int64 T_LONG64; typedef unsigned __int64 T_ULONG64; +typedef T_ULONG64 ULONG64; +typedef T_LONG64 LONG64; +typedef T_ULONG64 UINT64; #else #if defined(_MAC) && defined(_MAC_INT_64) typedef __int64 T_LONG64; diff --git a/DesktopEditor/doctrenderer/test/main.cpp b/DesktopEditor/doctrenderer/test/main.cpp index 7eaa99c9ca..7d428b3241 100644 --- a/DesktopEditor/doctrenderer/test/main.cpp +++ b/DesktopEditor/doctrenderer/test/main.cpp @@ -33,7 +33,7 @@ #ifdef USE_PDF_RENDERER #include "../../../PdfWriter/PdfRenderer.h" -#include "../../fontengine/ApplicationFonts.h" +#include "../../graphics/pro/Fonts.h" #endif int main(int argc, char *argv[]) diff --git a/DesktopEditor/freetype_names/FontMaps/FontMaps.cpp b/DesktopEditor/freetype_names/FontMaps/FontMaps.cpp index 321eba5194..b544fb3410 100644 --- a/DesktopEditor/freetype_names/FontMaps/FontMaps.cpp +++ b/DesktopEditor/freetype_names/FontMaps/FontMaps.cpp @@ -34,7 +34,7 @@ #include "../../common/File.h" #include -#include "../../fontengine/ApplicationFonts.h" +#include "../../graphics/pro/Fonts.h" #include "../../common/StringBuilder.h" class CFontInfoJS diff --git a/DesktopEditor/graphics/IRenderer.h b/DesktopEditor/graphics/IRenderer.h index 06551388db..87c8066483 100644 --- a/DesktopEditor/graphics/IRenderer.h +++ b/DesktopEditor/graphics/IRenderer.h @@ -34,9 +34,9 @@ #pragma once +#include #include "../common/IGrObject.h" #include "Matrix.h" -#include // тип в DrawPath const long c_nStroke = 0x0001; diff --git a/DesktopEditor/graphics/MetafileToGraphicsRenderer.h b/DesktopEditor/graphics/MetafileToGraphicsRenderer.h index ce5a8715d1..b0e9b502c3 100644 --- a/DesktopEditor/graphics/MetafileToGraphicsRenderer.h +++ b/DesktopEditor/graphics/MetafileToGraphicsRenderer.h @@ -35,229 +35,52 @@ #pragma once #include "./MetafileToRenderer.h" -#include "GraphicsRenderer.h" namespace NSOnlineOfficeBinToPdf { - class CMetafileToRenderterRaster : public IMetafileToRenderter + class CMetafileToRenderterRaster_private; + class GRAPHICS_DECL CMetafileToRenderterRaster : public IMetafileToRenderter { - public: - std::wstring wsHtmlPlace; - std::wstring wsThemesPlace; - - std::wstring wsTempDir; - - CApplicationFonts* appFonts; - - public: - int m_nRasterFormat; - int m_nSaveType; // 0 = stretch, 1 = aspect (width == maxsize) - bool m_bIsOnlyFirst; - std::wstring m_sFileName; - int m_nRasterW; - int m_nRasterH; - private: - std::vector m_arTempFiles; + CMetafileToRenderterRaster_private* m_internal; public: - CMetafileToRenderterRaster(IRenderer* pRenderer) : IMetafileToRenderter(pRenderer) - { - wsHtmlPlace = L""; - wsThemesPlace = L""; - - wsTempDir = L""; - - appFonts = NULL; - - m_nRasterFormat = 4; - m_nSaveType = 2; - m_bIsOnlyFirst = true; - m_sFileName = L""; - - m_nRasterW = 100; - m_nRasterH = 100; - } - virtual ~CMetafileToRenderterRaster() - { - for (std::vector::iterator i = m_arTempFiles.begin(); i != m_arTempFiles.end(); i++) - { - std::wstring sPath = *i; - if (NSFile::CFileBinary::Exists(sPath)) - NSFile::CFileBinary::Remove(sPath); - } - } + CMetafileToRenderterRaster(IRenderer* pRenderer); + virtual ~CMetafileToRenderterRaster(); public: - virtual std::wstring GetImagePath(const std::wstring& sImagePath) - { - std::wstring wsTempString = sImagePath; - if (0 == wsTempString.find(L"data:")) - { - try - { - int nFind = wsTempString.find(L","); - wsTempString = wsTempString.substr(nFind + 1); + virtual std::wstring GetImagePath(const std::wstring& sImagePath); + bool ConvertBuffer(BYTE* pBuffer, LONG lBufferLen); - std::wstring sTempDirectory = wsTempDir; - if (sTempDirectory.empty()) - sTempDirectory = NSFile::CFileBinary::GetTempPath(); + public: + std::wstring GetHtmlPlace(); + void SetHtmlPlace(const std::wstring& value); - std::wstring sTempFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTempDirectory, L"IMG"); - m_arTempFiles.push_back(sTempFilePath); + std::wstring GetThemesPlace(); + void SetThemesPlace(const std::wstring& value); - std::wstring wsBase64TempFile = sTempFilePath; - std::string sBase64MultyByte(wsTempString.begin(), wsTempString.end()); + std::wstring GetTempDir(); + void SetTempDir(const std::wstring& value); - int nBufferLen = NSBase64::Base64DecodeGetRequiredLength(sBase64MultyByte.length()); - BYTE* pImageBuffer = new BYTE[nBufferLen + 64]; + std::wstring GetFileName(); + void SetFileName(const std::wstring& value); - if (NSBase64::Base64Decode(sBase64MultyByte.c_str(), sBase64MultyByte.length(), pImageBuffer, &nBufferLen)) - { - NSFile::CFileBinary oFile; - if (oFile.CreateFileW(wsBase64TempFile)) - { - oFile.WriteFile(pImageBuffer, nBufferLen); - oFile.CloseFile(); - wsTempString = wsBase64TempFile; - } - } - else throw; - } - catch (...) - { - } - } - else - { - if (0 != wsTempString.find(L"http:") - && 0 != wsTempString.find(L"https:") - && 0 != wsTempString.find(L"ftp:") - && 0 != wsTempString.find(L"file:")) - { - if (0 == wsTempString.find(L"theme")) - { - if (L"" != wsThemesPlace) - wsTempString = wsThemesPlace + L"/" + wsTempString; - } - else - { - if (wsHtmlPlace.length() > 0) - { - if (0 == wsTempString.find(L"media") || NSFile::CFileBinary::Exists(wsHtmlPlace + L"/" + wsTempString)) - wsTempString = wsHtmlPlace + L"/" + wsTempString; - else - wsTempString = wsHtmlPlace + L"/media/" + wsTempString; - } + void SetApplication(NSFonts::IApplicationFonts* pFonts); - std::wstring wsSvgExt(L".svg"); - if (0 == wsTempString.compare(wsTempString.length() - wsSvgExt.length(), std::wstring::npos, wsSvgExt)) - { - std::wstring wsTestPath = wsTempString.substr(0, wsTempString.length() - wsSvgExt.length()); - if (NSFile::CFileBinary::Exists(wsTestPath + L".emf")) - wsTempString = wsTestPath + L".emf"; - else if (NSFile::CFileBinary::Exists(wsTestPath + L".wmf")) - wsTempString = wsTestPath + L".wmf"; - } - } + int GetRasterFormat(); + void SetRasterFormat(const int& value); - NSStringExt::Replace(wsTempString, L"\\", L"/"); - } + int GetSaveType(); + void SetSaveType(const int& value); - if (0 == wsTempString.find(L"file:///")) - { - // TODO: под linux код неправильный - NSStringExt::Replace(wsTempString, L"file:///", L""); - NSStringExt::Replace(wsTempString, L"\\", L"/"); - } - } + int GetRasterW(); + void SetRasterW(const int& value); - return wsTempString; - } + int GetRasterH(); + void SetRasterH(const int& value); - bool ConvertBuffer(BYTE* pBuffer, LONG lBufferLen) - { - std::wstring sMain = m_sFileName; - std::wstring sExt = L""; - if (!m_bIsOnlyFirst) - { - std::wstring::size_type pos = m_sFileName.find_last_of('.'); - if (std::wstring::npos == pos) - return false; - - sMain = m_sFileName.substr(0, pos); - sExt = m_sFileName.substr(pos); - } - - CMetafilePagesInfo oInfo; - oInfo.CheckBuffer(pBuffer, lBufferLen); - - int nPagesCount = oInfo.PagesCount; - if (0 == nPagesCount) - return false; - - if (m_bIsOnlyFirst) - nPagesCount = 1; - - CFontManager* pFontManager = appFonts->GenerateFontManager(); - CFontsCache* pFontsCache = new CFontsCache(); - pFontsCache->SetStreams(appFonts->GetStreams()); - pFontManager->SetOwnerCache(pFontsCache); - - CImageFilesCache* pImagesCache = new CImageFilesCache(appFonts); - - for (int nPageIndex = 0; nPageIndex < nPagesCount; ++nPageIndex) - { - CBgraFrame oFrame; - int nRasterW = m_nRasterW; - int nRasterH = m_nRasterH; - - if (1 == m_nSaveType) - { - double w = oInfo.arSizes[nPageIndex].width; - double h = oInfo.arSizes[nPageIndex].height; - - double dKoef1 = nRasterW / w; - double dKoef2 = nRasterH / h; - if (dKoef1 > dKoef2) - dKoef1 = dKoef2; - - nRasterW = (int)(w * dKoef1 + 0.5); - nRasterH = (int)(h * dKoef1 + 0.5); - } - - oFrame.put_Width(nRasterW); - oFrame.put_Height(nRasterH); - oFrame.put_Stride(4 * nRasterW); - - BYTE* pDataRaster = new BYTE[4 * nRasterW * nRasterH]; - memset(pDataRaster, 0xFF, 4 * nRasterW * nRasterH); - oFrame.put_Data(pDataRaster); - - CGraphicsRenderer oRenderer; - oRenderer.SetFontManager(pFontManager); - oRenderer.SetImageCache(pImagesCache); - - oRenderer.CreateFromBgraFrame(&oFrame); - oRenderer.SetTileImageDpi(96.0); - oRenderer.SetSwapRGB(false); - - this->m_pRenderer = &oRenderer; - BYTE* pBufferPage = oInfo.arSizes[nPageIndex].data; - LONG nLen = lBufferLen - ((LONG)(pBufferPage - pBuffer)); - NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(pBufferPage, nLen, this); - - if (m_bIsOnlyFirst) - oFrame.SaveFile(sMain + sExt, m_nRasterFormat); - else - oFrame.SaveFile(sMain + std::to_wstring(nPageIndex + 1) + sExt, m_nRasterFormat); - } - - RELEASEINTERFACE(pFontManager); - RELEASEINTERFACE(pImagesCache); - - return true; - } + bool GetIsOnlyFirst(); + void SetIsOnlyFirst(const bool& value); }; } diff --git a/DesktopEditor/graphics/MetafileToRenderer.cpp b/DesktopEditor/graphics/MetafileToRenderer.cpp new file mode 100644 index 0000000000..8efdfaf0bb --- /dev/null +++ b/DesktopEditor/graphics/MetafileToRenderer.cpp @@ -0,0 +1,965 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2018 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once + +#include "./MetafileToRendererCheck.h" +#include "agg_math.h" + +IMetafileToRenderter::IMetafileToRenderter(IRenderer* pRenderer) +{ + m_pRenderer = pRenderer; +} +void IMetafileToRenderter::EnableBrushRect(bool bValue) +{ +} +void IMetafileToRenderter::SetLinearGradiant(const double& x0, const double& y0, const double& x1, const double& y1) +{ + double dAngle = 0; + if (fabs(x1 - x0) >= FLT_EPSILON || fabs(y1 - y0) >= FLT_EPSILON) + dAngle = 180 * atan2(y1 - y0, x1 - x0) / agg::pi; + + m_pRenderer->put_BrushType(/*c_BrushTypePathGradient1*/2006); + m_pRenderer->put_BrushLinearAngle(dAngle); +} + +void IMetafileToRenderter::SetRadialGradiant(const double& dX0, const double& dY0, const double& dR0, const double& dX1, const double& dY1, const double& dR1) +{ + // TODO: + m_pRenderer->put_BrushType(/*c_BrushTypePathGradient2*/2007); +} + +namespace NSOnlineOfficeBinToPdf +{ + inline INT32 ReadInt(BYTE*& pData, int& nOffset) + { + #ifdef _ARM_ALIGN_ + INT32 ret = 0; + memcpy(&ret, pData, sizeof(INT32)); + pData += 4; + nOffset += 4; + return ret; + #else + INT32 ret = *((INT32*)pData); + pData += 4; + nOffset += 4; + return ret; + #endif + } + inline void SkipInt(BYTE*& pData, int& nOffset, int nCount = 1) + { + pData += (nCount << 2); + nOffset += (nCount << 2); + } + + inline USHORT ReadUSHORT(BYTE*& pData, int& nOffset) + { + #ifdef _ARM_ALIGN_ + USHORT ret = 0; + memcpy(&ret, pData, sizeof(USHORT)); + pData += 2; + nOffset += 2; + return ret; + #else + USHORT ret = *((USHORT*)pData); + pData += 2; + nOffset += 2; + return ret; + #endif + } + inline void SkipUSHORT(BYTE*& pData, int& nOffset) + { + pData += 2; + nOffset += 2; + } + + inline std::wstring ReadString16(BYTE*& pData, int& nOffset, int nLen) + { + std::wstring wsTempString; + #ifdef _ARM_ALIGN_ + + if (sizeof(wchar_t) == 4) + { + #if !defined(_WIN32) && !defined(_WIN64) + int len = nLen / 2; + unsigned short* buf = new unsigned short[len]; + memcpy(buf, pData, nLen); + wsTempString = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)buf, len); + RELEASEARRAYOBJECTS(buf); + #endif + } + else + { + int len = nLen / 2; + wchar_t* buf = new wchar_t[len]; + memcpy(buf, pData, nLen); + wsTempString = std::wstring(buf, len); + RELEASEARRAYOBJECTS(buf); + } + + #else + + if (sizeof(wchar_t) == 4) + { + #if !defined(_WIN32) && !defined(_WIN64) + wsTempString = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)pData, nLen / 2); + #endif + } + else + { + wsTempString = std::wstring((wchar_t*)pData, nLen / 2); + } + + #endif + pData += nLen; + nOffset += nLen; + return wsTempString; + } + inline void SkipString16(BYTE*& pData, int& nOffset, int nLen) + { + pData += nLen; + nOffset += nLen; + } + + bool ConvertBufferToRenderer(BYTE* pBuffer, LONG lBufferLen, IMetafileToRenderter* pCorrector) + { + IRenderer* pRenderer = pCorrector->m_pRenderer; + + LONG lRendererType = 0; + pRenderer->get_Type(&lRendererType); + + CommandType eCommand = ctError; + + bool bIsPathOpened = false; + int curindex = 0; + + BYTE* current = pBuffer; + while (curindex < lBufferLen) + { + eCommand = (CommandType)(*current); + current++; + curindex++; + switch (eCommand) + { + case ctPageWidth: + { + pRenderer->put_Width(ReadInt(current, curindex) / 100000.0); + break; + } + case ctPageHeight: + { + pRenderer->put_Height(ReadInt(current, curindex) / 100000.0); + break; + } + case ctPageStart: + { + pRenderer->NewPage(); + pRenderer->BeginCommand(c_nPageType); + + // TODO: + pRenderer->put_PenLineStartCap(Aggplus::LineCapFlat); + pRenderer->put_PenLineEndCap(Aggplus::LineCapFlat); + break; + } + case ctPageEnd: + { + if (bIsPathOpened) + { + pRenderer->PathCommandEnd(); + pRenderer->EndCommand(c_nPathType); + } + bIsPathOpened = false; + + pRenderer->EndCommand(c_nPageType); + + if (lRendererType == c_nGrRenderer) + return true; + + break; + } + case ctPenColor: + { + pRenderer->put_PenColor(ReadInt(current, curindex)); + break; + } + case ctPenAlpha: + { + pRenderer->put_PenAlpha(*current); + current++; + curindex++; + break; + } + case ctPenSize: + { + pRenderer->put_PenSize(ReadInt(current, curindex) / 100000.0); + break; + } + case ctPenDashStyle: + { + BYTE nDashType = *current++; + curindex++; + switch (nDashType) + { + case Aggplus::DashStyleCustom: + { + int nCountDash = ReadInt(current, curindex); + if (0 < nCountDash) + { + double* pDash = new double[nCountDash]; + for (int nDash = 0; nDash < nCountDash; ++nDash) + { + pDash[nDash] = ReadInt(current, curindex) / 100000.0; + } + + if (c_nGrRenderer == lRendererType) + { + for (int nDash = 0; nDash < nCountDash; ++nDash) + { + // в отрисовщике - баг. зачем-то умножается на коеф 25.4/dpi + // чтобы не менять там (перед выпуском) - умножаю здесь на обратку + double dDpiX = 0; + pRenderer->get_DpiX(&dDpiX); + pDash[nDash] *= (dDpiX / 25.4); + } + } + + pRenderer->PenDashPattern(pDash, nCountDash); + delete[] pDash; + } + } + default: + pRenderer->put_PenDashStyle(nDashType); + break; + } + + break; + } + case ctPenLineJoin: + { + pRenderer->put_PenLineJoin(*current); + current++; + curindex++; + break; + } + case ctBrushType: + { + pRenderer->put_BrushType(ReadInt(current, curindex)); + break; + } + case ctBrushColor1: + { + pRenderer->put_BrushColor1(ReadInt(current, curindex)); + break; + } + case ctBrushAlpha1: + { + pRenderer->put_BrushAlpha1(*current); + current++; + curindex++; + break; + } + case ctBrushColor2: + { + pRenderer->put_BrushColor1(ReadInt(current, curindex)); + break; + } + case ctBrushAlpha2: + { + pRenderer->put_BrushAlpha2(*current); + current++; + curindex++; + break; + } + case ctBrushRectable: + { + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + double m3 = ReadInt(current, curindex) / 100000.0; + double m4 = ReadInt(current, curindex) / 100000.0; + pRenderer->BrushRect(0, m1, m2, m3, m4); + break; + } + case ctBrushRectableEnabled: + { + bool bEnable = (1 == *current) ? true : false; + pCorrector->EnableBrushRect(bEnable); + + current += 1; + curindex += 1; + break; + } + case ctBrushTexturePath: + { + int nLen = 2 * ReadUSHORT(current, curindex); + std::wstring sTempPath = ReadString16(current, curindex, nLen); + + std::wstring sImagePath = pCorrector->GetImagePath(sTempPath); + pRenderer->put_BrushTexturePath(sImagePath); + break; + } + case ctBrushGradient: + { + current++; + curindex++; + + while (true) + { + BYTE _command = *current; + current++; + curindex++; + + if (251 == _command) + break; + + switch (_command) + { + case 0: + { + current += 5; + curindex += 5; + double x0 = ReadInt(current, curindex) / 100000.0; + double y0 = ReadInt(current, curindex) / 100000.0; + double x1 = ReadInt(current, curindex) / 100000.0; + double y1 = ReadInt(current, curindex) / 100000.0; + + pCorrector->SetLinearGradiant(x0, y0, x1, y1); + break; + } + case 1: + { + current++; + curindex++; + double x0 = ReadInt(current, curindex) / 100000.0; + double y0 = ReadInt(current, curindex) / 100000.0; + double x1 = ReadInt(current, curindex) / 100000.0; + double y1 = ReadInt(current, curindex) / 100000.0; + double r0 = ReadInt(current, curindex) / 100000.0; + double r1 = ReadInt(current, curindex) / 100000.0; + pCorrector->SetRadialGradiant(x0, y0, r0, x1, y1, r1); + break; + } + case 2: + { + LONG lColorsCount = (LONG)ReadInt(current, curindex); + if (0 >= lColorsCount) + { + pRenderer->put_BrushGradientColors(NULL, NULL, 0); + } + else + { + LONG* pColors = new LONG[lColorsCount]; + double* pPositions = new double[lColorsCount]; + + if (!pColors) + break; + + if (!pPositions) + { + delete[] pColors; + break; + } + + for (LONG lIndex = 0; lIndex < lColorsCount; lIndex++) + { + pPositions[lIndex] = ReadInt(current, curindex) / 100000.0; + pColors[lIndex] = ReadInt(current, curindex); + } + + pRenderer->put_BrushGradientColors(pColors, pPositions, lColorsCount); + + delete[] pColors; + delete[] pPositions; + } + + break; + } + default: + { + break; + } + }; + } + + break; + } + case ctBrushTextureMode: + { + LONG lMode = (LONG)(*current); + pRenderer->put_BrushTextureMode(lMode); + + current += 1; + curindex += 1; + break; + } + case ctBrushTextureAlpha: + { + LONG lAlpha = (LONG)(*current); + pRenderer->put_BrushTextureAlpha(lAlpha); + + current += 1; + curindex += 1; + break; + } + case ctSetTransform: + { + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + double m3 = ReadInt(current, curindex) / 100000.0; + double m4 = ReadInt(current, curindex) / 100000.0; + double m5 = ReadInt(current, curindex) / 100000.0; + double m6 = ReadInt(current, curindex) / 100000.0; + pRenderer->SetTransform(m1, m2, m3, m4, m5, m6); + break; + } + case ctPathCommandStart: + { + if (bIsPathOpened) + { + pRenderer->PathCommandEnd(); + pRenderer->EndCommand(c_nPathType); + } + + pRenderer->BeginCommand(c_nPathType); + pRenderer->PathCommandStart(); + + bIsPathOpened = true; + break; + } + case ctPathCommandMoveTo: + { + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + pRenderer->PathCommandMoveTo(m1, m2); + break; + } + case ctPathCommandLineTo: + { + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + pRenderer->PathCommandLineTo(m1, m2); + break; + } + case ctPathCommandCurveTo: + { + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + double m3 = ReadInt(current, curindex) / 100000.0; + double m4 = ReadInt(current, curindex) / 100000.0; + double m5 = ReadInt(current, curindex) / 100000.0; + double m6 = ReadInt(current, curindex) / 100000.0; + pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6); + break; + } + case ctPathCommandClose: + { + pRenderer->PathCommandClose(); + break; + } + case ctPathCommandEnd: + { + if (bIsPathOpened) + { + pRenderer->PathCommandEnd(); + pRenderer->EndCommand(c_nPathType); + bIsPathOpened = false; + } + break; + } + case ctDrawPath: + { + pRenderer->DrawPath(ReadInt(current, curindex)); + break; + } + case ctDrawImageFromFile: + { + int nLen = ReadInt(current, curindex); + std::wstring sTempPath = ReadString16(current, curindex, nLen); + std::wstring sImagePath = pCorrector->GetImagePath(sTempPath); + + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + double m3 = ReadInt(current, curindex) / 100000.0; + double m4 = ReadInt(current, curindex) / 100000.0; + + try + { + pRenderer->DrawImageFromFile(sImagePath, m1, m2, m3, m4); + } + catch (...) + { + } + + break; + } + case ctFontName: + { + int _sLen = 2 * (int)ReadUSHORT(current, curindex); + std::wstring wsTempString = ReadString16(current, curindex, _sLen); + pRenderer->put_FontName(wsTempString); + break; + } + case ctFontSize: + { + double m1 = ReadInt(current, curindex) / 100000.0; + pRenderer->put_FontSize(m1); + break; + } + case ctFontStyle: + { + pRenderer->put_FontStyle(ReadInt(current, curindex)); + break; + } + case ctDrawText: + { + int _sLen = 2 * (int)ReadUSHORT(current, curindex); + std::wstring wsTempString = ReadString16(current, curindex, _sLen); + + double m1 = ReadInt(current, curindex) / 100000.0; + double m2 = ReadInt(current, curindex) / 100000.0; + + pRenderer->CommandDrawText(wsTempString, m1, m2, 0, 0); + break; + } + case ctBeginCommand: + { + if (bIsPathOpened) + { + pRenderer->PathCommandEnd(); + pRenderer->EndCommand(4); + bIsPathOpened = false; + } + pRenderer->BeginCommand((DWORD)(ReadInt(current, curindex))); + break; + } + case ctEndCommand: + { + if (bIsPathOpened) + { + pRenderer->EndCommand(4); + bIsPathOpened = false; + } + pRenderer->EndCommand((DWORD)(ReadInt(current, curindex))); + pRenderer->PathCommandEnd(); + break; + } + case ctGradientFill: + { + // TODO: Эта команда не должна приходить + INT32 gradientType = ReadInt(current, curindex); + + std::wstring sXml, sXmlStop; + if (0 == gradientType) // linearGradient + { + double x1 = ReadInt(current, curindex) / 100000.0; + double x2 = ReadInt(current, curindex) / 100000.0; + double y1 = ReadInt(current, curindex) / 100000.0; + double y2 = ReadInt(current, curindex) / 100000.0; + + int stops = ReadInt(current, curindex); + + for (int i = 0; i < stops; ++i) + { + INT32 color = static_cast(*current); + double opacity = static_cast(static_cast(*(current + 1))) / 255.0; + double offset = static_cast(static_cast(*(current + 2))) / 255.0; + + current += 6 * 4; // 4 + 1 + 1 + curindex += 6 * 4; + } + } + else if (1 == gradientType) + { + double cx = ReadInt(current, curindex) / 100000.0; + double cy = ReadInt(current, curindex) / 100000.0; + double r = ReadInt(current, curindex) / 100000.0; + double fx = ReadInt(current, curindex) / 100000.0; + double fy = ReadInt(current, curindex) / 100000.0; + + int stops = ReadInt(current, curindex); + + for (int i = 0; i < stops; ++i) + { + INT32 color = static_cast(*current); + double opacity = static_cast(static_cast(*(current + 1))) / 255.0; + double offset = static_cast(static_cast(*(current + 2))) / 255.0; + + current += 6 * 4; // 4 + 1 + 1 + curindex += 6 * 4; + } + } + break; + } + case ctGradientFillXML: + { + // TODO: Эта команда не должна приходить + INT32 gradientType = ReadInt(current, curindex); + int _sLen = ReadInt(current, curindex); + std::wstring wsTempString = ReadString16(current, curindex, _sLen); + break; + } + case ctGradientStroke: + { + // TODO: Эта команда не должна приходить + INT32 gradientType = ReadInt(current, curindex); + if (0 == gradientType) // linearGradient + { + double x1 = ReadInt(current, curindex) / 100000.0; + double x2 = ReadInt(current, curindex) / 100000.0; + double y1 = ReadInt(current, curindex) / 100000.0; + double y2 = ReadInt(current, curindex) / 100000.0; + int stops = ReadInt(current, curindex); + + for (int i = 0; i < stops; ++i) + { + INT32 color = static_cast(*current); + double opacity = static_cast(static_cast(*(current + 1))) / 255.0; + double offset = static_cast(static_cast(*(current + 2))) / 255.0; + + current += 6 * 4; // 4 + 1 + 1 + curindex += 6 * 4; + } + } + else if (1 == gradientType) + { + double cx = ReadInt(current, curindex) / 100000.0; + double cy = ReadInt(current, curindex) / 100000.0; + double r = ReadInt(current, curindex) / 100000.0; + double fx = ReadInt(current, curindex) / 100000.0; + double fy = ReadInt(current, curindex) / 100000.0; + int stops = ReadInt(current, curindex); + + for (int i = 0; i < stops; ++i) + { + INT32 color = static_cast(*current); + double opacity = static_cast(static_cast(*(current + 1))) / 255.0; + double offset = static_cast(static_cast(*(current + 2))) / 255.0; + + current += 6 * 4; // 4 + 1 + 1 + curindex += 6 * 4; + } + } + break; + } + case ctGradientStrokeXML: + { + // TODO: Эта команда не должна приходить + INT32 gradientType = ReadInt(current, curindex); + int _sLen = (int)ReadInt(current, curindex); + std::wstring wsTempString = ReadString16(current, curindex, _sLen); + break; + } + default: + { + break; + } + }; // switch (eCommand) + } // while (curindex < len) + + return true; + } + + void CMetafilePagesInfo::CheckBuffer(BYTE* pBuffer, LONG lBufferLen) + { + CommandType eCommand = ctError; + + bool bIsPathOpened = false; + int curindex = 0; + + BYTE* current = pBuffer; + while (curindex < lBufferLen) + { + eCommand = (CommandType)(*current); + current++; + curindex++; + switch (eCommand) + { + case ctPageWidth: + { + arSizes[PagesCount - 1].width = (ReadInt(current, curindex) / 100000.0); + break; + } + case ctPageHeight: + { + arSizes[PagesCount - 1].height = (ReadInt(current, curindex) / 100000.0); + break; + } + case ctPageStart: + { + AddPage(); + arSizes[PagesCount - 1].data = current; + break; + } + case ctPageEnd: + { + break; + } + case ctPenColor: + { + SkipInt(current, curindex); + break; + } + case ctPenAlpha: + { + current++; + curindex++; + break; + } + case ctPenSize: + { + SkipInt(current, curindex); + break; + } + case ctPenDashStyle: + { + BYTE nDashType = *current++; + curindex++; + switch (nDashType) + { + case Aggplus::DashStyleCustom: + { + int nCountDash = ReadInt(current, curindex); + if (0 < nCountDash) + { + SkipInt(current, curindex, nCountDash); + } + } + default: + break; + } + + break; + } + case ctPenLineJoin: + { + current++; + curindex++; + break; + } + case ctBrushType: + { + SkipInt(current, curindex); + break; + } + case ctBrushColor1: + { + SkipInt(current, curindex); + break; + } + case ctBrushAlpha1: + { + current++; + curindex++; + break; + } + case ctBrushColor2: + { + SkipInt(current, curindex); + break; + } + case ctBrushAlpha2: + { + current++; + curindex++; + break; + } + case ctBrushRectable: + { + SkipInt(current, curindex, 4); + break; + } + case ctBrushRectableEnabled: + { + current += 1; + curindex += 1; + break; + } + case ctBrushTexturePath: + { + int nLen = 2 * ReadUSHORT(current, curindex); + SkipString16(current, curindex, nLen); + break; + } + case ctBrushGradient: + { + current++; + curindex++; + + while (true) + { + BYTE _command = *current; + current++; + curindex++; + + if (251 == _command) + break; + + switch (_command) + { + case 0: + { + current += 5; + curindex += 5; + SkipInt(current, curindex, 4); + break; + } + case 1: + { + current++; + curindex++; + SkipInt(current, curindex, 6); + break; + } + case 2: + { + LONG lColorsCount = (LONG)ReadInt(current, curindex); + if (0 <= lColorsCount) + { + SkipInt(current, curindex, 2 * lColorsCount); + } + + break; + } + default: + { + break; + } + }; + } + + break; + } + case ctBrushTextureMode: + { + current += 1; + curindex += 1; + break; + } + case ctBrushTextureAlpha: + { + current += 1; + curindex += 1; + break; + } + case ctSetTransform: + { + SkipInt(current, curindex, 6); + break; + } + case ctPathCommandStart: + { + break; + } + case ctPathCommandMoveTo: + { + SkipInt(current, curindex, 2); + break; + } + case ctPathCommandLineTo: + { + SkipInt(current, curindex, 2); + break; + } + case ctPathCommandCurveTo: + { + SkipInt(current, curindex, 6); + break; + } + case ctPathCommandClose: + { + break; + } + case ctPathCommandEnd: + { + break; + } + case ctDrawPath: + { + SkipInt(current, curindex); + break; + } + case ctDrawImageFromFile: + { + int nLen = ReadInt(current, curindex); + SkipString16(current, curindex, nLen); + + SkipInt(current, curindex, 4); + break; + } + case ctFontName: + { + int nLen = 2 * (int)ReadUSHORT(current, curindex); + SkipString16(current, curindex, nLen); + break; + } + case ctFontSize: + { + SkipInt(current, curindex); + break; + } + case ctFontStyle: + { + SkipInt(current, curindex); + break; + } + case ctDrawText: + { + int nLen = 2 * (int)ReadUSHORT(current, curindex); + SkipString16(current, curindex, nLen); + + SkipInt(current, curindex, 2); + break; + } + case ctBeginCommand: + { + SkipInt(current, curindex); + break; + } + case ctEndCommand: + { + SkipInt(current, curindex); + break; + } + case ctGradientFill: + case ctGradientFillXML: + case ctGradientStroke: + case ctGradientStrokeXML: + { + // TODO: Эта команда не должна приходить + return; + } + default: + { + break; + } + }; // switch (eCommand) + } // while (curindex < len) + } +} diff --git a/DesktopEditor/graphics/MetafileToRendererCheck.h b/DesktopEditor/graphics/MetafileToRendererCheck.h new file mode 100644 index 0000000000..97e6dae5ca --- /dev/null +++ b/DesktopEditor/graphics/MetafileToRendererCheck.h @@ -0,0 +1,83 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2018 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#ifndef _BUILD_METAFILE_TO_IRENDERER_CHECK_H_ +#define _BUILD_METAFILE_TO_IRENDERER_CHECK_H_ + +#pragma once + +#include "MetafileToRenderer.h" +#include "../common/Array.h" + +namespace NSOnlineOfficeBinToPdf +{ + class CMetafilePageInfo + { + public: + double width; + double height; + + BYTE* data; + + public: + CMetafilePageInfo() + { + width = 0; + height = 0; + + data = NULL; + } + }; + + class CMetafilePagesInfo + { + public: + int PagesCount; + CArray arSizes; + + public: + CMetafilePagesInfo() + { + PagesCount = 0; + } + + public: + inline void AddPage() + { + ++PagesCount; + arSizes.Add(); + } + + void CheckBuffer(BYTE* pBuffer, LONG lBufferLen); + }; +} + +#endif // _BUILD_METAFILE_TO_IRENDERER_H_ diff --git a/DesktopEditor/graphics/TemporaryCS.cpp b/DesktopEditor/graphics/TemporaryCS.cpp index 8929ad9523..7eef875caa 100644 --- a/DesktopEditor/graphics/TemporaryCS.cpp +++ b/DesktopEditor/graphics/TemporaryCS.cpp @@ -156,6 +156,27 @@ namespace NSCriticalSection if (NULL != m_pCS) m_pCS->Leave(); } + + CRITICAL_SECTION_SMART::CRITICAL_SECTION_SMART() + { + m_pCS = new CRITICAL_SECTION(); + m_pCS->InitializeCriticalSection(); + } + CRITICAL_SECTION_SMART::~CRITICAL_SECTION_SMART() + { + m_pCS->DeleteCriticalSection(); + RELEASEOBJECT(m_pCS); + } + void CRITICAL_SECTION_SMART::Enter() + { + if (NULL != m_pCS) + m_pCS->Enter(); + } + void CRITICAL_SECTION_SMART::Leave() + { + if (NULL != m_pCS) + m_pCS->Leave(); + } } CTemporaryCS::CTemporaryCS(NSCriticalSection::CRITICAL_SECTION* cs) diff --git a/DesktopEditor/graphics/TemporaryCS.h b/DesktopEditor/graphics/TemporaryCS.h index 8e1d6e8551..1027d7a67a 100644 --- a/DesktopEditor/graphics/TemporaryCS.h +++ b/DesktopEditor/graphics/TemporaryCS.h @@ -52,6 +52,19 @@ namespace NSCriticalSection void Enter(); void Leave(); }; + + class KERNEL_DECL CRITICAL_SECTION_SMART + { + private: + CRITICAL_SECTION* m_pCS; + + public: + CRITICAL_SECTION_SMART(); + ~CRITICAL_SECTION_SMART(); + + void Enter(); + void Leave(); + }; } class KERNEL_DECL CTemporaryCS diff --git a/DesktopEditor/graphics/pro/Fonts.h b/DesktopEditor/graphics/pro/Fonts.h index 45548603d2..a8aef0ffb8 100644 --- a/DesktopEditor/graphics/pro/Fonts.h +++ b/DesktopEditor/graphics/pro/Fonts.h @@ -463,6 +463,10 @@ namespace NSFonts virtual bool IsSymbolic(bool bIsOS2Check = false) = 0; virtual int IsUnicodeRangeAvailable(unsigned long ulBit, unsigned int un4ByteIndex) = 0; + + virtual void CheckTextMatrix() = 0; + virtual bool SetTextMatrix(const double& fA, const double& fB, const double& fC, const double fD, double fE, double fF) = 0; + virtual void SetFontMatrix(const double& fA, const double& fB, const double& fC, const double fD, double fE, double fF) = 0; }; namespace NSFontFile diff --git a/DesktopEditor/graphics/pro/graphics.pro b/DesktopEditor/graphics/pro/graphics.pro index afd0a91bc9..946309441b 100644 --- a/DesktopEditor/graphics/pro/graphics.pro +++ b/DesktopEditor/graphics/pro/graphics.pro @@ -119,6 +119,7 @@ SOURCES += \ ./../GraphicsRenderer.cpp \ ./../Image.cpp \ ./../MetafileToRenderer.cpp \ + ./../MetafileToGraphicsRenderer.cpp \ \ ./../../fontengine/ApplicationFonts.cpp \ ./../../fontengine/FontFile.cpp \ diff --git a/DesktopEditor/xml/include/xmlutils.h b/DesktopEditor/xml/include/xmlutils.h index d471601688..8f9704eb34 100644 --- a/DesktopEditor/xml/include/xmlutils.h +++ b/DesktopEditor/xml/include/xmlutils.h @@ -36,7 +36,7 @@ #include #include -#include "../../DesktopEditor/common/StringBuilder.h" +#include "../../common/StringBuilder.h" namespace XmlUtils { @@ -271,6 +271,9 @@ public: void WriteAttribute(const std::wstring& strAttributeName, int nValue, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = (L"")); void WriteAttribute(const std::wstring& strAttributeName, double dValue); }; + + std::wstring KERNEL_DECL GetNameNoNS(const std::wstring & strNodeName); + std::wstring KERNEL_DECL GetNamespace(const std::wstring& strNodeName); } #endif // _BUILD_XMLUTILS_CROSSPLATFORM_H_ diff --git a/DocxRenderer/src/logic/FontManagerBase.h b/DocxRenderer/src/logic/FontManagerBase.h index 1d529da5e4..617877493c 100644 --- a/DocxRenderer/src/logic/FontManagerBase.h +++ b/DocxRenderer/src/logic/FontManagerBase.h @@ -2,7 +2,7 @@ #define DOCX_RENDERER_FMB_H #include "Common.h" -#include "../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../DesktopEditor/graphics/pro/Fonts.h" namespace NSFontManager { diff --git a/HtmlRenderer/include/ASCSVGWriter.h b/HtmlRenderer/include/ASCSVGWriter.h index fecceb5763..67f88edeab 100644 --- a/HtmlRenderer/include/ASCSVGWriter.h +++ b/HtmlRenderer/include/ASCSVGWriter.h @@ -33,13 +33,9 @@ #define _ASC_HTMLRENDERER_SVG_WRITER_H_ #include "../../DesktopEditor/graphics/IRenderer.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" +#include "../../DesktopEditor/graphics/GraphicsPath.h" -namespace Aggplus -{ - class CMatrix; - class CGraphicsPathSimpleConverter; -} -class CFontManager; namespace NSHtmlRenderer { class CSVGGraphicsWriter; @@ -187,14 +183,14 @@ namespace NSHtmlRenderer HRESULT CommandString(const LONG& lType, const std::wstring& sCommand); public: - void SetFontManager(CFontManager* pFontManager); + void SetFontManager(NSFonts::IFontManager* pFontManager); private: NSHtmlRenderer::CSVGGraphicsWriter* m_pVectorWriter; Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter; // конвертер сложных гафических путей в простые - CFontManager* m_pFontManager; // менеджер шрифтов + NSFonts::IFontManager* m_pFontManager; // менеджер шрифтов bool m_bDeleteFontManager; Aggplus::CMatrix* m_pBaseTransform; // матрица перерасчета координатных осей (здесь: миллиметры -> пикселы) diff --git a/HtmlRenderer/src/ASCSVGWriter.cpp b/HtmlRenderer/src/ASCSVGWriter.cpp index 1eec1658a2..c06e72ef1e 100644 --- a/HtmlRenderer/src/ASCSVGWriter.cpp +++ b/HtmlRenderer/src/ASCSVGWriter.cpp @@ -67,7 +67,7 @@ namespace NSHtmlRenderer m_pFontManager = NULL; if (bIsInitializeFonts) { - m_pFontManager = new CFontManager(); + m_pFontManager = NSFonts::NSFontManager::Create(); m_pFontManager->Initialize(); } @@ -925,7 +925,7 @@ namespace NSHtmlRenderer return S_OK; } // -------------------------------------------------------------------------------------------- - void CASCSVGWriter::SetFontManager(CFontManager* pFontManager) + void CASCSVGWriter::SetFontManager(NSFonts::IFontManager* pFontManager) { if(NULL != pFontManager) { @@ -1026,10 +1026,10 @@ namespace NSHtmlRenderer m_pFontManager->LoadFontFromFile(m_pFont->Path, (float)dSizeFont, m_dDpiX, m_dDpiY, 0); } - if (bIsTransform && NULL != m_pFontManager->m_pFont) + if (bIsTransform && NULL != m_pFontManager->GetFile()) { - m_pFontManager->m_pFont->SetFontMatrix(m_dTextScale, 0, 0, m_dTextScale, 0, 0); - m_pFontManager->m_pFont->CheckTextMatrix(); + m_pFontManager->GetFile()->SetFontMatrix(m_dTextScale, 0, 0, m_dTextScale, 0, 0); + m_pFontManager->GetFile()->CheckTextMatrix(); } *m_pInstalledFont = *m_pFont; diff --git a/PdfWriter/Src/FontCidTT.cpp b/PdfWriter/Src/FontCidTT.cpp index 55182925f9..8a82c26d82 100644 --- a/PdfWriter/Src/FontCidTT.cpp +++ b/PdfWriter/Src/FontCidTT.cpp @@ -35,7 +35,7 @@ #include "Utils.h" #include "FontTTWriter.h" -#include "../../DesktopEditor/fontengine/FontManager.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" #include "../../DesktopEditor/common/File.h" #include diff --git a/X2tConverter/build/Qt/X2tConverter.pri b/X2tConverter/build/Qt/X2tConverter.pri index 84d302aea3..61370a755d 100755 --- a/X2tConverter/build/Qt/X2tConverter.pri +++ b/X2tConverter/build/Qt/X2tConverter.pri @@ -40,13 +40,10 @@ core_linux_64 { DEFINES += UNICODE \ _UNICODE \ - _USE_LIBXML2_READER_ \ #DISABLE_FILE_DOWNLOADER \ FILTER_FLATE_DECODE_ENABLED \ - CXIMAGE_DONT_DECLARE_TCHAR \ DONT_WRITE_EMBEDDED_FONTS \ - AVS_USE_CONVERT_PPTX_TOCUSTOM_VML \ - LIBXML_READER_ENABLED + AVS_USE_CONVERT_PPTX_TOCUSTOM_VML DEFINES += PDFREADER_USE_DYNAMIC_LIBRARY DEFINES += PDFWRITER_USE_DYNAMIC_LIBRARY @@ -57,19 +54,9 @@ DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY DEFINES += FILE_FORMAT_CHECKER_WITH_MACRO -core_windows { - INCLUDEPATH += ../../../OfficeUtils/src/zlib-1.2.3 -} -core_mac { - INCLUDEPATH += ../../../OfficeUtils/src/zlib-1.2.3 -} - -INCLUDEPATH += ../../../DesktopEditor/xml/build/qt - - -INCLUDEPATH += ../../../DesktopEditor/xml/libxml2/include -INCLUDEPATH += ../../../DesktopEditor/freetype-2.5.2/include -INCLUDEPATH += ../../../DesktopEditor/agg-2.4/include +DEFINES += KERNEL_USE_DYNAMIC_LIBRARY +DEFINES += GRAPHICS_USE_DYNAMIC_LIBRARY +LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lkernel -lgraphics INCLUDEPATH += $$PWD/../../../Common/DocxFormat DEPENDPATH += $$PWD/../../../Common/DocxFormat @@ -90,13 +77,10 @@ DEPENDPATH += $$PWD/../../../ASCOfficeDocxFile2 SOURCES += ../../src/cextracttools.cpp \ ../../../Common/OfficeFileFormatChecker2.cpp \ - ../../src/ASCConverters.cpp \ - ../../../DesktopEditor/xml/src/xmllight.cpp \ - ../../../DesktopEditor/xml/src/xmldom.cpp + ../../src/ASCConverters.cpp HEADERS += ../../src/cextracttools.h \ ../../../Common/OfficeFileFormatChecker.h \ - ../../src/ASCConverters.h \ - ../../../DesktopEditor/graphics/MetafileToGraphicsRenderer.h + ../../src/ASCConverters.h #Xls file @@ -121,10 +105,6 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lASCOfficeDocxFile2Lib LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lPPTXFormatLib #docxformat LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lDocxFormatLib -#office utils -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lOfficeUtils -#graphics -LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lgraphics #doctrenderer LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer #HtmlRenderer @@ -148,19 +128,10 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri) core_windows { LIBS += -lAdvapi32 - LIBS += -lurlmon - LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxml } core_linux { LIBS += -lz - LIBS += -lxml2 - LIBS += -lcurl -} - -mac { - LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxml - LIBS += -framework AppKit } ######################################################## diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index b2c4054cb6..e7373ceafa 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -35,8 +35,6 @@ #include "../../PdfWriter/OnlineOfficeBinToPdf.h" #include "cextracttools.h" -#include "../../DesktopEditor/common/Path.h" -#include "../../DesktopEditor/common/Directory.h" #include "../../OfficeUtils/src/OfficeUtils.h" #include "../../Common/3dParty/pole/pole.h" @@ -52,7 +50,7 @@ #include "../../ASCOfficeOdfFileW/source/Oox2OdfConverter/Oox2OdfConverter.h" #include "../../DesktopEditor/doctrenderer/doctrenderer.h" #include "../../DesktopEditor/doctrenderer/docbuilder.h" -#include "../../DesktopEditor/fontengine/ApplicationFonts.h" +#include "../../DesktopEditor/graphics/pro/Fonts.h" #include "../../DesktopEditor/graphics/MetafileToGraphicsRenderer.h" #include "../../PdfReader/PdfReader.h" #include "../../PdfReader/Src/ErrorConstants.h" @@ -63,19 +61,22 @@ #include "../../ASCOfficeXlsFile2/source/XlsXlsxConverter/ConvertXls2Xlsx.h" #include "../../OfficeCryptReader/source/ECMACryptFile.h" +#include "../../DesktopEditor/common/Path.h" +#include "../../DesktopEditor/common/Directory.h" + #include #include namespace NExtractTools { - void initApplicationFonts(CApplicationFonts& oApplicationFonts, InputParams& params) + void initApplicationFonts(NSFonts::IApplicationFonts* pApplicationFonts, InputParams& params) { std::wstring sFontPath = params.getFontPath(); if(sFontPath.empty()) - oApplicationFonts.Initialize(); + pApplicationFonts->Initialize(); else - oApplicationFonts.InitializeFromFolder(sFontPath); + pApplicationFonts->InitializeFromFolder(sFontPath); } std::wstring getExtentionByRasterFormat(int format) { @@ -1122,72 +1123,76 @@ namespace NExtractTools // bin -> pdf int bin2pdf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) { - CApplicationFonts oApplicationFonts; - initApplicationFonts(oApplicationFonts, params); - CPdfRenderer pdfWriter(&oApplicationFonts); + NSFonts::IApplicationFonts* pApplicationFonts; + initApplicationFonts(pApplicationFonts, params); + CPdfRenderer pdfWriter(pApplicationFonts); pdfWriter.SetTempFolder(sTemp); pdfWriter.SetThemesPlace(sThemeDir); int nReg = (bPaid == false) ? 0 : 1; + int nRet = 0; if (params.getIsNoBase64()) { - return S_OK == pdfWriter.OnlineWordToPdfFromBinary(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + nRet = S_OK == pdfWriter.OnlineWordToPdfFromBinary(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } else { - return S_OK == pdfWriter.OnlineWordToPdf(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + nRet = S_OK == pdfWriter.OnlineWordToPdf(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } + RELEASEOBJECT(pApplicationFonts); + return nRet; } int bin2image (const std::wstring &sTFileDir, BYTE* pBuffer, LONG lBufferLen, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params) { long nRes = 0; - CApplicationFonts oApplicationFonts; - initApplicationFonts(oApplicationFonts, params); + NSFonts::IApplicationFonts* pApplicationFonts; + initApplicationFonts(pApplicationFonts, params); NSOnlineOfficeBinToPdf::CMetafileToRenderterRaster imageWriter(NULL); - imageWriter.wsHtmlPlace = sTFileDir; - imageWriter.wsThemesPlace = sThemeDir; - imageWriter.wsTempDir = sTemp; - imageWriter.appFonts = &oApplicationFonts; + imageWriter.SetHtmlPlace(sTFileDir); + imageWriter.SetThemesPlace(sThemeDir); + imageWriter.SetTempDir(sTemp); + imageWriter.SetApplication(pApplicationFonts); if(NULL != params.m_oThumbnail) { InputParamsThumbnail* oThumbnail = params.m_oThumbnail; if(NULL != oThumbnail->format) { - imageWriter.m_nRasterFormat = *oThumbnail->format; + imageWriter.SetRasterFormat(*oThumbnail->format); } if(NULL != oThumbnail->aspect) { - imageWriter.m_nSaveType = *oThumbnail->aspect; + imageWriter.SetSaveType(*oThumbnail->aspect); } if(NULL != oThumbnail->first) { - imageWriter.m_bIsOnlyFirst = *oThumbnail->first; + imageWriter.SetIsOnlyFirst(*oThumbnail->first); } if(NULL != oThumbnail->width) { - imageWriter.m_nRasterW = *oThumbnail->width; + imageWriter.SetRasterW(*oThumbnail->width); } if(NULL != oThumbnail->height) { - imageWriter.m_nRasterH = *oThumbnail->height; + imageWriter.SetRasterH(*oThumbnail->height); } } std::wstring sThumbnailDir; - if(imageWriter.m_bIsOnlyFirst) + if(imageWriter.GetIsOnlyFirst()) { - imageWriter.m_sFileName = sTo; + imageWriter.SetFileName(sTo); } else { sThumbnailDir = sTemp + FILE_SEPARATOR_STR + L"thumbnails"; NSDirectory::CreateDirectory(sThumbnailDir); - imageWriter.m_sFileName = sThumbnailDir + FILE_SEPARATOR_STR + L"image" + getExtentionByRasterFormat(imageWriter.m_nRasterFormat); + imageWriter.SetFileName(sThumbnailDir + FILE_SEPARATOR_STR + L"image" + getExtentionByRasterFormat(imageWriter.GetRasterFormat())); } nRes = imageWriter.ConvertBuffer(pBuffer, lBufferLen) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; - if(!imageWriter.m_bIsOnlyFirst) + if(!imageWriter.GetIsOnlyFirst()) { COfficeUtils oCOfficeUtils(NULL); nRes = S_OK == oCOfficeUtils.CompressFileOrDirectory(sThumbnailDir, sTo) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; } + RELEASEOBJECT(pApplicationFonts); return nRes; } int bin2imageBase64 (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, const std::wstring &sThemeDir, InputParams& params) @@ -1251,13 +1256,14 @@ namespace NExtractTools } else { - CApplicationFonts oApplicationFonts; - initApplicationFonts(oApplicationFonts, params); - CPdfRenderer pdfWriter(&oApplicationFonts); + NSFonts::IApplicationFonts* pApplicationFonts; + initApplicationFonts(pApplicationFonts, params); + CPdfRenderer pdfWriter(pApplicationFonts); pdfWriter.SetTempFolder(sTemp); pdfWriter.SetThemesPlace(sThemeDir); int nReg = (bPaid == false) ? 0 : 1; nRes = (S_OK == pdfWriter.OnlineWordToPdfFromBinary(sPdfBinFile, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + RELEASEOBJECT(pApplicationFonts); } //удаляем sPdfBinFile, потому что он не в Temp if (NSFile::CFileBinary::Exists(sPdfBinFile)) @@ -2796,13 +2802,14 @@ namespace NExtractTools { sFilePathOut += _T(".pdf"); - CApplicationFonts oApplicationFonts; - initApplicationFonts(oApplicationFonts, params); - CPdfRenderer pdfWriter(&oApplicationFonts); + NSFonts::IApplicationFonts* pApplicationFonts; + initApplicationFonts(pApplicationFonts, params); + CPdfRenderer pdfWriter(pApplicationFonts); pdfWriter.SetTempFolder(sTemp); pdfWriter.SetThemesPlace(sThemeDir); int nReg = (bPaid == false) ? 0 : 1; nRes = (S_OK == pdfWriter.OnlineWordToPdfFromBinary(sFilePathIn, sFilePathOut)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + RELEASEOBJECT(pApplicationFonts); } else if (NSDoctRenderer::DoctRendererFormat::FormatFile::HTML == eTypeTo) { @@ -2822,7 +2829,7 @@ namespace NExtractTools } return nRes; } - int PdfDjvuXpsToRenderer(IOfficeDrawingFile** ppReader, IRenderer* pRenderer, const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, CApplicationFonts* pApplicationFonts) + int PdfDjvuXpsToRenderer(IOfficeDrawingFile** ppReader, IRenderer* pRenderer, const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, NSFonts::IApplicationFonts* pApplicationFonts) { int nRes = 0; IOfficeDrawingFile* pReader = NULL; @@ -2899,7 +2906,7 @@ namespace NExtractTools return nRes; } - int PdfDjvuXpsToImage(IOfficeDrawingFile** ppReader, const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, CApplicationFonts* pApplicationFonts) + int PdfDjvuXpsToImage(IOfficeDrawingFile** ppReader, const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params, NSFonts::IApplicationFonts* pApplicationFonts) { int nRes = 0; IOfficeDrawingFile* pReader = NULL; @@ -3630,8 +3637,8 @@ namespace NExtractTools int fromCrossPlatform(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, InputParams& params) { int nRes = 0; - CApplicationFonts oApplicationFonts; - initApplicationFonts(oApplicationFonts, params); + NSFonts::IApplicationFonts* pApplicationFonts; + initApplicationFonts(pApplicationFonts, params); if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo) { if(nFormatFrom == nFormatTo) @@ -3640,10 +3647,10 @@ namespace NExtractTools } else { - CPdfRenderer pdfWriter(&oApplicationFonts); + CPdfRenderer pdfWriter(pApplicationFonts); pdfWriter.SetTempFolder(sTemp); IOfficeDrawingFile* pReader = NULL; - nRes = PdfDjvuXpsToRenderer(&pReader, &pdfWriter, sFrom, nFormatFrom, sTo, sTemp, params, &oApplicationFonts); + nRes = PdfDjvuXpsToRenderer(&pReader, &pdfWriter, sFrom, nFormatFrom, sTo, sTemp, params, pApplicationFonts); pdfWriter.SaveToFile(sTo); RELEASEOBJECT(pReader); } @@ -3659,20 +3666,21 @@ namespace NExtractTools NSHtmlRenderer::CASCHTMLRenderer3 oHtmlRenderer; oHtmlRenderer.CreateOfficeFile(sToDir); IOfficeDrawingFile* pReader = NULL; - nRes = PdfDjvuXpsToRenderer(&pReader, &oHtmlRenderer, sFrom, nFormatFrom, sTo, sTemp, params, &oApplicationFonts); + nRes = PdfDjvuXpsToRenderer(&pReader, &oHtmlRenderer, sFrom, nFormatFrom, sTo, sTemp, params, pApplicationFonts); oHtmlRenderer.CloseFile(params.getIsNoBase64()); RELEASEOBJECT(pReader); } else if(0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo)) { IOfficeDrawingFile* pReader = NULL; - nRes = PdfDjvuXpsToImage(&pReader, sFrom, nFormatFrom, sTo, sTemp, params, &oApplicationFonts); + nRes = PdfDjvuXpsToImage(&pReader, sFrom, nFormatFrom, sTo, sTemp, params, pApplicationFonts); RELEASEOBJECT(pReader); } else { nRes = AVS_FILEUTILS_ERROR_CONVERT; } + RELEASEOBJECT(pApplicationFonts); return nRes; } int fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, InputParams& params)