Added CFontStyle and StyleManager.

This commit is contained in:
SEAlGo
2022-08-09 11:07:08 +03:00
parent 1f6707479e
commit 96fa62ac80
36 changed files with 866 additions and 345 deletions

View File

@ -34,7 +34,7 @@
#include "../DesktopEditor/graphics/pro/officedrawingfile.h"
#include "../DesktopEditor/graphics/pro/Fonts.h"
#include "src/logic/ElementParagraph.h"
#include "src/logic/elements/Paragraph.h"
#ifndef DOCXRENDERER_USE_DYNAMIC_LIBRARY
#define DOCXRENDERER_DECL_EXPORT

View File

@ -26,44 +26,47 @@ LIBS += -lgdi32 \
}
HEADERS += \
src/logic/BaseItem.h \
src/logic/ElementContText.h \
src/logic/ElementOldShape.h \
src/logic/ElementShape.h \
src/logic/ElementTextLine.h \
src/logic/ImageManager.h \
src/logic/elements/BaseItem.h \
src/logic/elements/ContText.h \
src/logic/elements/Image.h \
src/logic/elements/OldShape.h \
src/logic/elements/Paragraph.h \
src/logic/elements/Shape.h \
src/logic/elements/TextLine.h \
src/logic/managers/ImageManager.h \
src/logic/managers/FontManager.h \
src/logic/managers/FontManagerBase.h \
src/logic/managers/StyleManager.h \
src/logic/styles/BaseStyle.h \
src/logic/styles/FontStyle.h \
src/resources/ColorTable.h \
src/resources/Constants.h \
src/resources/ImageInfo.h \
src/resources/LinesTable.h \
src/resources/SingletonTemplate.h \
src/resources/SortElements.h \
src/resources/VectorGraphics.h \
src/resources/resources.h \
\
src/resources/utils.h \
src/logic/Page.h \
src/logic/Document.h \
src/logic/ElementImage.h \
src/logic/ElementParagraph.h \
src/logic/FontManager.h \
src/logic/FontManagerBase.h \
\
DocxRenderer.h \
src/resources/utils.h
DocxRenderer.h
SOURCES += \
src/logic/BaseItem.cpp \
src/logic/Document.cpp \
src/logic/ElementContText.cpp \
src/logic/ElementImage.cpp \
src/logic/ElementOldShape.cpp \
src/logic/ElementParagraph.cpp \
src/logic/ElementShape.cpp \
src/logic/ElementTextLine.cpp \
src/logic/FontManager.cpp \
src/logic/FontManagerBase.cpp \
src/logic/ImageManager.cpp \
src/logic/elements/BaseItem.cpp \
src/logic/elements/ContText.cpp \
src/logic/elements/Image.cpp \
src/logic/elements/OldShape.cpp \
src/logic/elements/Paragraph.cpp \
src/logic/elements/Shape.cpp \
src/logic/elements/TextLine.cpp \
src/logic/managers/FontManager.cpp \
src/logic/managers/FontManagerBase.cpp \
src/logic/managers/ImageManager.cpp \
src/logic/managers/StyleManager.cpp \
src/logic/styles/FontStyle.cpp \
src/logic/Page.cpp \
src/logic/Document.cpp \
src/resources/VectorGraphics.cpp \
src/resources/resources.cpp \
\
DocxRenderer.cpp

View File

@ -1,15 +0,0 @@
#ifndef DOCX_RENDERER_COMMON_H
#define DOCX_RENDERER_COMMON_H
#include "../DesktopEditor/common/StringBuilder.h"
#include "../DesktopEditor/common/StringUTF32.h"
#include "../DesktopEditor/common/CalculatorCRC32.h"
#include "../DesktopEditor/graphics/Matrix.h"
#include "../DesktopEditor/graphics/structures.h"
#include "../DesktopEditor/graphics/TemporaryCS.h"
#include "../DesktopEditor/raster/BgraFrame.h"
#include "../DesktopEditor/common/Directory.h"
#include "../DesktopEditor/xml/include/xmlutils.h"
#include "../DesktopEditor/graphics/pro/Graphics.h"
#endif // DOCX_RENDERER_COMMON_H

View File

