полностью реализован механизм билда статической и динамической библиотеки

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63673 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
Oleg.Korshul
2015-07-23 14:20:18 +00:00
committed by Alexander Trofimov
parent 3d027e9fd0
commit e5a0ebb024
10 changed files with 126 additions and 39 deletions

View File

@ -1,4 +1,4 @@
#include "DjVu.h" #include "DjVu.h"
#include "DjVuFileImplementation.h" #include "DjVuFileImplementation.h"
class CApplicationFonts; class CApplicationFonts;

View File

@ -1,14 +1,20 @@
#pragma once #pragma once
#include <string> #include <string>
#include "../DesktopEditor/graphics/IRenderer.h" #include "../DesktopEditor/graphics/IRenderer.h"
#ifndef DJVU_USE_DYNAMIC_LIBRARY
#define DJVU_DECL_EXPORT
#else
#include "../DesktopEditor/common/base_export.h"
#define DJVU_DECL_EXPORT Q_DECL_EXPORT
#endif
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> CDjVuFileImplementation, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> h-<2D><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // –аботаем через класс CDjVuFileImplementation, чтобы когда цепл¤лс¤ данный h-файл, ничего лишнего не инклюдилось
class CDjVuFileImplementation; class CDjVuFileImplementation;
class CApplicationFonts; class CApplicationFonts;
class CDjVuFile class DJVU_DECL_EXPORT CDjVuFile
{ {
private: private:
@ -28,4 +34,4 @@ public:
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak); void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
void ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType); void ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType);
void ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath); void ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath);
}; };

View File

@ -6,14 +6,71 @@
QT -= core gui QT -= core gui
VERSION = 1.0.0.1
TARGET = DjVuFile TARGET = DjVuFile
TEMPLATE = lib TEMPLATE = lib
CONFIG += staticlib
DEFINES += UNICODE #CONFIG += staticlib
DEFINES += _UNICODE CONFIG += shared
DEFINES += _USE_LIBXML2_READER_
DEFINES += LIBXML_READER_ENABLED ############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../SDK/lib
# WINDOWS
win32:contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTDIR = $$DESTINATION_SDK_PATH/win_64/DEBUG
} else {
DESTDIR = $$DESTINATION_SDK_PATH/win_64
}
}
win32:!contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTDIR = $$DESTINATION_SDK_PATH/win_32/DEBUG
} else {
DESTDIR = $$DESTINATION_SDK_PATH/win_32
}
}
linux-g++:contains(QMAKE_HOST.arch, x86_64):{
DESTDIR = $$DESTINATION_SDK_PATH/linux_64
}
linux-g++:!contains(QMAKE_HOST.arch, x86_64):{
DESTDIR = $$DESTINATION_SDK_PATH/linux_32
}
################################################
############# dynamic dependencies #############
shared {
DEFINES += DJVU_USE_DYNAMIC_LIBRARY
LIBS += -L$$DESTDIR -lASCOfficeUtilsLib
LIBS += -L$$DESTDIR -lgraphics
LIBS += -L$$DESTDIR -llibxml
LIBS += -L$$DESTDIR -lPdfWriter
message(dynamic)
win32 {
LIBS += -lgdi32 \
-ladvapi32 \
-luser32 \
-lshell32
TARGET_EXT = .dll
}
linux-g++ | linux-g++-64 | linux-g++-32 {
CONFIG += plugin
TARGET_EXT = .so
}
}
################################################
INCLUDEPATH += \
../DesktopEditor/agg-2.4/include \
../DesktopEditor/freetype-2.5.2/include
SOURCES += DjVu.cpp \ SOURCES += DjVu.cpp \
DjVuFileImplementation.cpp \ DjVuFileImplementation.cpp \

View File

