mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-31 10:21:37 +08:00
Compare commits
23 Commits
v9.1.0.58
...
fix/bug597
| Author | SHA1 | Date | |
|---|---|---|---|
| 950482095c | |||
| 8ca89ca9b7 | |||
| da705edfb8 | |||
| 2ed318df0f | |||
| 771ee80ec5 | |||
| 4ddf4521c4 | |||
| 1491bd8802 | |||
| e7de9af0e0 | |||
| b79001a9fd | |||
| 49d4b5c1d2 | |||
| fa513eb83f | |||
| e84e0a6ce8 | |||
| a7b5866bc6 | |||
| f3ee3c8c91 | |||
| e108591a7e | |||
| 29f1dc454b | |||
| 4ea504f688 | |||
| a82cf375b7 | |||
| c2a733f465 | |||
| e4a7cf63c9 | |||
| 66501ab353 | |||
| 1fc61459b8 | |||
| 064a04a600 |
@ -72,7 +72,7 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
@ -153,6 +153,17 @@ std::wstring EncodeXmlString(const std::wstring& s)
|
||||
return sRes;
|
||||
}
|
||||
|
||||
enum class EParagraphPropertie
|
||||
{
|
||||
Sup,
|
||||
Sub,
|
||||
Strikethrough,
|
||||
Emphasis,
|
||||
Strong
|
||||
};
|
||||
|
||||
typedef std::vector<EParagraphPropertie> ParagraphProperties;
|
||||
|
||||
class CFb2File_Private
|
||||
{
|
||||
public:
|
||||
@ -175,6 +186,8 @@ private:
|
||||
bool m_bInNote;
|
||||
bool m_bInTable;
|
||||
|
||||
ParagraphProperties m_arParagraphProperties;
|
||||
|
||||
// STitleInfo* m_pSrcTitleInfo; // Данные об исходнике книги
|
||||
// SPublishInfo* m_pPublishInfo; // Сведения об издании книги
|
||||
// std::map<std::wstring, std::wstring> m_mCustomInfo; // Произвольная информация
|
||||
@ -221,6 +234,58 @@ public:
|
||||
return m_oLightReader.ReadNextNode() && m_oLightReader.GetName() == L"FictionBook";
|
||||
}
|
||||
|
||||
void OpenP(NSStringUtils::CStringBuilder& oBuilder)
|
||||
{
|
||||
if (m_bInP || m_bInTable)
|
||||
return;
|
||||
|
||||
oBuilder.WriteString(L"<p>");
|
||||
m_bInP = true;
|
||||
}
|
||||
|
||||
void CloseP(NSStringUtils::CStringBuilder& oBuilder)
|
||||
{
|
||||
if (!m_bInP || m_bInTable)
|
||||
return;
|
||||
|
||||
oBuilder.WriteString(L"</p>");
|
||||
m_bInP = false;
|
||||
}
|
||||
|
||||
void WriteText(NSStringUtils::CStringBuilder& oBuilder, const std::wstring& wsText, const std::vector<EParagraphPropertie>& arPProperties)
|
||||
{
|
||||
if (wsText.end() == std::find_if_not(wsText.begin(), wsText.end(), [](wchar_t wchChar){ return iswspace(wchChar) && 0xa0 != wchChar;}))
|
||||
return;
|
||||
|
||||
OpenP(oBuilder);
|
||||
|
||||
for (const EParagraphPropertie ePropertie : arPProperties)
|
||||
{
|
||||
switch(ePropertie)
|
||||
{
|
||||
case EParagraphPropertie::Sup: oBuilder.WriteString(L"<sup>"); break;
|
||||
case EParagraphPropertie::Sub: oBuilder.WriteString(L"<sub>"); break;
|
||||
case EParagraphPropertie::Strikethrough: oBuilder.WriteString(L"<strikethrough>"); break;
|
||||
case EParagraphPropertie::Emphasis: oBuilder.WriteString(L"<emphasis>"); break;
|
||||
case EParagraphPropertie::Strong: oBuilder.WriteString(L"<strong>"); break;
|
||||
}
|
||||
}
|
||||
|
||||
oBuilder.WriteEncodeXmlString(wsText);
|
||||
|
||||
for (ParagraphProperties::const_reverse_iterator itPropertie = arPProperties.crbegin(); itPropertie != arPProperties.crend(); ++itPropertie)
|
||||
{
|
||||
switch(*itPropertie)
|
||||
{
|
||||
case EParagraphPropertie::Sup: oBuilder.WriteString(L"</sup>"); break;
|
||||
case EParagraphPropertie::Sub: oBuilder.WriteString(L"</sub>"); break;
|
||||
case EParagraphPropertie::Strikethrough: oBuilder.WriteString(L"</strikethrough>"); break;
|
||||
case EParagraphPropertie::Emphasis: oBuilder.WriteString(L"</emphasis>"); break;
|
||||
case EParagraphPropertie::Strong: oBuilder.WriteString(L"</strong>"); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Читает image
|
||||
// НЕ имеет право писать p
|
||||
void readImage(NSStringUtils::CStringBuilder& oBuilder)
|
||||
@ -1449,7 +1514,7 @@ public:
|
||||
|
||||
// html -> fb2
|
||||
|
||||
void readStream(NSStringUtils::CStringBuilder& oXml)
|
||||
void readStream(NSStringUtils::CStringBuilder& oXml, ParagraphProperties& arPProperties)
|
||||
{
|
||||
int nDepth = m_oLightReader.GetDepth();
|
||||
if (m_oLightReader.IsEmptyNode() || !m_oLightReader.ReadNextSiblingNode2(nDepth))
|
||||
@ -1458,7 +1523,7 @@ public:
|
||||
{
|
||||
std::wstring sName = m_oLightReader.GetName();
|
||||
if (sName == L"#text")
|
||||
oXml.WriteEncodeXmlString(m_oLightReader.GetText());
|
||||
WriteText(oXml, m_oLightReader.GetText(), arPProperties);
|
||||
else if (sName == L"br" && !m_bInTable)
|
||||
{
|
||||
bool bPBB = false, bCBB = false;
|
||||
@ -1501,26 +1566,18 @@ public:
|
||||
m_oLightReader.MoveToElement();
|
||||
if (m_bFootnote && !sFootnoteName.empty())
|
||||
{
|
||||
readStream(oFootnote);
|
||||
readStream(oFootnote, arPProperties);
|
||||
m_mFootnotes.insert(std::make_pair(sFootnoteName, oFootnote.GetData()));
|
||||
m_bFootnote = false;
|
||||
}
|
||||
else
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
}
|
||||
else if (sName == L"p")
|
||||
{
|
||||
if (!m_bInTable && !m_bInP)
|
||||
{
|
||||
oXml.WriteString(L"<p>");
|
||||
m_bInP = true;
|
||||
}
|
||||
readStream(oXml);
|
||||
if (!m_bInTable && m_bInP)
|
||||
{
|
||||
oXml.WriteString(L"</p>");
|
||||
m_bInP = false;
|
||||
}
|
||||
OpenP(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
CloseP(oXml);
|
||||
}
|
||||
else if (sName == L"title")
|
||||
{
|
||||
@ -1564,7 +1621,7 @@ public:
|
||||
bInH = true;
|
||||
m_bInP = true;
|
||||
}
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
if (bInH)
|
||||
{
|
||||
oXml.WriteString(L"</p></title>");
|
||||
@ -1590,52 +1647,55 @@ public:
|
||||
sAlign = sStyle.substr(nAlign + 1, (nAlignEnd < sStyle.length() ? nAlignEnd : sStyle.length()) - nAlign);
|
||||
if (sAlign == L"super")
|
||||
{
|
||||
oXml.WriteString(L"<sup>");
|
||||
readStream(oXml);
|
||||
oXml.WriteString(L"</sup>");
|
||||
arPProperties.push_back(EParagraphPropertie::Sup);
|
||||
readStream(oXml, arPProperties);
|
||||
arPProperties.pop_back();
|
||||
}
|
||||
else if (sAlign == L"sub")
|
||||
{
|
||||
oXml.WriteString(L"<sub>");
|
||||
readStream(oXml);
|
||||
oXml.WriteString(L"</sub>");
|
||||
arPProperties.push_back(EParagraphPropertie::Sub);
|
||||
readStream(oXml, arPProperties);
|
||||
arPProperties.pop_back();
|
||||
}
|
||||
else
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
}
|
||||
else
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
}
|
||||
else if (sName == L"s")
|
||||
{
|
||||
oXml.WriteString(L"<strikethrough>");
|
||||
readStream(oXml);
|
||||
oXml.WriteString(L"</strikethrough>");
|
||||
arPProperties.push_back(EParagraphPropertie::Strikethrough);
|
||||
readStream(oXml, arPProperties);
|
||||
arPProperties.pop_back();
|
||||
}
|
||||
else if (sName == L"i")
|
||||
{
|
||||
oXml.WriteString(L"<emphasis>");
|
||||
readStream(oXml);
|
||||
oXml.WriteString(L"</emphasis>");
|
||||
arPProperties.push_back(EParagraphPropertie::Emphasis);
|
||||
readStream(oXml, arPProperties);
|
||||
arPProperties.pop_back();
|
||||
}
|
||||
else if (sName == L"b")
|
||||
{
|
||||
oXml.WriteString(L"<strong>");
|
||||
readStream(oXml);
|
||||
oXml.WriteString(L"</strong>");
|
||||
arPProperties.push_back(EParagraphPropertie::Strong);
|
||||
readStream(oXml, arPProperties);
|
||||
arPProperties.pop_back();
|
||||
}
|
||||
else if (sName == L"table")
|
||||
{
|
||||
oXml.WriteString(L"<table>");
|
||||
m_bInTable = true;
|
||||
readStream(oXml);
|
||||
|
||||
ParagraphProperties arTableProperties;
|
||||
readStream(oXml, arTableProperties);
|
||||
|
||||
oXml.WriteString(L"</table>");
|
||||
m_bInTable = false;
|
||||
}
|
||||
else if (sName == L"tr")
|
||||
{
|
||||
oXml.WriteString(L"<tr>");
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
oXml.WriteString(L"</tr>");
|
||||
}
|
||||
else if (sName == L"td" || sName == L"th")
|
||||
@ -1650,7 +1710,7 @@ public:
|
||||
}
|
||||
m_oLightReader.MoveToElement();
|
||||
oXml.WriteString(L">");
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
oXml.WriteString(L"</td>");
|
||||
}
|
||||
else if (sName == L"a")
|
||||
@ -1690,13 +1750,13 @@ public:
|
||||
m_oLightReader.MoveToElement();
|
||||
oXml.WriteString(L">");
|
||||
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
oXml.WriteString(L"</a>");
|
||||
}
|
||||
else if (sName == L"ul")
|
||||
readLi(oXml, true);
|
||||
readLi(oXml, true, arPProperties);
|
||||
else if (sName == L"ol")
|
||||
readLi(oXml, false);
|
||||
readLi(oXml, false, arPProperties);
|
||||
else if (sName == L"img")
|
||||
{
|
||||
std::wstring sId, sBinary;
|
||||
@ -1716,11 +1776,11 @@ public:
|
||||
oXml.WriteString(L"<image l:href=\"#img" + sId + L".png\"/>");
|
||||
}
|
||||
else
|
||||
readStream(oXml);
|
||||
readStream(oXml, arPProperties);
|
||||
} while (m_oLightReader.ReadNextSiblingNode2(nDepth));
|
||||
}
|
||||
|
||||
void readLi(NSStringUtils::CStringBuilder& oXml, bool bUl)
|
||||
void readLi(NSStringUtils::CStringBuilder& oXml, bool bUl, ParagraphProperties& arProperties)
|
||||
{
|
||||
int nNum = 1;
|
||||
while (m_oLightReader.MoveToNextAttribute())
|
||||
@ -1734,9 +1794,8 @@ public:
|
||||
{
|
||||
if (m_oLightReader.GetName() == L"li")
|
||||
{
|
||||
if (!m_bInP)
|
||||
oXml.WriteString(L"<p>");
|
||||
m_bInP = true;
|
||||
OpenP(oXml);
|
||||
|
||||
if (bUl)
|
||||
oXml.AddCharSafe(183);
|
||||
else
|
||||
@ -1773,10 +1832,9 @@ public:
|
||||
oXml.WriteString(sPoint);
|
||||
}
|
||||
oXml.WriteString(L" ");
|
||||
readStream(oXml);
|
||||
if (m_bInP)
|
||||
oXml.WriteString(L"</p>");
|
||||
m_bInP = false;
|
||||
readStream(oXml, arProperties);
|
||||
|
||||
CloseP(oXml);
|
||||
}
|
||||
} while (m_oLightReader.ReadNextSiblingNode2(nDeath));
|
||||
}
|
||||
@ -2113,6 +2171,7 @@ HRESULT CFb2File::FromHtml(const std::wstring& sHtmlFile, const std::wstring& sD
|
||||
|
||||
//XmlUtils::CXmlLiteReader oIndexHtml;
|
||||
std::wstring xhtml = htmlToXhtml(sContent, bNeedConvert);
|
||||
|
||||
if (!m_internal->m_oLightReader.FromString(xhtml))
|
||||
return S_FALSE;
|
||||
|
||||
@ -2123,7 +2182,8 @@ HRESULT CFb2File::FromHtml(const std::wstring& sHtmlFile, const std::wstring& sD
|
||||
|
||||
//std::vector<std::wstring> arrBinary;
|
||||
NSStringUtils::CStringBuilder oDocument;
|
||||
m_internal->readStream(oDocument);
|
||||
ParagraphProperties arProperties;
|
||||
m_internal->readStream(oDocument, arProperties);
|
||||
|
||||
NSStringUtils::CStringBuilder oRes;
|
||||
oRes.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\"?><FictionBook xmlns=\"http://www.gribuser.ru/xml/fictionbook/2.0\" xmlns:l=\"http://www.w3.org/1999/xlink\">");
|
||||
|
||||
@ -265,6 +265,7 @@ struct CTextSettings
|
||||
bool bMergeText; // Объединять подяр идущий текст в 1?
|
||||
int nLi; // Уровень списка
|
||||
bool bNumberingLi; // Является ли список нумерованным
|
||||
bool bWritedLi; // Записан ли уже w:numPr
|
||||
|
||||
std::wstring sPStyle;
|
||||
|
||||
@ -278,12 +279,12 @@ struct CTextSettings
|
||||
NSCSS::CCompiledStyle oAdditionalStyle;
|
||||
|
||||
CTextSettings()
|
||||
: bBdo(false), bPre(false), bQ(false), bAddSpaces(true), bMergeText(false), nLi(-1), bNumberingLi(false), eTextMode(Normal)
|
||||
: bBdo(false), bPre(false), bQ(false), bAddSpaces(true), bMergeText(false), nLi(-1), bNumberingLi(false), bWritedLi(false), eTextMode(Normal)
|
||||
{}
|
||||
|
||||
CTextSettings(const CTextSettings& oTS) :
|
||||
bBdo(oTS.bBdo), bPre(oTS.bPre), bQ(oTS.bQ), bAddSpaces(oTS.bAddSpaces), bMergeText(oTS.bMergeText),
|
||||
nLi(oTS.nLi),bNumberingLi(oTS.bNumberingLi), sPStyle(oTS.sPStyle), eTextMode(oTS.eTextMode)
|
||||
nLi(oTS.nLi), bNumberingLi(oTS.bNumberingLi), bWritedLi(oTS.bWritedLi), sPStyle(oTS.sPStyle), eTextMode(oTS.eTextMode)
|
||||
{}
|
||||
|
||||
void AddPStyle(const std::wstring& wsStyle)
|
||||
@ -3962,6 +3963,7 @@ private:
|
||||
m_oLightReader.MoveToElement();
|
||||
|
||||
oTSLiP.nLi++;
|
||||
oTSLiP.bWritedLi = false;
|
||||
|
||||
if (!wsValue.empty())
|
||||
{
|
||||
@ -4230,7 +4232,7 @@ private:
|
||||
CloseP(oXml, sSelectors);
|
||||
}
|
||||
|
||||
bool readImage (NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& sSelectors, const CTextSettings& oTS)
|
||||
bool readImage (NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& sSelectors, CTextSettings& oTS)
|
||||
{
|
||||
std::wstring wsAlt, sSrcM;
|
||||
bool bRes = false;
|
||||
@ -4355,7 +4357,7 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring wrP(NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& sSelectors, const CTextSettings& oTS)
|
||||
std::wstring wrP(NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& sSelectors, CTextSettings& oTS)
|
||||
{
|
||||
OpenP(oXml);
|
||||
|
||||
@ -4386,8 +4388,18 @@ private:
|
||||
}
|
||||
|
||||
if (oTS.nLi >= 0)
|
||||
oXml->WriteString(L"<w:numPr><w:ilvl w:val=\"" + std::to_wstring(oTS.nLi) + L"\"/><w:numId w:val=\"" +
|
||||
(!oTS.bNumberingLi ? L"1" : std::to_wstring(m_nNumberingId + 1)) + L"\"/></w:numPr>");
|
||||
{
|
||||
if (!oTS.bWritedLi)
|
||||
{
|
||||
oXml->WriteString(L"<w:numPr><w:ilvl w:val=\"" + std::to_wstring(oTS.nLi) + L"\"/><w:numId w:val=\"" +
|
||||
(!oTS.bNumberingLi ? L"1" : std::to_wstring(m_nNumberingId + 1)) + L"\"/></w:numPr>");
|
||||
|
||||
oTS.bWritedLi = true;
|
||||
}
|
||||
else if (sSelectors.back().m_pCompiledStyle->m_oText.GetIndent().Empty() &&
|
||||
oTS.oAdditionalStyle.m_oText.GetIndent().Empty())
|
||||
oXml->WriteString(L"<w:ind w:left=\"" + std::to_wstring(720 * (oTS.nLi + 1)) + L"\"/>");
|
||||
}
|
||||
|
||||
oXml->WriteString(oTS.sPStyle + sPSettings);
|
||||
oXml->WriteNodeEnd(L"w:pPr");
|
||||
|
||||
@ -5,10 +5,9 @@
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/SystemUtils.h"
|
||||
#include "../../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/pro/Graphics.h"
|
||||
#include "../../../DesktopEditor/graphics/pro/Image.h"
|
||||
|
||||
#include "../Paragraph/ParaText.h"
|
||||
#include "../Paragraph/CtrlTable.h"
|
||||
@ -1293,8 +1292,8 @@ void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
|
||||
else
|
||||
{
|
||||
m_oDocXml.WriteString(L"<w:pgSz w:w=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetWidth())) + L"\" w:h=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetHeight())) + L"\"/>");
|
||||
m_oDocXml.WriteString(L"<w:pgMar w:top=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginTop())) + L"\" w:right=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginRight())) + L"\" w:bottom=\"" +
|
||||
std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginBottom())) + L"\" w:left=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginRight())) + L"\" w:header=\"" +
|
||||
m_oDocXml.WriteString(L"<w:pgMar w:top=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginTop() + pPage->GetMarginHeader())) + L"\" w:right=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginRight())) + L"\" w:bottom=\"" +
|
||||
std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginBottom() + pPage->GetMarginFooter())) + L"\" w:left=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginRight())) + L"\" w:header=\"" +
|
||||
std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginHeader())) + L"\" w:footer=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginFooter())) + L"\" w:gutter=\"" +
|
||||
std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginGutter())) + L"\"/>");
|
||||
}
|
||||
@ -1647,13 +1646,13 @@ void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStr
|
||||
if (nullptr == pCtrlShape)
|
||||
return;
|
||||
|
||||
int nFinalWidth = pCtrlShape->GetCurWidth();
|
||||
int nFinalHeight = pCtrlShape->GetCurHeight();
|
||||
int nFinalWidth = std::abs(pCtrlShape->GetWidth());
|
||||
int nFinalHeight = std::abs(pCtrlShape->GetHeight());
|
||||
|
||||
if (0 == nFinalWidth || 0 == nFinalHeight)
|
||||
{
|
||||
nFinalWidth = std::abs(pCtrlShape->GetWidth());
|
||||
nFinalHeight = std::abs(pCtrlShape->GetHeight());
|
||||
nFinalWidth = pCtrlShape->GetCurWidth();
|
||||
nFinalHeight = pCtrlShape->GetCurHeight();
|
||||
}
|
||||
|
||||
if (nullptr != pWidth)
|
||||
@ -2026,7 +2025,11 @@ void CConverter2OOXML::WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short
|
||||
return;
|
||||
}
|
||||
case ENumType::TOTAL_PAGE:
|
||||
ushValue = m_ushPageCount; break;
|
||||
{
|
||||
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||
oBuilder.WriteString(L"<w:fldSimple w:instr=\"NUMPAGES \\* ARABIC\"><w:r><w:t>1</w:t></w:r></w:fldSimple>");
|
||||
return;
|
||||
}
|
||||
case ENumType::FOOTNOTE:
|
||||
{
|
||||
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||
|
||||
@ -152,7 +152,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
{
|
||||
UPDATE_CURRENT_TEXT();
|
||||
|
||||
if (sText.length() < unIndex + 6 || (sText[unIndex] != sText[unIndex + 6] && sText[unIndex] != sText[unIndex + 7]))
|
||||
if (sText.length() < unIndex + 7 || (sText[unIndex] != sText[unIndex + 6] && sText[unIndex] != sText[unIndex + 7]))
|
||||
continue;
|
||||
|
||||
arParas.push_back(new CCtrlCharacter(L" _", ECtrlCharType::TABULATION));
|
||||
|
||||
@ -30,6 +30,7 @@ INCLUDEPATH += \
|
||||
|
||||
HEADERS += \
|
||||
OFDFile.h \
|
||||
src/Annotation.h \
|
||||
src/Content/ImageObject.h \
|
||||
src/Content/PageBlock.h \
|
||||
src/Content/PathObject.h \
|
||||
@ -52,6 +53,7 @@ HEADERS += \
|
||||
src/Types/Font.h \
|
||||
src/Types/MultiMedia.h \
|
||||
src/Types/PageArea.h \
|
||||
src/Types/PenSettings.h \
|
||||
src/Types/Signature.h \
|
||||
src/Types/TemplatePage.h \
|
||||
src/Utils/Types.h \
|
||||
@ -60,6 +62,7 @@ HEADERS += \
|
||||
|
||||
SOURCES += \
|
||||
OFDFile.cpp \
|
||||
src/Annotation.cpp \
|
||||
src/Content/ImageObject.cpp \
|
||||
src/Content/PageBlock.cpp \
|
||||
src/Content/PathObject.cpp \
|
||||
@ -80,6 +83,7 @@ SOURCES += \
|
||||
src/Types/Font.cpp \
|
||||
src/Types/MultiMedia.cpp \
|
||||
src/Types/PageArea.cpp \
|
||||
src/Types/PenSettings.cpp \
|
||||
src/Types/Signature.cpp \
|
||||
src/Types/TemplatePage.cpp \
|
||||
src/Utils/Types.cpp \
|
||||
|
||||
205
OFDFile/src/Annotation.cpp
Normal file
205
OFDFile/src/Annotation.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
#include "Annotation.h"
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CParameter::CParameter(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
do
|
||||
{
|
||||
if ("Name" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
m_wsName = oLiteReader.GetText();
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
m_wsValue = oLiteReader.GetText2();
|
||||
}
|
||||
|
||||
CAnnot::CAnnot(CXmlReader& oLiteReader)
|
||||
: m_bVisible(true), m_bPrint(true), m_bNoZoom(false), m_bNoRotate(false), m_bReadOnly(true)
|
||||
{
|
||||
if (oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string wsAttributeName;
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("Type" == wsAttributeName)
|
||||
{
|
||||
const std::string sValue{oLiteReader.GetTextA()};
|
||||
|
||||
if ("Link" == sValue)
|
||||
m_eType = EAnnotType::Link;
|
||||
else if ("Path" == sValue)
|
||||
m_eType = EAnnotType::Path;
|
||||
else if ("Highlight" == sValue)
|
||||
m_eType = EAnnotType::Highlight;
|
||||
else if ("Stamp" == sValue)
|
||||
m_eType = EAnnotType::Stamp;
|
||||
else if ("Watermark" == sValue)
|
||||
m_eType = EAnnotType::Watermark;
|
||||
}
|
||||
else if ("Visible" == wsAttributeName)
|
||||
{
|
||||
if ("false" == oLiteReader.GetTextA())
|
||||
m_bVisible = false;
|
||||
}
|
||||
else if ("Print" == wsAttributeName)
|
||||
{
|
||||
if ("false" == oLiteReader.GetTextA())
|
||||
m_bPrint = false;
|
||||
}
|
||||
else if ("NoZoom" == wsAttributeName)
|
||||
{
|
||||
if ("true" == oLiteReader.GetTextA())
|
||||
m_bNoZoom = true;
|
||||
}
|
||||
else if ("NoRotate" == wsAttributeName)
|
||||
{
|
||||
if ("true" == oLiteReader.GetTextA())
|
||||
m_bNoRotate = true;
|
||||
}
|
||||
else if ("ReadOnly" == wsAttributeName)
|
||||
{
|
||||
if ("true" == oLiteReader.GetTextA())
|
||||
m_bReadOnly = true;
|
||||
}
|
||||
}while(oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:Parameters" == sNodeName)
|
||||
{
|
||||
const int nChildDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nChildDepth))
|
||||
{
|
||||
if ("ofd:Parameter" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
m_arParameters.push_back(new CParameter(oLiteReader));
|
||||
}
|
||||
}
|
||||
else if ("ofd:Appearance" == sNodeName)
|
||||
m_arAppearances.push_back(new CAppearance(oLiteReader));
|
||||
}
|
||||
}
|
||||
|
||||
CAnnot::~CAnnot()
|
||||
{
|
||||
ClearContainer(m_arParameters);
|
||||
ClearContainer(m_arAppearances);
|
||||
}
|
||||
|
||||
void CAnnot::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (!m_bPrint)
|
||||
return;
|
||||
|
||||
for (const CAppearance* pAppearance : m_arAppearances)
|
||||
pAppearance->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
|
||||
CPageAnnot::CPageAnnot()
|
||||
{}
|
||||
|
||||
CPageAnnot* CPageAnnot::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, wsRootPath))
|
||||
return nullptr;
|
||||
|
||||
const std::wstring wsNormalizedPath = CombinePaths(wsRootPath, wsFilePath);
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || "ofd:PageAnnot" != oLiteReader.GetNameA())
|
||||
return nullptr;
|
||||
|
||||
CPageAnnot *pPageAnnot = new CPageAnnot();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:Annot" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
pPageAnnot->m_arAnnots.push_back(new CAnnot(oLiteReader));
|
||||
}
|
||||
|
||||
return pPageAnnot;
|
||||
}
|
||||
|
||||
void CPageAnnot::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
for (const CAnnot* pAnnot : m_arAnnots)
|
||||
pAnnot->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
|
||||
CAnnotation::CAnnotation()
|
||||
: m_pPageAnnot(nullptr)
|
||||
{}
|
||||
|
||||
CAnnotation::~CAnnotation()
|
||||
{
|
||||
if (nullptr != m_pPageAnnot)
|
||||
delete m_pPageAnnot;
|
||||
}
|
||||
|
||||
bool CAnnotation::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, wsRootPath))
|
||||
return false;
|
||||
|
||||
std::wstring wsNormalizedPath = CombinePaths(wsRootPath, wsFilePath);
|
||||
|
||||
if (L"xml" != NSFile::GetFileExtention(wsNormalizedPath))
|
||||
wsNormalizedPath = CombinePaths(wsNormalizedPath, L"Annotations.xml");
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || L"ofd:Annotations" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if (L"ofd:Page" != oLiteReader.GetName())
|
||||
continue;
|
||||
|
||||
const int nChildDepth = oLiteReader.GetDepth();
|
||||
while (oLiteReader.ReadNextSiblingNode(nChildDepth))
|
||||
{
|
||||
if (L"ofd:FileLoc" != oLiteReader.GetName())
|
||||
continue;
|
||||
|
||||
if (nullptr == m_pPageAnnot)
|
||||
m_pPageAnnot = CPageAnnot::Read(oLiteReader.GetText2(), NSSystemPath::GetDirectoryName(wsNormalizedPath));
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr != m_pPageAnnot;
|
||||
}
|
||||
|
||||
void CAnnotation::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr != m_pPageAnnot)
|
||||
m_pPageAnnot->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
}
|
||||
77
OFDFile/src/Annotation.h
Normal file
77
OFDFile/src/Annotation.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef ANNOTATION_H
|
||||
#define ANNOTATION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Content/PageBlock.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CParameter
|
||||
{
|
||||
public:
|
||||
CParameter(CXmlReader& oLiteReader);
|
||||
private:
|
||||
std::wstring m_wsName;
|
||||
std::wstring m_wsValue;
|
||||
};
|
||||
|
||||
typedef CPageBlock CAppearance;
|
||||
|
||||
enum class EAnnotType
|
||||
{
|
||||
Link,
|
||||
Path,
|
||||
Highlight,
|
||||
Stamp,
|
||||
Watermark
|
||||
};
|
||||
|
||||
class CAnnot
|
||||
{
|
||||
public:
|
||||
CAnnot(CXmlReader& oLiteReader);
|
||||
~CAnnot();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
private:
|
||||
EAnnotType m_eType;
|
||||
bool m_bVisible;
|
||||
bool m_bPrint;
|
||||
bool m_bNoZoom;
|
||||
bool m_bNoRotate;
|
||||
bool m_bReadOnly;
|
||||
|
||||
std::vector<CParameter*> m_arParameters;
|
||||
std::vector<CAppearance*> m_arAppearances;
|
||||
};
|
||||
|
||||
class CPageAnnot
|
||||
{
|
||||
public:
|
||||
CPageAnnot();
|
||||
|
||||
static CPageAnnot* Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
private:
|
||||
|
||||
std::vector<CAnnot*> m_arAnnots;
|
||||
};
|
||||
|
||||
class CAnnotation
|
||||
{
|
||||
public:
|
||||
CAnnotation();
|
||||
~CAnnotation();
|
||||
|
||||
bool Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
private:
|
||||
CPageAnnot *m_pPageAnnot;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ANNOTATION_H
|
||||
@ -30,12 +30,12 @@ bool CContent::Read(CXmlReader& oLiteReader)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CContent::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CContent::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const CLayer* pLayer : m_arLayers)
|
||||
pLayer->Draw(pRenderer, oCommonData);
|
||||
pLayer->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public:
|
||||
~CContent();
|
||||
|
||||
bool Read(CXmlReader& oLiteReader);
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -4,9 +4,7 @@
|
||||
namespace OFD
|
||||
{
|
||||
CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||
: m_bVisible(true), m_unDrawParam(0), m_dLineWidth(0.353),
|
||||
m_eCap(ECap::Butt), m_eJoin(EJoin::Miter), m_dMiterLimit(4.234),
|
||||
m_dDashOffset(0.), m_uchAlpha(255)
|
||||
: m_bVisible(true), m_unDrawParam(0), m_oPenSettings(oLiteReader)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
@ -27,36 +25,6 @@ CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||
m_oCTM.Read(oLiteReader.GetTextA());
|
||||
else if (L"DrawParam" == wsAttributeName)
|
||||
m_unDrawParam = oLiteReader.GetUInteger(true);
|
||||
else if (L"LineWidth" == wsAttributeName)
|
||||
m_dLineWidth = oLiteReader.GetDouble(true);
|
||||
else if (L"Cap" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Butt" == wsValue)
|
||||
m_eCap = ECap::Butt;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eCap = ECap::Round;
|
||||
else if (L"Square" == wsValue)
|
||||
m_eCap = ECap::Square;
|
||||
}
|
||||
else if (L"Join" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Miter" == wsValue)
|
||||
m_eJoin = EJoin::Miter;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eJoin = EJoin::Round;
|
||||
else if (L"Bevel" == wsValue)
|
||||
m_eJoin = EJoin::Bevel;
|
||||
}
|
||||
else if (L"MiterLimit" == wsAttributeName)
|
||||
m_dMiterLimit = oLiteReader.GetDouble(true);
|
||||
else if (L"DashOffset" == wsAttributeName)
|
||||
m_dDashOffset = oLiteReader.GetDouble(true);
|
||||
else if (L"Alpha" == wsAttributeName)
|
||||
m_uchAlpha = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
@ -67,6 +35,8 @@ void CGraphicUnit::Apply(IRenderer* pRenderer, TMatrix& oOldTransform) const
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
m_oPenSettings.Apply(pRenderer);
|
||||
|
||||
pRenderer->GetTransform(&oOldTransform.m_dM11, &oOldTransform.m_dM12, &oOldTransform.m_dM21, &oOldTransform.m_dM22, &oOldTransform.m_dDx, &oOldTransform.m_dDy);
|
||||
|
||||
Aggplus::CMatrix oTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
#ifndef GRAPHICUNIT_H
|
||||
#define GRAPHICUNIT_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Types/PenSettings.h"
|
||||
#include "../Utils/Types.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CGraphicUnit
|
||||
@ -17,28 +13,7 @@ class CGraphicUnit
|
||||
bool m_bVisible;
|
||||
TMatrix m_oCTM;
|
||||
unsigned int m_unDrawParam;
|
||||
double m_dLineWidth;
|
||||
|
||||
enum class ECap
|
||||
{
|
||||
Butt,
|
||||
Round,
|
||||
Square
|
||||
} m_eCap;
|
||||
|
||||
enum class EJoin
|
||||
{
|
||||
Miter,
|
||||
Round,
|
||||
Bevel
|
||||
} m_eJoin;
|
||||
|
||||
double m_dMiterLimit;
|
||||
double m_dDashOffset;
|
||||
std::vector<double> m_arDashPattern;
|
||||
unsigned char m_uchAlpha;
|
||||
|
||||
friend class CPathObject;
|
||||
CPenSettings m_oPenSettings;
|
||||
public:
|
||||
CGraphicUnit(CXmlReader& oLiteReader);
|
||||
|
||||
|
||||
@ -8,13 +8,20 @@
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
enum class EPageType
|
||||
{
|
||||
Page,
|
||||
TemplatePage,
|
||||
Anotation
|
||||
};
|
||||
|
||||
class IPageBlock : public IOFDElement
|
||||
{
|
||||
public:
|
||||
IPageBlock(CXmlReader& oLiteReader)
|
||||
: IOFDElement(oLiteReader){};
|
||||
virtual ~IPageBlock(){};
|
||||
virtual void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const = 0;
|
||||
virtual void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ CImageObject::CImageObject(CXmlReader& oLiteReader)
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == oCommonData.GetDocumentRes())
|
||||
return;
|
||||
|
||||
@ -12,7 +12,7 @@ class CImageObject : public IPageBlock, public CGraphicUnit
|
||||
public:
|
||||
CImageObject(CXmlReader& oLiteReader);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,12 @@ CLayer::~CLayer()
|
||||
delete pPageBlock;
|
||||
}
|
||||
|
||||
void CLayer::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CLayer::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
pPageBlock->Draw(pRenderer, oCommonData);
|
||||
pPageBlock->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ public:
|
||||
CLayer(CXmlReader& oLiteReader);
|
||||
~CLayer();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,20 @@ namespace OFD
|
||||
CPageBlock::CPageBlock(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader)
|
||||
{
|
||||
if ("ofd:PageBlock" != oLiteReader.GetNameA() || oLiteReader.IsEmptyNode())
|
||||
if (oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
do
|
||||
{
|
||||
if ("Boundary" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
m_oBoundary.Read(oLiteReader.GetTextA());
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
if (oLiteReader.IsEmptyNode())
|
||||
return;
|
||||
|
||||
CPageBlock::ReadIntoContainer(oLiteReader, m_arPageBlocks);
|
||||
@ -41,12 +54,19 @@ void CPageBlock::ReadIntoContainer(CXmlReader& oLiteReader, std::vector<IPageBlo
|
||||
}
|
||||
}
|
||||
|
||||
void CPageBlock::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CPageBlock::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
|
||||
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dDx + m_oBoundary.m_dX, dDy + m_oBoundary.m_dY);
|
||||
|
||||
for (const IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
pPageBlock->Draw(pRenderer, oCommonData);
|
||||
pPageBlock->Draw(pRenderer, oCommonData, ePageType);
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,19 +2,20 @@
|
||||
#define PAGEBLOCK_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPageBlock : public IPageBlock
|
||||
{
|
||||
TBox m_oBoundary;
|
||||
|
||||
std::vector<IPageBlock*> m_arPageBlocks;
|
||||
public:
|
||||
CPageBlock(CXmlReader& oLiteReader);
|
||||
|
||||
static void ReadIntoContainer(CXmlReader& oLiteReader, std::vector<IPageBlock*>& arPageBlocks);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#include "PathObject.h"
|
||||
|
||||
#include "src/Utils/Utils.h"
|
||||
#include "../Types/DrawParam.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
@ -132,7 +134,7 @@ void CPathObject::AddElement(const IPathElement* pElement)
|
||||
m_arElements.push_back(pElement);
|
||||
}
|
||||
|
||||
void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_arElements.empty())
|
||||
return;
|
||||
@ -168,38 +170,46 @@ void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
}
|
||||
}
|
||||
|
||||
const CRes* pPublicRes{oCommonData.GetPublicRes()};
|
||||
std::vector<const CDrawParam*> arDrawParams{pPublicRes->GetDrawParams()};
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
{
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(pPublicRes));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_BrushColor1(0);
|
||||
pRenderer->put_BrushAlpha1(0xff);
|
||||
|
||||
if (EPageType::TemplatePage == ePageType)
|
||||
for (const CDrawParam* pDrawParam : arDrawParams)
|
||||
if (pDrawParam->ApplyFillColor(pRenderer, pPublicRes))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
pRenderer->put_BrushType(c_BrushTypeNotSet);
|
||||
|
||||
|
||||
if(m_bStroke)
|
||||
{
|
||||
pRenderer->put_PenSize(m_dLineWidth);
|
||||
|
||||
if (nullptr != m_pStrokeColor)
|
||||
{
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(pPublicRes));
|
||||
pRenderer->put_PenAlpha(m_pStrokeColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_PenColor(0);
|
||||
pRenderer->put_PenAlpha(0xff);
|
||||
|
||||
if (EPageType::TemplatePage == ePageType)
|
||||
for (const CDrawParam* pDrawParam : arDrawParams)
|
||||
if (pDrawParam->ApplyStrokeColor(pRenderer, pPublicRes))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
CPathObject(CXmlReader& oLiteReader);
|
||||
~CPathObject();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -178,12 +178,14 @@ CTextObject::~CTextObject()
|
||||
delete pTextCode;
|
||||
}
|
||||
|
||||
void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_arTextCodes.empty())
|
||||
return;
|
||||
|
||||
const CFont* pFont = oCommonData.GetPublicRes()->GetFont(m_unFontID);
|
||||
const CRes* pPublicRes{oCommonData.GetPublicRes()};
|
||||
|
||||
const CFont* pFont = pPublicRes->GetFont(m_unFontID);
|
||||
|
||||
if (nullptr == pFont)
|
||||
return;
|
||||
@ -193,19 +195,25 @@ void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
std::vector<const CDrawParam*> arDrawParams{pPublicRes->GetDrawParams()};
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
{
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(pPublicRes));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_BrushColor1(0);
|
||||
pRenderer->put_BrushAlpha1(0xff);
|
||||
|
||||
if (EPageType::TemplatePage == ePageType)
|
||||
for (const CDrawParam* pDrawParam : arDrawParams)
|
||||
if (pDrawParam->ApplyFillColor(pRenderer, pPublicRes))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -248,15 +256,14 @@ TCGTransform TCGTransform::Read(CXmlReader& oLiteReader)
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
unsigned int unCount = 0;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth) && unCount < oCGTransform.m_unGlyphCount)
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:Glyphs" == oLiteReader.GetNameA())
|
||||
{
|
||||
oCGTransform.m_arGlyphs.push_back(oLiteReader.GetUInteger());
|
||||
++unCount;
|
||||
}
|
||||
if ("ofd:Glyphs" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
const std::vector<unsigned int> arValues{oLiteReader.GetArrayUInteger()};
|
||||
oCGTransform.m_arGlyphs.insert(oCGTransform.m_arGlyphs.end(), arValues.begin(), arValues.end());
|
||||
}
|
||||
|
||||
return oCGTransform;
|
||||
@ -264,10 +271,10 @@ TCGTransform TCGTransform::Read(CXmlReader& oLiteReader)
|
||||
|
||||
bool TCGTransform::Draw(IRenderer* pRenderer, const LONG& lUnicode, unsigned int& unIndex, double dX, double dY) const
|
||||
{
|
||||
if (m_unCodePosition != unIndex || 0 == m_unCodeCount || 0 == m_unGlyphCount)
|
||||
if (m_unCodePosition + m_arGlyphs.size() > unIndex || 0 == m_unCodeCount || m_arGlyphs.empty())
|
||||
return false;
|
||||
|
||||
for (unsigned int unGlyphCount = 0; unGlyphCount < m_unGlyphCount; ++unGlyphCount)
|
||||
for (unsigned int unGlyphCount = 0; unGlyphCount < m_arGlyphs.size(); ++unGlyphCount)
|
||||
pRenderer->CommandDrawTextExCHAR(lUnicode, m_arGlyphs[unGlyphCount], dX, dY, 0, 0);
|
||||
|
||||
unIndex += m_unCodeCount;
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
CTextObject(CXmlReader& oLiteReader);
|
||||
~CTextObject();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -55,15 +55,15 @@ bool CDocument::Read(const std::wstring& wsFilePath, IFolder* pFolder)
|
||||
|
||||
const std::wstring wsCoreDirectory{pFolder->getFullFilePath(NSSystemPath::GetDirectoryName(wsFilePath))};
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if (L"ofd:CommonData" == wsNodeName)
|
||||
if ("ofd:CommonData" == sNodeName)
|
||||
m_oCommonData.Read(oLiteReader, wsCoreDirectory);
|
||||
else if (L"ofd:Pages" == wsNodeName)
|
||||
else if ("ofd:Pages" == sNodeName)
|
||||
{
|
||||
const int nPagesDepth = oLiteReader.GetDepth();
|
||||
|
||||
@ -99,8 +99,10 @@ bool CDocument::Read(const std::wstring& wsFilePath, IFolder* pFolder)
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
}
|
||||
else if (L"ofd:Permissions" == wsNodeName)
|
||||
else if ("ofd:Permissions" == sNodeName)
|
||||
m_oPermission.Read(oLiteReader);
|
||||
else if ("ofd:Annotations" == sNodeName)
|
||||
m_oAnnotation.Read(oLiteReader.GetText2(), wsCoreDirectory);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -116,7 +118,9 @@ bool CDocument::DrawPage(IRenderer* pRenderer, int nPageIndex) const
|
||||
if (itFound == m_mPages.cend())
|
||||
return false;
|
||||
|
||||
itFound->second->Draw(pRenderer, m_oCommonData);
|
||||
itFound->second->Draw(pRenderer, m_oCommonData, EPageType::Page);
|
||||
|
||||
m_oAnnotation.Draw(pRenderer, m_oCommonData, EPageType::Anotation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define DOCUMENT_H
|
||||
|
||||
#include "Page.h"
|
||||
#include "Annotation.h"
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
@ -26,6 +27,7 @@ class CDocument
|
||||
{
|
||||
CCommonData m_oCommonData;
|
||||
CPermission m_oPermission;
|
||||
CAnnotation m_oAnnotation;
|
||||
|
||||
std::map<unsigned int, CPage*> m_mPages;
|
||||
public:
|
||||
|
||||
@ -61,7 +61,7 @@ CPage* CPage::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPat
|
||||
return pPage;
|
||||
}
|
||||
|
||||
void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
@ -73,10 +73,10 @@ void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
const CTemplatePage *pTemplatePage = oCommonData.GetTemplatePage(m_parTemplatePage.first, m_parTemplatePage.second);
|
||||
|
||||
if (nullptr != pTemplatePage && EZOrder::Background == pTemplatePage->GetZOrder() && nullptr != pTemplatePage->GetPage())
|
||||
pTemplatePage->GetPage()->Draw(pRenderer, oCommonData);
|
||||
pTemplatePage->GetPage()->Draw(pRenderer, oCommonData, EPageType::TemplatePage);
|
||||
}
|
||||
|
||||
m_oContent.Draw(pRenderer, oCommonData);
|
||||
m_oContent.Draw(pRenderer, oCommonData, ePageType);
|
||||
|
||||
pRenderer->EndCommand(c_nImageType);
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ public:
|
||||
~CPage();
|
||||
|
||||
static CPage* Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
|
||||
void GetPageSize(double& dWidth, double& dHeight) const;
|
||||
};
|
||||
|
||||
@ -47,7 +47,7 @@ bool CRes::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
if (!oLiteReader.FromFile(wsFullPath) || !oLiteReader.ReadNextNode() || L"ofd:Res" != oLiteReader.GetName() || oLiteReader.IsEmptyNode())
|
||||
return false;
|
||||
|
||||
std::wstring wsResRootPath;
|
||||
std::wstring wsResRootPath{wsRootPath};
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
@ -135,4 +135,14 @@ const CCompositeGraphicUnit* CRes::GetCompositeGraphicUnit(unsigned int unId) co
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CCompositeGraphicUnit, m_mCCompositeGraphicUnits);
|
||||
}
|
||||
|
||||
std::vector<const CDrawParam*> CRes::GetDrawParams() const
|
||||
{
|
||||
std::vector<const CDrawParam*> arValues;
|
||||
|
||||
for (std::map<unsigned int, CDrawParam*>::const_iterator itBegin = m_mDrawParams.cbegin(); itBegin != m_mDrawParams.cend(); ++itBegin)
|
||||
arValues.push_back(itBegin->second);
|
||||
|
||||
return arValues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
#include "Types/MultiMedia.h"
|
||||
#include "Types/CompositeGraphicUnit.h"
|
||||
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CRes
|
||||
@ -31,6 +29,8 @@ public:
|
||||
const CFont* GetFont(unsigned int unId) const;
|
||||
const CMultiMedia* GetMultiMedia(unsigned int unId) const;
|
||||
const CCompositeGraphicUnit* GetCompositeGraphicUnit(unsigned int unId) const;
|
||||
|
||||
std::vector<const CDrawParam*> GetDrawParams() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#include "Color.h"
|
||||
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CColor::CColor(CXmlReader& oXmlReader)
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
#define COLOR_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CRes;
|
||||
class CColor
|
||||
{
|
||||
BYTE m_oValues[4];
|
||||
|
||||
@ -3,6 +3,63 @@
|
||||
namespace OFD
|
||||
{
|
||||
CDrawParam::CDrawParam(CXmlReader& oXmlReader)
|
||||
: IOFDElement(oXmlReader)
|
||||
{}
|
||||
: IOFDElement(oXmlReader), m_oPenSettings(oXmlReader),
|
||||
m_pStrokeColor(nullptr), m_pFillColor(nullptr)
|
||||
{
|
||||
std::string sName;
|
||||
const int nDepth = oXmlReader.GetDepth();
|
||||
|
||||
while (oXmlReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sName = oXmlReader.GetNameA();
|
||||
|
||||
if ("ofd:FillColor" == sName)
|
||||
{
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
|
||||
m_pFillColor = new CColor(oXmlReader);
|
||||
}
|
||||
else if ("ofd:StrokeColor" == sName)
|
||||
{
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
m_pStrokeColor = new CColor(oXmlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CDrawParam::~CDrawParam()
|
||||
{
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
}
|
||||
|
||||
bool CDrawParam::ApplyStrokeColor(IRenderer* pRenderer, const CRes* pPublicRes) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == m_pStrokeColor)
|
||||
return false;
|
||||
|
||||
m_oPenSettings.Apply(pRenderer);
|
||||
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(pPublicRes));
|
||||
pRenderer->put_PenAlpha(m_pStrokeColor->GetAlpha());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDrawParam::ApplyFillColor(IRenderer* pRenderer, const CRes* pPublicRes) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == m_pFillColor)
|
||||
return false;
|
||||
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(pPublicRes));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,23 @@
|
||||
#define DRAWPARAM_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
#include "PenSettings.h"
|
||||
#include "Color.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CDrawParam : public IOFDElement
|
||||
{
|
||||
CPenSettings m_oPenSettings;
|
||||
|
||||
CColor *m_pStrokeColor;
|
||||
CColor *m_pFillColor;
|
||||
public:
|
||||
CDrawParam(CXmlReader& oXmlReader);
|
||||
~CDrawParam();
|
||||
|
||||
bool ApplyStrokeColor(IRenderer* pRenderer, const CRes* pPublicRes) const;
|
||||
bool ApplyFillColor(IRenderer* pRenderer, const CRes* pPublicRes) const;
|
||||
};
|
||||
}
|
||||
#endif // DRAWPARAM_H
|
||||
|
||||
87
OFDFile/src/Types/PenSettings.cpp
Normal file
87
OFDFile/src/Types/PenSettings.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include "PenSettings.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CPenSettings::CPenSettings(CXmlReader& oLiteReader)
|
||||
: m_dLineWidth(0.353), m_eCap(ECap::Butt),
|
||||
m_eJoin(EJoin::Miter), m_dMiterLimit(4.234), m_dDashOffset(0.)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"LineWidth" == wsAttributeName)
|
||||
m_dLineWidth = oLiteReader.GetDouble(true);
|
||||
else if (L"Cap" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Butt" == wsValue)
|
||||
m_eCap = ECap::Butt;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eCap = ECap::Round;
|
||||
else if (L"Square" == wsValue)
|
||||
m_eCap = ECap::Square;
|
||||
}
|
||||
else if (L"Join" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Miter" == wsValue)
|
||||
m_eJoin = EJoin::Miter;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eJoin = EJoin::Round;
|
||||
else if (L"Bevel" == wsValue)
|
||||
m_eJoin = EJoin::Bevel;
|
||||
}
|
||||
else if (L"MiterLimit" == wsAttributeName)
|
||||
m_dMiterLimit = oLiteReader.GetDouble(true);
|
||||
else if (L"DashOffset" == wsAttributeName)
|
||||
m_dDashOffset = oLiteReader.GetDouble(true);
|
||||
else if (L"Alpha" == wsAttributeName)
|
||||
m_uchAlpha = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CPenSettings::Apply(IRenderer* pRenderer) const
|
||||
{
|
||||
pRenderer->put_PenSize(m_dLineWidth);
|
||||
pRenderer->put_PenAlpha(m_uchAlpha);
|
||||
pRenderer->put_BrushAlpha1(m_uchAlpha);
|
||||
|
||||
BYTE nCapStyle = 0;
|
||||
switch (m_eCap)
|
||||
{
|
||||
case ECap::Butt: nCapStyle = Aggplus::LineCapFlat; break;
|
||||
case ECap::Round: nCapStyle = Aggplus::LineCapRound; break;
|
||||
case ECap::Square: nCapStyle = Aggplus::LineCapSquare; break;
|
||||
}
|
||||
|
||||
pRenderer->put_PenLineStartCap(nCapStyle);
|
||||
pRenderer->put_PenLineEndCap(nCapStyle);
|
||||
|
||||
BYTE nJoinStyle = 0;
|
||||
switch (m_eJoin)
|
||||
{
|
||||
case EJoin::Miter: nJoinStyle = Aggplus::LineJoinMiter; break;
|
||||
case EJoin::Round: nJoinStyle = Aggplus::LineJoinRound; break;
|
||||
case EJoin::Bevel: nJoinStyle = Aggplus::LineJoinBevel; break;
|
||||
}
|
||||
|
||||
pRenderer->put_PenLineJoin(nJoinStyle);
|
||||
|
||||
if (!m_arDashPattern.empty())
|
||||
{
|
||||
pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom);
|
||||
pRenderer->put_PenDashOffset(m_dDashOffset);
|
||||
pRenderer->PenDashPattern((double*)m_arDashPattern.data(), m_arDashPattern.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
39
OFDFile/src/Types/PenSettings.h
Normal file
39
OFDFile/src/Types/PenSettings.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef PENSETTINGS_H
|
||||
#define PENSETTINGS_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPenSettings
|
||||
{
|
||||
double m_dLineWidth;
|
||||
|
||||
enum class ECap
|
||||
{
|
||||
Butt,
|
||||
Round,
|
||||
Square
|
||||
} m_eCap;
|
||||
|
||||
enum class EJoin
|
||||
{
|
||||
Miter,
|
||||
Round,
|
||||
Bevel
|
||||
} m_eJoin;
|
||||
|
||||
double m_dMiterLimit;
|
||||
double m_dDashOffset;
|
||||
std::vector<double> m_arDashPattern;
|
||||
unsigned char m_uchAlpha;
|
||||
public:
|
||||
CPenSettings(CXmlReader& oLiteReader);
|
||||
|
||||
void Apply(IRenderer* pRenderer) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PENSETTINGS_H
|
||||
@ -9,7 +9,7 @@ enum class EZOrder
|
||||
{
|
||||
Body,
|
||||
Background
|
||||
} ;
|
||||
};
|
||||
|
||||
EZOrder GetZOrderFromString(const std::string& sValue);
|
||||
|
||||
|
||||
@ -65,4 +65,20 @@ std::vector<double> CXmlReader::GetArrayDoubles(bool bIsAttribute)
|
||||
|
||||
return arDoubleValues;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> CXmlReader::GetArrayUInteger(bool bIsAttribute)
|
||||
{
|
||||
const std::vector<std::string> arValues{Split(GetTextValueA(bIsAttribute), ' ')};
|
||||
|
||||
if(arValues.empty())
|
||||
return std::vector<unsigned int>();
|
||||
|
||||
std::vector<unsigned int> arUIntValues(arValues.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arValues.size(); ++unIndex)
|
||||
if (!StringToUInteger(arValues[unIndex], arUIntValues[unIndex]))
|
||||
return std::vector<unsigned int>();
|
||||
|
||||
return arUIntValues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ public:
|
||||
double GetDouble(bool bIsAttribute = false);
|
||||
std::vector<std::string> GetArrayStrings(bool bIsAttribute = false);
|
||||
std::vector<double> GetArrayDoubles(bool bIsAttribute = false);
|
||||
std::vector<unsigned int> GetArrayUInteger(bool bIsAttribute = false);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1290,7 +1290,7 @@ namespace BinXlsxRW
|
||||
|
||||
int id = m_pOfficeDrawingConverter->m_pReader->m_nCountEmbedded++;
|
||||
|
||||
bool bMacroEnabled = false; //todooo detect
|
||||
bool bMacroEnabled = false;
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(id) + (bMacroEnabled ? L".xlsm" : L".xlsx");
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
@ -1327,7 +1327,7 @@ namespace BinXlsxRW
|
||||
std::wstring sThemePath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"theme";
|
||||
std::wstring sEmbeddingsPath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"embeddings";
|
||||
|
||||
BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sEmbeddingsPath, sThemePath, oDrawingConverter.GetContentTypes(), NULL, true);
|
||||
BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sEmbeddingsPath, sThemePath, oDrawingConverter.GetContentTypes(), NULL, false);
|
||||
|
||||
std::wstring sXmlOptions, sMediaPath, sEmbedPath;
|
||||
BinXlsxRW::CXlsxSerializer::CreateXlsxFolders(sXmlOptions, sDstEmbeddedTemp, sMediaPath, sEmbedPath);
|
||||
|
||||
@ -4878,9 +4878,9 @@ void CDrawingConverter::CheckEffectShape(PPTX::Logic::SpTreeElem* oElem, XmlUtil
|
||||
nullable<SimpleTypes::CColorType> oColor2;
|
||||
nullable_string oId;
|
||||
nullable<SimpleTypes::Vml::CVml_Matrix> oMatrix;
|
||||
SimpleTypes::CTrueFalse oObscured;
|
||||
SimpleTypes::Vml::CVml_Vector2D_Units_Or_Percentage oOffset;
|
||||
SimpleTypes::Vml::CVml_Vector2D_Units_Or_Percentage oOffset2;
|
||||
nullable<SimpleTypes::CTrueFalse> oObscured;
|
||||
nullable<SimpleTypes::Vml::CVml_Vector2D_Units_Or_Percentage> oOffset;
|
||||
nullable<SimpleTypes::Vml::CVml_Vector2D_Units_Or_Percentage> oOffset2;
|
||||
nullable<SimpleTypes::Vml::CVml_1_65536> oOpacity;
|
||||
nullable<SimpleTypes::Vml::CVml_Vector2D_Percentage> oOrigin;
|
||||
SimpleTypes::CShadowType oType;
|
||||
@ -4921,16 +4921,16 @@ void CDrawingConverter::CheckEffectShape(PPTX::Logic::SpTreeElem* oElem, XmlUtil
|
||||
pEffectLst->outerShdw->Color.Color->Modifiers.push_back(oMod);
|
||||
}
|
||||
|
||||
double offsetX = oOffset.IsXinPoints() ? oOffset.GetX() : 0;
|
||||
double offsetY = oOffset.IsYinPoints() ? oOffset.GetY() : 0;
|
||||
|
||||
double dist = sqrt(offsetX * offsetX + offsetY * offsetY);
|
||||
double dir = (offsetX != 0) ? atan(offsetY / offsetX) * 180. / 3.1415926 : 0;
|
||||
if (offsetX < 0) dir += 180;
|
||||
if (dir < 0) dir += 360;
|
||||
|
||||
if (dist > 0 && dir > 0)
|
||||
if (oOffset.IsInit())
|
||||
{
|
||||
double offsetX = oOffset->IsXinPoints() ? oOffset->GetX() : 0;
|
||||
double offsetY = oOffset->IsYinPoints() ? oOffset->GetY() : 0;
|
||||
|
||||
double dist = sqrt(offsetX * offsetX + offsetY * offsetY);
|
||||
double dir = ((offsetX != 0) ? atan(offsetY / offsetX) : 1) * 180. / 3.1415926;
|
||||
if (offsetX < 0) dir += 180;
|
||||
if (dir < 0) dir += 360;
|
||||
|
||||
pEffectLst->outerShdw->dist = dist * (635 * 20);
|
||||
pEffectLst->outerShdw->dir = (int)(dir * 60000);
|
||||
}
|
||||
@ -6307,6 +6307,108 @@ void CDrawingConverter::ConvertGroupVML(PPTX::Logic::SpTreeElem& oElem, const st
|
||||
oGroup.toXmlWriterVML(&oWriter, *m_pTheme, *m_pClrMap, rels);
|
||||
}
|
||||
}
|
||||
void CDrawingConverter::ConvertParaVML(XmlUtils::CXmlNode& node, PPTX::Logic::Paragraph *p)
|
||||
{
|
||||
if (!p) return;
|
||||
|
||||
std::wstring strStyle = node.GetAttribute(L"style");
|
||||
PPTX::CCSS oCSSParser;
|
||||
oCSSParser.LoadFromString2(strStyle);
|
||||
|
||||
//todooo oCSSParser->pPr
|
||||
|
||||
std::vector<XmlUtils::CXmlNode> nodesDiv1 = node.GetNodes(L"*");
|
||||
for (auto node1 : nodesDiv1)
|
||||
{
|
||||
if (node1.IsValid())
|
||||
{
|
||||
PPTX::Logic::Run* run = new PPTX::Logic::Run();
|
||||
|
||||
std::wstring name = node1.GetName();
|
||||
if (name == L"p" || name == L"div")
|
||||
{
|
||||
ConvertParaVML(node1, p);
|
||||
}
|
||||
else if (name == L"font")
|
||||
{
|
||||
run->rPr = new PPTX::Logic::RunProperties();
|
||||
|
||||
std::wstring text = node1.GetText();
|
||||
|
||||
if (true == text.empty())
|
||||
{
|
||||
std::vector<XmlUtils::CXmlNode> nodesDiv2 = node1.GetNodes(L"*");
|
||||
for (auto node2 : nodesDiv2)
|
||||
{
|
||||
name = node2.GetName();
|
||||
std::wstring text2 = node2.GetText();
|
||||
|
||||
if (name == L"b")
|
||||
run->rPr->b = true;
|
||||
else if (name == L"i")
|
||||
run->rPr->i = true;
|
||||
|
||||
if (false == text2.empty())
|
||||
{
|
||||
text += text2;
|
||||
}
|
||||
|
||||
std::vector<XmlUtils::CXmlNode> nodesDiv3 = node2.GetNodes(L"*");
|
||||
for (auto node3 : nodesDiv3)
|
||||
{
|
||||
name = node3.GetName();
|
||||
|
||||
if (name == L"b")
|
||||
run->rPr->b = true;
|
||||
else if (name == L"i")
|
||||
run->rPr->i = true;
|
||||
|
||||
text += node3.GetText();
|
||||
}
|
||||
}
|
||||
}
|
||||
run->SetText(text);
|
||||
|
||||
std::vector<std::wstring > attNames, attValues;
|
||||
node1.GetAllAttributes(attNames, attValues);
|
||||
|
||||
if (attNames.size() > 0)
|
||||
{
|
||||
for (size_t r = 0; r < attNames.size(); r++)
|
||||
{
|
||||
if (attNames[r] == L"color" && attValues[r].length() == 7)
|
||||
{
|
||||
XmlUtils::replace_all(attValues[r], L"#", L"");
|
||||
|
||||
PPTX::Logic::SolidFill* fill = new PPTX::Logic::SolidFill();
|
||||
PPTX::Logic::SrgbClr* color = new PPTX::Logic::SrgbClr();
|
||||
|
||||
color->SetHexString(attValues[r]);
|
||||
fill->Color.Color = color;
|
||||
|
||||
run->rPr->Fill.Fill = fill;
|
||||
run->rPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
|
||||
}
|
||||
else if (attNames[r] == L"size")
|
||||
{
|
||||
run->rPr->sz = XmlUtils::GetInteger(attValues[r]) * 5;
|
||||
}
|
||||
else if (attNames[r] == L"face")
|
||||
{
|
||||
run->rPr->latin = new PPTX::Logic::TextFont();
|
||||
run->rPr->latin->typeface = attValues[r];
|
||||
run->rPr->latin->m_name = L"a:latin";
|
||||
}
|
||||
}
|
||||
}
|
||||
PPTX::Logic::RunElem elm;
|
||||
p->RunElems.push_back(elm);
|
||||
|
||||
p->RunElems.back().InitRun(run);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void CDrawingConverter::ConvertTextVML(XmlUtils::CXmlNode &nodeTextBox, PPTX::Logic::Shape* pShape)
|
||||
{
|
||||
if (pShape->txBody.IsInit() == false)
|
||||
@ -6326,100 +6428,9 @@ void CDrawingConverter::ConvertTextVML(XmlUtils::CXmlNode &nodeTextBox, PPTX::Lo
|
||||
{
|
||||
PPTX::Logic::Paragraph p;
|
||||
|
||||
std::wstring strStyle = node.GetAttribute(L"style");
|
||||
PPTX::CCSS oCSSParser;
|
||||
oCSSParser.LoadFromString2(strStyle);
|
||||
ConvertParaVML(node, &p);
|
||||
|
||||
//todooo oCSSParser->pPr
|
||||
|
||||
std::vector<XmlUtils::CXmlNode> nodesDiv1 = node.GetNodes(L"*");
|
||||
for (auto node1 : nodesDiv1)
|
||||
{
|
||||
if (node1.IsValid())
|
||||
{
|
||||
PPTX::Logic::Run* run = new PPTX::Logic::Run();
|
||||
|
||||
name = node1.GetName();
|
||||
if (name == L"font")
|
||||
{
|
||||
run->rPr = new PPTX::Logic::RunProperties();
|
||||
|
||||
std::wstring text = node1.GetText();
|
||||
|
||||
if (true == text.empty())
|
||||
{
|
||||
std::vector<XmlUtils::CXmlNode> nodesDiv2 = node1.GetNodes(L"*");
|
||||
for (auto node2 : nodesDiv2)
|
||||
{
|
||||
name = node2.GetName();
|
||||
std::wstring text2 = node2.GetText();
|
||||
|
||||
if (name == L"b")
|
||||
run->rPr->b = true;
|
||||
else if (name == L"i")
|
||||
run->rPr->i = true;
|
||||
|
||||
if (false == text2.empty())
|
||||
{
|
||||
text += text2;
|
||||
}
|
||||
|
||||
std::vector<XmlUtils::CXmlNode> nodesDiv3 = node2.GetNodes(L"*");
|
||||
for (auto node3 : nodesDiv3)
|
||||
{
|
||||
name = node3.GetName();
|
||||
|
||||
if (name == L"b")
|
||||
run->rPr->b = true;
|
||||
else if (name == L"i")
|
||||
run->rPr->i = true;
|
||||
|
||||
text += node3.GetText();
|
||||
}
|
||||
}
|
||||
}
|
||||
run->SetText(text);
|
||||
|
||||
std::vector<std::wstring > attNames, attValues;
|
||||
node1.GetAllAttributes(attNames,attValues);
|
||||
|
||||
if (attNames.size() > 0)
|
||||
{
|
||||
for (size_t r = 0; r < attNames.size(); r++)
|
||||
{
|
||||
if (attNames[r] == L"color" && attValues[r].length() == 7)
|
||||
{
|
||||
XmlUtils::replace_all(attValues[r], L"#", L"");
|
||||
|
||||
PPTX::Logic::SolidFill* fill = new PPTX::Logic::SolidFill();
|
||||
PPTX::Logic::SrgbClr* color = new PPTX::Logic::SrgbClr();
|
||||
|
||||
color->SetHexString(attValues[r]);
|
||||
fill->Color.Color = color;
|
||||
|
||||
run->rPr->Fill.Fill = fill;
|
||||
run->rPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
|
||||
}
|
||||
else if (attNames[r] == L"size")
|
||||
{
|
||||
run->rPr->sz = XmlUtils::GetInteger(attValues[r]) * 5;
|
||||
}
|
||||
else if (attNames[r] == L"face")
|
||||
{
|
||||
run->rPr->latin = new PPTX::Logic::TextFont();
|
||||
run->rPr->latin->typeface = attValues[r];
|
||||
run->rPr->latin->m_name = L"a:latin";
|
||||
}
|
||||
}
|
||||
}
|
||||
PPTX::Logic::RunElem elm;
|
||||
p.RunElems.push_back(elm);
|
||||
|
||||
p.RunElems.back().InitRun(run);
|
||||
}
|
||||
}
|
||||
}
|
||||
pShape->txBody->Paragrs.push_back(p);
|
||||
pShape->txBody->Paragrs.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,6 +95,7 @@ namespace PPTX
|
||||
class Shape;
|
||||
class ClrMap;
|
||||
class UniColor;
|
||||
class Paragraph;
|
||||
}
|
||||
|
||||
class CStringTrimmer
|
||||
@ -311,7 +312,8 @@ namespace NSBinPptxRW
|
||||
void ConvertShapeVML (PPTX::Logic::SpTreeElem& oShape, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter, bool bSignature = false);
|
||||
void ConvertGroupVML (PPTX::Logic::SpTreeElem& oGroup, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter);
|
||||
|
||||
void ConvertTextVML (XmlUtils::CXmlNode &nodeTextBox, PPTX::Logic::Shape* pShape);
|
||||
void ConvertTextVML (XmlUtils::CXmlNode &node, PPTX::Logic::Shape* pShape);
|
||||
void ConvertParaVML (XmlUtils::CXmlNode& node, PPTX::Logic::Paragraph* p);
|
||||
|
||||
HRESULT SetCurrentRelsPath();
|
||||
};
|
||||
|
||||
@ -346,8 +346,12 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p
|
||||
{
|
||||
spaceBeforeTwip += list_properties->text_min_label_width_->get_value_unit(odf_types::length::pt);
|
||||
}
|
||||
if (spaceBeforeTwip>0)
|
||||
propertiesOut.fo_margin_left_ = odf_types::length(spaceBeforeTwip,odf_types::length::pt);
|
||||
if (spaceBeforeTwip > 0)
|
||||
propertiesOut.fo_margin_top_ = odf_types::length(spaceBeforeTwip, odf_types::length::pt);
|
||||
}
|
||||
if (list_properties->fo_width_)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -463,7 +463,7 @@ void xlsx_conversion_context::serialize_bookViews(std::wostream & strm)
|
||||
{
|
||||
for (size_t i = 0; i < sheets_.size(); i++)
|
||||
{
|
||||
if (false == sheets_[i]->external_ref().empty() && sheets_[i]->name() == *sActiveTable)
|
||||
if (sheets_[i]->external_ref().empty() && sheets_[i]->name() == *sActiveTable)
|
||||
{
|
||||
CP_XML_ATTR(L"activeTab", i);
|
||||
break;
|
||||
|
||||
@ -916,32 +916,49 @@ void text_list_level_style_image::pptx_convert(oox::pptx_conversion_context & Co
|
||||
|
||||
std::wostream & strm = Context.get_text_context().get_styles_context().list_style();
|
||||
|
||||
// style_list_level_properties * listLevelProperties = dynamic_cast<style_list_level_properties *>( list_level_properties_.get() );
|
||||
//
|
||||
//style_list_level_label_alignment * labelAlignment = listLevelProperties ?
|
||||
// dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL;
|
||||
style_list_level_properties* listLevelProperties = dynamic_cast<style_list_level_properties*>(list_level_properties_.get());
|
||||
|
||||
style_list_level_label_alignment* labelAlignment = listLevelProperties ?
|
||||
dynamic_cast<style_list_level_label_alignment*>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL;
|
||||
|
||||
//int level = text_list_level_style_attr_.get_text_level();
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
style_text_properties * textProperties = dynamic_cast<style_text_properties *>(text_properties_.get());
|
||||
wchar_t bullet = L'\x2022';
|
||||
|
||||
if (textProperties)///эти свойства относятся
|
||||
// к отрисовки значков !!! а не самого текста
|
||||
{
|
||||
textProperties->content_.pptx_convert_as_list(Context);
|
||||
strm << Context.get_text_context().get_styles_context().text_style().str();
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"a:buChar")
|
||||
{
|
||||
if (image_attr_.xlink_attlist_.href_ && false == image_attr_.xlink_attlist_.href_->empty())
|
||||
{
|
||||
//if ((textProperties) && (textProperties->content().style_font_charset_))
|
||||
//{
|
||||
// if (textProperties->content().style_font_charset_.get() == L"x-xsymbol")bullet = bullet + 0xf000;
|
||||
//}
|
||||
CP_XML_ATTR(L"char",bullet/*convert_bullet_char(bullet)*/);
|
||||
std::wstring ref_image;
|
||||
bool isMediaInternal = true;
|
||||
std::wstring rid = Context.get_mediaitems()->add_or_find(*image_attr_.xlink_attlist_.href_, oox::typeImage, isMediaInternal, ref_image, oox::document_place);
|
||||
Context.get_slide_context().add_rels(isMediaInternal, rid, ref_image, oox::typeImage);
|
||||
|
||||
//a:buSzPct
|
||||
CP_XML_NODE(L"a:buBlip")
|
||||
{
|
||||
CP_XML_NODE(L"a:blip")
|
||||
{
|
||||
CP_XML_ATTR(L"r:embed", rid);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
style_text_properties* textProperties = dynamic_cast<style_text_properties*>(text_properties_.get());
|
||||
wchar_t bullet = L'\x2022';
|
||||
|
||||
if (textProperties)///эти свойства относятся
|
||||
// к отрисовки значков !!! а не самого текста
|
||||
{
|
||||
textProperties->content_.pptx_convert_as_list(Context);
|
||||
strm << Context.get_text_context().get_styles_context().text_style().str();
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"a:buChar")
|
||||
{
|
||||
//if ((textProperties) && (textProperties->content().style_font_charset_))
|
||||
//{
|
||||
// if (textProperties->content().style_font_charset_.get() == L"x-xsymbol")bullet = bullet + 0xf000;
|
||||
//}
|
||||
CP_XML_ATTR(L"char", bullet/*convert_bullet_char(bullet)*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
PATH_LIB_BUILD_TOOLS = ../../../../../build_tools/out/android/onlyoffice/mobile/lib
|
||||
PATH_LIB_DST = ../extras/libs/x2t
|
||||
PATH_SRC_CORE = ../../../..
|
||||
PATH_SRC_ICU_DAT_FILE = ../../../../../build_tools/out/android/onlyoffice/mobile/lib/arm64-v8a/icudt58l.dat
|
||||
PATH_SRC_ICU_DAT_FILE = ../../../../../build_tools/out/android/onlyoffice/mobile/lib/arm64-v8a/icudt74l.dat
|
||||
PATH_SRC_ICU_V8_DAT_FILE = ../../../../Common/3dParty/v8/android/build/arm64-v8a/icudtl.dat
|
||||
PATH_SRC_ICU_V8_EXTRA_DAT_FILE = ../../../../Common/3dParty/v8/android/build/arm64-v8a/icudtl_extra.dat
|
||||
NAME_LIB = x2tConverter
|
||||
|
||||
Reference in New Issue
Block a user