fix fonts in folder, xps in folder

This commit is contained in:
Kulikova Svetlana
2021-06-28 18:14:27 +03:00
parent dbc591ab44
commit a1b480b83e
13 changed files with 127 additions and 65 deletions

View File

@ -52,6 +52,7 @@ public:
virtual int GetPagesCount() = 0; virtual int GetPagesCount() = 0;
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) = 0; virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) = 0;
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak) = 0; virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak) = 0;
virtual unsigned char* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH) = 0;
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1) = 0; virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1) = 0;
}; };

View File

@ -28,12 +28,12 @@ WASM_EXPORT void Fonts_Destroy()
{ {
RELEASEOBJECT(CApplicationFontStreams::m_pMemoryStorage); RELEASEOBJECT(CApplicationFontStreams::m_pMemoryStorage);
} }
WASM_EXPORT void Fonts_Add(void* fonts, const char* id, BYTE* data, LONG size) WASM_EXPORT void Fonts_Add(void* fonts, const char* id, BYTE* data, LONG size)
{ {
CGlobalFontsMemoryStorage* pFonts = (CGlobalFontsMemoryStorage*)fonts; CGlobalFontsMemoryStorage* pFonts = (CGlobalFontsMemoryStorage*)fonts;
pFonts->Add(id, data, size); pFonts->Add(id, data, size);
} }
WASM_EXPORT void Fonts_Remove(void* fonts, const char* id) WASM_EXPORT void Fonts_Remove(void* fonts, const char* id)
{ {
CGlobalFontsMemoryStorage* pFonts = (CGlobalFontsMemoryStorage*)fonts; CGlobalFontsMemoryStorage* pFonts = (CGlobalFontsMemoryStorage*)fonts;
pFonts->Remove(id); pFonts->Remove(id);
@ -47,15 +47,20 @@ WASM_EXPORT void Graphics_Free(void* p)
{ {
if (p) ::free(p); if (p) ::free(p);
} }
WASM_EXPORT void* Graphics_Create(double width_px, double height_px, double width_mm, double height_mm) WASM_EXPORT void* Graphics_Create()
{ {
return new CGraphicsFileDrawing(width_px, height_px, width_mm, height_mm); return new CGraphicsFileDrawing();
} }
WASM_EXPORT void Graphics_Destroy(void* graphics) WASM_EXPORT void Graphics_Destroy(void* graphics)
{ {
CGraphicsFileDrawing* pGraphics = (CGraphicsFileDrawing*)graphics; CGraphicsFileDrawing* pGraphics = (CGraphicsFileDrawing*)graphics;
if (pGraphics) delete pGraphics; if (pGraphics) delete pGraphics;
} }
WASM_EXPORT bool Graphics_Load(void* graphics, BYTE* data, LONG size)
{
CGraphicsFileDrawing* pGraphics = (CGraphicsFileDrawing*)graphics;
return pGraphics->LoadFromMemory(data, size);
}
WASM_EXPORT int Graphics_GetPagesCount(void* graphics) WASM_EXPORT int Graphics_GetPagesCount(void* graphics)
{ {
CGraphicsFileDrawing* pGraphics = (CGraphicsFileDrawing*)graphics; CGraphicsFileDrawing* pGraphics = (CGraphicsFileDrawing*)graphics;
@ -204,6 +209,7 @@ WASM_EXPORT bool Graphics_TEST(void* graphics)
*/ */
// текст // текст
/*
CGraphicsRenderer* pGraphics = ptGraphics->GetGraphicsForTest(); CGraphicsRenderer* pGraphics = ptGraphics->GetGraphicsForTest();
pGraphics->SetCoordTransformOffset(-210.583, -111.159); pGraphics->SetCoordTransformOffset(-210.583, -111.159);
pGraphics->SetTransform(1, 0, 0, 1, 0, 0); pGraphics->SetTransform(1, 0, 0, 1, 0, 0);
@ -230,6 +236,7 @@ WASM_EXPORT bool Graphics_TEST(void* graphics)
pGraphics->put_IntegerGrid(true); pGraphics->put_IntegerGrid(true);
pGraphics->ResetTransform(); pGraphics->ResetTransform();
*/
return true; return true;
} }
@ -658,7 +665,8 @@ int main()
//void* test = Graphics_Create(210, 210, 55.5625, 55.5625); //void* test = Graphics_Create(210, 210, 55.5625, 55.5625);
//void* test = Graphics_Create(203, 187, 53.7104, 49.4771); //void* test = Graphics_Create(203, 187, 53.7104, 49.4771);
//void* test = Graphics_Create(265, 265, 70.1146, 70.1146); //void* test = Graphics_Create(265, 265, 70.1146, 70.1146);
void* test = Graphics_Create(211, 119, 55.8251, 31.2208); //void* test = Graphics_Create(211, 119, 55.8251, 31.2208);
void* test = Graphics_Create();
void* fonts = Fonts_Create(); void* fonts = Fonts_Create();
BYTE* pData = NULL; BYTE* pData = NULL;
@ -667,6 +675,7 @@ int main()
//if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test.png", &pData, nBytesCount)) //if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test.png", &pData, nBytesCount))
if (!oFile.ReadAllBytes(L"C:/Windows/Fonts/arial.ttf", &pData, nBytesCount)) if (!oFile.ReadAllBytes(L"C:/Windows/Fonts/arial.ttf", &pData, nBytesCount))
{ {
Fonts_Destroy();
Graphics_Destroy(test); Graphics_Destroy(test);
RELEASEARRAYOBJECTS(pData); RELEASEARRAYOBJECTS(pData);
return 1; return 1;
@ -675,7 +684,19 @@ int main()
Fonts_Add(fonts, "Arial", pData, nBytesCount); Fonts_Add(fonts, "Arial", pData, nBytesCount);
Graphics_TEST(test); BYTE* pXpsData = NULL;
DWORD nXpsBytesCount;
if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test.xps", &pXpsData, nXpsBytesCount))
{
Fonts_Destroy();
Graphics_Destroy(test);
RELEASEARRAYOBJECTS(pData);
RELEASEARRAYOBJECTS(pXpsData);
return 1;
}
oFile.CloseFile();
Graphics_Load(test, pXpsData, nXpsBytesCount);
int nHeight = Graphics_GetPageHeight(test, 1); int nHeight = Graphics_GetPageHeight(test, 1);
int nWidth = Graphics_GetPageWidth(test, 1); int nWidth = Graphics_GetPageWidth(test, 1);
BYTE* res = Graphics_GetPage(test, 1, nWidth, nHeight); BYTE* res = Graphics_GetPage(test, 1, nWidth, nHeight);
@ -683,7 +704,11 @@ int main()
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
std::cout << (int)res[i] << " "; std::cout << (int)res[i] << " ";
CBgraFrame* resFrame = ((CGraphicsFileDrawing*)test)->GetFrameForTest(); CBgraFrame* resFrame = new CBgraFrame();
resFrame->put_Data(res);
resFrame->put_Width(nWidth);
resFrame->put_Height(nHeight);
resFrame->put_Stride(-4 * nWidth);
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG); resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
Fonts_Destroy(); Fonts_Destroy();

View File

@ -9,73 +9,46 @@
class CGraphicsFileDrawing class CGraphicsFileDrawing
{ {
private: private:
CBgraFrame* m_pFrame;
CGraphicsRenderer* m_pGraphics;
IOfficeDrawingFile* pReader; IOfficeDrawingFile* pReader;
NSFonts::IApplicationFonts* pApplicationFonts; NSFonts::IApplicationFonts* pApplicationFonts;
public: public:
CGraphicsFileDrawing(double width_px, double height_px, double width_mm, double height_mm) CGraphicsFileDrawing()
{ {
pApplicationFonts = NSFonts::NSApplication::Create(); pApplicationFonts = NSFonts::NSApplication::Create();
pApplicationFonts->Initialize(); pApplicationFonts->Initialize();
pReader = new CXpsFile(pApplicationFonts); pReader = new CXpsFile(pApplicationFonts);
int nRasterW = (int)width_px;
int nRasterH = (int)height_px;
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
unsigned int back = 0xffffff;
unsigned int* pData32 = (unsigned int*)pData;
unsigned int* pData32End = pData32 + nRasterW * nRasterH;
while (pData32 < pData32End)
*pData32++ = back;
m_pFrame = new CBgraFrame();
m_pFrame->put_IsRGBA(true);
m_pFrame->put_Data(pData);
m_pFrame->put_Width(nRasterW);
m_pFrame->put_Height(nRasterH);
m_pGraphics = (CGraphicsRenderer*)NSGraphics::Create();
m_pGraphics->CreateFromBgraFrame(m_pFrame);
m_pGraphics->SetSwapRGB(true);
m_pGraphics->put_Width(width_mm);
m_pGraphics->put_Height(height_mm);
NSFonts::IApplicationFonts* m_pApplicationFonts = NSFonts::NSApplication::Create();
NSFonts::IFontManager* pManager = m_pApplicationFonts->GenerateFontManager();
m_pGraphics->SetFontManager(pManager);
} }
~CGraphicsFileDrawing() ~CGraphicsFileDrawing()
{ {
RELEASEOBJECT(m_pGraphics); RELEASEOBJECT(pReader);
RELEASEOBJECT(m_pFrame); RELEASEOBJECT(pApplicationFonts);
} }
bool LoadFromMemory(BYTE* data, DWORD length)
{
return pReader->LoadFromMemory(data, length);
}
int GetPagesCount() int GetPagesCount()
{ {
return 1; return pReader->GetPagesCount();
} }
int GetPageHeight(int nPageIndex) int GetPageHeight(int nPageIndex)
{ {
return m_pFrame->get_Height(); double dPageDpiX, dPageDpiY;
double dWidth, dHeight;
pReader->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
return dHeight;
} }
int GetPageWidth (int nPageIndex) int GetPageWidth (int nPageIndex)
{ {
return m_pFrame->get_Width(); double dPageDpiX, dPageDpiY;
double dWidth, dHeight;
pReader->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
return dWidth;
} }
BYTE* GetPage (int nPageIndex, int nRasterW, int nRasterH) BYTE* GetPage (int nPageIndex, int nRasterW, int nRasterH)
{ {
return m_pFrame->get_Data(); return pReader->ConvertToPixels(nPageIndex, nRasterW, nRasterH);
}
CGraphicsRenderer* GetGraphicsForTest()
{
return m_pGraphics;
}
CBgraFrame* GetFrameForTest()
{
return m_pFrame;
} }
}; };

View File

@ -87,6 +87,10 @@ void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* p
if (m_pImplementation) if (m_pImplementation)
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak); m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
} }
BYTE* CDjVuFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
{
return NULL;
}
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH) void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
{ {
if (m_pImplementation) if (m_pImplementation)

View File

@ -67,6 +67,7 @@ public:
virtual int GetPagesCount(); virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY); virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak); virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1); virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
void ConvertToPdf(const std::wstring& path); void ConvertToPdf(const std::wstring& path);