@ -1,4 +1,4 @@
#include "DjVuFileImplementation.h" #include "DjVuFileImplementation.h"
#include "../DesktopEditor/common/File.h" #include "../DesktopEditor/common/File.h"
#include "../DesktopEditor/common/Directory.h" #include "../DesktopEditor/common/Directory.h"
@ -29,11 +29,10 @@ namespace NSDjvu
GUTF8String utf8String(sText.c_str()); GUTF8String utf8String(sText.c_str());
return utf8String; return utf8String;
} }
static CString MakeCString(GUTF8String& strText) static std::string MakeCString(GUTF8String& strText)
{ {
std::string sString(strText.getbuf()); std::string sString(strText.getbuf());
std::wstring wsString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.length()); return sString;
return CString(wsString.c_str());
} }
static int GetInteger(const std::wstring& wsString) static int GetInteger(const std::wstring& wsString)
{ {
@ -42,7 +41,7 @@ namespace NSDjvu
try try
{ {
return _ttoi(wsString.c_str()); return std::stoi(wsString);
} }
catch (...) catch (...)
{ {
@ -162,7 +161,7 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRende
} }
catch (...) catch (...)
{ {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // белая страница
} }
} }
void CDjVuFileImplementation::ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType) void CDjVuFileImplementation::ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType)
@ -252,6 +251,10 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP
double dRendWidth = 0; double dRendWidth = 0;
double dRendHeight = 0; double dRendHeight = 0;
pRenderer->NewPage();
pRenderer->put_Width(25.4 * nWidth / dRendDpiX);
pRenderer->put_Height(25.4 * nHeight / dRendDpiY);
pRenderer->get_Width(&dRendWidth); pRenderer->get_Width(&dRendWidth);
pRenderer->get_Height(&dRendHeight); pRenderer->get_Height(&dRendHeight);
@ -272,7 +275,7 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP
} }
else if (c_nHtmlRendrerer == lRendererType) else if (c_nHtmlRendrerer == lRendererType)
{ {
// TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // TODO: Нужно реализовать функцию
// pRenderer->GetMaxImageSize(); // pRenderer->GetMaxImageSize();
//VARIANT var; //VARIANT var;
//renderer->GetAdditionalParam(L"MaxImageSize", &var); //renderer->GetAdditionalParam(L"MaxImageSize", &var);
@ -358,7 +361,7 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP
} }
else else
{ {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>?? // белый фрейм??
//memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight); //memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight);
GRect oRectAll(0, 0, lImageWidth, lImageHeight); GRect oRectAll(0, 0, lImageWidth, lImageHeight);
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll); GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
@ -582,7 +585,7 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer,
} }
else else
{ {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>?? // белый фрейм??
//memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight); //memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight);
GRect oRectAll(0, 0, lImageWidth, lImageHeight); GRect oRectAll(0, 0, lImageWidth, lImageHeight);
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll); GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
@ -692,7 +695,7 @@ void CDjVuFileImplementation::CreateGrFrame(IRenderer* pRenderer,
LONG lImageWidth = 0; LONG lImageWidth = 0;
LONG lImageHeight = 0; LONG lImageHeight = 0;
// TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // TODO: Реализовать для графического рендерера
//VARIANT var; //VARIANT var;
//renderer->GetAdditionalParam(L"Pixels", &var); //renderer->GetAdditionalParam(L"Pixels", &var);
@ -773,7 +776,7 @@ void CDjVuFileImplementation::CreateGrFrame(IRenderer* pRenderer,
} }
else else
{ {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>?? // белый фрейм??
//memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight); //memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight);
GRect oRectAll(0, 0, lImageWidth, lImageHeight); GRect oRectAll(0, 0, lImageWidth, lImageHeight);
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll); GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
@ -855,18 +858,18 @@ XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
XmlUtils::CXmlNode hiddenText; XmlUtils::CXmlNode hiddenText;
XmlUtils::CXmlNode pageColumn; XmlUtils::CXmlNode pageColumn;
XmlUtils::CXmlNode region; XmlUtils::CXmlNode region;
hiddenText.FromXmlString(NSDjvu::MakeCString(pageText)); hiddenText.FromXmlStringA(NSDjvu::MakeCString(pageText));
hiddenText.GetNode(_T("PAGECOLUMN"), pageColumn); hiddenText.GetNode(L"PAGECOLUMN", pageColumn);
pageColumn.GetNode(_T("REGION"), region); pageColumn.GetNode(L"REGION", region);
region.GetNode(_T("PARAGRAPH"), paragraph); region.GetNode(L"PARAGRAPH", paragraph);
} }
return paragraph; return paragraph;
} }
void CDjVuFileImplementation::TextToRenderer(IRenderer* pRenderer, XmlUtils::CXmlNode oTextNode, double dKoef, bool isView) void CDjVuFileImplementation::TextToRenderer(IRenderer* pRenderer, XmlUtils::CXmlNode oTextNode, double dKoef, bool isView)
{ {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>) // Выставим шрифт пустой (чтобы растягивать по всему ректу)
pRenderer->put_FontName(L"DjvuEmptyFont"); pRenderer->put_FontName(L"DjvuEmptyFont");
CString csText = oTextNode.GetXml(); //std::wstring csText = oTextNode.GetXml();
XmlUtils::CXmlNodes oLinesNodes; XmlUtils::CXmlNodes oLinesNodes;
oTextNode.GetNodes(L"LINE", oLinesNodes); oTextNode.GetNodes(L"LINE", oLinesNodes);
for (int nLineIndex = 0; nLineIndex < oLinesNodes.GetCount(); ++nLineIndex) for (int nLineIndex = 0; nLineIndex < oLinesNodes.GetCount(); ++nLineIndex)
@ -879,11 +882,11 @@ void CDjVuFileImplementation::TextToRenderer(IRenderer* pRenderer,
{ {
XmlUtils::CXmlNode oWordNode; XmlUtils::CXmlNode oWordNode;
oWordsNodes.GetAt(nWordIndex, oWordNode); oWordsNodes.GetAt(nWordIndex, oWordNode);
CString csWord = oWordNode.GetText(); std::wstring csWord = oWordNode.GetText();
CString csCoords = oWordNode.GetAttribute(L"coords"); std::wstring csCoords = oWordNode.GetAttribute(L"coords");
double arrCoords[4]; double arrCoords[4];
ParseCoords(csCoords.GetBuffer(), arrCoords, dKoef); ParseCoords(csCoords, arrCoords, dKoef);
DrawPageText(pRenderer, arrCoords, csWord.GetBuffer()); DrawPageText(pRenderer, arrCoords, csWord);
} }
} }
} }

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
#include "libdjvu/DjVuDocument.h" #include "libdjvu/DjVuDocument.h"
#include "libdjvu/DjVuImage.h" #include "libdjvu/DjVuImage.h"
@ -20,7 +20,7 @@
#define _UNICODE #define _UNICODE
#define _USE_LIBXML2_READER_ #define _USE_LIBXML2_READER_
#define LIBXML_READER_ENABLED #define LIBXML_READER_ENABLED
#include "../Common/DocxFormat/Source/XML/xmlutils.h" #include "../DesktopEditor/xml/include/xmlutils.h"
#include "../DesktopEditor/graphics/IRenderer.h" #include "../DesktopEditor/graphics/IRenderer.h"

