mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fixed a bug with glued text in hwpx
This commit is contained in:
@ -63,6 +63,14 @@ std::wstring CXMLReader::GetText()
|
||||
return (m_bParseAttribute) ? m_pReader->GetText() : m_pReader->GetText2();
|
||||
}
|
||||
|
||||
const char* CXMLReader::GetTextChar()
|
||||
{
|
||||
if (nullptr == m_pReader)
|
||||
return "";
|
||||
|
||||
return m_pReader->GetTextChar();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T CXMLReader::GetAttribute(const std::string& sName, T _default, T (*GetValue)(CXMLReader&))
|
||||
{
|
||||
@ -155,6 +163,11 @@ bool CXMLReader::ReadNextNode()
|
||||
return (nullptr != m_pReader) ? m_pReader->ReadNextNode() : false;
|
||||
}
|
||||
|
||||
bool CXMLReader::Read(XmlUtils::XmlNodeType& eNodeType)
|
||||
{
|
||||
return (nullptr != m_pReader) ? m_pReader->Read(eNodeType) : false;
|
||||
}
|
||||
|
||||
int CXMLReader::GetIntValue(CXMLReader& oXmlReader)
|
||||
{
|
||||
return std::atoi(oXmlReader.GetTextA().c_str());
|
||||
@ -231,7 +244,7 @@ double CXMLReader::GetDoubleValue(CXMLReader& oXmlReader)
|
||||
if (bExpNegative)
|
||||
nExponent = -nExponent;
|
||||
|
||||
dResult *= std::pow(10., nExponent);
|
||||
dResult *= pow(10., nExponent);
|
||||
}
|
||||
|
||||
return bNegative ? -dResult : dResult;
|
||||
|
||||
@ -24,6 +24,7 @@ public:
|
||||
double GetDouble();
|
||||
std::string GetTextA();
|
||||
std::wstring GetText();
|
||||
const char* GetTextChar();
|
||||
|
||||
int GetAttributeInt(const std::string& sName, int nDefault = 0);
|
||||
bool GetAttributeBool(const std::string& sName);
|
||||
@ -40,6 +41,7 @@ public:
|
||||
std::string GetName();
|
||||
bool ReadNextSiblingNode(unsigned int unDepth);
|
||||
bool ReadNextNode();
|
||||
bool Read(XmlUtils::XmlNodeType& eNodeType);
|
||||
private:
|
||||
static int GetIntValue(CXMLReader& oXmlReader);
|
||||
static bool GetBoolValue(CXMLReader& oXmlReader);
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include "CtrlShapeVideo.h"
|
||||
#include "ParaText.h"
|
||||
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
CHWPPargraph::CHWPPargraph()
|
||||
@ -101,21 +103,42 @@ bool CHWPPargraph::ParseHWPParagraph(CXMLReader& oReader, int nCharShapeID, int
|
||||
}
|
||||
else if ("hp:t" == sNodeName)
|
||||
{
|
||||
m_arP.push_back(new CParaText(L"____", oReader.GetText(), 0, nCharShapeID));
|
||||
if (oReader.IsEmptyNode())
|
||||
return false;
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Child)
|
||||
const int nDepth = oReader.GetDepth();
|
||||
XmlUtils::XmlNodeType eNodeType = XmlUtils::XmlNodeType_EndElement;
|
||||
while (oReader.Read(eNodeType) && oReader.GetDepth() >= nDepth && XmlUtils::XmlNodeType_EndElement != eNodeType)
|
||||
{
|
||||
if ("hp:lineBreak" == sNodeChildName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::LINE_BREAK));
|
||||
else if ("hp:hyphen" == sNodeChildName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_HYPHEN));
|
||||
else if ("hp:nbSpace" == sNodeChildName ||
|
||||
"hp:fwSpace" == sNodeChildName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_SPACE));
|
||||
else if ("hp:tab" == sNodeChildName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::TABULATION));
|
||||
if (eNodeType == XmlUtils::XmlNodeType_Text ||
|
||||
eNodeType == XmlUtils::XmlNodeType_Whitespace ||
|
||||
eNodeType == XmlUtils::XmlNodeType_SIGNIFICANT_WHITESPACE ||
|
||||
eNodeType == XmlUtils::XmlNodeType_CDATA)
|
||||
{
|
||||
const char* pValue = oReader.GetTextChar();
|
||||
std::wstring wsValue;
|
||||
|
||||
if('\0' != pValue[0])
|
||||
{
|
||||
NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pValue, (LONG)strlen(pValue), wsValue);
|
||||
m_arP.push_back(new CParaText(L"____", wsValue, 0, nCharShapeID));
|
||||
}
|
||||
}
|
||||
else if (eNodeType == XmlUtils::XmlNodeType_Element)
|
||||
{
|
||||
const std::string sChildNodeName{oReader.GetName()};
|
||||
|
||||
if ("hp:lineBreak" == sChildNodeName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::LINE_BREAK));
|
||||
else if ("hp:hyphen" == sChildNodeName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_HYPHEN));
|
||||
else if ("hp:nbSpace" == sChildNodeName ||
|
||||
"hp:fwSpace" == sChildNodeName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_SPACE));
|
||||
else if ("hp:tab" == sChildNodeName)
|
||||
m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::TABULATION));
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hp:tbl" == sNodeName)
|
||||
m_arP.push_back(new CCtrlTable(L" lbt", oReader, nVersion));
|
||||
|
||||
Reference in New Issue
Block a user