View File

@ -265,6 +265,10 @@ namespace PdfReader
m_pInternal->m_pPDFDocument->DisplayPage(&oRendererOut, nPageIndex, 72.0, 72.0, 0, false, true, false); m_pInternal->m_pPDFDocument->DisplayPage(&oRendererOut, nPageIndex, 72.0, 72.0, 0, false, true, false);
} }
} }
BYTE* CPdfReader::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
{
return NULL;
}
void CPdfReader::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH) void CPdfReader::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
{ {
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager(); NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();

View File

@ -66,6 +66,7 @@ namespace PdfReader
virtual int GetPagesCount(); virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY); virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak); virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1); virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
EError GetError(); EError GetError();

View File

@ -168,6 +168,46 @@ void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pB
m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak); m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak);
} }
BYTE* CXpsFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
{
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
pFontCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
pFontManager->SetOwnerCache(pFontCache);
NSGraphics::IGraphicsRenderer* pRenderer = NSGraphics::Create();
pRenderer->SetFontManager(pFontManager);
double dPageDpiX, dPageDpiY;
double dWidth, dHeight;
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
int nWidth = (nRasterW > 0) ? nRasterW : ((int)dWidth * 96 / dPageDpiX);
int nHeight = (nRasterH > 0) ? nRasterH : ((int)dHeight * 96 / dPageDpiX);
BYTE* pBgraData = new BYTE[nWidth * nHeight * 4];
if (!pBgraData)
return NULL;
memset(pBgraData, 0xff, nWidth * nHeight * 4);
CBgraFrame oFrame;
oFrame.put_Data(pBgraData);
oFrame.put_Width(nWidth);
oFrame.put_Height(nHeight);
oFrame.put_Stride(-4 * nWidth);
pRenderer->CreateFromBgraFrame(&oFrame);
pRenderer->SetSwapRGB(false);
pRenderer->put_Width(dWidth);
pRenderer->put_Height(dHeight);
bool bBreak = false;
DrawPageOnRenderer(pRenderer, nPageIndex, &bBreak);
RELEASEINTERFACE(pFontManager);
RELEASEOBJECT(pRenderer);
return pBgraData;
}
void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH) void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
{ {
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager(); NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();

View File

@ -62,6 +62,7 @@ public:
virtual int GetPagesCount(); virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY); virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak); virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1); virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
void ConvertToPdf(const std::wstring& wsDstPath); void ConvertToPdf(const std::wstring& wsDstPath);