View File

@ -99,9 +99,11 @@ inline unsigned char
umin(unsigned char a, unsigned char b) umin(unsigned char a, unsigned char b)
{ return (a>b) ? b : a; } { return (a>b) ? b : a; }
#if 0
inline float inline float
fmin(float a, float b) fmin(float a, float b)
{ return (a>b) ? b : a; } { return (a>b) ? b : a; }
#endif

View File

@ -3,6 +3,7 @@
#include "../../DesktopEditor/fontengine/ApplicationFonts.h" #include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include "../../PdfReader/PdfReader.h" #include "../../PdfReader/PdfReader.h"
#include "../../DjVuFile/DjVu.h"
#include "../include/HTMLRenderer3.h" #include "../include/HTMLRenderer3.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -10,12 +11,21 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
//std::wstring sFile = L"\\\\KIRILLOV8\\_Office\\PDF\\Android intro(2p).pdf"; //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"\\\\kirillov8\\_Office\\PDF\\Main Window(15p).pdf";
std::wstring sFile = L"D:\\knut.djvu";
CApplicationFonts oFonts; CApplicationFonts oFonts;
oFonts.Initialize(); oFonts.Initialize();
#if 0
PdfReader::CPdfReader oReader(&oFonts); PdfReader::CPdfReader oReader(&oFonts);
oReader.SetTempFolder(L"D:\\test\\Document"); oReader.SetTempFolder(L"D:\\test\\Document");
#endif
#if 1
CDjVuFile oReader;
#endif
bool bResult = oReader.LoadFromFile(sFile.c_str()); bool bResult = oReader.LoadFromFile(sFile.c_str());
NSHtmlRenderer::CASCHTMLRenderer3 oHtmlRenderer; NSHtmlRenderer::CASCHTMLRenderer3 oHtmlRenderer;

