From b8f1d41eef51c880152a260ab36daab024ced5f2 Mon Sep 17 00:00:00 2001 From: "Oleg.Korshul" Date: Thu, 23 Jul 2015 15:08:51 +0000 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=D1=8E=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=20=D0=BC=D0=B5=D1=85=D0=B0=D0=BD=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=20=D0=B1=D0=B8=D0=BB=D0=B4=D0=B0=20=D1=81=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B9=20=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD=D0=B0=D0=BC=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63675 954022d7-b5bf-4e40-9824-e11837661b57 --- HtmlRenderer/test/main.cpp | 30 ++++++++++++++++++++++++-- HtmlRenderer/test/test.pro | 6 +++--- XpsFile/XpsFile.cpp | 4 +++- XpsFile/XpsFile.h | 11 ++++++++-- XpsFile/XpsLib/Document.cpp | 4 ++-- XpsFile/XpsLib/Document.h | 7 +----- XpsFile/XpsLib/Page.cpp | 34 +++++++++++++++--------------- XpsFile/XpsLib/Page.h | 4 ++-- XpsFile/XpsLib/StaticResources.cpp | 6 +++--- XpsFile/XpsLib/Utils.cpp | 15 ++++++------- XpsFile/XpsLib/Utils.h | 4 ++-- XpsFile/XpsLib/WString.cpp | 19 ++++++++++++++++- XpsFile/XpsLib/WString.h | 7 +++++- 13 files changed, 101 insertions(+), 50 deletions(-) diff --git a/HtmlRenderer/test/main.cpp b/HtmlRenderer/test/main.cpp index 3ce2e2d41e..b2df32cdb0 100644 --- a/HtmlRenderer/test/main.cpp +++ b/HtmlRenderer/test/main.cpp @@ -4,6 +4,7 @@ #include "../../PdfReader/PdfReader.h" #include "../../DjVuFile/DjVu.h" +#include "../../XpsFile/XpsFile.h" #include "../include/HTMLRenderer3.h" int main(int argc, char *argv[]) @@ -12,7 +13,8 @@ int main(int argc, char *argv[]) //std::wstring sFile = L"\\\\KIRILLOV8\\_Office\\PDF\\Android intro(2p).pdf"; //std::wstring sFile = L"\\\\kirillov8\\_Office\\PDF\\Main Window(15p).pdf"; - std::wstring sFile = L"D:\\knut.djvu"; + //std::wstring sFile = L"D:\\knut.djvu"; + std::wstring sFile = L"D:\\bankomats.xps"; CApplicationFonts oFonts; oFonts.Initialize(); @@ -22,10 +24,15 @@ int main(int argc, char *argv[]) oReader.SetTempFolder(L"D:\\test\\Document"); #endif -#if 1 +#if 0 CDjVuFile oReader; #endif +#if 1 + CXpsFile oReader(&oFonts); + oReader.SetTempFolder(L"D:\\test\\Document"); +#endif + bool bResult = oReader.LoadFromFile(sFile.c_str()); NSHtmlRenderer::CASCHTMLRenderer3 oHtmlRenderer; @@ -34,7 +41,26 @@ int main(int argc, char *argv[]) int nPagesCount = oReader.GetPagesCount(); for (int i = 0; i < nPagesCount; ++i) { +#if 1 + oHtmlRenderer.NewPage(); + oHtmlRenderer.BeginCommand(c_nPageType); + + double dPageDpiX, dPageDpiY; + double dWidth, dHeight; + oReader.GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY); + + dWidth *= 25.4 / dPageDpiX; + dHeight *= 25.4 / dPageDpiY; + + oHtmlRenderer.put_Width(dWidth); + oHtmlRenderer.put_Height(dHeight); +#endif + oReader.DrawPageOnRenderer(&oHtmlRenderer, i, NULL); + +#if 1 + oHtmlRenderer.EndCommand(c_nPageType); +#endif } oHtmlRenderer.CloseFile(); diff --git a/HtmlRenderer/test/test.pro b/HtmlRenderer/test/test.pro index 1361515ec0..fa65f4fce7 100644 --- a/HtmlRenderer/test/test.pro +++ b/HtmlRenderer/test/test.pro @@ -13,20 +13,20 @@ CONFIG += console CONFIG -= app_bundle DEFINES += PDFREADER_USE_DYNAMIC_LIBRARY -DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY +DEFINES += XPS_USE_DYNAMIC_LIBRARY DEFINES += DJVU_USE_DYNAMIC_LIBRARY +DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY INCLUDEPATH += \ ../../DesktopEditor/freetype-2.5.2/include TEMPLATE = app -LIBS += -L../../../SDK/lib/win_64/DEBUG -lASCOfficeUtilsLib LIBS += -L../../../SDK/lib/win_64/DEBUG -lgraphics LIBS += -L../../../SDK/lib/win_64/DEBUG -lHtmlRenderer -LIBS += -L../../../SDK/lib/win_64/DEBUG -llibxml LIBS += -L../../../SDK/lib/win_64/DEBUG -lPdfReader LIBS += -L../../../SDK/lib/win_64/DEBUG -lDjVuFile +LIBS += -L../../../SDK/lib/win_64/DEBUG -lXpsFile LIBS += -lgdi32 \ -ladvapi32 \ -luser32 \ diff --git a/XpsFile/XpsFile.cpp b/XpsFile/XpsFile.cpp index 51dab5cde8..81e01c0bc0 100644 --- a/XpsFile/XpsFile.cpp +++ b/XpsFile/XpsFile.cpp @@ -14,6 +14,8 @@ using namespace XPS; CXpsFile::CXpsFile(CApplicationFonts* pAppFonts) { + m_pDocument = NULL; + m_pAppFonts = pAppFonts; // Создаем менеджер шрифтов с собственным кэшем @@ -174,4 +176,4 @@ void CXpsFile::ConvertToPdf(const std::wstring& wsPath) } oPdf.SaveToFile(wsPath); -} \ No newline at end of file +} diff --git a/XpsFile/XpsFile.h b/XpsFile/XpsFile.h index 13dbbe143c..cc0d3179cd 100644 --- a/XpsFile/XpsFile.h +++ b/XpsFile/XpsFile.h @@ -3,6 +3,13 @@ #include +#ifndef XPS_USE_DYNAMIC_LIBRARY +#define XPS_DECL_EXPORT +#else +#include "../DesktopEditor/common/base_export.h" +#define XPS_DECL_EXPORT Q_DECL_EXPORT +#endif + namespace XPS { class CDocument; @@ -12,7 +19,7 @@ class IRenderer; class CApplicationFonts; class CFontManager; -class CXpsFile +class XPS_DECL_EXPORT CXpsFile { public: CXpsFile(CApplicationFonts* pAppFonts); @@ -36,4 +43,4 @@ private: XPS::CDocument* m_pDocument; }; -#endif // _XPS_FILE_H \ No newline at end of file +#endif // _XPS_FILE_H diff --git a/XpsFile/XpsLib/Document.cpp b/XpsFile/XpsLib/Document.cpp index 3132052116..2da4f59ba9 100644 --- a/XpsFile/XpsLib/Document.cpp +++ b/XpsFile/XpsLib/Document.cpp @@ -1,7 +1,7 @@ #include "Document.h" #include "StaticResources.h" -#include "../../Common/DocxFormat/Source/XML/xmlutils.h" +#include "../../DesktopEditor/xml/include/xmlutils.h" #include "../../DesktopEditor/common/File.h" namespace XPS @@ -182,4 +182,4 @@ namespace XPS m_mStaticResources.insert(std::pair(wsPath, pStaticResource)); return pStaticResource; } -} \ No newline at end of file +} diff --git a/XpsFile/XpsLib/Document.h b/XpsFile/XpsLib/Document.h index 0f294d6681..fa3e89a914 100644 --- a/XpsFile/XpsLib/Document.h +++ b/XpsFile/XpsLib/Document.h @@ -6,11 +6,6 @@ #include #include -#define UNICODE -#define _UNICODE -#define _USE_LIBXML2_READER_ -#define LIBXML_READER_ENABLED - #include "../../DesktopEditor/graphics/IRenderer.h" #include "../../DesktopEditor/graphics/TemporaryCS.h" @@ -41,4 +36,4 @@ namespace XPS }; } -#endif //_XPS_XPSLIB_DOCUMENT_H \ No newline at end of file +#endif //_XPS_XPSLIB_DOCUMENT_H diff --git a/XpsFile/XpsLib/Page.cpp b/XpsFile/XpsLib/Page.cpp index b206be37ad..ccc3af6f54 100644 --- a/XpsFile/XpsLib/Page.cpp +++ b/XpsFile/XpsLib/Page.cpp @@ -90,10 +90,10 @@ namespace XPS if (wsNodeName == L"FixedPage") { ReadAttribute(oReader, L"Width", wsAttrName); - nW = XmlUtils::GetInteger(wsAttrName.c_str()); + nW = wsAttrName.tointeger(); ReadAttribute(oReader, L"Height", wsAttrName); - nH = XmlUtils::GetInteger(wsAttrName.c_str()); + nH = wsAttrName.tointeger(); break; } } @@ -112,10 +112,10 @@ namespace XPS if (wsNodeName == L"FixedPage") { ReadAttribute(oReader, L"Width", wsAttrName); - nW = XmlUtils::GetInteger(wsAttrName.c_str()); + nW = wsAttrName.tointeger(); ReadAttribute(oReader, L"Height", wsAttrName); - nH = XmlUtils::GetInteger(wsAttrName.c_str()); + nH = wsAttrName.tointeger(); break; } } @@ -128,10 +128,10 @@ namespace XPS else if (wsNodeName == L"FixedPage") { ReadAttribute(oReader, L"Width", wsAttrName); - nW = XmlUtils::GetInteger(wsAttrName.c_str()); + nW = wsAttrName.tointeger(); ReadAttribute(oReader, L"Height", wsAttrName); - nH = XmlUtils::GetInteger(wsAttrName.c_str()); + nH = wsAttrName.tointeger(); } } void Page::Draw(IRenderer* pRenderer, bool* pbBreak) @@ -206,14 +206,14 @@ namespace XPS bool bTransform = false, bClip = false, bOpacity = false, bResource = false; if (oReader.MoveToFirstAttribute()) { - CWString wsAttrName = oReader.GetName(); + std::string wsAttrName = oReader.GetNameA(); while (!wsAttrName.empty()) { - if (wsAttrName == L"Clip") - bClip = ClipToRenderer(oReader.GetText(), pState); - else if (wsAttrName == L"RenderTransform") - bTransform = TransformToRenderer(oReader.GetText(), pState); - else if (wsAttrName == L"Opacity") + if (wsAttrName == "Clip") + bClip = ClipToRenderer(oReader.GetText().c_str(), pState); + else if (wsAttrName == "RenderTransform") + bTransform = TransformToRenderer(oReader.GetText().c_str(), pState); + else if (wsAttrName == "Opacity") { pState->PushOpacity(GetDouble(oReader.GetText())); bOpacity = true; @@ -222,7 +222,7 @@ namespace XPS if (!oReader.MoveToNextAttribute()) break; - wsAttrName = oReader.GetName(); + wsAttrName = oReader.GetNameA(); } } oReader.MoveToElement(); @@ -813,15 +813,15 @@ namespace XPS } else if (L"StrokeDashCap" == wsAttrName) { - nDashCap = GetCapStyle(oReader.GetText()); + nDashCap = GetCapStyle(oReader.GetTextA()); } else if (L"StrokeEndLineCap" == wsAttrName) { - nEndCap = GetCapStyle(oReader.GetText()); + nEndCap = GetCapStyle(oReader.GetTextA()); } else if (L"StrokeStartLineCap" == wsAttrName) { - nStartCap = GetCapStyle(oReader.GetText()); + nStartCap = GetCapStyle(oReader.GetTextA()); } else if (L"StrokeLineJoin" == wsAttrName) { @@ -1032,4 +1032,4 @@ namespace XPS return ReadPathGeometry(oReader, wsData, wsTransform); } } -} \ No newline at end of file +} diff --git a/XpsFile/XpsLib/Page.h b/XpsFile/XpsLib/Page.h index 06cb9d011f..728743b838 100644 --- a/XpsFile/XpsLib/Page.h +++ b/XpsFile/XpsLib/Page.h @@ -2,7 +2,7 @@ #define _XPS_XPSLIB_PAGE_H #include "../../DesktopEditor/graphics/IRenderer.h" -#include "../../Common/DocxFormat/Source/XML/xmlutils.h" +#include "../../DesktopEditor/xml/include/xmlutils.h" #include "../../DesktopEditor/fontengine/FontManager.h" #include "FontList.h" @@ -45,4 +45,4 @@ namespace XPS }; } -#endif // _XPS_XPSLIB_PAGE_H \ No newline at end of file +#endif // _XPS_XPSLIB_PAGE_H diff --git a/XpsFile/XpsLib/StaticResources.cpp b/XpsFile/XpsLib/StaticResources.cpp index 4c2f1883de..1f1ecd2452 100644 --- a/XpsFile/XpsLib/StaticResources.cpp +++ b/XpsFile/XpsLib/StaticResources.cpp @@ -1,6 +1,6 @@ #include "StaticResources.h" -#include "../../Common/DocxFormat/Source/XML/xmlutils.h" +#include "../../DesktopEditor/xml/include/xmlutils.h" #include "../../DesktopEditor/graphics/IRenderer.h" #include "../../DesktopEditor/graphics/structures.h" #include "../../PdfWriter/PdfRenderer.h" @@ -230,7 +230,7 @@ namespace XPS { if (wsAttrName == L"ImageSource") { - pBrush = new CImageBrush(oReader.GetText()); + pBrush = new CImageBrush(oReader.GetText().c_str()); } else if (wsAttrName == L"x:Key" && pwsKey) { @@ -411,4 +411,4 @@ namespace XPS ReadSTColor(wsBrush, nBgr, nAlpha); return new CSolidBrush(nBgr, nAlpha * dCurOpacity); } -} \ No newline at end of file +} diff --git a/XpsFile/XpsLib/Utils.cpp b/XpsFile/XpsLib/Utils.cpp index 9a60f5e109..94aba1db62 100644 --- a/XpsFile/XpsLib/Utils.cpp +++ b/XpsFile/XpsLib/Utils.cpp @@ -1,7 +1,7 @@ #include "Utils.h" #include "../../DesktopEditor/common/String.h" #include "../../DesktopEditor/common/Types.h" -#include "../../Common/DocxFormat/Source/XML/xmlutils.h" +#include "../../DesktopEditor/xml/include/xmlutils.h" #include "../../DesktopEditor/graphics/IRenderer.h" #ifndef M_PI @@ -758,17 +758,16 @@ namespace XPS else return; } - unsigned char GetCapStyle(const wchar_t* wsCapStyle) + unsigned char GetCapStyle(const std::string& wsCapStyle) { BYTE nCapStyle = Aggplus::LineCapFlat; - CWString wsDashCap = wsCapStyle; - if (wsDashCap == L"Flat") + if (wsCapStyle == "Flat") nCapStyle = Aggplus::LineCapFlat; - else if (wsDashCap == L"Round") + else if (wsCapStyle == "Round") nCapStyle = Aggplus::LineCapRound; - else if (wsDashCap == L"Square") + else if (wsCapStyle == "Square") nCapStyle = Aggplus::LineCapSquare; - else if (wsDashCap == L"Triangle") + else if (wsCapStyle == "Triangle") nCapStyle = Aggplus::LineCapTriangle; return nCapStyle; @@ -1703,4 +1702,4 @@ namespace XPS int nPos = 0; dValue = GetDouble(wsString.c_str(), nPos, wsString.size()); } -} \ No newline at end of file +} diff --git a/XpsFile/XpsLib/Utils.h b/XpsFile/XpsLib/Utils.h index c94ce41a93..5bc7f299c0 100644 --- a/XpsFile/XpsLib/Utils.h +++ b/XpsFile/XpsLib/Utils.h @@ -63,7 +63,7 @@ namespace XPS bool GetBool(const std::wstring& wsString); void GetBgra(const std::wstring& wsString, int& nBgr, int& nAlpha); - unsigned char GetCapStyle(const wchar_t* wsCapStyle); + unsigned char GetCapStyle(const std::string& wsCapStyle); std::wstring NormalizePath(const std::wstring& wsPath); std::wstring GetPath(const std::wstring& wsPath); @@ -92,4 +92,4 @@ namespace XPS void ReadGradientStops(XmlUtils::CXmlLiteReader& oReader, std::vector& vColors, std::vector& vPositions, const double& dOpacity); } -#endif // _XPS_XPSLIB_UTILS_H \ No newline at end of file +#endif // _XPS_XPSLIB_UTILS_H diff --git a/XpsFile/XpsLib/WString.cpp b/XpsFile/XpsLib/WString.cpp index 256c1c33b7..9f34f8de00 100644 --- a/XpsFile/XpsLib/WString.cpp +++ b/XpsFile/XpsLib/WString.cpp @@ -64,6 +64,13 @@ namespace XPS m_unLen = 0; create(wsString, false); } + CWString::CWString(const std::wstring& wsString) + { + m_bOwnBuffer = false; + m_pBuffer = NULL; + m_unLen = 0; + create(wsString, true); + } CWString::CWString(wchar_t* wsString, bool bCopy, int nLen) { m_bOwnBuffer = false; @@ -102,6 +109,12 @@ namespace XPS m_bOwnBuffer = false; } } + void CWString::create(const std::wstring& sString, bool bCopy) + { + // unused bCopy + create(sString.c_str(), true, (int)sString.length()); + } + void CWString::clear() { if (m_bOwnBuffer) @@ -206,6 +219,10 @@ namespace XPS { return 0 == m_unLen; } + int CWString::tointeger() const + { + return _wtoi(c_str()); + } std::vector CWString::split(wchar_t wChar, bool bCopy) { std::vector vResult; @@ -226,4 +243,4 @@ namespace XPS } return vResult; } -} \ No newline at end of file +} diff --git a/XpsFile/XpsLib/WString.h b/XpsFile/XpsLib/WString.h index da6a7aadbd..81d6bd5070 100644 --- a/XpsFile/XpsLib/WString.h +++ b/XpsFile/XpsLib/WString.h @@ -2,6 +2,7 @@ #define _XPS_XPSLIB_WSTRING_H #include +#include namespace XPS { @@ -11,10 +12,12 @@ namespace XPS public: CWString(); CWString(const wchar_t* wsString); + CWString(const std::wstring& wsString); CWString(const CWString& wsString); CWString(wchar_t* wsString, bool bCopy, int nLen = -1); ~CWString(); void create(const wchar_t*, bool bCopy, int nLen = -1); + void create(const std::wstring& sString, bool bCopy); void operator=(const wchar_t* wsString); void operator=(const CWString& wsString); bool operator<(const CWString& wsString) const; @@ -27,6 +30,8 @@ namespace XPS const wchar_t* c_str() const; void clear(); + int tointeger() const; + std::vector split(wchar_t wChar, bool bCopy = false); private: @@ -37,4 +42,4 @@ namespace XPS }; } -#endif //_XPS_XPSLIB_WSTRING_H \ No newline at end of file +#endif //_XPS_XPSLIB_WSTRING_H