@ -6,11 +6,23 @@ namespace NSDocxRenderer
m_pAppFonts(pFonts), m_oCurrentPage(pFonts)
{
m_oSimpleGraphicsConverter.SetRenderer(pRenderer);
m_oWriter.AddSize(10000);
}
void CDocument::Clear()
{
m_oPen.SetDefaultParams();
m_oBrush.SetDefaultParams();
m_oFont.SetDefaultParams();
m_oShadow.SetDefaultParams();
m_oEdge.SetDefaultParams();
m_oTransform.Reset();
m_lClipMode = 0;
}
m_lPagesCount = 0;
m_oWriter.Clear();
}
CDocument::~CDocument() {
m_lClipMode = 0;
@ -642,7 +654,7 @@ namespace NSDocxRenderer
double y = 0;
double w = 0;
double h = 0;
pInfo = new CImageInfo(m_oManager.WriteImage(m_oBrush.TexturePath, x, y, w, h));
pInfo = new CImageInfo(m_oImageManager.WriteImage(m_oBrush.TexturePath, x, y, w, h));
}
m_oCurrentPage.DrawPath(nType, pInfo);
@ -703,13 +715,13 @@ namespace NSDocxRenderer
//-------- Функции для вывода изображений --------------------------------------------------
HRESULT CDocument::DrawImage(IGrObject* pImage, double fX, double fY, double fWidth, double fHeight)
{
CImageInfo* pInfo = new CImageInfo(m_oManager.WriteImage((Aggplus::CImage*)pImage, fX, fY, fWidth, fHeight));
CImageInfo* pInfo = new CImageInfo(m_oImageManager.WriteImage((Aggplus::CImage*)pImage, fX, fY, fWidth, fHeight));
m_oCurrentPage.WriteImage(pInfo, fX, fY, fWidth, fHeight);
return S_OK;
}
HRESULT CDocument::DrawImageFromFile(const std::wstring& sVal, double fX, double fY, double fWidth, double fHeight)
{
CImageInfo* pInfo = new CImageInfo(m_oManager.WriteImage(sVal, fX, fY, fWidth, fHeight));
CImageInfo* pInfo = new CImageInfo(m_oImageManager.WriteImage(sVal, fX, fY, fWidth, fHeight));
m_oCurrentPage.WriteImage(pInfo, fX, fY, fWidth, fHeight);
return S_OK;
}
@ -817,14 +829,15 @@ namespace NSDocxRenderer
Clear();
m_lCurrentCommandType = 0;
m_oCurrentPage.Init(&m_oFont, &m_oPen, &m_oBrush, &m_oShadow, &m_oEdge, &m_oTransform, &m_oSimpleGraphicsConverter);
m_oCurrentPage.Init(&m_oFont, &m_oPen, &m_oBrush, &m_oShadow, &m_oEdge, &m_oTransform, &m_oSimpleGraphicsConverter, &m_oStyleManager);
m_oManager.NewDocument();
m_oImageManager.NewDocument();
m_oStyleManager.NewDocument();
// media
m_oManager.m_strDstMedia = m_strTempDirectory + L"/word/media";
NSDirectory::CreateDirectory(m_oManager.m_strDstMedia);
m_oImageManager.m_strDstMedia = m_strTempDirectory + L"/word/media";
NSDirectory::CreateDirectory(m_oImageManager.m_strDstMedia);
m_oCurrentPage.m_oManager.m_oFontTable.m_mapTable.clear();
m_oCurrentPage.m_oFontManager.Init();
m_oDocumentStream.CloseFile();
m_oDocumentStream.CreateFileW(m_strTempDirectory + L"/word/document.xml");
@ -865,14 +878,26 @@ namespace NSDocxRenderer
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\">\
<w:body>");
m_lPagesCount = 0;
m_oWriter.Clear();
m_oWriter.AddSize(10000);
return true;
}
void CDocument::Close()
{
BuildDocumentXmlRels();
BuildFontTableXml();
BuildStylesXml();
// document
m_oCurrentPage.WriteSectionToFile(true, m_oWriter);
m_oWriter.WriteString(L"</w:body></w:document>");
m_oDocumentStream.WriteStringUTF8(m_oWriter.GetData());
m_oWriter.ClearNoAttack();
m_oDocumentStream.CloseFile();
}
void CDocument::BuildDocumentXmlRels()
{
// сохраним rels (images & docs)
NSStringUtils::CStringBuilder oWriter;
@ -885,7 +910,7 @@ namespace NSDocxRenderer
<Relationship Id=\"rId4\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\" Target=\"fontTable.xml\"/>\
<Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme.xml\"/>");
for (auto iterImage : m_oManager.m_mapImageData)
for (auto iterImage : m_oImageManager.m_mapImageData)
{
CImageInfo& oInfo = iterImage.second;
@ -896,7 +921,7 @@ namespace NSDocxRenderer
oWriter.WriteString(L"\"/>");
}
for (auto iterImage : m_oManager.m_mapImagesFile)
for (auto iterImage : m_oImageManager.m_mapImagesFile)
{
CImageInfo& oInfo = iterImage.second;
@ -911,12 +936,26 @@ namespace NSDocxRenderer
NSFile::CFileBinary::SaveToFile(m_strTempDirectory + L"/word/_rels/document.xml.rels", oWriter.GetData());
oWriter.ClearNoAttack();
}
void CDocument::BuildFontTableXml()
{
NSStringUtils::CStringBuilder oWriter;
// сохраним fontTable
oWriter.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<w:fonts xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">");
<w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
CFontTable* pFontTable = &m_oCurrentPage.m_oManager.m_oFontTable;
CFontTable* pFontTable = &m_oCurrentPage.m_oFontManager.m_oFontTable;
for (std::map<std::wstring, CFontTableEntry>::iterator iterFont = pFontTable->m_mapTable.begin(); iterFont != pFontTable->m_mapTable.end(); iterFont++)
{
CFontTableEntry& oEntry = iterFont->second;
@ -955,13 +994,219 @@ namespace NSDocxRenderer
oWriter.WriteString(L"</w:fonts>");
NSFile::CFileBinary::SaveToFile(m_strTempDirectory + L"/word/fontTable.xml", oWriter.GetData());
}
// document
m_oCurrentPage.WriteSectionToFile(true, m_oWriter);
m_oWriter.WriteString(L"</w:body></w:document>");
m_oDocumentStream.WriteStringUTF8(m_oWriter.GetData());
m_oWriter.ClearNoAttack();
void CDocument::BuildStylesXml()
{
NSStringUtils::CStringBuilder oWriter;
m_oDocumentStream.CloseFile();
// сохраним styles
oWriter.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<w:styles xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
oWriter.WriteString(L"<w:docDefaults>");
oWriter.WriteString(L"<w:rPrDefault><w:rPr>");
oWriter.WriteString(L"<w:lang w:val=\"en-US\" w:eastAsia=\"en-US\" w:bidi=\"ar-SA\"/><w:rFonts w:eastAsiaTheme=\"minorHAnsi\" w:ascii=\"Times New Roman\" w:hAnsi=\"Times New Roman\" w:cs=\"Times New Roman\"/>");
oWriter.WriteString(L"</w:rPr></w:rPrDefault>");
oWriter.WriteString(L"<w:pPrDefault><w:pPr/></w:pPrDefault>");
oWriter.WriteString(L"</w:docDefaults>");
oWriter.WriteString(L"<w:latentStyles w:defLockedState=\"false\" w:defUIPriority=\"99\" w:defSemiHidden=\"true\" w:defUnhideWhenUsed=\"true\" w:defQFormat=\"false\" w:count=\"267\">");
oWriter.WriteString(L"<w:lsdException w:name=\"Normal\" w:semiHidden=\"false\" w:uiPriority=\"0\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 1\" w:semiHidden=\"false\" w:uiPriority=\"9\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 2\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 3\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 4\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 5\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 6\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 7\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 8\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"heading 9\" w:uiPriority=\"9\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 1\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 2\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 3\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 4\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 5\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 6\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 7\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 8\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"toc 9\" w:uiPriority=\"39\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"caption\" w:uiPriority=\"35\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Title\" w:semiHidden=\"false\" w:uiPriority=\"10\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Default Paragraph Font\" w:uiPriority=\"1\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Subtitle\" w:semiHidden=\"false\" w:uiPriority=\"11\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Strong\" w:semiHidden=\"false\" w:uiPriority=\"22\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Emphasis\" w:semiHidden=\"false\" w:uiPriority=\"20\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Table Grid\" w:semiHidden=\"false\" w:uiPriority=\"59\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Placeholder Text\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"No Spacing\" w:semiHidden=\"false\" w:uiPriority=\"1\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Revision\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"List Paragraph\" w:semiHidden=\"false\" w:uiPriority=\"34\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Quote\" w:semiHidden=\"false\" w:uiPriority=\"29\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Intense Quote\" w:semiHidden=\"false\" w:uiPriority=\"30\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3 Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid Accent 1\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3 Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid Accent 2\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3 Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid Accent 3\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3 Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid Accent 4\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3 Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid Accent 5\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Shading Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"60\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light List Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"61\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Light Grid Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"62\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 1 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"63\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Shading 2 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"64\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 1 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"65\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium List 2 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"66\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 1 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"67\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 2 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"68\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Medium Grid 3 Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"69\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Dark List Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"70\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Shading Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"71\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful List Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"72\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Colorful Grid Accent 6\" w:semiHidden=\"false\" w:uiPriority=\"73\" w:unhideWhenUsed=\"false\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Subtle Emphasis\" w:semiHidden=\"false\" w:uiPriority=\"19\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Intense Emphasis\" w:semiHidden=\"false\" w:uiPriority=\"21\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Subtle Reference\" w:semiHidden=\"false\" w:uiPriority=\"31\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Intense Reference\" w:semiHidden=\"false\" w:uiPriority=\"32\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Book Title\" w:semiHidden=\"false\" w:uiPriority=\"33\" w:unhideWhenUsed=\"false\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"Bibliography\" w:uiPriority=\"37\"/>");
oWriter.WriteString(L"<w:lsdException w:name=\"TOC Heading\" w:uiPriority=\"39\" w:qFormat=\"true\"/>");
oWriter.WriteString(L"</w:latentStyles>");
oWriter.WriteString(L"<w:style w:type=\"paragraph\" w:default=\"1\" w:styleId=\"Normal\"><w:name w:val=\"Normal\"/>");
oWriter.WriteString(L"</w:style>");
oWriter.WriteString(L"<w:style w:type=\"character\" w:default=\"1\" w:styleId=\"DefaultParagraphFont\">");
oWriter.WriteString(L"<w:name w:val=\"Default Paragraph Font\"/>");
oWriter.WriteString(L"<w:uiPriority w:val=\"1\"/>");
oWriter.WriteString(L"<w:semiHidden/>");
oWriter.WriteString(L"<w:unhideWhenUsed/>");
oWriter.WriteString(L"<w:noProof/>"); //отключение проверки орфографии
oWriter.WriteString(L"<w:b w:val=\"0\"/>");
oWriter.WriteString(L"<w:bCs w:val=\"0\"/>");
oWriter.WriteString(L"<w:i w:val=\"0\"/>");
oWriter.WriteString(L"<w:iCs w:val=\"0\"/>");
oWriter.WriteString(L"<w:color w:val=\"111111\"/>");
oWriter.WriteString(L"</w:style>");
oWriter.WriteString(L"<w:style w:type=\"table\" w:default=\"1\" w:styleId=\"TableNormal\">");
oWriter.WriteString(L"<w:name w:val=\"Normal Table\"/>");
oWriter.WriteString(L"<w:semiHidden/>");
oWriter.WriteString(L"<w:unhideWhenUsed/>");
oWriter.WriteString(L"<w:qFormat/>");
oWriter.WriteString(L"<w:tblPr>");
oWriter.WriteString(L"<w:tblInd w:w=\"0\" w:type=\"dxa\"/>");
oWriter.WriteString(L"<w:tblCellMar>");
oWriter.WriteString(L"<w:top w:w=\"0\" w:type=\"dxa\"/>");
oWriter.WriteString(L"<w:left w:w=\"108\" w:type=\"dxa\"/>");
oWriter.WriteString(L"<w:bottom w:w=\"0\" w:type=\"dxa\"/>");
oWriter.WriteString(L"<w:right w:w=\"108\" w:type=\"dxa\"/>");
oWriter.WriteString(L"</w:tblCellMar>");
oWriter.WriteString(L"</w:tblPr>");
oWriter.WriteString(L"</w:style>");
oWriter.WriteString(L"<w:style w:type=\"numbering\" w:default=\"1\" w:styleId=\"NoList\">");
oWriter.WriteString(L"<w:name w:val=\"No List\"/>");
oWriter.WriteString(L"<w:semiHidden/>");
oWriter.WriteString(L"<w:unhideWhenUsed/>");
oWriter.WriteString(L"<w:uiPriority w:val=\"99\"/>");
oWriter.WriteString(L"</w:style>");
for (auto pStyle : m_oStyleManager.m_mapStyles)
{
pStyle.second->ToXml(oWriter);
}
oWriter.WriteString(L"</w:styles>");
NSFile::CFileBinary::SaveToFile(m_strTempDirectory + L"/word/styles.xml", oWriter.GetData());
}
}

