From 72c2753cab0d327e96e62d9f83654a0827866dea Mon Sep 17 00:00:00 2001 From: Kulikova Svetlana Date: Tue, 9 Nov 2021 15:08:33 +0300 Subject: [PATCH] xps refactoring --- XpsFile/XpsLib/Document.cpp | 8 ++++---- XpsFile/XpsLib/Document.h | 4 ++-- XpsFile/XpsLib/FontList.h | 3 +-- XpsFile/XpsLib/XpsPage.cpp | 17 ++++++++--------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/XpsFile/XpsLib/Document.cpp b/XpsFile/XpsLib/Document.cpp index 12db4a5391..d65d899574 100644 --- a/XpsFile/XpsLib/Document.cpp +++ b/XpsFile/XpsLib/Document.cpp @@ -130,7 +130,7 @@ namespace XPS std::wstring wsFilePath = GetPath(wsSourceFile); - #ifdef BUILDING_WASM_MODULE + #ifdef BUILDING_WASM_MODULE // Оглавление, содержание, structure oReader.Clear(); @@ -209,7 +209,7 @@ namespace XPS } } } - #endif + #endif oReader.Clear(); @@ -242,7 +242,7 @@ namespace XPS continue; } - #ifdef BUILDING_WASM_MODULE + #ifdef BUILDING_WASM_MODULE int nDepth = oReader.GetDepth(); while (oReader.ReadNextSiblingNode(nDepth)) { @@ -267,7 +267,7 @@ namespace XPS } } } - #endif + #endif m_mPages.insert(std::pair(nIndex++, new XPS::Page(wsPagePath, m_wsPath, &m_oFontList, m_pFontManager, this))); } diff --git a/XpsFile/XpsLib/Document.h b/XpsFile/XpsLib/Document.h index 58de762c6a..aa983d60f7 100644 --- a/XpsFile/XpsLib/Document.h +++ b/XpsFile/XpsLib/Document.h @@ -58,7 +58,7 @@ namespace XPS void Close(); CStaticResource* GetStaticResource(const wchar_t* wsPath); - #ifdef BUILDING_WASM_MODULE + #ifdef BUILDING_WASM_MODULE struct CDocumentStructure { int nLevel; @@ -72,7 +72,7 @@ namespace XPS BYTE* GetPageLinks (int nPageIndex); std::vector m_vStructure; std::map m_mInternalLinks; - #endif + #endif private: IFolder* m_wsPath; diff --git a/XpsFile/XpsLib/FontList.h b/XpsFile/XpsLib/FontList.h index 3a8ea49631..5604486a5b 100644 --- a/XpsFile/XpsLib/FontList.h +++ b/XpsFile/XpsLib/FontList.h @@ -72,7 +72,7 @@ namespace XPS unsigned char sKey[16]; GetFontKey(wsName, sKey); - // нужно одменить первые 32 байта файла + // Нужно подменить первые 32 байта файла if (IFolder::iftFolder == pFolder->getType()) { NSFile::CFileBinary oFile; @@ -106,7 +106,6 @@ namespace XPS sFontData[nIndex] ^= sKey[nIndex % 16]; } - // если это режим,когда все в памяти - то сразу закидываем в сторадж измененный шрифт if (NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage()) NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage()->Add(wsFontPath, buffer->Buffer, buffer->Size); diff --git a/XpsFile/XpsLib/XpsPage.cpp b/XpsFile/XpsLib/XpsPage.cpp index de1e6e8c27..7b099ffec5 100644 --- a/XpsFile/XpsLib/XpsPage.cpp +++ b/XpsFile/XpsLib/XpsPage.cpp @@ -694,7 +694,7 @@ namespace XPS } #ifdef BUILDING_WASM_MODULE LONG nCount = m_oLine.GetCountChars(); - if (0 != nCount) + if (nCount) DumpLine(); m_pPageMeta.WriteLen(); #endif @@ -1320,9 +1320,9 @@ namespace XPS CWString wsFill; CWString wsClip, wsTransform, wsPathData, wsPathTransform; - #ifdef BUILDING_WASM_MODULE + #ifdef BUILDING_WASM_MODULE std::vector::iterator find = m_pDocument->m_vStructure.end(); - #endif + #endif if (oReader.MoveToFirstAttribute()) { std::wstring wsAttrName = oReader.GetName(); @@ -1412,7 +1412,7 @@ namespace XPS { wsPathData.create(oReader.GetText(), true); } - #ifdef BUILDING_WASM_MODULE + #ifdef BUILDING_WASM_MODULE else if (L"Name" == wsAttrName) { std::wstring wsNameTarget = oReader.GetText(); @@ -1499,7 +1499,7 @@ namespace XPS } } } - #endif + #endif if (!oReader.MoveToNextAttribute()) break; @@ -1508,21 +1508,20 @@ namespace XPS } } oReader.MoveToElement(); - #ifdef BUILDING_WASM_MODULE + #ifdef BUILDING_WASM_MODULE if (find != m_pDocument->m_vStructure.end()) { std::wstring wsPath = wsPathData.c_stdstr(); size_t nFindY = wsPath.find(L','); if (nFindY != std::wstring::npos) { - nFindY++; - size_t nFindEndY = wsPath.find(L' ', nFindY); + size_t nFindEndY = wsPath.find(L' ', ++nFindY); if (nFindEndY != std::wstring::npos) // координата назначения на странице назначения find->dY = GetDouble(wsPath.substr(nFindY, nFindEndY - nFindY)); } } - #endif + #endif CBrush* pBrush = NULL; bool bDeleteBrush = false;