View File

@ -23,6 +23,10 @@ LIBS += -lgdi32 \
-lshell32 -lshell32
} }
INCLUDEPATH += \
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include \
$$CORE_ROOT_DIR/DesktopEditor/freetype-2.10.4/include/freetype
HEADERS += \ HEADERS += \
XpsFile.h \ XpsFile.h \
XpsLib/ContextState.h \ XpsLib/ContextState.h \

View File

@ -33,6 +33,7 @@
#include <stdio.h> #include <stdio.h>
#include "../../DesktopEditor/common/StringExt.h" #include "../../DesktopEditor/common/StringExt.h"
#include "../../DesktopEditor/graphics/structures.h" #include "../../DesktopEditor/graphics/structures.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../PdfWriter/PdfRenderer.h" #include "../../PdfWriter/PdfRenderer.h"
#include "Document.h" #include "Document.h"
@ -47,6 +48,9 @@
#endif #endif
#define IsFromResource(String) (!String.empty() && '{' == String[0]) #define IsFromResource(String) (!String.empty() && '{' == String[0])
#ifndef BUILDING_WASM_MODULE
CGlobalFontsMemoryStorage* CApplicationFontStreams::m_pMemoryStorage = NULL;
#endif
namespace XPS namespace XPS
{ {
@ -447,6 +451,10 @@ namespace XPS
std::wstring wsRelativePath = (std::wstring::npos == nSlashPos) ? m_wsPagePath : m_wsPagePath.substr(0, nSlashPos + 1); std::wstring wsRelativePath = (std::wstring::npos == nSlashPos) ? m_wsPagePath : m_wsPagePath.substr(0, nSlashPos + 1);
wsFontPath = wsRelativePath + wsFontPath; wsFontPath = wsRelativePath + wsFontPath;
} }
else
{
wsFontPath = m_wsRootPath->getFullFilePath(wsFontPath);
}
std::wstring wsExt = GetFileExtension(wsFontPath); std::wstring wsExt = GetFileExtension(wsFontPath);
NSStringExt::ToLower(wsExt); NSStringExt::ToLower(wsExt);
@ -456,6 +464,8 @@ namespace XPS
IFolder::CBuffer* buffer = NULL; IFolder::CBuffer* buffer = NULL;
m_wsRootPath->read(wsFontPath, buffer); m_wsRootPath->read(wsFontPath, buffer);
m_pFontList->Check(wsFontName, buffer->Buffer, buffer->Size); m_pFontList->Check(wsFontName, buffer->Buffer, buffer->Size);
if (CApplicationFontStreams::m_pMemoryStorage)
CApplicationFontStreams::m_pMemoryStorage->Add(U_TO_UTF8(wsFontPath), buffer->Buffer, buffer->Size);
m_wsRootPath->write(wsFontPath, buffer->Buffer, buffer->Size); m_wsRootPath->write(wsFontPath, buffer->Buffer, buffer->Size);
delete buffer; delete buffer;
} }
@ -628,7 +638,7 @@ namespace XPS
int nIndicesPos = 0, nIndicesLen = wsIndices.size(); int nIndicesPos = 0, nIndicesLen = wsIndices.size();
int nUtf16Pos = 0; int nUtf16Pos = 0;
bool bRtoL = (nBidiLevel % 2 ? true : false); bool bRtoL = (nBidiLevel % 2 ? true : false);
m_pFontManager->LoadFontFromFile(wsFontPath, 0, (float)(dFontSize * 0.75), 96, 96); m_pFontManager->LoadFontFromFile(m_wsRootPath->getFullFilePath(wsFontPath), 0, (float)(dFontSize * 0.75), 96, 96);
double dFontKoef = dFontSize / 100.0; double dFontKoef = dFontSize / 100.0;
bool bNeedItalic = false, bNeedBold = false; bool bNeedItalic = false, bNeedBold = false;
@ -963,7 +973,7 @@ namespace XPS
if (pBrush) if (pBrush)
{ {
if (pBrush->IsImageBrush()) if (pBrush->IsImageBrush())
((CImageBrush*)pBrush)->SetPaths(m_wsRootPath->getFullFilePath(L"").c_str(), GetPath(m_wsPagePath).c_str()); ((CImageBrush*)pBrush)->SetPaths(m_wsRootPath, GetPath(m_wsPagePath).c_str());
bFill = pBrush->SetToRenderer(pRenderer); bFill = pBrush->SetToRenderer(pRenderer);
if (bDeleteBrush) if (bDeleteBrush)

View File

@ -152,24 +152,21 @@ namespace XPS
} }
bool CImageBrush::SetToRenderer(IRenderer* pRenderer) bool CImageBrush::SetToRenderer(IRenderer* pRenderer)
{ {
std::wstring wsPath = m_wsRoot.c_stdstr(); std::wstring wsPath = m_wsPath.c_stdstr();
wsPath += m_wsPath.c_stdstr(); if (!m_wsRoot->exists(wsPath))
if (!NSFile::CFileBinary::Exists(wsPath))
{ {
wsPath = m_wsPage.c_stdstr(); wsPath = m_wsPage.c_stdstr() + m_wsPath.c_stdstr();
wsPath += m_wsPath.c_stdstr(); if (!m_wsRoot->exists(wsPath))
if (!NSFile::CFileBinary::Exists(wsPath))
return false; return false;
} }
pRenderer->put_BrushType(c_BrushTypeTexture); pRenderer->put_BrushType(c_BrushTypeTexture);
pRenderer->put_BrushTexturePath(wsPath); pRenderer->put_BrushTexturePath(m_wsRoot->getFullFilePath(wsPath));
return true; return true;
} }
void CImageBrush::SetPaths(const wchar_t* wsRoot, const wchar_t* wsPage) void CImageBrush::SetPaths(IFolder* wsRoot, const wchar_t* wsPage)
{ {
m_wsRoot.create(wsRoot, true); m_wsRoot = wsRoot;
m_wsPage.create(wsPage, true); m_wsPage.create(wsPage, true);
} }
bool CLinearGradientBrush::SetToRenderer(IRenderer* pRenderer) bool CLinearGradientBrush::SetToRenderer(IRenderer* pRenderer)

View File

@ -33,6 +33,7 @@
#define _XPS_XPSLIB_STATICRESOURCES_H #define _XPS_XPSLIB_STATICRESOURCES_H
#include "Utils.h" #include "Utils.h"
#include "../../OfficeUtils/src/ZipFolder.h"
#include <map> #include <map>
namespace XmlUtils namespace XmlUtils
@ -100,11 +101,11 @@ namespace XPS
} }
bool SetToRenderer(IRenderer* pRenderer); bool SetToRenderer(IRenderer* pRenderer);
bool IsImageBrush() { return true; } bool IsImageBrush() { return true; }
void SetPaths(const wchar_t* wsRoot, const wchar_t* wsPage); void SetPaths(IFolder* wsRoot, const wchar_t* wsPage);
private: private:
CWString m_wsPath; CWString m_wsPath;
CWString m_wsRoot; IFolder* m_wsRoot;
CWString m_wsPage; CWString m_wsPage;
}; };
class CGradientBrush : public CBrush class CGradientBrush : public CBrush