mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix bugs in html to ooxml conversion
This commit is contained in:
@ -21,11 +21,11 @@ namespace NSCSS
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point)
|
||||
{}
|
||||
|
||||
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
|
||||
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
|
||||
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure),
|
||||
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay){}
|
||||
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
|
||||
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
|
||||
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure),
|
||||
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay){}
|
||||
|
||||
CCompiledStyle::~CCompiledStyle()
|
||||
{
|
||||
@ -176,6 +176,7 @@ namespace NSCSS
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-top"):
|
||||
CASE(L"topmargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
@ -186,6 +187,7 @@ namespace NSCSS
|
||||
}
|
||||
CASE(L"margin-right"):
|
||||
CASE(L"margin-block-end"):
|
||||
CASE(L"rightmargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
@ -195,6 +197,7 @@ namespace NSCSS
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-bottom"):
|
||||
CASE(L"bottommargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
@ -205,6 +208,7 @@ namespace NSCSS
|
||||
}
|
||||
CASE(L"margin-left"):
|
||||
CASE(L"margin-block-start"):
|
||||
CASE(L"leftmargin"):
|
||||
{
|
||||
if (bIsThereBorder)
|
||||
break;
|
||||
|
||||
@ -1423,7 +1423,12 @@ namespace NSCSS
|
||||
|
||||
bool CBorderSide::Empty() const
|
||||
{
|
||||
return m_oWidth.Empty() || m_oWidth.Zero();
|
||||
return m_oWidth.Empty();
|
||||
}
|
||||
|
||||
bool CBorderSide::Zero() const
|
||||
{
|
||||
return m_oWidth.Zero();
|
||||
}
|
||||
|
||||
CBorderSide &CBorderSide::operator+=(const CBorderSide &oBorderSide)
|
||||
@ -1622,6 +1627,12 @@ namespace NSCSS
|
||||
m_oRight.Empty() && m_oBottom.Empty();
|
||||
}
|
||||
|
||||
bool CBorder::Zero() const
|
||||
{
|
||||
return m_oLeft.Zero() && m_oTop.Zero() &&
|
||||
m_oRight.Zero() && m_oBottom.Zero();
|
||||
}
|
||||
|
||||
bool CBorder::EqualSides() const
|
||||
{
|
||||
return m_oLeft == m_oTop && m_oTop == m_oRight && m_oRight == m_oBottom;
|
||||
@ -1654,6 +1665,9 @@ namespace NSCSS
|
||||
|
||||
CBorder &CBorder::operator+=(const CBorder &oBorder)
|
||||
{
|
||||
if (oBorder.Empty())
|
||||
return *this;
|
||||
|
||||
m_oLeft = oBorder.m_oLeft;
|
||||
m_oTop = oBorder.m_oTop;
|
||||
m_oRight = oBorder.m_oRight;
|
||||
@ -2200,8 +2214,7 @@ namespace NSCSS
|
||||
|
||||
void CFont::Clear()
|
||||
{
|
||||
m_oSize = CDigit(24., 0);
|
||||
|
||||
m_oSize .Clear();
|
||||
m_oLineHeight.Clear();
|
||||
m_oFamily .Clear();
|
||||
m_oStretch .Clear();
|
||||
|
||||
@ -439,6 +439,7 @@ namespace NSCSS
|
||||
const CColor& GetColor() const;
|
||||
|
||||
bool Empty() const;
|
||||
bool Zero() const;
|
||||
|
||||
CBorderSide& operator+=(const CBorderSide& oBorderSide);
|
||||
bool operator==(const CBorderSide& oBorderSide) const;
|
||||
@ -499,6 +500,7 @@ namespace NSCSS
|
||||
void Unblock();
|
||||
|
||||
bool Empty() const;
|
||||
bool Zero() const;
|
||||
bool EqualSides() const;
|
||||
|
||||
const CEnum& GetCollapse() const;
|
||||
|
||||
@ -74,6 +74,8 @@ namespace NSCSS
|
||||
|
||||
void CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
{
|
||||
oElement.AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
|
||||
|
||||
if (arStandartedStyles.empty())
|
||||
return;
|
||||
|
||||
|
||||
@ -233,6 +233,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"99");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"24");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Color, L"0000FF");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_U, L"single");
|
||||
}
|
||||
|
||||
@ -37,6 +37,13 @@ static void replace_all(std::string& s, const std::string& s1, const std::string
|
||||
|
||||
static std::wstring htmlToXhtml(std::string& sFileContent)
|
||||
{
|
||||
// Избавляемся от лишних символов до <...
|
||||
boost::regex oRegex("<[a-zA-Z]");
|
||||
boost::match_results<typename std::string::const_iterator> oResult;
|
||||
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
// Избавление от <a/>
|
||||
size_t posA = sFileContent.find("<a ");
|
||||
while(posA != std::string::npos)
|
||||
|
||||
Reference in New Issue
Block a user