View File

@ -14,6 +14,7 @@ CONFIG -= app_bundle
DEFINES += PDFREADER_USE_DYNAMIC_LIBRARY DEFINES += PDFREADER_USE_DYNAMIC_LIBRARY
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
DEFINES += DJVU_USE_DYNAMIC_LIBRARY
INCLUDEPATH += \ INCLUDEPATH += \
../../DesktopEditor/freetype-2.5.2/include ../../DesktopEditor/freetype-2.5.2/include
@ -25,6 +26,7 @@ LIBS += -L../../../SDK/lib/win_64/DEBUG -lgraphics
LIBS += -L../../../SDK/lib/win_64/DEBUG -lHtmlRenderer LIBS += -L../../../SDK/lib/win_64/DEBUG -lHtmlRenderer
LIBS += -L../../../SDK/lib/win_64/DEBUG -llibxml LIBS += -L../../../SDK/lib/win_64/DEBUG -llibxml
LIBS += -L../../../SDK/lib/win_64/DEBUG -lPdfReader LIBS += -L../../../SDK/lib/win_64/DEBUG -lPdfReader
LIBS += -L../../../SDK/lib/win_64/DEBUG -lDjVuFile
LIBS += -lgdi32 \ LIBS += -lgdi32 \
-ladvapi32 \ -ladvapi32 \
-luser32 \ -luser32 \

View File

@ -6,6 +6,13 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#ifndef PDFWRITER_USE_DYNAMIC_LIBRARY
#define PDFWRITER_DECL_EXPORT
#else
#include "../DesktopEditor/common/base_export.h"
#define PDFWRITER_DECL_EXPORT Q_DECL_EXPORT
#endif
struct Pix; struct Pix;
namespace PdfWriter namespace PdfWriter
@ -30,7 +37,7 @@ class CApplicationFonts;
class CRendererCommandBase; class CRendererCommandBase;
class CRendererTextCommand; class CRendererTextCommand;
class CPdfRenderer : public IRenderer class PDFWRITER_DECL_EXPORT CPdfRenderer : public IRenderer
{ {
public: public:
CPdfRenderer(CApplicationFonts* pAppFonts); CPdfRenderer(CApplicationFonts* pAppFonts);

View File

@ -2,7 +2,7 @@
#include "Utils.h" #include "Utils.h"
#include "Encrypt.h" #include "Encrypt.h"
#include "Objects.h" #include "Objects.h"
#include "FastStringToDouble.h" //#include "FastStringToDouble.h"
#include <sstream> #include <sstream>
@ -793,7 +793,7 @@ namespace PdfWriter
} }
else else
{ {
if (!m_oFile.CreateFile(wsFilePath)) if (!m_oFile.CreateFileW(wsFilePath))
return false; return false;
} }
@ -870,7 +870,7 @@ namespace PdfWriter
} }
else else
{ {
if (!m_oFile.CreateFile(wsFilePath)) if (!m_oFile.CreateFileW(wsFilePath))
return false; return false;
} }
@ -892,4 +892,4 @@ namespace PdfWriter
m_nFilePos = m_oFile.TellFile(); m_nFilePos = m_oFile.TellFile();
m_oFile.CloseFile(); m_oFile.CloseFile();
} }
} }