View File

@ -2,6 +2,8 @@
#include "Page.h"
#include "../DesktopEditor/common/Directory.h"
#include "../resources/resources.h"
#include "managers/ImageManager.h"
#include "managers/StyleManager.h"
namespace NSDocxRenderer
{
@ -28,7 +30,8 @@ namespace NSDocxRenderer
LONG m_lClipMode;
CPage m_oCurrentPage;
CImageManager m_oManager;
CImageManager m_oImageManager;
CStyleManager m_oStyleManager;
double m_dWidth {0.0};
double m_dHeight {0.0};
@ -196,7 +199,8 @@ namespace NSDocxRenderer
bool CreateDocument();
void Close();
void ClearTextData();
void BuildDocumentXmlRels();
void BuildFontTableXml();
void BuildStylesXml();
};
}

View File

@ -7,13 +7,13 @@
namespace NSDocxRenderer
{
CPage::CPage(NSFonts::IApplicationFonts* pFonts) : m_oManager(pFonts), m_oManagerLight(pFonts)
CPage::CPage(NSFonts::IApplicationFonts* pFonts) : m_oFontManager(pFonts), m_oFontManagerLight(pFonts)
{
}
void CPage::Init(NSStructures::CFont* pFont, NSStructures::CPen* pPen, NSStructures::CBrush* pBrush,
NSStructures::CShadow* pShadow, NSStructures::CEdgeText* pEdge, Aggplus::CMatrix* pMatrix,
Aggplus::CGraphicsPathSimpleConverter* pSimple)
Aggplus::CGraphicsPathSimpleConverter* pSimple, CStyleManager* pStyleManager)
{
m_pFont = pFont;
m_pPen = pPen;
@ -24,8 +24,10 @@ namespace NSDocxRenderer
m_pTransform = pMatrix;
m_pSimpleGraphicsConverter = pSimple;
m_oManager.m_pFont = m_pFont;
m_oManager.m_pTransform = m_pTransform;
m_pStyleManager = pStyleManager;
m_oFontManager.m_pFont = m_pFont;
m_oFontManager.m_pTransform = m_pTransform;
m_pCurrentLine = nullptr;
@ -327,10 +329,10 @@ namespace NSDocxRenderer
bool bIsPath = ((nullptr == pGids) && !bIsPDFAnalyzer) ? false : true;
m_oManager.LoadFont(0, !bIsPath);
m_oFontManager.LoadFont(0, !bIsPath);
if (bIsPath)
m_oManager.GenerateFontName2(oText);
m_oFontManager.GenerateFontName2(oText);
if (fabs(dTextW) < 0.01 || (dTextW > 10))
{
@ -341,46 +343,49 @@ namespace NSDocxRenderer
if (nullptr != pGids)
{
m_oManager.SetStringGid(1);
m_oManager.MeasureStringGids(pGids, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
m_oFontManager.SetStringGid(1);
m_oFontManager.MeasureStringGids(pGids, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
}
else
{
// такого быть не должно (только из xps)
m_oManager.SetStringGid(0);
m_oManager.MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
m_oFontManager.SetStringGid(0);
m_oFontManager.MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
}
dTextW = _w;
}
double dBaseLinePos = dTextY + fBaseLineOffset;
dTextH = m_oManager.GetFontHeight();
dTextH = m_oFontManager.GetFontHeight();
CContText* pCont = new CContText(m_oManagerLight);
CContText* pCont = new CContText(&m_oFontManagerLight, m_pStyleManager);
pCont->m_dLeft = dTextX;
pCont->m_dBaselinePos = dBaseLinePos;
pCont->m_dBaselineOffset = m_oManager.m_oFont.m_dBaselineOffset;
pCont->m_dBaselineOffset = m_oFontManager.m_oFont.m_dBaselineOffset;
pCont->m_dLastX = dTextX;
pCont->m_dTop = dBaseLinePos - dTextH - m_oManager.m_oFont.m_dBaselineOffset;
pCont->m_dTop = dBaseLinePos - dTextH - m_oFontManager.m_oFont.m_dBaselineOffset;
pCont->m_dWidth = dTextW;
pCont->m_dHeight = dTextH;
pCont->m_dRight = dTextX + dTextW;
pCont->m_oText = oText;
pCont->m_oFont = m_oManager.m_oFont.m_oFont;
pCont->m_oBrush = *m_pBrush;
//Первичное заполнение стилей
m_pStyleManager->m_pCurrentStyle->m_oFont = m_oFontManager.m_oFont.m_oFont;
m_pStyleManager->m_pCurrentStyle->m_oBrush = *m_pBrush;
if (bIsPath)
{
pCont->m_strPickFontName = m_oManager.m_strCurrentPickFont;
pCont->m_lPickFontStyle = m_oManager.m_lCurrentPictFontStyle;
m_pStyleManager->m_pCurrentStyle->m_strPickFontName = m_oFontManager.m_strCurrentPickFont;
m_pStyleManager->m_pCurrentStyle->m_lPickFontStyle = m_oFontManager.m_lCurrentPictFontStyle;
}
pCont->m_dSpaceWidthMM = m_oManager.m_dSpaceWidthMM;
pCont->m_pFontStyle = m_pStyleManager->GetStyle();
pCont->m_dSpaceWidthMM = m_oFontManager.m_dSpaceWidthMM;
m_arSymbol.push_back(pCont);
}
@ -462,7 +467,7 @@ namespace NSDocxRenderer
if ((bIf1 || bIf2) && bIf3 && bIf4)
{
//note Выбираем Cont c максимальным размером шрифта (возможно понадобится для определения толщины линий)
if (!pShape->m_pCont || pShape->m_pCont->m_oFont.Size < pCont->m_oFont.Size)
if (!pShape->m_pCont || pShape->m_pCont->m_pFontStyle->m_oFont.Size < pCont->m_pFontStyle->m_oFont.Size)
{
pShape->m_pCont = pCont;
}
@ -619,14 +624,19 @@ namespace NSDocxRenderer
}
if (pShape->m_eGraphicsType == eGraphicsType::gtComplicatedFigure &&
pCont->m_oBrush.Color1 == c_iGreyColor &&
pCont->m_pFontStyle->m_oBrush.Color1 == c_iGreyColor &&
eVType == eVerticalCrossingType::vctCurrentOutsideNext &&
(eHType == eHorizontalCrossingType::hctCurrentOutsideNext ||
eHType == eHorizontalCrossingType::hctCurrentRightOfNext))
{
pCont->m_bIsShadowPresent = true;
pCont->m_bIsOutlinePresent = true;
pCont->m_oBrush.Color1 = pShape->m_oPen.Color;
*m_pStyleManager->m_pCurrentStyle = *pCont->m_pFontStyle;
m_pStyleManager->m_pCurrentStyle->m_oBrush.Color1 = pShape->m_oPen.Color;
pCont->m_pFontStyle = m_pStyleManager->GetStyle();
pShape->m_bIsNotNecessaryToUse = true;
}
}
@ -651,7 +661,7 @@ namespace NSDocxRenderer
if (bIf1 && bIf2 && bIf3 && bIf4)
{
pCont->m_oFont.Strikeout = TRUE;
pCont->m_bIsStrikeoutPresent = true;;
if (pShape->m_eLineType == eLineType::ltDouble)
{
pCont->m_bIsDoubleStrikeout = true;
@ -679,7 +689,7 @@ namespace NSDocxRenderer
if (bIf1 && bIf2 && bIf3 && bIf4)
{
pCont->m_oFont.Underline = TRUE;
pCont->m_bIsUnderlinePresent = true;;
pCont->m_eUnderlineType = pShape->m_eLineType;
pCont->m_lUnderlineColor = pShape->m_dHeight > 0.3 ? pShape->m_oBrush.Color1 : pShape->m_oPen.Color;
return true;
@ -704,7 +714,7 @@ namespace NSDocxRenderer
eHType != eHorizontalCrossingType::hctNoCrossingCurrentLeftOfNext &&
eHType != eHorizontalCrossingType::hctNoCrossingCurrentRightOfNext;
//Цвета должны быть разными
bool bIf4 = pCont->m_oBrush.Color1 != pShape->m_oBrush.Color1;
bool bIf4 = pCont->m_pFontStyle->m_oBrush.Color1 != pShape->m_oBrush.Color1;
bool bIf5 = pShape->m_oBrush.Color1 == c_iBlackColor && pShape->m_oPen.Color == c_iWhiteColor;
if (bIf1 && bIf2 && bIf3 && bIf4 && !bIf5)
@ -1004,7 +1014,10 @@ namespace NSDocxRenderer
if (pCont->m_pCont)
{
pCont->m_oFont.Size = pCont->m_pCont->m_oFont.Size;
//pCont->m_pFontStyle->m_oFont.Size = pCont->m_pCont->m_pFontStyle->m_oFont.Size;
*m_pStyleManager->m_pCurrentStyle = *pCont->m_pFontStyle;
m_pStyleManager->m_pCurrentStyle->m_oFont.Size = pCont->m_pCont->m_pFontStyle->m_oFont.Size;
pCont->m_pFontStyle = m_pStyleManager->GetStyle();
}
if (pLineNext->m_dLeft > pCont->m_dLeft)
@ -1025,7 +1038,10 @@ namespace NSDocxRenderer
if (pCont->m_pCont)
{
pCont->m_oFont.Size = pCont->m_pCont->m_oFont.Size;
//pCont->m_pFontStyle->m_oFont.Size = pCont->m_pCont->m_pFontStyle->m_oFont.Size;
*m_pStyleManager->m_pCurrentStyle = *pCont->m_pFontStyle;
m_pStyleManager->m_pCurrentStyle->m_oFont.Size = pCont->m_pCont->m_pFontStyle->m_oFont.Size;
pCont->m_pFontStyle = m_pStyleManager->GetStyle();
}
if (pLine->m_dLeft > pCont->m_dLeft)

View File

@ -1,9 +1,10 @@
#pragma once
#include "../DesktopEditor/graphics/pro/Graphics.h"
#include "ElementOldShape.h"
#include "ElementParagraph.h"
#include "ElementImage.h"
#include "ElementShape.h"
#include "elements/OldShape.h"
#include "elements/Paragraph.h"
#include "elements/Image.h"
#include "elements/Shape.h"
#include "managers/StyleManager.h"
namespace NSDocxRenderer
{
@ -19,6 +20,8 @@ namespace NSDocxRenderer
Aggplus::CMatrix* m_pTransform {nullptr};
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter {nullptr};
CStyleManager* m_pStyleManager {nullptr};
CVectorGraphics m_oVector;
double m_dWidth {0.0};
@ -34,8 +37,8 @@ namespace NSDocxRenderer
CTextLine* m_pCurrentLine {nullptr};
CFontManager m_oManager;
CFontManagerLight m_oManagerLight;
CFontManager m_oFontManager;
CFontManagerLight m_oFontManagerLight;
TextAssociationType m_eTextAssociationType {tatPlainLine};
@ -49,7 +52,8 @@ namespace NSDocxRenderer
CPage(NSFonts::IApplicationFonts* pFonts);
~CPage();
void Init(NSStructures::CFont* pFont, NSStructures::CPen* pPen, NSStructures::CBrush* pBrush,
NSStructures::CShadow* pShadow, NSStructures::CEdgeText* pEdge, Aggplus::CMatrix* pMatrix, Aggplus::CGraphicsPathSimpleConverter* pSimple);
NSStructures::CShadow* pShadow, NSStructures::CEdgeText* pEdge, Aggplus::CMatrix* pMatrix,
Aggplus::CGraphicsPathSimpleConverter* pSimple, CStyleManager* pStyleManager);
void Clear();
void ClearImages();

View File

@ -1,5 +1,5 @@
#include "BaseItem.h"
#include "../resources/Constants.h"
#include "../../resources/Constants.h"
namespace NSDocxRenderer
{

View File

@ -1,17 +1,18 @@
#include "ElementContText.h"
#include "../resources/ColorTable.h"
#include "../resources/SingletonTemplate.h"
#include "../resources/utils.h"
#include "ContText.h"
#include "../../resources/ColorTable.h"
#include "../../resources/SingletonTemplate.h"
#include "../../resources/utils.h"
namespace NSDocxRenderer
{
CContText::CContText(CFontManagerLight& oManagerLight): CBaseItem(ElemType::etContText),
m_pManagerLight(&oManagerLight)
CContText::CContText(CFontManagerLight* pManagerLight, CStyleManager* pStyleManager):
CBaseItem(ElemType::etContText), m_pManagerLight(pManagerLight), m_pStyleManager(pStyleManager)
{
}
void CContText::Clear()
{
m_pFontStyle = nullptr;
}
CContText::CContText(const CContText& oSrc): CBaseItem(ElemType::etContText)
@ -28,11 +29,22 @@ namespace NSDocxRenderer
CBaseItem::operator=(oSrc);
m_oFont = oSrc.m_oFont;
m_oBrush = oSrc.m_oBrush;
m_pFontStyle = oSrc.m_pFontStyle;
m_strPickFontName = oSrc.m_strPickFontName;
m_lPickFontStyle = oSrc.m_lPickFontStyle;
m_bIsStrikeoutPresent = oSrc.m_bIsStrikeoutPresent;
m_bIsDoubleStrikeout = oSrc.m_bIsDoubleStrikeout;
m_bIsHighlightPresent = oSrc.m_bIsHighlightPresent;
m_lHighlightColor = oSrc.m_lHighlightColor;
m_bIsUnderlinePresent = oSrc.m_bIsUnderlinePresent;
m_eUnderlineType = oSrc.m_eUnderlineType;
m_lUnderlineColor = oSrc.m_lUnderlineColor;
m_bIsShadowPresent = oSrc.m_bIsShadowPresent;
m_bIsOutlinePresent = oSrc.m_bIsOutlinePresent;
m_bIsEmbossPresent = oSrc.m_bIsEmbossPresent;
m_bIsEngravePresent = oSrc.m_bIsEngravePresent;
m_oText = oSrc.m_oText;
@ -41,22 +53,12 @@ namespace NSDocxRenderer
m_dSpaceWidthMM = oSrc.m_dSpaceWidthMM;
m_bIsNeedSpace = oSrc.m_bIsNeedSpace;
m_bIsDoubleStrikeout = oSrc.m_bIsDoubleStrikeout;
m_bIsHighlightPresent = oSrc.m_bIsHighlightPresent;
m_lHighlightColor = oSrc.m_lHighlightColor;
m_eUnderlineType = oSrc.m_eUnderlineType;
m_lUnderlineColor = oSrc.m_lUnderlineColor;
m_eVertAlignType = oSrc.m_eVertAlignType;
m_bIsShadowPresent = oSrc.m_bIsShadowPresent;
m_bIsOutlinePresent = oSrc.m_bIsOutlinePresent;
m_bIsEmbossPresent = oSrc.m_bIsEmbossPresent;
m_bIsEngravePresent = oSrc.m_bIsEngravePresent;
m_pShape = oSrc.m_pShape;
m_pManagerLight = oSrc.m_pManagerLight;
m_pStyleManager = oSrc.m_pStyleManager;
m_pCont = oSrc.m_pCont;
#if USING_DELETE_DUPLICATING_CONTS == 0
m_pDuplicateCont = oSrc.m_pDuplicateCont;
@ -85,15 +87,13 @@ namespace NSDocxRenderer
oWriter.WriteString(L"<w:r>");
oWriter.WriteString(L"<w:rPr>");
oWriter.WriteString(L"<w:noProof/>"); //отключение проверки орфографии
oWriter.WriteString(L"<w:rStyle w:val=\"");
oWriter.WriteString(m_pFontStyle->GetStyleId());
oWriter.WriteString(L"\"/>");
if (m_strPickFontName.empty())
if (m_pFontStyle->m_strPickFontName.empty())
{
if (m_oFont.Bold)
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (m_oFont.Italic)
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
if (m_bIsNeedSpace)
{
m_dWidth += m_dSpaceWidthMM;
@ -102,11 +102,6 @@ namespace NSDocxRenderer
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle))
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (0x02 == (0x02 & m_lPickFontStyle))
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
if (m_bIsNeedSpace)
{
m_dWidth += m_pManagerLight->GetSpaceWidth();
@ -117,8 +112,8 @@ namespace NSDocxRenderer
m_eVertAlignType != eVertAlignType::vatSuperscript)
{
// нужно перемерять...
double ___dSize = (double)(static_cast<LONG>(m_oFont.Size * 2)) / 2;
m_pManagerLight->LoadFont(m_strPickFontName, m_lPickFontStyle, ___dSize, false);
double ___dSize = (double)(static_cast<LONG>(m_pFontStyle->m_oFont.Size * 2)) / 2;
m_pManagerLight->LoadFont(m_pFontStyle->m_strPickFontName, m_pFontStyle->m_lPickFontStyle, ___dSize, false);
double dWidth = m_pManagerLight->MeasureStringWidth(m_oText.ToStdWString());
double dSpacing = (m_dWidth - dWidth) / (m_oText.length() + 1);
@ -157,39 +152,7 @@ namespace NSDocxRenderer
}
}
int lSize = static_cast<int>(2 * m_oFont.Size);
oWriter.WriteString(L"<w:sz w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/><w:szCs w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/>");
std::wstring& strFontName = m_strPickFontName.empty() ? m_oFont.Name : m_strPickFontName;
oWriter.WriteString(L"<w:rFonts w:ascii=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:hAnsi=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:cs=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\"/>");
if (m_eVertAlignType == eVertAlignType::vatSubscript)
{
oWriter.WriteString(L"<w:vertAlign w:val=\"subscript\"/>");
}
else if (m_eVertAlignType == eVertAlignType::vatSuperscript)
{
oWriter.WriteString(L"<w:vertAlign w:val=\"superscript\"/>");
}
if (ConvertColorBGRToRGB(m_oBrush.Color1) != c_iBlackColor)
{
oWriter.WriteString(L"<w:color w:val=\"");
oWriter.WriteHexInt3(ConvertColorBGRToRGB(m_oBrush.Color1));
oWriter.WriteString(L"\"/>");
}
if (m_oFont.Strikeout == TRUE)
if (m_bIsStrikeoutPresent)
{
if (m_bIsDoubleStrikeout)
{
@ -201,12 +164,12 @@ namespace NSDocxRenderer
}
}
if (m_oFont.Underline == TRUE)
if (m_bIsUnderlinePresent)
{
oWriter.WriteString(L"<w:u w:val=");
oWriter.WriteString(SingletonInstance<LinesTable>().ConverLineToString(m_eUnderlineType));
if (m_lUnderlineColor != m_oBrush.Color1)
if (m_lUnderlineColor != m_pFontStyle->m_oBrush.Color1)
{
oWriter.WriteString(L" w:color=\"");
oWriter.WriteHexInt3(ConvertColorBGRToRGB(m_lUnderlineColor));
@ -217,6 +180,7 @@ namespace NSDocxRenderer
if (m_bIsHighlightPresent)
{
//note В <w:style это не работает
ColorTable& colorTable = SingletonInstance<ColorTable>();
if (colorTable.IsStandardColor(m_lHighlightColor))
{
@ -231,6 +195,15 @@ namespace NSDocxRenderer
oWriter.WriteString(L"\"/>");
}
if (m_eVertAlignType == eVertAlignType::vatSubscript)
{
oWriter.WriteString(L"<w:vertAlign w:val=\"subscript\"/>");
}
else if (m_eVertAlignType == eVertAlignType::vatSuperscript)
{
oWriter.WriteString(L"<w:vertAlign w:val=\"superscript\"/>");
}
oWriter.WriteString(L"</w:rPr>");
oWriter.WriteString(L"<w:t xml:space=\"preserve\">");
@ -246,44 +219,16 @@ namespace NSDocxRenderer
{
oWriter.WriteString(L"<w:r><w:rPr>");
double dSpaceMMSize = m_dSpaceWidthMM;
if (m_strPickFontName.empty())
{
if (m_oFont.Bold && bIsNeedSaveFormat)
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (m_oFont.Italic && bIsNeedSaveFormat)
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle) && bIsNeedSaveFormat)
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (0x02 == (0x02 & m_lPickFontStyle) && bIsNeedSaveFormat)
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
oWriter.WriteString(L"<w:rStyle w:val=\"");
oWriter.WriteString(m_pFontStyle->GetStyleId());
oWriter.WriteString(L"\"/>");
double dSpaceMMSize = m_dSpaceWidthMM;
if (!m_pFontStyle->m_strPickFontName.empty())
{
dSpaceMMSize = m_pManagerLight->GetSpaceWidth();
}
int lSize = (int)(2 * m_oFont.Size);
oWriter.WriteString(L"<w:sz w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/><w:szCs w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/>");
std::wstring& strFontName = m_strPickFontName.empty() ? m_oFont.Name : m_strPickFontName;
oWriter.WriteString(L"<w:rFonts w:ascii=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:hAnsi=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:cs=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\"/>");
oWriter.WriteString(L"<w:color w:val=\"");
oWriter.WriteHexInt3(ConvertColorBGRToRGB(m_oBrush.Color1));
oWriter.WriteString(L"\"/>");
LONG lSpacing = static_cast<LONG>((dSpacingMM - dSpaceMMSize) * c_dMMToDx);
//note принудительно уменьшаем spacing чтобы текстовые линии не выходили за правую границу
lSpacing -= 1;
@ -294,24 +239,44 @@ namespace NSDocxRenderer
oWriter.WriteString(L"\"/>");
}
if (ConvertColorBGRToRGB(m_oBrush.Color1) != c_iBlackColor)
if (m_bIsEmbossPresent && bIsNeedSaveFormat)
{
oWriter.WriteString(L"<w:color w:val=\"");
oWriter.WriteHexInt3(ConvertColorBGRToRGB(m_oBrush.Color1));
oWriter.WriteString(L"\"/>");
oWriter.WriteString(L"<w:emboss/>");
}
else if (m_bIsEngravePresent && bIsNeedSaveFormat)
{
oWriter.WriteString(L"<w:imprint/>");
}
else
{
if (m_bIsOutlinePresent && bIsNeedSaveFormat)
{
oWriter.WriteString(L"<w:outline/>");
}
if (m_bIsShadowPresent && bIsNeedSaveFormat)
{
oWriter.WriteString(L"<w:shadow/>");
}
}
if (m_oFont.Strikeout == TRUE && bIsNeedSaveFormat)
if (m_bIsStrikeoutPresent && bIsNeedSaveFormat)
{
oWriter.WriteString(L"<w:strike/>");
if (m_bIsDoubleStrikeout)
{
oWriter.WriteString(L"<w:dstrike/>");
}
else
{
oWriter.WriteString(L"<w:strike/>");
}
}
if (m_oFont.Underline == TRUE && bIsNeedSaveFormat)
if (m_bIsUnderlinePresent && bIsNeedSaveFormat)
{
oWriter.WriteString(L"<w:u w:val=");
oWriter.WriteString(SingletonInstance<LinesTable>().ConverLineToString(m_eUnderlineType));
if (m_lUnderlineColor != m_oBrush.Color1)
if (m_lUnderlineColor != m_pFontStyle->m_oBrush.Color1)
{
oWriter.WriteString(L" w:color=\"");
oWriter.WriteHexInt3(ConvertColorBGRToRGB(m_lUnderlineColor));
@ -322,6 +287,7 @@ namespace NSDocxRenderer
if (m_bIsHighlightPresent && bIsNeedSaveFormat)
{
//note В <w:style это не работает
ColorTable& colorTable = SingletonInstance<ColorTable>();
if (colorTable.IsStandardColor(m_lHighlightColor))
{
@ -353,30 +319,22 @@ namespace NSDocxRenderer
bool CContText::IsEqual(const CContText* oSrc)
{
//todo Скорее всего это временное решение
bool bIf1 = true; //m_strPickFontName == oSrc->m_strPickFontName;
bool bIf2 = m_eUnderlineType == oSrc->m_eUnderlineType;
bool bIf3 = m_lUnderlineColor == oSrc->m_lUnderlineColor;
bool bIf4 = m_bIsHighlightPresent == oSrc->m_bIsHighlightPresent;
bool bIf5 = m_lHighlightColor == oSrc->m_lHighlightColor;
bool bIf6 = m_bIsDoubleStrikeout == oSrc->m_bIsDoubleStrikeout;
bool bIf7 = m_bIsShadowPresent == oSrc->m_bIsShadowPresent;
bool bIf8 = m_pShape == oSrc->m_pShape;
bool bIf9 = m_oFont.Name == L"" || oSrc->m_oFont.Name == L"" ? true : m_oFont.IsEqual(&oSrc->m_oFont);
bool bIf10 = m_oBrush.IsEqual(&oSrc->m_oBrush);
bool bIf1 = m_pFontStyle->GetStyleId() == oSrc->m_pFontStyle->GetStyleId();
bool bIf2 = m_pShape == oSrc->m_pShape;
bool bIf3 = m_bIsStrikeoutPresent == oSrc->m_bIsStrikeoutPresent;
bool bIf4 = m_bIsDoubleStrikeout == oSrc->m_bIsDoubleStrikeout;
bool bIf5 = m_bIsHighlightPresent == oSrc->m_bIsHighlightPresent;
bool bIf6 = m_lHighlightColor == oSrc->m_lHighlightColor;
bool bIf7 = m_bIsUnderlinePresent == oSrc->m_bIsUnderlinePresent;
bool bIf8 = m_eUnderlineType == oSrc->m_eUnderlineType;
bool bIf9 = m_lUnderlineColor == oSrc->m_lUnderlineColor;
bool bIf10 = m_bIsShadowPresent == oSrc->m_bIsShadowPresent;
bool bIf11 = m_bIsOutlinePresent == oSrc->m_bIsOutlinePresent;
bool bIf12 = m_bIsEmbossPresent == oSrc->m_bIsEmbossPresent;
bool bIf13 = m_bIsEngravePresent == oSrc->m_bIsEngravePresent;
if (bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 && bIf8 && bIf9 && bIf10)
/*if( m_strPickFontName == oSrc->m_strPickFontName &&
m_eUnderlineType == oSrc->m_eUnderlineType &&
m_lUnderlineColor == oSrc->m_lUnderlineColor &&
m_bIsHighlightPresent == oSrc->m_bIsHighlightPresent &&
m_lHighlightColor == oSrc->m_lHighlightColor &&
m_bIsDoubleStrikeout == oSrc->m_bIsDoubleStrikeout &&
m_bIsShadowPresent == oSrc->m_bIsShadowPresent &&
//m_eVertAlignType == oSrc->m_eVertAlignType &&
m_pShape == oSrc->m_pShape &&
m_oFont.IsEqual(&oSrc->m_oFont) &&
m_oBrush.IsEqual(&oSrc->m_oBrush))*/
if (bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 && bIf8 &&
bIf9 && bIf10 && bIf11 && bIf12 && bIf13)
{
return true;
}
@ -411,15 +369,15 @@ namespace NSDocxRenderer
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext; //текущий cont левее
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext; //текущий cont правее
//Размеры шрифта и текст должны бать одинаковыми
bool bIf5 = m_oFont.Size == pCont->m_oFont.Size;
bool bIf5 = m_pFontStyle->m_oFont.Size == pCont->m_pFontStyle->m_oFont.Size;
bool bIf6 = m_oText == pCont->m_oText;
//Цвет тени должен быть серым
bool bIf7 = m_oBrush.Color1 == c_iGreyColor;
bool bIf8 = pCont->m_oBrush.Color1 == c_iGreyColor;
bool bIf9 = m_oBrush.Color1 == c_iBlackColor;
bool bIf10 = pCont->m_oBrush.Color1 == c_iBlackColor;
bool bIf11 = m_oBrush.Color1 == c_iGreyColor2;
bool bIf12 = pCont->m_oBrush.Color1 == c_iGreyColor2;
bool bIf7 = m_pFontStyle->m_oBrush.Color1 == c_iGreyColor;
bool bIf8 = pCont->m_pFontStyle->m_oBrush.Color1 == c_iGreyColor;
bool bIf9 = m_pFontStyle->m_oBrush.Color1 == c_iBlackColor;
bool bIf10 = pCont->m_pFontStyle->m_oBrush.Color1 == c_iBlackColor;
bool bIf11 = m_pFontStyle->m_oBrush.Color1 == c_iGreyColor2;
bool bIf12 = pCont->m_pFontStyle->m_oBrush.Color1 == c_iGreyColor2;
//note Каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
//note Логика подобрана для конкретного примера - возможно нужно будет ее обобщить.
@ -491,8 +449,8 @@ namespace NSDocxRenderer
eHType == eHorizontalCrossingType::hctCurrentRightOfNext) &&
fabs(m_dLeft - pCont->m_dRight) < c_dTHE_STRING_X_PRECISION_MM * 3;
//Размеры шрифта должны бать разными
bool bIf5 = m_oFont.Size * 0.7 > pCont->m_oFont.Size;
bool bIf6 = m_oFont.Size < pCont->m_oFont.Size * 0.7;
bool bIf5 = m_pFontStyle->m_oFont.Size * 0.7 > pCont->m_pFontStyle->m_oFont.Size;
bool bIf6 = m_pFontStyle->m_oFont.Size < pCont->m_pFontStyle->m_oFont.Size * 0.7;
if (bIf3 || bIf4)
{

View File

@ -1,9 +1,11 @@
#pragma once
#include "BaseItem.h"
#include "../DesktopEditor/common/StringBuilder.h"
#include "FontManager.h"
#include "../resources/Constants.h"
#include "../resources/LinesTable.h"
#include "../managers/FontManager.h"
#include "../managers/StyleManager.h"
#include "../styles/FontStyle.h"
#include "../../resources/Constants.h"
#include "../../resources/LinesTable.h"
namespace NSDocxRenderer
@ -21,36 +23,36 @@ namespace NSDocxRenderer
class CContText : public CBaseItem
{
public:
NSStructures::CFont m_oFont;
NSStructures::CBrush m_oBrush;
CFontStyle* m_pFontStyle {nullptr};
std::wstring m_strPickFontName {L""};
LONG m_lPickFontStyle {0};
NSStringUtils::CStringUTF32 m_oText;
double m_dBaselineOffset {0};
double m_dLastX {0};
double m_dSpaceWidthMM {0};
bool m_bIsNeedSpace {false};
bool m_bIsStrikeoutPresent {false};
bool m_bIsDoubleStrikeout {false};
bool m_bIsHighlightPresent {false};
LONG m_lHighlightColor {c_iBlackColor};
bool m_bIsUnderlinePresent {false};
eLineType m_eUnderlineType {eLineType::ltUnknown};
LONG m_lUnderlineColor {c_iBlackColor};
eVertAlignType m_eVertAlignType {eVertAlignType::vatUnknown};
bool m_bIsShadowPresent {false};
bool m_bIsOutlinePresent {false};
bool m_bIsEmbossPresent {false};
bool m_bIsEngravePresent {false};
NSStringUtils::CStringUTF32 m_oText;
double m_dBaselineOffset {0};
double m_dLastX {0};
double m_dSpaceWidthMM {0};
bool m_bIsNeedSpace {false};
eVertAlignType m_eVertAlignType {eVertAlignType::vatUnknown};
const CShape* m_pShape {nullptr}; //Если не nullptr, то есть фоновая графика - можно анализировать.
CFontManagerLight* m_pManagerLight {nullptr};
CStyleManager* m_pStyleManager {nullptr};
const CContText* m_pCont {nullptr}; //Если не nullptr, то есть привязка к vatSubscript или vatSuperscript;
#if USING_DELETE_DUPLICATING_CONTS == 0
@ -58,7 +60,7 @@ namespace NSDocxRenderer
#endif
public:
CContText(CFontManagerLight& oManagerLight);
CContText(CFontManagerLight* pManagerLight, CStyleManager* pStyleManager);
~CContText(){}
void Clear() override final;

View File

@ -1,6 +1,6 @@
#include "ElementImage.h"
#include "../resources/Constants.h"
#include "../resources/utils.h"
#include "Image.h"
#include "../../resources/Constants.h"
#include "../../resources/utils.h"
namespace NSDocxRenderer
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "BaseItem.h"
#include "ImageManager.h"
#include "../../resources/ImageInfo.h"
namespace NSDocxRenderer
{

View File

@ -1,5 +1,5 @@
#include "ElementOldShape.h"
#include "../resources/utils.h"
#include "OldShape.h"
#include "../../resources/utils.h"
namespace NSDocxRenderer
{

View File

@ -1,7 +1,7 @@
#pragma once
#include "BaseItem.h"
#include "../resources/VectorGraphics.h"
#include "ElementParagraph.h"
#include "../../resources/VectorGraphics.h"
#include "Paragraph.h"
namespace NSDocxRenderer
{

View File

@ -1,4 +1,4 @@
#include "ElementParagraph.h"
#include "Paragraph.h"
#include "src/resources/ColorTable.h"
#include "src/resources/SingletonTemplate.h"
#include "src/resources/utils.h"
@ -213,7 +213,7 @@ namespace NSDocxRenderer
{
if (m_lColorOfShadingFill == pCont->m_lHighlightColor)
{
pCont->m_bIsHighlightPresent = false;
pCont->m_bIsHighlightPresent = true;
}
}
}
@ -228,15 +228,15 @@ namespace NSDocxRenderer
{
for (auto pCont : pLine->m_arConts)
{
if (!pSelectedCont || pSelectedCont->m_oFont.Size < pCont->m_oFont.Size)
if (!pSelectedCont || pSelectedCont->m_pFontStyle->m_oFont.Size < pCont->m_pFontStyle->m_oFont.Size)
{
pSelectedCont = pCont;
}
else if (pSelectedCont->m_oFont.Size == pCont->m_oFont.Size)
else if (pSelectedCont->m_pFontStyle->m_oFont.Size == pCont->m_pFontStyle->m_oFont.Size)
{
//note считаем что обычный < Italic < Bold < Bold-Italic
if (pSelectedCont->m_oFont.GetTextFontStyle() <
pCont->m_oFont.GetTextFontStyle())
if (pSelectedCont->m_pFontStyle->m_oFont.GetTextFontStyle() <
pCont->m_pFontStyle->m_oFont.GetTextFontStyle())
{
pSelectedCont = pCont;
}
@ -244,8 +244,8 @@ namespace NSDocxRenderer
}
}
UINT lSize = static_cast<UINT>(2 * pSelectedCont->m_oFont.Size);
UINT nType = pSelectedCont->m_oFont.GetTextFontStyle();
UINT lSize = static_cast<UINT>(2 * pSelectedCont->m_pFontStyle->m_oFont.Size);
UINT nType = pSelectedCont->m_pFontStyle->m_oFont.GetTextFontStyle();
if (nType > 3)
{

View File

@ -1,7 +1,7 @@
#pragma once
#include "BaseItem.h"
#include "FontManager.h"
#include "ElementTextLine.h"
#include "../managers/FontManager.h"
#include "TextLine.h"
namespace NSDocxRenderer
{

View File

@ -1,7 +1,7 @@
#include "ElementShape.h"
#include "Shape.h"
#include <limits.h>
#include "../resources/Constants.h"
#include "../resources/utils.h"
#include "../../resources/Constants.h"
#include "../../resources/utils.h"
namespace NSDocxRenderer
{

View File

@ -1,8 +1,8 @@
#pragma once
#include "ElementParagraph.h"
#include "../resources/LinesTable.h"
#include "../resources/VectorGraphics.h"
#include "ImageManager.h"
#include "Paragraph.h"
#include "../../resources/ImageInfo.h"
#include "../../resources/LinesTable.h"
#include "../../resources/VectorGraphics.h"
namespace NSDocxRenderer
{

View File

@ -1,6 +1,6 @@
#include "ElementTextLine.h"
#include "../resources/Constants.h"
#include "../resources/SortElements.h"
#include "TextLine.h"
#include "../../resources/Constants.h"
#include "../../resources/SortElements.h"
namespace NSDocxRenderer
{
@ -285,15 +285,15 @@ namespace NSDocxRenderer
for (auto pCont : m_arConts)
{
if (!pSelectedCont || pSelectedCont->m_oFont.Size < pCont->m_oFont.Size)
if (!pSelectedCont || pSelectedCont->m_pFontStyle->m_oFont.Size < pCont->m_pFontStyle->m_oFont.Size)
{
pSelectedCont = pCont;
}
else if (pSelectedCont->m_oFont.Size == pCont->m_oFont.Size)
else if (pSelectedCont->m_pFontStyle->m_oFont.Size == pCont->m_pFontStyle->m_oFont.Size)
{
//note считаем что обычный < Italic < Bold < Bold-Italic
if (pSelectedCont->m_oFont.GetTextFontStyle() <
pCont->m_oFont.GetTextFontStyle())
if (pSelectedCont->m_pFontStyle->m_oFont.GetTextFontStyle() <
pCont->m_pFontStyle->m_oFont.GetTextFontStyle())
{
pSelectedCont = pCont;
}
@ -305,8 +305,8 @@ namespace NSDocxRenderer
return c_dRightBorderCorrectionSize[0][0];
}
UINT lSize = static_cast<UINT>(2 * pSelectedCont->m_oFont.Size);
UINT nType = pSelectedCont->m_oFont.GetTextFontStyle();
UINT lSize = static_cast<UINT>(2 * pSelectedCont->m_pFontStyle->m_oFont.Size);
UINT nType = pSelectedCont->m_pFontStyle->m_oFont.GetTextFontStyle();
if (nType > 3)
{

View File

@ -1,5 +1,5 @@
#pragma once
#include "ElementContText.h"
#include "ContText.h"
namespace NSDocxRenderer
{

View File

@ -1,5 +1,5 @@
#include "FontManager.h"
#include "../resources/Constants.h"
#include "../../resources/Constants.h"
namespace NSDocxRenderer
{
@ -35,7 +35,7 @@ namespace NSDocxRenderer
void CFontManager::AddFontToMap()
{
if (m_oFontTable.m_mapTable.end() != m_oFontTable.m_mapTable.find(m_oFont.m_strFamilyName))
if (m_oFontTable.m_mapTable.end() == m_oFontTable.m_mapTable.find(m_oFont.m_strFamilyName))
{
CFontTableEntry oEntry;
oEntry.m_strFamilyName = m_oFont.m_strFamilyName;
@ -204,7 +204,7 @@ namespace NSDocxRenderer
if (bIsNeedAddToMap)
{
if (m_oFontTable.m_mapTable.end() != m_oFontTable.m_mapTable.find(m_strCurrentPickFont))
if (m_oFontTable.m_mapTable.end() == m_oFontTable.m_mapTable.find(m_strCurrentPickFont))
{
CFontTableEntry oEntry;
oEntry.m_strFamilyName = m_strCurrentPickFont;

View File

@ -262,7 +262,7 @@ namespace NSFontManager
m_strFamilyName = oSrc.m_strFamilyName;
m_strPANOSE = oSrc.m_strPANOSE;
m_lStyle = oSrc.m_lStyle;
m_arSignature = m_arSignature;
m_arSignature = oSrc.m_arSignature;
m_bIsFixedWidth = oSrc.m_bIsFixedWidth;
m_lAvgWidth = oSrc.m_lAvgWidth;
@ -474,6 +474,7 @@ namespace NSFontManager
// PANOSE
BYTE pPanose[10];
m_pManager->GetFile()->GetPanose(pPanose);
m_oFont.m_strPANOSE.clear();
for ( int i = 0; i < 10; i++ )
{
m_oFont.m_strPANOSE += ToHexString(pPanose[i]);

View File

@ -1,49 +1,11 @@
#pragma once
#include "../DesktopEditor/common/StringBuilder.h"
#include "../DesktopEditor/common/CalculatorCRC32.h"
#include "../DesktopEditor/raster/BgraFrame.h"
#include "../../resources/ImageInfo.h"
#include <map>
namespace NSDocxRenderer
{
class CImageInfo
{
public:
enum ImageType
{
itPNG = 0,
itJPG = 1
};
public:
ImageType m_eType {itPNG};
UINT m_nId {0};
std::wstring m_strFileName {L""};
public:
CImageInfo(){}
CImageInfo(const CImageInfo &oSrc)
{
*this = oSrc;
}
CImageInfo& operator=(const CImageInfo &oSrc)
{
if (this == &oSrc)
{
return *this;
}
m_eType = oSrc.m_eType;
m_nId = oSrc.m_nId;
m_strFileName = oSrc.m_strFileName;
return *this;
}
};
class CImageManager
{
public:

View File

@ -0,0 +1,49 @@
#include "StyleManager.h"
#include <utility>
namespace NSDocxRenderer
{
CStyleManager::CStyleManager()
{
m_pCurrentStyle = new CFontStyle();
}
CStyleManager::~CStyleManager()
{
Clear();
delete m_pCurrentStyle;
}
void CStyleManager::Clear()
{
for (auto pStyle : m_mapStyles)
{
RELEASEOBJECT(pStyle.second);
}
m_mapStyles.clear();
}
void CStyleManager::NewDocument()
{
Clear();
}
CFontStyle* CStyleManager::GetStyle()
{
for (auto pStyle : m_mapStyles)
{
if (pStyle.second->IsEqual(m_pCurrentStyle))
{
return pStyle.second;
}
}
auto pairStyle = std::make_pair(m_pCurrentStyle->GetStyleId(), m_pCurrentStyle);
m_mapStyles.insert(pairStyle);
m_pCurrentStyle = new CFontStyle();
return pairStyle.second;
}
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <map>
#include "../DesktopEditor/common/StringBuilder.h"
#include "../styles/FontStyle.h"
namespace NSDocxRenderer
{
class CStyleManager
{
public:
std::map<std::wstring, CFontStyle*> m_mapStyles;
CFontStyle* m_pCurrentStyle;
public:
CStyleManager();
virtual ~CStyleManager();
void Clear();
void NewDocument();
CFontStyle* GetStyle();
};
}

View File

@ -0,0 +1,6 @@
#include "BaseStyle.h"
CBaseStyle::CBaseStyle()
{
}

View File

@ -0,0 +1,45 @@
#pragma once
#include "../DesktopEditor/common/StringBuilder.h"
namespace NSDocxRenderer
{
class CBaseStyle
{
protected:
enum class eStyleType
{
stUnknown,
stParagraph,
stCharacter,
stTable,
stNumbering
};
public:
CBaseStyle(const eStyleType& eType): m_eType(eType) {}
virtual ~CBaseStyle() {}
CBaseStyle& operator=(const CBaseStyle& oSrc)
{
if (this == &oSrc)
{
return *this;
}
m_eType = oSrc.m_eType;
m_bIsNotNecessaryToUse = oSrc.m_bIsNotNecessaryToUse;
return *this;
}
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) = 0;
private:
eStyleType m_eType {eStyleType::stUnknown};
public:
bool m_bIsNotNecessaryToUse {false};
};
}

View File

@ -0,0 +1,137 @@
#include "FontStyle.h"
#include "../../resources/ColorTable.h"
#include "../../resources/SingletonTemplate.h"
#include "../../resources/utils.h"
namespace NSDocxRenderer
{
CFontStyle::CFontStyle() : CBaseStyle(CBaseStyle::eStyleType::stCharacter)
{
static UINT iId = 0;
iId++;
if (iId < 10)
{
m_strStyleId = L"fontstyle0" + std::to_wstring(iId);
}
else
{
m_strStyleId = L"fontstyle" + std::to_wstring(iId);
}
}
CFontStyle& CFontStyle::operator=(const CFontStyle& oSrc)
{
if (this == &oSrc)
{
return *this;
}
CBaseStyle::operator=(oSrc);
m_strStyleId = oSrc.m_strStyleId;
m_oFont = oSrc.m_oFont;
m_oBrush = oSrc.m_oBrush;
m_strPickFontName = oSrc.m_strPickFontName;
m_lPickFontStyle = oSrc.m_lPickFontStyle;
return *this;
}
bool CFontStyle::IsEqual(const CFontStyle* oSrc)
{
bool bIf1 = m_oFont.Name == L"" || oSrc->m_oFont.Name == L"" ? true : m_oFont.IsEqual(&oSrc->m_oFont);
bool bIf2 = m_oBrush.IsEqual(&oSrc->m_oBrush);
bool bIf3 = m_strPickFontName == oSrc->m_strPickFontName;
bool bIf4 = m_lPickFontStyle == oSrc->m_lPickFontStyle;
if (bIf1 && bIf2 && bIf3 && bIf4)
{
return true;
}
return false;
}
\
void CFontStyle::ToXml(NSStringUtils::CStringBuilder& oWriter)
{
if (m_bIsNotNecessaryToUse)
{
return;
}
oWriter.WriteString(L"<w:style");
oWriter.WriteString(L" w:type=\"character\"");
oWriter.WriteString(L" w:customStyle=\"1\"");
oWriter.WriteString(L" w:styleId=\"");
oWriter.WriteString(m_strStyleId);
oWriter.WriteString(L"\">");
oWriter.WriteString(L"<w:name w:val=\"");
oWriter.WriteString(m_strStyleId);
oWriter.WriteString(L"\"/>");
oWriter.WriteString(L"<w:basedOn w:val=\"");
oWriter.WriteString(L"DefaultParagraphFont"); //todo сделать дерево зависимостей
oWriter.WriteString(L"\"/>");
//oWriter.WriteString(L"<w:rsid w:val=\"00BB76B0\"/>");
oWriter.WriteString(L"<w:rPr>");
std::wstring& strFontName = m_strPickFontName.empty() ? m_oFont.Name : m_strPickFontName;
oWriter.WriteString(L"<w:rFonts w:ascii=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:hAnsi=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:cs=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:hint=\"default\"/>");
if (m_strPickFontName.empty())
{
if (m_oFont.Bold)
{
oWriter.WriteString(L"<w:b/>");
oWriter.WriteString(L"<w:bCs/>");
}
if (m_oFont.Italic)
{
oWriter.WriteString(L"<w:i/>");
oWriter.WriteString(L"<w:iCs/>");
}
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle))
{
oWriter.WriteString(L"<w:b/>");
oWriter.WriteString(L"<w:bCs/>");
}
if (0x02 == (0x02 & m_lPickFontStyle))
{
oWriter.WriteString(L"<w:i/>");
oWriter.WriteString(L"<w:iCs/>");
}
}
if (ConvertColorBGRToRGB(m_oBrush.Color1) != c_iBlackColor2)
{
oWriter.WriteString(L"<w:color w:val=\"");
oWriter.WriteHexInt3(ConvertColorBGRToRGB(m_oBrush.Color1));
oWriter.WriteString(L"\"/>");
}
int lSize = static_cast<int>(2 * m_oFont.Size);
oWriter.WriteString(L"<w:sz w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/><w:szCs w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/>");
oWriter.WriteString(L"</w:rPr>");
oWriter.WriteString(L"</w:style>");
}
}

View File

@ -0,0 +1,36 @@
#pragma once
#include "BaseStyle.h"
#include "../managers/FontManager.h"
#include "../../resources/Constants.h"
#include "../../resources/LinesTable.h"
namespace NSDocxRenderer
{
class CFontStyle : public CBaseStyle
{
public:
NSStructures::CFont m_oFont;
NSStructures::CBrush m_oBrush;
std::wstring m_strPickFontName {L""};
LONG m_lPickFontStyle {0};
private:
std::wstring m_strStyleId {L""};
public:
CFontStyle();
~CFontStyle(){}
CFontStyle& operator=(const CFontStyle& oSrc);
void ToXml(NSStringUtils::CStringBuilder& oWriter) override final;
bool IsEqual(const CFontStyle* oSrc);
std::wstring GetStyleId() {return m_strStyleId;}
};
}

View File

@ -32,6 +32,7 @@ const double c_dMAX_LINE_HEIGHT_MM = 2.5;
const UINT c_iWhiteColor = 0xFFFFFF;
const UINT c_iBlackColor = 0x000000;
const UINT c_iBlackColor2 = 0x111111;
const UINT c_iGreyColor = 0xC0C0C0;
const UINT c_iGreyColor2 = 0x999999;

View File

@ -0,0 +1,43 @@
#pragma once
#include "../DesktopEditor/common/StringBuilder.h"
namespace NSDocxRenderer
{
class CImageInfo
{
public:
enum ImageType
{
itPNG = 0,
itJPG = 1
};
public:
ImageType m_eType {itPNG};
UINT m_nId {0};
std::wstring m_strFileName {L""};
public:
CImageInfo(){}
CImageInfo(const CImageInfo &oSrc)
{
*this = oSrc;
}
CImageInfo& operator=(const CImageInfo &oSrc)
{
if (this == &oSrc)
{
return *this;
}
m_eType = oSrc.m_eType;
m_nId = oSrc.m_nId;
m_strFileName = oSrc.m_strFileName;
return *this;
}
};
}

File diff suppressed because one or more lines are too long