diff --git a/Common/3dParty/html/css/src/CCompiledStyle.cpp b/Common/3dParty/html/css/src/CCompiledStyle.cpp
index b0fd7282c7..fc8a7c0639 100644
--- a/Common/3dParty/html/css/src/CCompiledStyle.cpp
+++ b/Common/3dParty/html/css/src/CCompiledStyle.cpp
@@ -441,7 +441,7 @@ namespace NSCSS
sValue += *iWord;
if (L' ' == sValue.front())
- sValue.erase(0, 1);
+ sValue.erase(0, 1);
if (!sValue.empty() && ((*iWord).back() == L';' || iWord == (arWords.end() - 1)))
{
diff --git a/Common/3dParty/html/css/src/CUnitMeasureConverter.cpp b/Common/3dParty/html/css/src/CUnitMeasureConverter.cpp
index 8f7fd2f648..2f40fb3b91 100644
--- a/Common/3dParty/html/css/src/CUnitMeasureConverter.cpp
+++ b/Common/3dParty/html/css/src/CUnitMeasureConverter.cpp
@@ -138,41 +138,36 @@ namespace NSCSS
}
bool CUnitMeasureConverter::GetValue(const std::wstring &wsValue, double &dValue, UnitMeasure &enUnitMeasure)
{
- std::wstring::const_iterator oFoundDigit = std::find_if(wsValue.begin(), wsValue.end(), std::iswdigit);
+ std::wregex oRegex(LR"((\.\d+|\d+(\.\d+)?)\s*(px|pt|cm|mm|in|pc|%|rem)?)");
+ std::wsmatch oMatches;
- if (wsValue.end() == oFoundDigit)
+ if(!std::regex_search(wsValue, oMatches, oRegex))
return false;
- std::wistringstream(wsValue) >> dValue;
+ dValue = stod(oMatches[1]);
- std::wstring::const_iterator oFoundUM = std::find_if(oFoundDigit, wsValue.end(), [](wchar_t wcSymbol){ return std::iswalpha(wcSymbol) || L'%' == wcSymbol; });
-
- if (wsValue.end() != oFoundUM)
+ if (L"px" == oMatches[3])
+ enUnitMeasure = Pixel;
+ else if (L"pt" == oMatches[3])
+ enUnitMeasure = Point;
+ else if (L"cm" == oMatches[3])
+ enUnitMeasure = Cantimeter;
+ else if (L"mm" == oMatches[3])
+ enUnitMeasure = Millimeter;
+ else if (L"in" == oMatches[3])
+ enUnitMeasure = Inch;
+ else if (L"pc" == oMatches[3])
+ enUnitMeasure = Peak;
+ else if (L"%" == oMatches[3])
+ enUnitMeasure = Percent;
+ else if (L"rem" == oMatches[3])
{
- if (L'%' == *oFoundUM)
- {
- enUnitMeasure = Percent;
- return true;
- }
-
- std::wstring wsUnitMeasure(oFoundUM, oFoundUM + 2);
-
- if (L"px" == wsUnitMeasure)
- enUnitMeasure = Pixel;
- else if (L"pt" == wsUnitMeasure)
- enUnitMeasure = Point;
- else if (L"cm" == wsUnitMeasure)
- enUnitMeasure = Cantimeter;
- else if (L"mm" == wsUnitMeasure)
- enUnitMeasure = Millimeter;
- else if (L"in" == wsUnitMeasure)
- enUnitMeasure = Inch;
- else if (L"pc" == wsUnitMeasure)
- enUnitMeasure = Peak;
+ enUnitMeasure = Percent;
+ dValue *= 100.;
}
else
enUnitMeasure = None;
-
+
return true;
}
}
diff --git a/Common/3dParty/html/css/src/CUnitMeasureConverter.h b/Common/3dParty/html/css/src/CUnitMeasureConverter.h
index 8136e1ba6d..f57143f8c1 100644
--- a/Common/3dParty/html/css/src/CUnitMeasureConverter.h
+++ b/Common/3dParty/html/css/src/CUnitMeasureConverter.h
@@ -20,6 +20,7 @@ namespace NSCSS
class CUnitMeasureConverter
{
CUnitMeasureConverter();
+ static std::wstring GetUnitMeasure(const std::wstring::const_iterator& itBegin, const std::wstring::const_iterator& itEnd);
public:
static double ConvertPx(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertCm(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
diff --git a/Common/3dParty/html/css/src/StyleProperties.cpp b/Common/3dParty/html/css/src/StyleProperties.cpp
index a4fd7a5681..f9570c7931 100644
--- a/Common/3dParty/html/css/src/StyleProperties.cpp
+++ b/Common/3dParty/html/css/src/StyleProperties.cpp
@@ -1232,6 +1232,9 @@ namespace NSCSS
{
if (wsValue.empty())
return false;
+
+ if (L"none" == wsValue)
+ return true;
const std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsW(wsValue, false, L" ");
for (const std::wstring& sValue : arValues)
@@ -1966,13 +1969,7 @@ namespace NSCSS
bool CFont::SetLineHeight(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
- if (m_oLineHeight.SetValue(wsValue, unLevel, bHardMode))
- {
- m_oLineHeight *= 10.;
- return true;
- }
-
- return false;
+ return m_oLineHeight.SetValue(wsValue, unLevel, bHardMode);
}
bool CFont::SetFamily(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
diff --git a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp
index 6e3c3011e0..9604c5aa74 100644
--- a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp
+++ b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp
@@ -6,6 +6,11 @@
#include
#include
+#define LINEHEIGHTSCALE 10 // Значение LineHeight в OOXML должно быть в 10 раз больше чем указано в стиле
+#define LINEHEIGHTCOEF 24 // Используется когда LineHeight указан в процентном соотношении
+#define SPACINGCOEF 20 // Используется для конвертации в OOXML значение интервала между абзацами (Измерение в двадцатых долях от точки)
+#define FONTSCALE 2 // Значение шрифта при конвертации в OOXML необходимо увеличиыать в 2 рааз
+
namespace NSCSS
{
CStyleUsed::CStyleUsed(const CCompiledStyle &oStyle, bool bIsPStyle)
@@ -99,8 +104,8 @@ namespace NSCSS
}
sId.pop_back();
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, sId);
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sId);
+ oElement.AddBasicProperties(BProperties::B_Name, sId);
+ oElement.AddBasicProperties(BProperties::B_StyleId, sId);
}
void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
@@ -148,11 +153,11 @@ namespace NSCSS
if (!oParentStyle.Empty())
{
- oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
+ oParentStyle.AddBasicProperties(BProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
if (!bIsPStyle)
{
- oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
- oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, L"character");
+ oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
+ oParentStyle.AddBasicProperties(BProperties::B_Type, L"character");
}
}
}
@@ -168,7 +173,7 @@ namespace NSCSS
{
if (bIsPStyle)
{
- oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
+ oParentStyle.AddBasicProperties(BProperties::B_QFormat, L"true");
m_sStyle += oParentStyle.GetPStyle();
}
else
@@ -182,7 +187,7 @@ namespace NSCSS
return;
}
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sParentsStyleID);
+ oElement.AddBasicProperties(BProperties::B_BasedOn, sParentsStyleID);
}
else if (!oStandardXmlElement.Empty() && !oParentStyle.Empty())
{
@@ -194,18 +199,18 @@ namespace NSCSS
m_sId = sStandPlusParent;
return;
}
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandPlusParent);
+ oElement.AddBasicProperties(BProperties::B_BasedOn, sStandPlusParent);
}
else
{
CXmlElement oTempElement = oParentStyle;
oTempElement += oStandardXmlElement;
- oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sStandPlusParent);
+ oTempElement.AddBasicProperties(BProperties::B_StyleId, sStandPlusParent);
if (bIsPStyle)
{
- oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
+ oTempElement.AddBasicProperties(BProperties::B_QFormat, L"true");
m_sStyle += oTempElement.GetPStyle();
}
else
@@ -218,7 +223,7 @@ namespace NSCSS
m_sId = sStandPlusParent;
return;
}
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, oTempElement.GetStyleId());
+ oElement.AddBasicProperties(BProperties::B_BasedOn, oTempElement.GetStyleId());
}
}
else if (!oStandardXmlElement.Empty() && oParentStyle.Empty())
@@ -228,7 +233,7 @@ namespace NSCSS
{
if (bIsPStyle)
{
- oStandardXmlElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
+ oStandardXmlElement.AddBasicProperties(BProperties::B_QFormat, L"true");
m_sStyle += oStandardXmlElement.GetPStyle();
}
else
@@ -241,7 +246,7 @@ namespace NSCSS
m_sId = sStandartStyleID;
return;
}
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandartStyleID);
+ oElement.AddBasicProperties(BProperties::B_BasedOn, sStandartStyleID);
}
if (oStyle.Empty() && oElement.Empty())
@@ -254,12 +259,12 @@ namespace NSCSS
if(!bIsPStyle)
m_sId += L"-c";
else
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
+ oElement.AddBasicProperties(BProperties::B_QFormat, L"true");
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, m_sId);
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, m_sId);
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
- oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1");
+ oElement.AddBasicProperties(BProperties::B_StyleId, m_sId);
+ oElement.AddBasicProperties(BProperties::B_Name, m_sId);
+ oElement.AddBasicProperties(BProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
+ oElement.AddBasicProperties(BProperties::B_CustomStyle, L"1");
}
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
@@ -268,7 +273,7 @@ namespace NSCSS
if (oStyle.Empty() && oXmlElement.Empty())
return;
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Jc, oStyle.m_oText.GetAlign().ToWString());
+ oXmlElement.AddPropertiesInP(PProperties::P_Jc, oStyle.m_oText.GetAlign().ToWString());
std::wstring sInfValue;
sInfValue.reserve(64);
@@ -289,7 +294,7 @@ namespace NSCSS
if (!sIndent.empty())
sInfValue += L"w:firstLine=\"" + sIndent + L"\" ";
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Ind, sInfValue);
+ oXmlElement.AddPropertiesInP(PProperties::P_Ind, sInfValue);
std::wstring sSpacingValue;
sSpacingValue.reserve(128);
@@ -297,35 +302,50 @@ namespace NSCSS
//TODO:: проверить Permission в Margin
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty() /*&& oStyle.m_oMargin.GetPermission()*/)
{
- sSpacingValue += L"w:afterAutospacing=\"1\" w:after=\"" + (oStyle.m_oMargin.GetBottom() + oStyle.m_oPadding.GetBottom()).ToWString() + L"\" ";
- sSpacingValue += L"w:beforeAutospacing=\"1\" w:before=\"" + (oStyle.m_oMargin.GetTop() + oStyle.m_oPadding.GetTop()) .ToWString() + L"\" ";
+ const double dSpacingBottom = oStyle.m_oMargin.GetBottom().ToDouble(NSCSS::Point) + oStyle.m_oPadding.GetBottom().ToDouble(NSCSS::Point);
+ const double dSpacingTop = oStyle.m_oMargin.GetTop().ToDouble(NSCSS::Point) + oStyle.m_oPadding.GetTop().ToDouble(NSCSS::Point);;
+
+ sSpacingValue += L" w:after=\"" + std::to_wstring(dSpacingBottom * SPACINGCOEF) + L"\" ";
+ sSpacingValue += L" w:before=\"" + std::to_wstring(dSpacingTop * SPACINGCOEF) + L"\" ";
}
else/* if (!oStyle.m_pBorder.Empty() || !oStyle.m_oMargin.GetPermission())*/
- sSpacingValue += L"w:after=\"0\" w:before=\"0\"";
+ sSpacingValue += L"w:after=\"0\" w:before=\"0\"";
- const std::wstring &sLineHeight = oStyle.m_oFont.GetLineHeight().ToWString();
- if (!sLineHeight.empty())
+ std::wstring wsLineHeight;
+
+ if (!oStyle.m_oFont.GetLineHeight().Empty())
{
- sSpacingValue += L" w:line=\"" + sLineHeight + L"\" w:lineRule=\"auto\"";
+ double dLineHeight = oStyle.m_oFont.GetLineHeight().ToDouble() * LINEHEIGHTSCALE;
+ NSCSS::UnitMeasure enUMLineHeight = oStyle.m_oFont.GetLineHeight().GetUnitMeasure();
+
+ if (NSCSS::UnitMeasure::None == enUMLineHeight || NSCSS::UnitMeasure::Percent == enUMLineHeight)
+ dLineHeight *= LINEHEIGHTCOEF;
+
+ wsLineHeight = std::to_wstring((int)dLineHeight);
}
- else if (!oStyle.m_oBorder.Empty())
+
+ if (!wsLineHeight.empty())
{
- sSpacingValue += L" w:line=\"" + std::to_wstring(static_cast(oStyle.m_oFont.GetSize().ToDouble() * 12 + 0.5f)) + L"\" w:lineRule=\"auto\"";
+ sSpacingValue += L" w:line=\"" + wsLineHeight + L"\" w:lineRule=\"auto\"";
}
+// else if (!oStyle.m_oBorder.Empty())
+// {
+// sSpacingValue += L" w:line=\"" + std::to_wstring(static_cast(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * 2 * SPACINGCOEF + 0.5f)) + L"\" w:lineRule=\"auto\"";
+// }
else if (!oStyle.m_oBorder.Empty())
- sSpacingValue += L"w:line=\"240\" w:lineRule=\"auto\" ";
+ sSpacingValue += L"w:line=\"240\" w:lineRule=\"auto\" ";
if (!sSpacingValue.empty())
{
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Spacing, sSpacingValue);
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_ContextualSpacing, L"true");
+ oXmlElement.AddPropertiesInP(PProperties::P_Spacing, sSpacingValue);
+ oXmlElement.AddPropertiesInP(PProperties::P_ContextualSpacing, L"true");
}
if (!oStyle.m_oBackground.Empty())
{
const std::wstring wsColor = oStyle.m_oBackground.GetColor().ToWString();
if (wsColor != L"ffffff")
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Shd, wsColor);
+ oXmlElement.AddPropertiesInP(PProperties::P_Shd, wsColor);
}
if (!oStyle.m_oBorder.Empty())
@@ -337,12 +357,12 @@ namespace NSCSS
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"0\" w:sz=\"" +
- sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
+ sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder);
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder);
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder);
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_TopBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_LeftBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_BottomBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_RightBorder, sBorder);
}
else
{
@@ -353,9 +373,9 @@ namespace NSCSS
const std::wstring sBorderWidth = oStyle.m_oBorder.GetTopBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
- sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
+ sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_TopBorder, sBorder);
}
if (!oStyle.m_oBorder.GetRightBorder().Empty())
@@ -365,9 +385,9 @@ namespace NSCSS
const std::wstring sBorderWidth = oStyle.m_oBorder.GetRightBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
- sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
+ sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_RightBorder, sBorder);
}
if (!oStyle.m_oBorder.GetBottomBorder().Empty())
@@ -377,9 +397,9 @@ namespace NSCSS
const std::wstring sBorderWidth = oStyle.m_oBorder.GetBottomBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
- sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
+ sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_BottomBorder, sBorder);
}
if (!oStyle.m_oBorder.GetLeftBorder().Empty())
@@ -389,9 +409,9 @@ namespace NSCSS
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
- sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
+ sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
- oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder);
+ oXmlElement.AddPropertiesInP(PProperties::P_LeftBorder, sBorder);
}
}
}
@@ -403,14 +423,14 @@ namespace NSCSS
if (oStyle.Empty() && oXmlElement.Empty())
return;
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Highlight, oStyle.m_oBackground.GetColor().ToWString());
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_U, (oStyle.m_oText.GetDecoration().m_oLine.Underline()) ? L"underline" : L"");
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Sz, oStyle.m_oFont.GetSize().ToWString());
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
- oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
+ oXmlElement.AddPropertiesInR(RProperties::R_Highlight, oStyle.m_oBackground.GetColor().ToWString());
+ oXmlElement.AddPropertiesInR(RProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
+ oXmlElement.AddPropertiesInR(RProperties::R_U, (oStyle.m_oText.GetDecoration().m_oLine.Underline()) ? L"underline" : L"");
+ oXmlElement.AddPropertiesInR(RProperties::R_Sz, std::to_wstring(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * FONTSCALE));
+ oXmlElement.AddPropertiesInR(RProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
+ oXmlElement.AddPropertiesInR(RProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
+ oXmlElement.AddPropertiesInR(RProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
+ oXmlElement.AddPropertiesInR(RProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
}
void CDocumentStyle::WriteRStyle (const NSCSS::CCompiledStyle& oStyle)
@@ -450,7 +470,7 @@ namespace NSCSS
SetPStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
- m_sStyle += oXmlElement.GetLitePStyle();
+ m_sStyle += oXmlElement.GetPStyle(true);
}
void CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
@@ -462,7 +482,7 @@ namespace NSCSS
SetRStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
- m_sStyle += oXmlElement.GetLiteRStyle();
+ m_sStyle += oXmlElement.GetRStyle(true);
}
void CDocumentStyle::WritePStyle (const NSCSS::CCompiledStyle& oStyle)
diff --git a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h
index d654800afb..886abc8c62 100644
--- a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h
+++ b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h
@@ -25,6 +25,10 @@ namespace NSCSS
class CSSCALCULATOR_EXPORT CDocumentStyle
{
+ typedef NSConstValues::NSProperties::BasicProperties BProperties;
+ typedef NSConstValues::NSProperties::ParagraphProperties PProperties;
+ typedef NSConstValues::NSProperties::RunnerProperties RProperties;
+
std::list m_arStandardStylesUsed;
std::list m_arStandardStyles;
std::list m_arStyleUsed;
diff --git a/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp b/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp
index 2affdd4e94..a3cb37abe2 100644
--- a/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp
+++ b/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp
@@ -8,6 +8,8 @@
#include
#include "../ConstValues.h"
+#define DEFAULTFONTNAME L"Times New Roman"
+
CXmlElement::CXmlElement()
{}
@@ -120,7 +122,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"44");
}
@@ -134,7 +136,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"33");
}
@@ -148,7 +150,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"26");
}
@@ -162,7 +164,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"22");
}
@@ -176,7 +178,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"18");
}
@@ -190,7 +192,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"15");
}
@@ -202,7 +204,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Paragraph character");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"p");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
}
else if (sNameDefaultElement == L"p")
{
@@ -221,7 +223,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Div character");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"div");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
}
else if (sNameDefaultElement == L"div")
{
@@ -242,7 +244,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddPropertiesInR(CSSProperties::RunnerProperties::R_Color, L"0000FF");
AddPropertiesInR(CSSProperties::RunnerProperties::R_U, L"single");
- AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, L"Times New Roman");
+ AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
}
else if (sNameDefaultElement == L"a")
{
@@ -289,13 +291,13 @@ CXmlElement& CXmlElement::operator+=(const CXmlElement& oElement)
if (oElement.Empty())
return *this;
- for (const std::map::value_type& oBasicElement : oElement.m_mBasicValues)
+ for (const BPropertiesMap::value_type& oBasicElement : oElement.m_mBasicValues)
m_mBasicValues[oBasicElement.first] = oBasicElement.second;
- for (const std::map::value_type& oPElement : oElement.m_mPStyleValues)
+ for (const PPropertiesMap::value_type& oPElement : oElement.m_mPStyleValues)
m_mPStyleValues[oPElement.first] = oPElement.second;
- for (const std::map::value_type& oRElement : oElement.m_mRStyleValues)
+ for (const RPropertiesMap::value_type& oRElement : oElement.m_mRStyleValues)
m_mRStyleValues[oRElement.first] = oRElement.second;
return *this;
@@ -317,7 +319,7 @@ bool CXmlElement::operator==(const CXmlElement &oElement)
m_mRStyleValues == oElement.m_mRStyleValues;
}
-std::wstring CXmlElement::ConvertPStyle() const
+std::wstring CXmlElement::ConvertPStyle(bool bIsLite) const
{
if (m_mPStyleValues.empty())
return std::wstring();
@@ -325,7 +327,7 @@ std::wstring CXmlElement::ConvertPStyle() const
std::wstring sPPr;
std::wstring sPBdr;
- for (const std::map::value_type& oItem : m_mPStyleValues)
+ for (const PPropertiesMap::value_type& oItem : m_mPStyleValues)
{
switch (oItem.first)
{
@@ -398,29 +400,31 @@ std::wstring CXmlElement::ConvertPStyle() const
if (!sPBdr.empty())
sPPr += L"" + sPBdr + L"";
+ if (bIsLite)
+ return sPPr;
+
return L"" + sPPr + L"";
}
-std::wstring CXmlElement::ConvertRStyle() const
+std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
{
if (m_mRStyleValues.empty())
return std::wstring();
std::wstring sRStyle;
- for (const std::map::value_type& oItem : m_mRStyleValues)
+ for (const RPropertiesMap::value_type& oItem : m_mRStyleValues)
{
switch (oItem.first)
{
case CSSProperties::RunnerProperties::R_RFonts:
{
- std::wstring wsFontFamily = L"Times New Roman";
+ std::wstring wsFontFamily = (oItem.second.empty() || L"\"inherit\"" == oItem.second) ? DEFAULTFONTNAME : oItem.second;
- sRStyle += (oItem.second != L"\"inherit\"") ? L""
- : L"";
+ sRStyle += L"";
break;
}
case CSSProperties::RunnerProperties::R_Sz:
@@ -476,6 +480,9 @@ std::wstring CXmlElement::ConvertRStyle() const
}
}
+ if (bIsLite)
+ return sRStyle;
+
return L"" + sRStyle + L"";
}
@@ -486,7 +493,7 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const
std::wstring sBasicInfo;
- for (const std::map::value_type& oItem : m_mBasicValues)
+ for (const BPropertiesMap::value_type& oItem : m_mBasicValues)
{
switch (oItem.first)
{
@@ -528,174 +535,96 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const
return sBasicInfo;
}
-std::wstring CXmlElement::GetStyle() const
+std::wstring CXmlElement::GetStyleArguments() const
{
- if (Empty())
- return std::wstring();
-
- std::wstring sStyle = L"::value_type& oItem : m_mBasicValues)
+ std::wstring wsStyleArguments;
+
+ for (const BPropertiesMap::value_type& oItem : m_mBasicValues)
{
switch (oItem.first)
{
case CSSProperties::BasicProperties::B_CustomStyle:
{
- sStyle += L" w:customStyle=\"" + oItem.second + L"\"";
+ wsStyleArguments += L" w:customStyle=\"" + oItem.second + L"\"";
break;
}
case CSSProperties::BasicProperties::B_StyleId:
{
- sStyle += L" w:styleId=\"" + oItem.second + L"\"";
+ wsStyleArguments += L" w:styleId=\"" + oItem.second + L"\"";
break;
}
case CSSProperties::BasicProperties::B_Type:
{
- sStyle += L" w:type=\"" + oItem.second + L"\"";
+ wsStyleArguments += L" w:type=\"" + oItem.second + L"\"";
break;
}
case CSSProperties::BasicProperties::B_Default:
{
- sStyle += L" w:default=\"" + oItem.second + L"\"";
+ wsStyleArguments += L" w:default=\"" + oItem.second + L"\"";
break;
}
default:
break;
}
}
- sStyle += L">";
- sStyle += ConvertBasicInfoStyle();
- sStyle += ConvertPStyle();
- sStyle += ConvertRStyle();
- sStyle += L"";
-
- return sStyle.length() > 19 ? sStyle : std::wstring();
+
+ return wsStyleArguments;
}
-std::wstring CXmlElement::GetLitePStyle() const
+std::wstring CXmlElement::GetStyle(bool bGetBasedInfo, bool bGetPInfo, bool bGetRInfo) const
{
if (Empty())
return std::wstring();
- const std::wstring &sLitePStyle = ConvertPStyle();
+ std::wstring wsStyleArguments = GetStyleArguments();
+ std::wstring wsStyleValue;
- return (sLitePStyle.empty()) ? sLitePStyle : sLitePStyle.substr(7, sLitePStyle.length() - 15);
-}
+ if (bGetBasedInfo)
+ wsStyleValue += ConvertBasicInfoStyle();
+
+ if (bGetPInfo)
+ wsStyleValue += ConvertPStyle();
+
+ if (bGetRInfo)
+ wsStyleValue += ConvertRStyle();
-std::wstring CXmlElement::GetLiteRStyle() const
-{
- if (Empty())
+ if (wsStyleArguments.empty() && wsStyleValue.empty())
return std::wstring();
- const std::wstring &sLiteRStyle = ConvertRStyle();
-
- return (sLiteRStyle.empty()) ? sLiteRStyle : sLiteRStyle.substr(7, sLiteRStyle.length() - 15);
+ return L"" + wsStyleValue + L"";
}
-std::wstring CXmlElement::GetPStyle() const
+std::wstring CXmlElement::GetPStyle(bool bIsLite) const
{
- if (m_mBasicValues.empty() && m_mPStyleValues.empty())
- return std::wstring();
-
- std::wstring sPStyle = L"::value_type& oItem : m_mBasicValues)
- {
- switch (oItem.first)
- {
- case CSSProperties::BasicProperties::B_CustomStyle:
- {
- sPStyle += L" w:customStyle=\"" + oItem.second + L"\"";
- break;
- }
- case CSSProperties::BasicProperties::B_StyleId:
- {
- sPStyle += L" w:styleId=\"" + oItem.second + L"\"";
- break;
- }
- case CSSProperties::BasicProperties::B_Type:
- {
- sPStyle += L" w:type=\"" + oItem.second + L"\"";
- break;
- }
- case CSSProperties::BasicProperties::B_Default:
- {
- sPStyle += L" w:default=\"" + oItem.second + L"\"";
- break;
- }
- default:
- break;
- }
- }
-
- sPStyle += L">";
- sPStyle += ConvertBasicInfoStyle();
- sPStyle += ConvertPStyle();
- sPStyle += L"";
-
- return sPStyle;
+ if (bIsLite)
+ return ConvertPStyle(true);
+
+ return GetStyle(true, true, false);
}
-std::wstring CXmlElement::GetRStyle() const
+std::wstring CXmlElement::GetRStyle(bool bIsLite) const
{
- if (m_mBasicValues.empty() && m_mRStyleValues.empty())
- return std::wstring();
-
- std::wstring sRStyle = L"::value_type& oItem : m_mBasicValues)
- {
- switch (oItem.first)
- {
- case CSSProperties::BasicProperties::B_CustomStyle:
- {
- sRStyle += L" w:customStyle=\"" + oItem.second + L"\"";
- break;
- }
- case CSSProperties::BasicProperties::B_StyleId:
- {
- sRStyle += L" w:styleId=\"" + oItem.second + L"\"";
- break;
- }
- case CSSProperties::BasicProperties::B_Type:
- {
- sRStyle += L" w:type=\"" + oItem.second + L"\"";
- break;
- }
-
- case CSSProperties::BasicProperties::B_Default:
- {
- sRStyle += L" w:default=\"" + oItem.second + L"\"";
- break;
- }
-
- default:
- break;
- }
- }
- sRStyle += L">";
- sRStyle += ConvertBasicInfoStyle();
- sRStyle += ConvertRStyle();
- sRStyle += L"";
-
- return sRStyle.length() > 22 ? sRStyle : std::wstring();
+ if (bIsLite)
+ return ConvertRStyle(true);
+
+ return GetStyle(true, false, true);
}
std::wstring CXmlElement::GetBasedOn() const
{
- std::map::const_iterator posBasedOn = m_mBasicValues.find(CSSProperties::BasicProperties::B_BasedOn);
+ BPropertiesMap::const_iterator posBasedOn = m_mBasicValues.find(CSSProperties::BasicProperties::B_BasedOn);
return (posBasedOn != m_mBasicValues.end()) ? posBasedOn->second : std::wstring();
}
std::wstring CXmlElement::GetStyleId() const
{
- std::map::const_iterator posStyleId = m_mBasicValues.find(CSSProperties::BasicProperties::B_StyleId);
+ BPropertiesMap::const_iterator posStyleId = m_mBasicValues.find(CSSProperties::BasicProperties::B_StyleId);
return (posStyleId != m_mBasicValues.end()) ? posStyleId->second : std::wstring();
}
std::wstring CXmlElement::GetName() const
{
- std::map::const_iterator posName = m_mBasicValues.find(CSSProperties::BasicProperties::B_Name);
+ BPropertiesMap::const_iterator posName = m_mBasicValues.find(CSSProperties::BasicProperties::B_Name);
return (posName != m_mBasicValues.end()) ? posName->second : std::wstring();
}
diff --git a/Common/3dParty/html/css/src/xhtml/CXmlElement.h b/Common/3dParty/html/css/src/xhtml/CXmlElement.h
index 8129a54607..4a7b0fa4bd 100644
--- a/Common/3dParty/html/css/src/xhtml/CXmlElement.h
+++ b/Common/3dParty/html/css/src/xhtml/CXmlElement.h
@@ -10,13 +10,19 @@ namespace { namespace CSSProperties = NSCSS::NSConstValues::NSProperties; }
class CXmlElement
{
- std::map m_mRStyleValues;
- std::map m_mPStyleValues;
- std::map m_mBasicValues;
+ typedef std::map RPropertiesMap;
+ typedef std::map PPropertiesMap;
+ typedef std::map BPropertiesMap;
+
+ RPropertiesMap m_mRStyleValues;
+ PPropertiesMap m_mPStyleValues;
+ BPropertiesMap m_mBasicValues;
- std::wstring ConvertPStyle() const;
- std::wstring ConvertRStyle() const;
- std::wstring ConvertBasicInfoStyle() const;
+ std::wstring ConvertPStyle(bool bIsLite = false) const;
+ std::wstring ConvertRStyle(bool bIsLite = false) const;
+ std::wstring ConvertBasicInfoStyle() const;
+
+ std::wstring GetStyleArguments() const;
public:
CXmlElement();
@@ -32,14 +38,12 @@ public:
void AddPropertiesInR (const CSSProperties::RunnerProperties& enProperties, const std::wstring& sValue);
void AddBasicProperties(const CSSProperties::BasicProperties& enProperties, const std::wstring& sValue);
- std::wstring GetLitePStyle() const;
- std::wstring GetLiteRStyle() const;
- std::wstring GetPStyle() const;
- std::wstring GetRStyle() const;
- std::wstring GetStyle() const;
- std::wstring GetBasedOn() const;
- std::wstring GetStyleId() const;
- std::wstring GetName() const;
+ std::wstring GetStyle(bool bGetBasedInfo = true, bool bGetPInfo = true, bool bGetRInfo = true) const;
+ std::wstring GetPStyle(bool bIsLite = false) const;
+ std::wstring GetRStyle(bool bIsLite = false) const;
+ std::wstring GetBasedOn() const;
+ std::wstring GetStyleId() const;
+ std::wstring GetName() const;
CXmlElement& operator+=(const CXmlElement& oElement);
CXmlElement& operator= (const CXmlElement& oelement);
diff --git a/Common/3dParty/libvlc/vlcplayer.cpp b/Common/3dParty/libvlc/vlcplayer.cpp
index 935efbce06..b0a7c0d217 100644
--- a/Common/3dParty/libvlc/vlcplayer.cpp
+++ b/Common/3dParty/libvlc/vlcplayer.cpp
@@ -2,7 +2,7 @@
#include
-CVlcPlayer::CVlcPlayer()
+CVlcPlayer::CVlcPlayer(QWidget* parent) : QWidget(parent)
{
// initialize libVLC
m_pVlcInstance = libvlc_new(0, NULL);
@@ -14,6 +14,9 @@ CVlcPlayer::CVlcPlayer()
}
// initialize vlc media player
m_pVlcPlayer = libvlc_media_player_new(m_pVlcInstance);
+ // disable event handling by vlc internals
+ libvlc_video_set_mouse_input(m_pVlcPlayer, false);
+ libvlc_video_set_key_input(m_pVlcPlayer, false);
// get event manager
m_pEventManager = libvlc_media_player_event_manager(m_pVlcPlayer);
diff --git a/Common/3dParty/libvlc/vlcplayer.h b/Common/3dParty/libvlc/vlcplayer.h
index bd33fd9c25..5bfa79741a 100644
--- a/Common/3dParty/libvlc/vlcplayer.h
+++ b/Common/3dParty/libvlc/vlcplayer.h
@@ -11,7 +11,7 @@ class CVlcPlayer : public QWidget
Q_OBJECT
public:
- CVlcPlayer();
+ CVlcPlayer(QWidget* parent = nullptr);
virtual ~CVlcPlayer();
public:
diff --git a/Common/js/string_utf8.js b/Common/js/string_utf8.js
index 6483236b3f..24fdfc06eb 100644
--- a/Common/js/string_utf8.js
+++ b/Common/js/string_utf8.js
@@ -4,6 +4,9 @@
undefined !== String.prototype.toUtf8)
return;
+ var STRING_UTF8_BUFFER_LENGTH = 1024;
+ var STRING_UTF8_BUFFER = new ArrayBuffer(STRING_UTF8_BUFFER_LENGTH);
+
/**
* Read string from utf8
* @param {Uint8Array} buffer
@@ -54,10 +57,10 @@
* Convert string to utf8 array
* @returns {Uint8Array}
*/
- String.prototype.toUtf8 = function(isNoEndNull) {
+ String.prototype.toUtf8 = function(isNoEndNull, isUseBuffer) {
var inputLen = this.length;
var testLen = 6 * inputLen + 1;
- var tmpStrings = new ArrayBuffer(testLen);
+ var tmpStrings = (isUseBuffer && testLen < STRING_UTF8_BUFFER_LENGTH) ? STRING_UTF8_BUFFER : new ArrayBuffer(testLen);
var code = 0;
var index = 0;
@@ -129,7 +132,7 @@
};
String.prototype.toUtf8Pointer = function(isNoEndNull) {
- var tmp = this.toUtf8(isNoEndNull);
+ var tmp = this.toUtf8(isNoEndNull, true);
var pointer = Module["_malloc"](tmp.length);
if (0 == pointer)
return null;
diff --git a/DesktopEditor/doctrenderer/docbuilder_p.cpp b/DesktopEditor/doctrenderer/docbuilder_p.cpp
index 28d055399a..df73c6b975 100644
--- a/DesktopEditor/doctrenderer/docbuilder_p.cpp
+++ b/DesktopEditor/doctrenderer/docbuilder_p.cpp
@@ -1421,7 +1421,7 @@ namespace NSDoctRenderer
bIsNoError = (0 == this->OpenFile(_builder_params[0].c_str(), _builder_params[1].c_str()));
else if ("CreateFile" == sFuncNum)
{
- if (L"docx" == _builder_params[0])
+ if (L"docx" == _builder_params[0] || L"docxf" == _builder_params[0] || L"oform" == _builder_params[0])
bIsNoError = this->CreateFile(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX);
else if (L"pptx" == _builder_params[0])
bIsNoError = this->CreateFile(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX);
diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h
index 429af34e46..0f9334561c 100644
--- a/DesktopEditor/doctrenderer/docbuilder_p.h
+++ b/DesktopEditor/doctrenderer/docbuilder_p.h
@@ -102,6 +102,12 @@ namespace NSDoctRenderer
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_PNG;
else if (L"vsdx" == sExt)
nFormat = AVS_OFFICESTUDIO_FILE_DRAW_VSDX;
+ else if (L"docxf" == sExt)
+ nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF;
+ else if (L"oform" == sExt)
+ nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM;
+ else if (L"html" == sExt)
+ nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER;
return nFormat;
}
}
@@ -1263,42 +1269,7 @@ namespace NSDoctRenderer
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
{
- int nType = -1;
- if (L"docx" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
- else if (L"doc" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
- else if (L"odt" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
- else if (L"rtf" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
- else if (L"txt" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
- else if (L"pptx" == ext)
- nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
- else if (L"odp" == ext)
- nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
- else if (L"xlsx" == ext)
- nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
- else if (L"xls" == ext)
- nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
- else if (L"ods" == ext)
- nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
- else if (L"csv" == ext)
- nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
- else if (L"pdf" == ext)
- nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
- else if (L"image" == ext)
- nType = AVS_OFFICESTUDIO_FILE_IMAGE;
- else if (L"jpg" == ext)
- nType = AVS_OFFICESTUDIO_FILE_IMAGE;
- else if (L"png" == ext)
- nType = AVS_OFFICESTUDIO_FILE_IMAGE;
- else if (L"html" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER;
- else if (L"vsdx" == ext)
- nType = AVS_OFFICESTUDIO_FILE_DRAW_VSDX;
-
+ int nType = GetFormatByTexExtention(ext);
return SaveFile(nType, path, params);
}
diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp
index 15cf6091cc..c5f5254e23 100644
--- a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp
+++ b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp
@@ -45,8 +45,8 @@ namespace MetaFile
m_oStream >> unSize;
- if (unSize > m_oStream.CanRead())
- SetError();
+ if (unSize - 1 > m_oStream.CanRead())
+ return SetError();
m_oStream >> ushType;
diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp
index bdb87e6e2c..0327597feb 100644
--- a/HtmlFile2/htmlfile2.cpp
+++ b/HtmlFile2/htmlfile2.cpp
@@ -704,6 +704,9 @@ private:
void readBody()
{
std::vector sSelectors;
+
+ sSelectors.push_back(NSCSS::CNode(L"html", L"", L""));
+
GetSubClass(&m_oDocXml, sSelectors);
/*
std::wstring sCrossId = std::to_wstring(m_nCrossId++);
diff --git a/MsBinaryFile/PptFile/Records/Drawing/ArtBlip.cpp b/MsBinaryFile/PptFile/Records/Drawing/ArtBlip.cpp
index fd38a46b2b..9b4f264038 100644
--- a/MsBinaryFile/PptFile/Records/Drawing/ArtBlip.cpp
+++ b/MsBinaryFile/PptFile/Records/Drawing/ArtBlip.cpp
@@ -94,7 +94,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
if (0x0216 == oHeader.RecInstance) lOffset = 16;
else if (0x0217 == oHeader.RecInstance) lOffset = 32;
- StreamUtils::StreamSkip(lOffset, pStream);
+ //StreamUtils::StreamSkip(lOffset, pStream);
lOffset += 34;
@@ -219,6 +219,17 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
{
pDecryptor->Decrypt((char*)pImage, oHeader.RecLen - lOffset, 0);
}
+ size_t lOffset2 = 0;
+ if (oHeader.RecType == RECORD_TYPE_ESCHER_BLIP_PNG)
+ {
+ std::string test((char*)pImage, (std::min)((int)oHeader.RecLen - lOffset, 4096));
+ if (std::string::npos != (lOffset2 = test.find("GIF89")))
+ {//gif in png chuncks - todooo from read header, chunks ....
+ sExt = L".gif";
+ lOffset -= lOffset2;
+ }
+ }
+
std::wstring strFile = L"Image " + std::to_wstring(nImagesCount + 1) + sExt;
NSFile::CFileBinary fileImage;
@@ -236,7 +247,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
_UINT32 dwOffset = 2;
fileImage.WriteFile((BYTE*)&dwOffset, 4);
}
- fileImage.WriteFile(pImage, oHeader.RecLen - lOffset);
+ fileImage.WriteFile(pImage + lOffset2, oHeader.RecLen - lOffset);
fileImage.CloseFile();
}
if (pImage)delete[] pImage;
diff --git a/OOXML/Binary/Document/BinReader/Readers.cpp b/OOXML/Binary/Document/BinReader/Readers.cpp
index 8bb1923ea1..ed890a8654 100644
--- a/OOXML/Binary/Document/BinReader/Readers.cpp
+++ b/OOXML/Binary/Document/BinReader/Readers.cpp
@@ -2752,7 +2752,7 @@ int Binary_tblPrReader::Read_CellPr(BYTE type, long length, void* poResult)
else if (c_oSerProp_cellPrType::CnfStyle == type)
{
ComplexTypes::Word::CCnf cnf;
- READ2_DEF(length, res, this->oBinary_pPrReader.ReadCnfStyle, &cnf);
+ READ1_DEF(length, res, this->oBinary_pPrReader.ReadCnfStyle, &cnf);
pCStringWriter->WriteString(cnf.ToString());
}
@@ -3969,6 +3969,32 @@ int Binary_SettingsTableReader::ReadSettings(BYTE type, long length, void* poRes
pSettings->m_oWriteProtection.Init();
READ1_DEF(length, res, this->ReadWriteProtect, pSettings->m_oWriteProtection.GetPointer());
}
+ else if (c_oSer_SettingsType::SdtGlobalShowHighlight == type)
+ {
+ m_pSettingsCustom->m_oSdtGlobalShowHighlight.Init();
+ m_pSettingsCustom->m_oSdtGlobalShowHighlight->m_oVal.FromBool(m_oBufferedStream.GetBool());
+ }
+ else if (c_oSer_SettingsType::AutoHyphenation == type)
+ {
+ pSettings->m_oAutoHyphenation.Init();
+ pSettings->m_oAutoHyphenation->m_oVal.FromBool(m_oBufferedStream.GetBool());
+ }
+ else if (c_oSer_SettingsType::HyphenationZone == type)
+ {
+ pSettings->m_oHyphenationZone.Init();
+ pSettings->m_oHyphenationZone->m_oVal.Init();
+ pSettings->m_oHyphenationZone->m_oVal->FromTwips(m_oBufferedStream.GetLong());
+ }
+ else if (c_oSer_SettingsType::DoNotHyphenateCaps == type)
+ {
+ pSettings->m_oDoNotHyphenateCaps.Init();
+ pSettings->m_oDoNotHyphenateCaps->m_oVal.FromBool(m_oBufferedStream.GetBool());
+ }
+ else if (c_oSer_SettingsType::ConsecutiveHyphenLimit == type)
+ {
+ pSettings->m_oConsecutiveHyphenLimit.Init();
+ pSettings->m_oConsecutiveHyphenLimit->m_oVal = m_oBufferedStream.GetLong();
+ }
else
res = c_oSerConstants::ReadUnknown;
return res;
diff --git a/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h b/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h
index 0a8aba14d5..465701e61c 100644
--- a/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h
+++ b/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h
@@ -901,8 +901,11 @@ extern int g_nCurFormatVersion;
BookFoldRevPrinting = 17,
SpecialFormsHighlight = 18,
DocumentProtection = 19,
- WriteProtection = 20
-
+ WriteProtection = 20,
+ AutoHyphenation = 21,
+ HyphenationZone = 22,
+ DoNotHyphenateCaps = 23,
+ ConsecutiveHyphenLimit = 24
};}
namespace c_oSer_MathPrType{enum c_oSer_SettingsType
{
diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.cpp b/OOXML/Binary/Document/BinWriter/BinWriters.cpp
index 9afda741d9..695e118580 100644
--- a/OOXML/Binary/Document/BinWriter/BinWriters.cpp
+++ b/OOXML/Binary/Document/BinWriter/BinWriters.cpp
@@ -8689,6 +8689,30 @@ void BinarySettingsTableWriter::WriteSettingsContent(OOX::CSettings& oSettings,
WriteWriteProtection(oSettings.m_oWriteProtection.get());
m_oBcw.WriteItemEnd(nCurPos);
}
+ if (oSettings.m_oAutoHyphenation.IsInit())
+ {
+ nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::AutoHyphenation);
+ m_oBcw.m_oStream.WriteBOOL(oSettings.m_oAutoHyphenation->m_oVal.ToBool());
+ m_oBcw.WriteItemEnd(nCurPos);
+ }
+ if (oSettings.m_oHyphenationZone.IsInit())
+ {
+ nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::HyphenationZone);
+ m_oBcw.m_oStream.WriteLONG(oSettings.m_oHyphenationZone->m_oVal->ToTwips());
+ m_oBcw.WriteItemEnd(nCurPos);
+ }
+ if (oSettings.m_oDoNotHyphenateCaps.IsInit())
+ {
+ nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::DoNotHyphenateCaps);
+ m_oBcw.m_oStream.WriteBOOL(oSettings.m_oDoNotHyphenateCaps->m_oVal.ToBool());
+ m_oBcw.WriteItemEnd(nCurPos);
+ }
+ if ((oSettings.m_oConsecutiveHyphenLimit.IsInit()) && (oSettings.m_oConsecutiveHyphenLimit->m_oVal.IsInit()))
+ {
+ nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::ConsecutiveHyphenLimit);
+ m_oBcw.m_oStream.WriteLONG(*oSettings.m_oConsecutiveHyphenLimit->m_oVal);
+ m_oBcw.WriteItemEnd(nCurPos);
+ }
};
void BinarySettingsTableWriter::WriteMathPr(const OOX::Logic::CMathPr &pMathPr)
{
diff --git a/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp b/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp
index 66f9f6bc85..aa8b9c95dd 100644
--- a/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp
+++ b/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp
@@ -467,6 +467,7 @@ namespace NSBinPptxRW
case _CXIMAGE_FORMAT_PNG:
case _CXIMAGE_FORMAT_WMF:
case _CXIMAGE_FORMAT_EMF:
+ case _CXIMAGE_FORMAT_GIF:
{
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
diff --git a/OOXML/Binary/Presentation/imagemanager.cpp b/OOXML/Binary/Presentation/imagemanager.cpp
index 34fd0bae10..b058280f4a 100644
--- a/OOXML/Binary/Presentation/imagemanager.cpp
+++ b/OOXML/Binary/Presentation/imagemanager.cpp
@@ -268,6 +268,15 @@ namespace NSShapeImageGen
result = true;
}
+ else if (checker.eFileType == _CXIMAGE_FORMAT_GIF)
+ {
+ oInfo.m_eType = itGIF;
+
+ OOX::CPath pathSaveItem = m_strDstMedia + FILE_SEPARATOR_STR + oInfo.GetPath2();
+ CDirectory::CopyFile(strFileSrc, pathSaveItem.GetPath());
+
+ result = true;
+ }
else if (checker.eFileType == _CXIMAGE_FORMAT_PNG)
{
oInfo.m_eType = itPNG;
diff --git a/OOXML/Binary/Presentation/imagemanager.h b/OOXML/Binary/Presentation/imagemanager.h
index 30dbd68b00..d757b0c449 100644
--- a/OOXML/Binary/Presentation/imagemanager.h
+++ b/OOXML/Binary/Presentation/imagemanager.h
@@ -50,12 +50,13 @@ namespace NSShapeImageGen
{
itJPG = 0,
itPNG = 1,
- itVIF = 2,
- itWMF = 3,
- itEMF = 4,
- itSVG = 5,
- itMedia = 6,
- itUnknown = 7
+ itGIF = 2,
+ itVIF = 3,
+ itWMF = 4,
+ itEMF = 5,
+ itSVG = 6,
+ itMedia = 7,
+ itUnknown = 8
};
class CMediaInfo
@@ -117,6 +118,9 @@ namespace NSShapeImageGen
case itPNG:
_strExt = L".png";
break;
+ case itGIF:
+ _strExt = L".gif";
+ break;
case itJPG:
_strExt = L".jpg";
break;
diff --git a/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp b/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp
index c7abd56e77..4fd8c8a60c 100644
--- a/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp
+++ b/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp
@@ -6646,15 +6646,15 @@ namespace BinXlsxRW
pLegend->m_spPr->m_namespace = L"cx";
res = ReadCT_PptxElement(0, length, pLegend->m_spPr.GetPointer());
}
- else if (c_oserct_chartExTitlePOS == type)
+ else if (c_oserct_chartExLegendPOS == type)
{
pLegend->m_pos = (SimpleTypes::Spreadsheet::ESidePos)m_oBufferedStream.GetUChar();
}
- else if (c_oserct_chartExTitleALIGN == type)
+ else if (c_oserct_chartExLegendALIGN == type)
{
pLegend->m_align = (SimpleTypes::Spreadsheet::EPosAlign)m_oBufferedStream.GetUChar();
}
- else if (c_oserct_chartExTitleOVERLAY == type)
+ else if (c_oserct_chartExLegendOVERLAY == type)
{
pLegend->m_overlay = m_oBufferedStream.GetBool();
}
@@ -6877,7 +6877,7 @@ namespace BinXlsxRW
pDataLabel->m_spPr->m_namespace = L"cx";
res = ReadCT_PptxElement(0, length, pDataLabel->m_spPr.GetPointer());
}
- else if (c_oserct_chartExDataLabelsVISABILITIES == type)
+ else if (c_oserct_chartExDataLabelVISABILITIES == type)
{
pDataLabel->m_visibility.Init();
READ1_DEF(length, res, this->ReadCT_ChartExDataLabelVisibilities, pDataLabel->m_visibility.GetPointer());
@@ -6895,7 +6895,7 @@ namespace BinXlsxRW
int res = c_oSerConstants::ReadOk;
OOX::Spreadsheet::ChartEx::CDataLabelHidden *pDataLabelHidden = static_cast(poResult);
- if (c_oserct_chartExDATA == type)
+ if (c_oserct_chartExDataLabelHiddenIDX == type)
{
pDataLabelHidden->m_idx = m_oBufferedStream.GetLong();
}
@@ -7026,7 +7026,7 @@ namespace BinXlsxRW
int res = c_oSerConstants::ReadOk;
OOX::Spreadsheet::ChartEx::CStatistics *pStatistics = static_cast(poResult);
- if (c_oserct_chartExDATA == type)
+ if (c_oserct_chartExStatisticsMETHOD == type)
{
pStatistics->m_quartileMethod = (SimpleTypes::Spreadsheet::EQuartileMethod)m_oBufferedStream.GetUChar();
}
@@ -7132,7 +7132,7 @@ namespace BinXlsxRW
pAxis->m_majorGridlines->m_name = L"cx:majorGridlines";
READ1_DEF(length, res, this->ReadCT_ChartExGridlines, pAxis->m_majorGridlines.GetPointer());
}
- else if (c_oserct_chartExAxisMAJORGRID == type)
+ else if (c_oserct_chartExAxisMINORGRID == type)
{
pAxis->m_minorGridlines.Init();
pAxis->m_minorGridlines->m_name = L"cx:minorGridlines";
@@ -7148,7 +7148,7 @@ namespace BinXlsxRW
pAxis->m_txPr->m_name = L"cx:txPr";
res = ReadCT_PptxElement(0, length, pAxis->m_txPr.GetPointer());
}
- else if (c_oserct_chartExDataLabelSPPR == type)
+ else if (c_oserct_chartExAxisSPPR == type)
{
pAxis->m_spPr = new PPTX::Logic::SpPr;
pAxis->m_spPr->m_namespace = L"cx";
diff --git a/OOXML/DocxFormat/Drawing/DrawingExt.cpp b/OOXML/DocxFormat/Drawing/DrawingExt.cpp
index 83af0ef60a..2248cc55e6 100644
--- a/OOXML/DocxFormat/Drawing/DrawingExt.cpp
+++ b/OOXML/DocxFormat/Drawing/DrawingExt.cpp
@@ -242,12 +242,13 @@ namespace OOX
}
else if ((sName == L"conditionalFormattings") && (false == oReader.IsEmptyNode()))
{
- while (oReader.ReadNextSiblingNode(oReader.GetDepth()))
+ int nCurDepth1 = oReader.GetDepth();
+ while (oReader.ReadNextSiblingNode(nCurDepth1))
{
OOX::Spreadsheet::CConditionalFormatting* pConditionalFormatting = new OOX::Spreadsheet::CConditionalFormatting();
*pConditionalFormatting = oReader;
m_arrConditionalFormatting.push_back(pConditionalFormatting);
- }
+ }
}
else if (sName == L"dataValidations")
{
@@ -289,7 +290,8 @@ namespace OOX
}
else if ((sName == L"slicerCachePivotTables") && false == oReader.IsEmptyNode())
{
- while (oReader.ReadNextSiblingNode(oReader.GetDepth()))
+ int nCurDepth1 = oReader.GetDepth();
+ while (oReader.ReadNextSiblingNode(nCurDepth1))
{
OOX::Spreadsheet::CSlicerCachePivotTable* pSlicerCachePivotTable = new OOX::Spreadsheet::CSlicerCachePivotTable();
*pSlicerCachePivotTable = oReader;
@@ -335,7 +337,8 @@ namespace OOX
}
else if ((sName == L"dataDisplayOptions16") && (false == oReader.IsEmptyNode()))
{
- while (oReader.ReadNextSiblingNode(oReader.GetDepth()))
+ int nCurDepth1 = oReader.GetDepth();
+ while (oReader.ReadNextSiblingNode(nCurDepth1))
{
std::wstring sName1 = XmlUtils::GetNameNoNS(oReader.GetName());
if (sName1 == L"dispNaAsBlank")
diff --git a/OOXML/DocxFormat/Settings/Settings.h b/OOXML/DocxFormat/Settings/Settings.h
index 481b9e3643..4764af82cb 100644
--- a/OOXML/DocxFormat/Settings/Settings.h
+++ b/OOXML/DocxFormat/Settings/Settings.h
@@ -935,34 +935,34 @@ namespace OOX
void SetDefaults();
//------------------------------------------------------------------------------------------------------------------
- nullable m_oActiveWritingStyle;
+ nullable m_oActiveWritingStyle;
nullable m_oAlignBordersAndEdges;
nullable m_oAlwaysMergeEmptyNamespace;
nullable m_oAlwaysShowPlaceholderText;
- nullable m_oAttachedSchema;
- nullable m_oAttachedTemplate;
+ nullable m_oAttachedSchema;
+ nullable m_oAttachedTemplate;
nullable m_oAutoFormatOverride;
nullable m_oAutoHyphenation;
nullable m_oBookFoldPrinting;
- nullable m_oBookFoldPrintingSheets;
+ nullable m_oBookFoldPrintingSheets;
nullable m_oBookFoldRevPrinting;
nullable m_oBordersDoNotSurroundFooter;
nullable m_oBordersDoNotSurroundHeader;
- nullable m_oCaptions;
- nullable m_oCharacterSpacingControl;
- nullable m_oClickAndTypeStyle;
- nullable m_oClrSchemeMapping;
- nullable m_oCompat;
- nullable m_oConsecutiveHyphenLimit;
- nullable m_oDecimalSymbol;
- nullable m_oDefaultTableStyle;
- nullable m_oDefaultTabStop;
+ nullable m_oCaptions;
+ nullable m_oCharacterSpacingControl;
+ nullable m_oClickAndTypeStyle;
+ nullable m_oClrSchemeMapping;
+ nullable m_oCompat;
+ nullable m_oConsecutiveHyphenLimit;
+ nullable m_oDecimalSymbol;
+ nullable m_oDefaultTableStyle;
+ nullable m_oDefaultTabStop;
nullable m_oDisplayBackgroundShape;
- nullable m_oDisplayHorizontalDrawingGridEvery;
- nullable m_oDisplayVerticalDrawingGridEvery;
- nullable m_oDocumentProtection;
- nullable m_oDocumentType;
- nullable m_oDocVars;
+ nullable m_oDisplayHorizontalDrawingGridEvery;
+ nullable m_oDisplayVerticalDrawingGridEvery;
+ nullable m_oDocumentProtection;
+ nullable m_oDocumentType;
+ nullable m_oDocVars;
nullable m_oDoNotAutoCompressPictures;
nullable m_oDoNotDemarcateInvalidXml;
nullable m_oDoNotDisplayPageBoundaries;
@@ -974,65 +974,65 @@ namespace OOX
nullable m_oDoNotTrackMoves;
nullable m_oDoNotUseMarginsForDrawingGridOrigin;
nullable m_oDoNotValidateAgainstSchema;
- nullable m_oDrawingGridHorizontalOrigin;
- nullable m_oDrawingGridHorizontalSpacing;
- nullable m_oDrawingGridVerticalOrigin;
- nullable m_oDrawingGridVerticalSpacing;
+ nullable m_oDrawingGridHorizontalOrigin;
+ nullable m_oDrawingGridHorizontalSpacing;
+ nullable m_oDrawingGridVerticalOrigin;
+ nullable m_oDrawingGridVerticalSpacing;
nullable m_oEmbedSystemFonts;
nullable m_oEmbedTrueTypeFonts;
- nullable m_oEndnotePr;
+ nullable m_oEndnotePr;
nullable m_oEvenAndOddHeaders;
- nullable m_oFootnotePr;
- nullable m_oForceUpgrade;
+ nullable m_oFootnotePr;
+ nullable m_oForceUpgrade;
nullable m_oFormsDesign;
nullable m_oGutterAtTop;
- nullable m_oHdrShapeDefaults;
+ nullable m_oHdrShapeDefaults;
nullable m_oHideGrammaticalErrors;
nullable m_oHideSpellingErrors;
- nullable m_oHyphenationZone;
+ nullable m_oHyphenationZone;
nullable m_oIgnoreMixedContent;
nullable m_oLinkStyles;
- nullable m_oListSeparator;
+ nullable m_oListSeparator;
// TO DO: Settings::mailMerge
- nullable m_oMathPr;
+ nullable m_oMathPr;
nullable m_oMirrorMargins;
- nullable m_oNoLineBreaksAfter;
- nullable m_oNoLineBreaksBefore;
+ nullable m_oNoLineBreaksAfter;
+ nullable m_oNoLineBreaksBefore;
nullable m_oNoPunctuationKerning;
nullable m_oPrintFormsData;
nullable m_oPrintFractionalCharacterWidth;
nullable m_oPrintPostScriptOverText;
nullable m_oPrintTwoOnOne;
- nullable m_oProofState;
- nullable m_oReadModeInkLockDown;
+ nullable m_oProofState;
+ nullable m_oReadModeInkLockDown;
nullable m_oRemoveDateAndTime;
nullable m_oRemovePersonalInformation;
- nullable m_oRevisionView;
- nullable m_oRsids;
+ nullable m_oRevisionView;
+ nullable m_oRsids;
nullable m_oSaveFormsData;
nullable m_oSaveInvalidXml;
nullable m_oSavePreviewPicture;
nullable m_oSaveSubsetFonts;
- nullable m_oSaveThroughtXslt;
+ nullable m_oSaveThroughtXslt;
nullable m_oSaveXmlDataOnly;
- nullable m_oSchemaLibrary;
- nullable m_oShapeDefaults;
+ nullable m_oSchemaLibrary;
+ nullable m_oShapeDefaults;
nullable m_oShowEnvelope;
nullable m_oShowXMLTags;
- std::vector m_arrSmartTagType;
+ std::vector m_arrSmartTagType;
nullable m_oStrictFirstAndLastChars;
nullable m_oStyleLockQFSet;
nullable m_oStyleLockTheme;
- nullable m_oStylePaneFormatFilter;
- nullable m_oStylePaneSortMethod;
- nullable m_oSummaryLength;
- nullable m_oThemeFontLang;
+ nullable m_oStylePaneFormatFilter;
+ nullable m_oStylePaneSortMethod;
+ nullable m_oSummaryLength;
+ nullable m_oThemeFontLang;
nullable m_oTrackRevisions;
nullable m_oUpdateFields;
nullable m_oUseXSLTWhenSaving;
- nullable m_oView;
- nullable m_oWriteProtection;
- nullable m_oZoom;
+ nullable m_oView;
+ nullable m_oWriteProtection;
+ nullable m_oZoom;
};
//--------------------------------------------------------------------------------
diff --git a/OOXML/PPTXFormat/Logic/Timing/TimeNodeBase.cpp b/OOXML/PPTXFormat/Logic/Timing/TimeNodeBase.cpp
index 3b4c7299a8..70d0dc2aae 100644
--- a/OOXML/PPTXFormat/Logic/Timing/TimeNodeBase.cpp
+++ b/OOXML/PPTXFormat/Logic/Timing/TimeNodeBase.cpp
@@ -94,7 +94,8 @@ namespace PPTX
m_node.reset(CreatePtrXmlContent(node));
else if(name == L"set")
m_node.reset(CreatePtrXmlContent(node));
- else m_node.reset();
+ else
+ m_node.reset();
}
void TimeNodeBase::GetTimeNodeFrom(XmlUtils::CXmlNode& element)
{
@@ -171,6 +172,8 @@ namespace PPTX
}
void TimeNodeBase::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
+ if (false == m_node.IsInit()) return;
+
switch (m_node->getType())
{
case OOX::et_p_par: pWriter->StartRecord(1); break;
diff --git a/OdfFile/Common/odf_elements_type.h b/OdfFile/Common/odf_elements_type.h
index 0f3931902d..fbbabc3a5a 100644
--- a/OdfFile/Common/odf_elements_type.h
+++ b/OdfFile/Common/odf_elements_type.h
@@ -285,6 +285,9 @@ enum ElementType
typeStyleMap,
typeStylePageMaster, // openoffice xml 1.0
+ typeStyleGradientStop,
+ typeStyleOpacityStop,
+
typeTableTemplate,
typeTableTemplateElement,
typeTableBodyTemplate,
diff --git a/OdfFile/DataTypes/color.cpp b/OdfFile/DataTypes/color.cpp
index c5df6a5bfa..910a5723bd 100644
--- a/OdfFile/DataTypes/color.cpp
+++ b/OdfFile/DataTypes/color.cpp
@@ -97,7 +97,7 @@ const std::wstring color::get_hex_value(bool alfa) const
unsigned int t = 0;
if ((s << tmp) && (s >> std::hex >> t) && (s >> std::ws).eof())
{
- result = XmlUtils::GetUpper(tmp);
+ result = tmp;
}
}
catch(...)
@@ -108,5 +108,36 @@ const std::wstring color::get_hex_value(bool alfa) const
if (alfa) return L"FF" + result;
else return result;
}
+//-----------------------------------------------------------------------------------------------------------------
+std::wostream& operator << (std::wostream& _Wostream, const color_type& _Val)
+{
+ switch (_Val.get_type())
+ {
+ case color_type::rgb:
+ _Wostream << L"rgb";
+ break;
+ case color_type::theme:
+ _Wostream << L"theme";
+ break;
+ default:
+ break;
+ }
+ return _Wostream;
+}
+
+color_type color_type::parse(const std::wstring& Str)
+{
+ std::wstring tmp = Str;
+ boost::algorithm::to_lower(tmp);
+
+ if (tmp == L"rgb")
+ return color_type(rgb);
+ else if (tmp == L"theme")
+ return color_type(theme);
+ else
+ {
+ return color_type(rgb);
+ }
+}
} }
diff --git a/OdfFile/DataTypes/color.h b/OdfFile/DataTypes/color.h
index 376dd21e49..9bf152095e 100644
--- a/OdfFile/DataTypes/color.h
+++ b/OdfFile/DataTypes/color.h
@@ -35,33 +35,58 @@
#include
#include "odfattributes.h"
+namespace cpdoccore {
+ namespace odf_types {
-namespace cpdoccore { namespace odf_types {
+ class color
+ {
+ public:
+ color() {};
-class color
-{
-public:
- color() {};
-
- color(const std::wstring & _Color) : color_(_Color) {};
-
- const std::wstring & get_color() const
- {
- return color_;
- };
+ color(const std::wstring& _Color) : color_(_Color) {};
- const std::wstring get_hex_value(bool alfa = false) const;
+ const std::wstring& get_color() const
+ {
+ return color_;
+ };
- static color parse(const std::wstring & Str);
+ const std::wstring get_hex_value(bool alfa = false) const;
-private:
- std::wstring color_;
-};
+ static color parse(const std::wstring& Str);
-std::wostream & operator << (std::wostream & _Wostream, const color & _Color);
-bool operator== (const color & c1, const color & c2);
-}
+ private:
+ std::wstring color_;
+ };
+ std::wostream& operator << (std::wostream& _Wostream, const color& _Color);
+ bool operator== (const color& c1, const color& c2);
+ //----------------------------------------------------------------------------------------------------------
+ class color_type
+ {
+ public:
+ enum type
+ {
+ rgb,
+ theme
+ };
+ color_type() {}
+
+ color_type(type _Type) : type_(_Type)
+ {}
+
+ type get_type() const
+ {
+ return type_;
+ };
+
+ static color_type parse(const std::wstring& Str);
+ private:
+ type type_;
+ };
+ std::wostream& operator << (std::wostream& _Wostream, const color_type& _Val);
+ }
+
+APPLY_PARSE_XML_ATTRIBUTES(odf_types::color_type);
APPLY_PARSE_XML_ATTRIBUTES(odf_types::color);
}
diff --git a/OdfFile/DataTypes/tabledatatype.cpp b/OdfFile/DataTypes/tabledatatype.cpp
new file mode 100644
index 0000000000..bdb8f2579e
--- /dev/null
+++ b/OdfFile/DataTypes/tabledatatype.cpp
@@ -0,0 +1,86 @@
+/*
+ * (c) Copyright Ascensio System SIA 2010-2023
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+
+#include "tabledatatype.h"
+
+#include
+#include
+
+namespace cpdoccore { namespace odf_types {
+
+std::wostream & operator << (std::wostream & _Wostream, const table_data_type& _Val)
+{
+ switch(_Val.get_type())
+ {
+ case table_data_type::automatic:
+ _Wostream << L"automatic";
+ break;
+ case table_data_type::text:
+ _Wostream << L"text";
+ break;
+ case table_data_type::number:
+ _Wostream << L"number";
+ break;
+ case table_data_type::background_color:
+ _Wostream << L"background_color";
+ break;
+ case table_data_type::text_color:
+ _Wostream << L"text_color";
+ break;
+ case table_data_type::user_defined:
+ _Wostream << _Val.get_user_defined();
+ break;
+ default:
+ _Wostream << L"text";
+ break;
+ }
+ return _Wostream;
+}
+table_data_type table_data_type::parse(const std::wstring & Str)
+{
+ if (Str == L"automatic")
+ return table_data_type(automatic);
+ else if (Str == L"text")
+ return table_data_type(text);
+ else if (Str == L"number")
+ return table_data_type(number);
+ else if (Str == L"background-color")
+ return table_data_type(background_color);
+ else if (Str == L"text-color")
+ return table_data_type(text_color);
+ else
+ {
+ return table_data_type(user_defined, Str);
+ }
+}
+
+} }
diff --git a/OdfFile/DataTypes/tabledatatype.h b/OdfFile/DataTypes/tabledatatype.h
new file mode 100644
index 0000000000..05ec23d17b
--- /dev/null
+++ b/OdfFile/DataTypes/tabledatatype.h
@@ -0,0 +1,76 @@
+/*
+ * (c) Copyright Ascensio System SIA 2010-2023
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+#pragma once
+
+#include
+#include
+#include "odfattributes.h"
+
+
+namespace cpdoccore { namespace odf_types {
+
+class table_data_type
+{
+public:
+ enum type
+ {
+ automatic,
+ text,
+ number,
+ background_color,
+ text_color,
+ user_defined
+ };
+
+ table_data_type() {}
+
+ table_data_type(type _Type, const std::wstring &user = L"") : type_(_Type), user_defined_(user)
+ {}
+
+ type get_type() const
+ {
+ return type_;
+ };
+ std::wstring get_user_defined() const
+ {
+ return user_defined_;
+ };
+ static table_data_type parse(const std::wstring & Str);
+private:
+ type type_;
+ std::wstring user_defined_;
+
+};
+std::wostream & operator << (std::wostream & _Wostream, const table_data_type& _Val);
+}
+APPLY_PARSE_XML_ATTRIBUTES(odf_types::table_data_type);
+}
diff --git a/OdfFile/DataTypes/tableoperator.cpp b/OdfFile/DataTypes/tableoperator.cpp
new file mode 100644
index 0000000000..e6f6ecd74e
--- /dev/null
+++ b/OdfFile/DataTypes/tableoperator.cpp
@@ -0,0 +1,114 @@
+/*
+ * (c) Copyright Ascensio System SIA 2010-2023
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+
+#include "tableoperator.h"
+
+#include
+#include
+
+namespace cpdoccore { namespace odf_types {
+
+std::wostream & operator << (std::wostream & _Wostream, const table_operator& _Val)
+{
+ switch(_Val.get_type())
+ {
+ case table_operator::Equal: _Wostream << L"="; break;
+ case table_operator::NotEqual: _Wostream << L"!="; break;
+ case table_operator::LessThan: _Wostream << L"<"; break;
+ case table_operator::GreaterThan: _Wostream << L">"; break;
+ case table_operator::LessThanOrEqual: _Wostream << L"<="; break;
+ case table_operator::GreaterThanOrEqual: _Wostream << L">="; break;
+ case table_operator::BeginsWith: _Wostream << L"begins"; break;
+ case table_operator::EndsWith: _Wostream << L"ends"; break;
+ case table_operator::Contains: _Wostream << L"contains"; break;
+ case table_operator::NotContains: _Wostream << L"!contains"; break;
+ case table_operator::NotBeginsWith: _Wostream << L"!begins"; break;
+ case table_operator::NotEndsWith: _Wostream << L"!ends"; break;
+ case table_operator::BottomPercent: _Wostream << L"bottom percent"; break;
+ case table_operator::BottomValues: _Wostream << L"bottom values"; break;
+ case table_operator::Empty: _Wostream << L"empty"; break;
+ case table_operator::NonEmpty: _Wostream << L"!empty"; break;
+ case table_operator::TopPercent: _Wostream << L"top percent"; break;
+ case table_operator::TopValues: _Wostream << L"top values"; break;
+ case table_operator::UserDefined: _Wostream << _Val.get_user_defined(); break;
+ default:
+ _Wostream << L"text";
+ break;
+ }
+ return _Wostream;
+}
+
+table_operator table_operator::parse(const std::wstring & Str)
+{
+ if (Str == L"=")
+ return table_operator(Equal);
+ else if (Str == L"!=")
+ return table_operator(NotEqual);
+ else if (Str == L"<")
+ return table_operator(LessThan);
+ else if (Str == L">")
+ return table_operator(GreaterThan);
+ else if (Str == L"<=")
+ return table_operator(LessThanOrEqual);
+ else if (Str == L">=")
+ return table_operator(GreaterThanOrEqual);
+ else if (Str == L"begins")
+ return table_operator(BeginsWith);
+ else if (Str == L"ends")
+ return table_operator(EndsWith);
+ else if (Str == L"!begins")
+ return table_operator(NotBeginsWith);
+ else if (Str == L"!ends")
+ return table_operator(NotEndsWith);
+ else if (Str == L"contains")
+ return table_operator(Contains);
+ else if (Str == L"!contains")
+ return table_operator(NotContains);
+ else if (Str == L"bottom percent")
+ return table_operator(BottomPercent);
+ else if (Str == L"bottom values")
+ return table_operator(BottomValues);
+ else if (Str == L"top percent")
+ return table_operator(TopPercent);
+ else if (Str == L"top values")
+ return table_operator(TopValues);
+ else if (Str == L"empty")
+ return table_operator(Empty);
+ else if (Str == L"!empty")
+ return table_operator(NonEmpty);
+ else
+ {
+ return table_operator(UserDefined, Str);
+ }
+}
+
+} }
diff --git a/OdfFile/DataTypes/tableoperator.h b/OdfFile/DataTypes/tableoperator.h
new file mode 100644
index 0000000000..36a1386c87
--- /dev/null
+++ b/OdfFile/DataTypes/tableoperator.h
@@ -0,0 +1,89 @@
+/*
+ * (c) Copyright Ascensio System SIA 2010-2023
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+#pragma once
+
+#include
+#include
+#include "odfattributes.h"
+
+
+namespace cpdoccore { namespace odf_types {
+
+class table_operator
+{
+public:
+ enum type
+ {
+ Equal,
+ NotEqual,
+ LessThan,
+ GreaterThan,
+ LessThanOrEqual,
+ GreaterThanOrEqual,
+ BeginsWith,
+ Contains,
+ NotContains,
+ EndsWith,
+ NotBeginsWith,
+ NotEndsWith,
+ BottomPercent,
+ BottomValues,
+ Empty,
+ NonEmpty,
+ TopPercent,
+ TopValues,
+ UserDefined
+ };
+
+ table_operator() {}
+
+ table_operator(type _Type, const std::wstring &user = L"") : type_(_Type), user_defined_(user)
+ {}
+
+ type get_type() const
+ {
+ return type_;
+ };
+ std::wstring get_user_defined() const
+ {
+ return user_defined_;
+ };
+ static table_operator parse(const std::wstring & Str);
+private:
+ type type_;
+ std::wstring user_defined_;
+
+};
+std::wostream & operator << (std::wostream & _Wostream, const table_operator& _Val);
+}
+APPLY_PARSE_XML_ATTRIBUTES(odf_types::table_operator);
+}
diff --git a/OdfFile/Formulas/formulasconvert.h b/OdfFile/Formulas/formulasconvert.h
index 86afb4f97e..6304298acc 100644
--- a/OdfFile/Formulas/formulasconvert.h
+++ b/OdfFile/Formulas/formulasconvert.h
@@ -99,9 +99,10 @@ public:
bool is_simple_ref(std::wstring const & expr);
std::wstring get_table_name();
+ void set_table_name(std::wstring const& val);
//Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19
- std::wstring convert_chart_distance(std::wstring const & expr);
+ std::wstring convert_ref_distances(std::wstring const & expr, std::wstring const& separator_in, std::wstring const& separator_out);
std::wstring convert_ref(std::wstring const & expr);
diff --git a/OdfFile/Formulas/formulasconvert_oox.cpp b/OdfFile/Formulas/formulasconvert_oox.cpp
index 7962dccd6c..ab1bae259e 100644
--- a/OdfFile/Formulas/formulasconvert_oox.cpp
+++ b/OdfFile/Formulas/formulasconvert_oox.cpp
@@ -64,7 +64,7 @@ public:
std::wstring convert_formula(const std::wstring& expr);
std::wstring convert_conditional_formula(const std::wstring& expr);
- std::wstring convert_chart_distance(const std::wstring& expr);
+ std::wstring convert_ref_distances(std::wstring const& expr, std::wstring const& separator_in, std::wstring const& separator_out);
static void replace_cells_range(std::wstring& expr, bool bSelect = true);
static void replace_semicolons(std::wstring& expr);
@@ -844,21 +844,21 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
//в
//Sheet2.C3:Sheet2.C19 Sheet2.L29:Sheet2.L36
//todooo
-std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring& expr1)
+std::wstring oox2odf_converter::Impl::convert_ref_distances(std::wstring const& expr1, std::wstring const& separator_in, std::wstring const& separator_out)
{
std::wstring expr = expr1;
- int res = expr.find(L"(");
- if (res ==0) expr = expr.substr(res + 1, expr.size()-1);
+ size_t res = expr.find(L"(");
+ if (res == 0) expr = expr.substr(res + 1, expr.size()-1);
res= expr.rfind(L")");
if (res ==expr.size()-2) expr = expr.substr(0, res);
- //распарсить по диапазонам - одф-пробел, ик-эль-запятая
+ //распарсить по диапазонам - пробел -> separator
std::vector distance_inp;
std::vector distance_out;
- boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
+ boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(separator_in), boost::algorithm::token_compress_on);
for (size_t i = 0; i < distance_inp.size(); i++)
{
@@ -902,7 +902,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
for (size_t i = 0 ; i < distance_out.size(); i++)
{
result += distance_out[i];
- result += L" ";
+ result += separator_out;
}
return result.substr(0, result.size()-1);
}
@@ -926,9 +926,9 @@ std::wstring oox2odf_converter::convert_formula(const std::wstring& expr)
{
return impl_->convert_formula(expr);
}
-std::wstring oox2odf_converter::convert_chart_distance(const std::wstring& expr)
+std::wstring oox2odf_converter::convert_ref_distances(std::wstring const& expr, std::wstring const& separator_in, std::wstring const& separator_out)
{
- return impl_->convert_chart_distance(expr);
+ return impl_->convert_ref_distances(expr, separator_in, separator_out);
}
std::wstring oox2odf_converter::convert_named_ref(const std::wstring& expr)
{
@@ -946,7 +946,10 @@ bool oox2odf_converter::is_simple_ref(std::wstring const & expr)
{
return impl_->is_simple_ref(expr);
}
-
+void oox2odf_converter::set_table_name(std::wstring const& val)
+{
+ impl_->table_name_ = val;
+}
std::wstring oox2odf_converter::get_table_name()
{
return impl_->table_name_;
diff --git a/OdfFile/Projects/Linux/OdfFormatLib.pro b/OdfFile/Projects/Linux/OdfFormatLib.pro
index 357aaa0dcf..6cd60c4550 100644
--- a/OdfFile/Projects/Linux/OdfFormatLib.pro
+++ b/OdfFile/Projects/Linux/OdfFormatLib.pro
@@ -137,6 +137,8 @@ SOURCES += \
../../DataTypes/grandtotal.cpp \
../../DataTypes/membertype.cpp \
../../DataTypes/tabletype.cpp \
+ ../../DataTypes/tabledatatype.cpp \
+ ../../DataTypes/tableoperator.cpp \
../../DataTypes/tableorientation.cpp \
../../DataTypes/tablefunction.cpp \
../../DataTypes/tableorder.cpp \
@@ -533,7 +535,9 @@ HEADERS += \
../../DataTypes/timeperiod.h \
../../DataTypes/messagetype.h \
../../DataTypes/stylecellprotect.h \
- \
+ ../../DataTypes/tabledatatype.h \
+ ../../DataTypes/tableoperator.h \
+ \
../../Formulas/formulasconvert.h \
../../Reader/Format/odf_document.h \
../../Reader/Format/abstract_xml.h \
diff --git a/OdfFile/Projects/Linux/odf_datatypes.cpp b/OdfFile/Projects/Linux/odf_datatypes.cpp
index a554438f8c..34c8b84ef5 100644
--- a/OdfFile/Projects/Linux/odf_datatypes.cpp
+++ b/OdfFile/Projects/Linux/odf_datatypes.cpp
@@ -140,3 +140,5 @@
#include "../../DataTypes/stylecellprotect.cpp"
#include "../../DataTypes/mathvariant.cpp"
#include "../../DataTypes/sparklines.cpp"
+#include "../../DataTypes/tabledatatype.cpp"
+#include "../../DataTypes/tableoperator.cpp"
diff --git a/OdfFile/Projects/Windows/cpcommon.vcxproj b/OdfFile/Projects/Windows/cpcommon.vcxproj
index 339364273f..8761c2330e 100644
--- a/OdfFile/Projects/Windows/cpcommon.vcxproj
+++ b/OdfFile/Projects/Windows/cpcommon.vcxproj
@@ -270,8 +270,10 @@
+
+
@@ -387,8 +389,10 @@
+
+
diff --git a/OdfFile/Projects/Windows/cpcommon.vcxproj.filters b/OdfFile/Projects/Windows/cpcommon.vcxproj.filters
index 66bcc111a5..dc5da92819 100644
--- a/OdfFile/Projects/Windows/cpcommon.vcxproj.filters
+++ b/OdfFile/Projects/Windows/cpcommon.vcxproj.filters
@@ -359,6 +359,12 @@
datatypes odf
+
+ datatypes odf
+
+
+ datatypes odf
+
@@ -696,5 +702,11 @@
datatypes odf
+
+ datatypes odf
+
+
+ datatypes odf
+
\ No newline at end of file
diff --git a/OdfFile/Reader/Converter/pptx_slide_context.cpp b/OdfFile/Reader/Converter/pptx_slide_context.cpp
index 97b9aa4bb2..705f4455fc 100644
--- a/OdfFile/Reader/Converter/pptx_slide_context.cpp
+++ b/OdfFile/Reader/Converter/pptx_slide_context.cpp
@@ -767,15 +767,22 @@ void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
{
if (!always && ( (!impl_->background_fill_) || (impl_->background_fill_->type == 0))) return;
+ std::wstring background_fill;
+ if (impl_->background_fill_)
+ {
+ std::wstringstream tmp_strm;
+ oox_serialize_fill(tmp_strm, impl_->background_fill_.get());
+ background_fill = tmp_strm.str();
+ }
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:bg")
{
CP_XML_NODE(L"p:bgPr")
{
- if (impl_->background_fill_)
+ if (false == background_fill.empty())
{
- oox_serialize_fill(CP_XML_STREAM(), impl_->background_fill_.get());
+ CP_XML_STREAM() << background_fill;
}
else
{
diff --git a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp
index c70317852d..8a1dada7ba 100644
--- a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp
+++ b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp
@@ -99,7 +99,11 @@ namespace oox {
//data bar
_CP_OPT(int) minLength;
_CP_OPT(int) maxLength;
+ _CP_OPT(std::wstring) axis_position;
+ _CP_OPT(std::wstring) axis_color;
+ _CP_OPT(std::wstring) negative_color;
//icon set
+ _CP_OPT(int) icon_set_type;
_CP_OPT(bool) reverse;
_CP_OPT(bool) iconset_percent;
_CP_OPT(int) iconset_type;
@@ -214,6 +218,31 @@ public:
CP_XML_ATTR(L"type", L"iconSet");
CP_XML_NODE(L"iconSet")
{
+ if (c.rules[j].icon_set_type)
+ {
+ switch (*c.rules[j].icon_set_type)
+ {
+ case 1: CP_XML_ATTR(L"iconSet", L"3ArrowsGray"); break;
+ case 2: CP_XML_ATTR(L"iconSet", L"3Flags"); break;
+ case 3: CP_XML_ATTR(L"iconSet", L"3Signs"); break;
+ case 4: CP_XML_ATTR(L"iconSet", L"3Symbols"); break;
+ case 5: CP_XML_ATTR(L"iconSet", L"3Symbols2"); break;
+ case 6: CP_XML_ATTR(L"iconSet", L"3TrafficLights1"); break;
+ case 7: CP_XML_ATTR(L"iconSet", L"3TrafficLights2"); break;
+ case 8: CP_XML_ATTR(L"iconSet", L"4Arrows"); break;
+ case 9: CP_XML_ATTR(L"iconSet", L"4ArrowsGray"); break;
+ case 10: CP_XML_ATTR(L"iconSet", L"4Rating"); break;
+ case 11: CP_XML_ATTR(L"iconSet", L"4RedToBlack"); break;
+ case 12: CP_XML_ATTR(L"iconSet", L"4TrafficLights"); break;
+ case 13: CP_XML_ATTR(L"iconSet", L"5Arrows"); break;
+ case 14: CP_XML_ATTR(L"iconSet", L"5ArrowsGray"); break;
+ case 15: CP_XML_ATTR(L"iconSet", L"5Quarters"); break;
+ case 16: CP_XML_ATTR(L"iconSet", L"5Rating"); break;
+ case 0:
+ default: CP_XML_ATTR(L"iconSet", L"3Arrows"); break;
+ break;
+ }
+ }
if (c.rules[j].showValue) CP_XML_ATTR(L"showValue", *c.rules[j].showValue);
for (size_t k = 0; k < c.rules[j].cfvo.size(); k++)
@@ -521,6 +550,22 @@ void xlsx_conditionalFormatting_context::add_color(std::wstring col)
{
impl_->conditionalFormattings_.back().rules.back().color.push_back(col);
}
+void xlsx_conditionalFormatting_context::set_negative_color(std::wstring col)
+{
+ impl_->conditionalFormattings_.back().rules.back().negative_color = col;
+}
+void xlsx_conditionalFormatting_context::set_axis_position(std::wstring val)
+{
+ impl_->conditionalFormattings_.back().rules.back().axis_position = val;
+}
+void xlsx_conditionalFormatting_context::set_axis_color(std::wstring val)
+{
+ impl_->conditionalFormattings_.back().rules.back().axis_color = val;
+}
+void xlsx_conditionalFormatting_context::set_icon_set_type(int type)
+{
+ impl_->conditionalFormattings_.back().rules.back().icon_set_type = type;
+}
void xlsx_conditionalFormatting_context::set_showVal(bool val)
{
impl_->conditionalFormattings_.back().rules.back().showValue = val;
diff --git a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h
index 6b37397a25..9176225541 100644
--- a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h
+++ b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h
@@ -58,6 +58,12 @@ public:
void add_sfv (int type, std::wstring value);
void add_color (std::wstring col);
+
+ void set_negative_color(std::wstring col);
+
+ void set_axis_position(std::wstring val);
+ void set_axis_color(std::wstring val);
+ void set_icon_set_type(int type);
void serialize(std::wostream & _Wostream);
private:
diff --git a/OdfFile/Reader/Converter/xlsx_table_state.cpp b/OdfFile/Reader/Converter/xlsx_table_state.cpp
index 00426cbfee..1c3249a2d9 100644
--- a/OdfFile/Reader/Converter/xlsx_table_state.cpp
+++ b/OdfFile/Reader/Converter/xlsx_table_state.cpp
@@ -48,15 +48,17 @@
namespace cpdoccore {
namespace oox {
-void xlsx_data_range::serialize_autofilter (std::wostream & _Wostream)
+void xlsx_data_range::serialize_autofilter(std::wostream& _Wostream)
{
- if (!filter) return;
+ if (!filter_button && filter_conditions.empty()) return;
CP_XML_WRITER(_Wostream)
- {
+ {
CP_XML_NODE(L"autoFilter")
{
CP_XML_ATTR(L"ref", ref);
+
+ serialize_filterColumn(CP_XML_STREAM(), 0);
}
}
}
@@ -64,63 +66,119 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
{
if (bySort.empty()) return;
- if (byRow) return;
-
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"sortState")
{
CP_XML_ATTR(L"ref", ref);
+ CP_XML_ATTR(L"xmlns:xlrd2", "http://schemas.microsoft.com/office/spreadsheetml/2017/richdata2");
if (!byRow)
CP_XML_ATTR(L"columnSort", true);
- for (size_t i = 0 ; i < bySort.size(); i++)
+ std::wstring ref_base, ref2, ref1;
+ size_t col_base, row_base, col_2, row_2;
+
+ size_t pos = ref.find(L":");
+ if (pos != std::wstring::npos)
+ {
+ ref_base = ref.substr(0, pos);
+ ref2 = ref.substr(pos + 1);
+ }
+ bool bSplit = getCellAddressInv(ref_base, col_base, row_base) && getCellAddressInv(ref2, col_2, row_2);
+
+ for (size_t i = 0 ; bSplit && i < bySort.size(); i++)
{
bool in_range = true;
- std::wstring ref1, ref2;
- size_t col_1, row_1, col_2, row_2;
-
- size_t pos = ref.find(L":");
- if (pos != std::wstring::npos)
+ if (byRow)
{
- ref1 = ref.substr(0, pos );
- ref2 = ref.substr(pos + 1);
+ if (col_base + bySort[i].first > col_2) in_range = false;
+
+ ref1 = getCellAddress(col_base + bySort[i].first + (withHeader ? 1 : 0), row_base);
+ ref2 = getCellAddress(col_base + bySort[i].first + (withHeader ? 1 : 0), row_2);
}
-
- if (getCellAddressInv(ref1, col_1, row_1) &&
- getCellAddressInv(ref2, col_2, row_2))
+ else
{
- if (byRow)
+ if ( bySort[i].first > row_2) in_range = false;
+
+ ref1 = getCellAddress(col_base, row_base + bySort[i].first + (withHeader ? 1 : 0));
+ ref2 = getCellAddress(col_2, row_base + bySort[i].first + (withHeader ? 1 : 0));
+ }
+ if (in_range)
+ {
+ CP_XML_NODE(L"sortCondition")
{
- if (bySort[i].first < col_1 || bySort[i].first > col_2) in_range = false;
+ CP_XML_ATTR(L"ref", ref1 + L":" + ref2);
- ref1 = getCellAddress(bySort[i].first + (withHeader ? 1 : 0), row_1);
- ref2 = getCellAddress(bySort[i].first + (withHeader ? 1 : 0), row_2);
+ if (bySort[i].second)
+ CP_XML_ATTR(L"descending", 1);
}
- else
- {
- if (bySort[i].first < row_1 || bySort[i].first > row_2) in_range = false;
- ref1 = getCellAddress(col_1, bySort[i].first + (withHeader ? 1 : 0));
- ref2 = getCellAddress(col_2, bySort[i].first + (withHeader ? 1 : 0));
- }
- if (in_range)
- {
- CP_XML_NODE(L"sortCondition")
- {
- CP_XML_ATTR(L"ref", ref1 + L":" + ref2);
-
- if (bySort[i].second)
- CP_XML_ATTR(L"descending", 1);
- }
-
- }
}
}
}
}
}
+void xlsx_data_range::serialize_filterColumn(std::wostream& _Wostream, int indexCol)
+{
+ CP_XML_WRITER(_Wostream)
+ {
+ CP_XML_NODE(L"filterColumn")
+ {
+ CP_XML_ATTR(L"colId", indexCol);
+ if (bFilterAndOr && filter_conditions.size() > 1)
+ {
+ CP_XML_NODE(L"customFilters")
+ {
+ if (*bFilterAndOr)
+ CP_XML_ATTR(L"and", 1);
+ else
+ CP_XML_ATTR(L"and", 0);
+ for (size_t i = 0; i < filter_conditions.size(); ++i)
+ {
+ CP_XML_NODE(L"customFilter")
+ {
+ switch (filter_conditions[i].operator_)
+ {
+ case 15: // !empty
+ case 0: CP_XML_ATTR(L"operator", L"notEqual"); break;
+ case 14: // empty
+ case 1: CP_XML_ATTR(L"operator", L"equal"); break;
+ case 2: CP_XML_ATTR(L"operator", L"LessThan"); break;
+ case 3: CP_XML_ATTR(L"operator", L"greaterThan"); break;
+ case 13: // bottom values
+ case 4: CP_XML_ATTR(L"operator", L"lessThanOrEqual"); break;
+ case 17: // top values
+ case 5: CP_XML_ATTR(L"operator", L"greaterThanOrEqual"); break;
+ }
+ CP_XML_ATTR(L"val", filter_conditions[i].value);
+ }
+ }
+ }
+ }
+ else if (1 == filter_conditions.size())
+ {
+ if (filter_conditions[0].type == 3/*odf_types::table_data_type::background_color*/ ||
+ filter_conditions[0].type == 4/*odf_types::table_data_type::text_color*/)
+ {
+ CP_XML_NODE(L"colorFilter")
+ {
+ if (filter_conditions[0].type == 3)
+ CP_XML_ATTR(L"cellColor", L"1");
+ CP_XML_ATTR(L"dxfId", filter_conditions[0].value);
+ }
+ }
+ else if (filter_conditions[0].operator_ == 17/*odf_types::table_operator::TopValues*/)
+ {
+ CP_XML_NODE(L"top10")
+ {
+ CP_XML_ATTR(L"val", filter_conditions[0].value);
+ }
+ }
+ }
+ }
+ }
+}
//-------------------------------------------------------------------------------------------------------------------------
xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName, int tableId)
diff --git a/OdfFile/Reader/Converter/xlsx_table_state.h b/OdfFile/Reader/Converter/xlsx_table_state.h
index 18ed314f1b..69f48a37b4 100644
--- a/OdfFile/Reader/Converter/xlsx_table_state.h
+++ b/OdfFile/Reader/Converter/xlsx_table_state.h
@@ -56,8 +56,15 @@ typedef _CP_PTR(xlsx_data_range) xlsx_data_range_ptr;
class xlsx_data_range
{
+ struct filter_condition
+ {
+ int field_number = 0;
+ int type = 0;
+ std::wstring value;
+ int operator_ = 0;
+ };
public:
- xlsx_data_range() : byRow(true), filter(false), bTablePart(true), withHeader(false), cell_start(0,0), cell_end(0,0) {}
+ xlsx_data_range() : byRow(true), filter_button(false), bTablePart(true), withHeader(false), cell_start(0,0), cell_end(0,0) {}
std::wstring table_name;
std::wstring name;
@@ -67,16 +74,20 @@ public:
std::pair cell_start;
std::pair cell_end;
- bool bTablePart;
- bool byRow;
- bool filter;
- bool withHeader;
+ bool bTablePart = true;
+ bool byRow = true;
+ bool filter_button = false;
+ bool withHeader = false;
std::vector> bySort; //field + order
- void serialize_sort (std::wostream & _Wostream);
- void serialize_autofilter (std::wostream & _Wostream);
+ _CP_OPT(bool) bFilterAndOr;
+ std::vector filter_conditions;
+ void serialize_sort (std::wostream & _Wostream);
+ void serialize_autofilter (std::wostream & _Wostream);
+ void serialize_filterColumn(std::wostream& _Wostream, int indexCol);
+
std::vector header_values;
void set_header(size_t row, size_t col1, size_t col2)
diff --git a/OdfFile/Reader/Converter/xlsx_tablecontext.cpp b/OdfFile/Reader/Converter/xlsx_tablecontext.cpp
index 0920ea7e94..3abda5bcd7 100644
--- a/OdfFile/Reader/Converter/xlsx_tablecontext.cpp
+++ b/OdfFile/Reader/Converter/xlsx_tablecontext.cpp
@@ -49,563 +49,588 @@
namespace cpdoccore {
namespace oox {
-//-----------------------------------------------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------------------------------------------
-xlsx_table_state_ptr xlsx_table_context::state()
-{
- if (!xlsx_table_states_.empty())
- return xlsx_table_states_.back();
- else
- return xlsx_table_state_ptr();
-}
-
-bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref, bool bNamedRangeOnly)
-{
- formulasconvert::odf2oox_converter convert;
- std::wstring oox_ref = convert.convert_named_ref(ref);
-
- std::wstring ref1, ref2;
- size_t pos = oox_ref.find(L":");
-
- std::wstring xlsx_table_name;
-
- if (pos != std::wstring::npos)
+ xlsx_table_state_ptr xlsx_table_context::state()
{
- ref1 = oox_ref.substr(0, pos );
- ref2 = oox_ref.substr(pos + 1);
-
- pos = ref1.find(L"!");
- if (pos > 0)
- {
- xlsx_table_name = ref1.substr(0, pos);
- ref1 = ref1.substr(pos + 1);
- }
-
- pos = ref2.find(L"!");
- if (pos > 0) ref2 = ref2.substr(pos + 1);
-
- size_t col1, col2, row1, row2;
-
- XmlUtils::replace_all( xlsx_table_name, L"'", L"");
-
- bool res1 = getCellAddressInv(ref1, col1, row1);
- bool res2 = getCellAddressInv(ref2, col2, row2);
-
- if (!res1)
- return false;
-
- if (!res2)
- {
- ref2 = ref1; col2 = col1; row2 = row1;
- }
-
- xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
-
- if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2 || bNamedRangeOnly)
- {//check range in pivots
- xlsx_data_ranges_.back()->bTablePart = false;
- }
- xlsx_data_ranges_.back()->name = name;
- xlsx_data_ranges_.back()->table_name = xlsx_table_name;
- xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
- xlsx_data_ranges_.back()->cell_start = std::pair(col1, row1);
- xlsx_data_ranges_.back()->cell_end = std::pair(col2, row2);
-
- xlsx_data_ranges_.back()->set_header(row1, col1, col2);
+ if (!xlsx_table_states_.empty())
+ return xlsx_table_states_.back();
+ else
+ return xlsx_table_state_ptr();
}
-//-----------------------------------------------------------------------
- if (!xlsx_table_name.empty())
+
+ bool xlsx_table_context::start_database_range(const std::wstring& name, const std::wstring& ref, bool bNamedRangeOnly)
{
- if (xlsx_data_ranges_.back()->bTablePart)
+ formulasconvert::odf2oox_converter convert;
+ std::wstring oox_ref = convert.convert_named_ref(ref);
+
+ std::wstring ref1, ref2;
+ size_t pos = oox_ref.find(L":");
+
+ std::wstring xlsx_table_name;
+
+ if (pos != std::wstring::npos)
{
- std::pair::iterator, std::multimap::iterator> range = xlsx_data_ranges_map_.equal_range(xlsx_table_name);
+ ref1 = oox_ref.substr(0, pos);
+ ref2 = oox_ref.substr(pos + 1);
- for (std::multimap::iterator it = range.first; it != range.second; ++it)
+ pos = ref1.find(L"!");
+ if (pos > 0)
{
- if (xlsx_data_ranges_[it->second]->bTablePart)
- {
- if (std::wstring::npos != xlsx_data_ranges_[it->second]->name.find(L"__Anonymous_Sheet_DB__"))
- xlsx_data_ranges_[it->second]->bTablePart = false;
- else
- xlsx_data_ranges_.back()->bTablePart = false;
- break;
- }
-
+ xlsx_table_name = ref1.substr(0, pos);
+ ref1 = ref1.substr(pos + 1);
}
+
+ pos = ref2.find(L"!");
+ if (pos > 0) ref2 = ref2.substr(pos + 1);
+
+ size_t col1, col2, row1, row2;
+
+ XmlUtils::replace_all(xlsx_table_name, L"'", L"");
+
+ bool res1 = getCellAddressInv(ref1, col1, row1);
+ bool res2 = getCellAddressInv(ref2, col2, row2);
+
+ if (!res1)
+ return false;
+
+ if (!res2)
+ {
+ ref2 = ref1; col2 = col1; row2 = row1;
+ }
+
+ xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
+
+ if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2 || bNamedRangeOnly)
+ {//check range in pivots
+ xlsx_data_ranges_.back()->bTablePart = false;
+ }
+ xlsx_data_ranges_.back()->name = name;
+ xlsx_data_ranges_.back()->table_name = xlsx_table_name;
+ xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
+ xlsx_data_ranges_.back()->cell_start = std::pair(col1, row1);
+ xlsx_data_ranges_.back()->cell_end = std::pair(col2, row2);
+
+ xlsx_data_ranges_.back()->set_header(row1, col1, col2);
}
//-----------------------------------------------------------------------
- xlsx_data_ranges_map_.insert(std::pair (xlsx_table_name, xlsx_data_ranges_.size() - 1));
- }
- return true;
-}
-void xlsx_table_context::set_database_orientation (bool val)
-{
- if (xlsx_data_ranges_.empty()) return;
-
- xlsx_data_ranges_.back()->byRow = val;
-}
-void xlsx_table_context::set_database_header (bool val)
-{
- if (xlsx_data_ranges_.empty()) return;
-
- xlsx_data_ranges_.back()->withHeader = val;
-}
-void xlsx_table_context::set_database_filter (bool val)
-{
- if (xlsx_data_ranges_.empty()) return;
-
- xlsx_data_ranges_.back()->filter = val;
-}
-void xlsx_table_context::end_database_range()
-{
- if (!xlsx_data_ranges_.back()->bTablePart && !xlsx_data_ranges_.back()->filter && !xlsx_data_ranges_.back()->table_name.empty())
- {
- xlsx_conversion_context_->get_xlsx_defined_names().add(xlsx_data_ranges_.back()->name,
- xlsx_data_ranges_.back()->table_name + L"!" + xlsx_data_ranges_.back()->ref, false, -1);
- }
-}
-
-void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
-{
- if (index < 0 || index > (int)xlsx_data_ranges_.size()) return;
-
- size_t col = state()->current_column();
- size_t row = state()->current_row();
-
- xlsx_data_ranges_[index]->set_header_value(col, row, value);
-}
-void xlsx_table_context::check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref)
-{
- std::wstring ref1, ref2;
- size_t col_1, row_1, col_2, row_2;
-
- size_t pos = ref.find(L":");
- if (pos != std::wstring::npos)
- {
- ref1 = ref.substr(0, pos );
- ref2 = ref.substr(pos + 1);
- }
- if (false == getCellAddressInv(ref1, col_1, row_1) ||
- false == getCellAddressInv(ref2, col_2, row_2)) return;
-
- for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
- {
- if (xlsx_data_ranges_[i]->table_name != table_name) continue;
-
- //if ( xlsx_data_ranges_[i]->cell_start.second < row_2 || xlsx_data_ranges_[i]->cell_end.second > row_1
- // || xlsx_data_ranges_[i]->cell_end.first < col_1 || xlsx_data_ranges_[i]->cell_start.first > col_2 )
-
- if (((col_1 <= xlsx_data_ranges_[i]->cell_start.first && xlsx_data_ranges_[i]->cell_start.first <= col_2) ||
- (xlsx_data_ranges_[i]->cell_start.first <= col_1 && col_1 <= xlsx_data_ranges_[i]->cell_end.first))
- &&
- (( row_1 <= xlsx_data_ranges_[i]->cell_start.second && xlsx_data_ranges_[i]->cell_start.second <= row_2) ||
- (xlsx_data_ranges_[i]->cell_start.second <= row_1 && row_1 <= xlsx_data_ranges_[i]->cell_end.second )))
+ if (!xlsx_table_name.empty())
{
- xlsx_data_ranges_[i]->bTablePart = false;
- }
- }
-}
-int xlsx_table_context::in_database_range()
-{
- int col = state()->current_column();
- int row = state()->current_row();
-
- for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
- {
- if (xlsx_data_ranges_[i]->table_name != state()->get_table_name()) continue;
-
- if (/*(xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)&& */
- xlsx_data_ranges_[i]->in_header(col, row))
- {
- return (int)i;
- }
- }
- return -1;
-}
-void xlsx_table_context::add_database_sort(int field_number, int order)
-{
- xlsx_data_ranges_.back()->bySort.push_back(std::pair(field_number, order == 1 ? false : true ));
-}
-
-
-xlsx_table_context::
-xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textContext): xlsx_conversion_context_(Context),
-xlsx_text_context_(textContext)
-{
-}
-
-void xlsx_table_context::start_table(const std::wstring & tableName, const std::wstring & tableStyleName, int id)
-{
- xlsx_table_state_ptr state = boost::make_shared(xlsx_conversion_context_, tableStyleName, tableName, id);
- xlsx_table_states_.push_back( state);
-}
-void xlsx_table_context::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
-{
- xlsx_table_states_.back()->set_protection(val, key, algorithm);
-}
-void xlsx_table_context::end_table()
-{
- xlsx_conversion_context_->get_dataValidations_context().clear();
-}
-void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
-{
- state()->start_cell(columnsSpanned, rowsSpanned);
-}
-
-void xlsx_table_context::end_cell()
-{
- state()->end_cell();
-}
-
-void xlsx_table_context::set_current_cell_style_id(unsigned int xfId)
-{
- return state()->set_current_cell_style_id(xfId);
-}
-
-int xlsx_table_context::get_current_cell_style_id()
-{
- return state()->get_current_cell_style_id();
-}
-
-void xlsx_table_context::start_cell_content()
-{
- xlsx_text_context_.start_cell_content();
-}
-
-int xlsx_table_context::end_cell_content(bool need_cache)
-{
- return xlsx_text_context_.end_cell_content(need_cache);
-}
-
-void xlsx_table_context::start_covered_cell()
-{
- return state()->start_covered_cell();
-}
-
-void xlsx_table_context::end_covered_cell()
-{
- return state()->end_covered_cell();
-}
-
-void xlsx_table_context::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
-{
- return state()->start_column(repeated, defaultCellStyleName);
-}
-
-unsigned int xlsx_table_context::columns_count()
-{
- return state()->columns_count();
-}
-
-void xlsx_table_context::set_header_page(_CP_OPT(double) val)
-{
- state()->header_page = val;
-}
-_CP_OPT(double) xlsx_table_context::get_header_page()
-{
- return state()->header_page;
-}
-void xlsx_table_context::set_footer_page(_CP_OPT(double) val)
-{
- state()->footer_page = val;
-}
-_CP_OPT(double) xlsx_table_context::get_footer_page()
-{
- return state()->footer_page;
-}
-
-std::wstring xlsx_table_context::default_row_cell_style()
-{
- return state()->default_row_cell_style();
-}
-
-std::wstring xlsx_table_context::default_column_cell_style()
-{
- return state()->default_column_cell_style();
-}
-
-int xlsx_table_context::current_column()
-{
- return state()->current_column();
-}
-
-int xlsx_table_context::current_row()
-{
- return state()->current_row();
-}
-
-
-void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
-{
- if (xlsx_data_ranges_.empty()) return;
-
- std::pair::iterator, std::multimap::iterator> range;
-
- range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
-
- for (std::multimap::iterator it = range.first; it != range.second; ++it)
- {
- if (xlsx_data_ranges_[it->second]->bTablePart) continue;
-
- xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
- }
-}
-void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels & Rels)
-{
- if (xlsx_data_ranges_.empty()) return;
-
- std::pair::iterator, std::multimap::iterator> range;
-
- range = xlsx_data_ranges_map_.equal_range(state()->get_table_name());
-
- for (std::multimap::iterator it = range.first; it != range.second; ++it)
- {
- if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
-
-// из за дебелизма мсофис которому ОБЯЗАТЕЛЬНО нужно прописывать имена колонок таблицы (и они должны быть еще
-// прописаны и в самих данных таблицы !!
-
- while (xlsx_data_ranges_[it->second]->header_values.size() > xlsx_data_ranges_[it->second]->cell_end.first -
- xlsx_data_ranges_[it->second]->cell_start.first + 1)
- {
- xlsx_data_ranges_[it->second]->header_values.pop_back();
- }
- int i = xlsx_data_ranges_[it->second]->header_values.size() - 1;
- for (; i >= 0; i--)
- {
- if (false == xlsx_data_ranges_[it->second]->header_values[i].empty())
+ if (xlsx_data_ranges_.back()->bTablePart)
{
- break;
- }
- }
+ std::pair::iterator, std::multimap::iterator> range = xlsx_data_ranges_map_.equal_range(xlsx_table_name);
- if (i == -1)
- {
- xlsx_data_ranges_[it->second]->bTablePart = false;
- continue;
- }
- else
- {
- size_t erase = xlsx_data_ranges_[it->second]->header_values.size() - 1 - i;
- if (erase > 0)
- {
- xlsx_data_ranges_[it->second]->header_values.erase(xlsx_data_ranges_[it->second]->header_values.begin() + i + 1, xlsx_data_ranges_[it->second]->header_values.end());
- xlsx_data_ranges_[it->second]->cell_end.first -= erase;
-
- std::wstring ref1 = getCellAddress(xlsx_data_ranges_[it->second]->cell_start.first, xlsx_data_ranges_[it->second]->cell_start.second);
- std::wstring ref2 = getCellAddress(xlsx_data_ranges_[it->second]->cell_end.first, xlsx_data_ranges_[it->second]->cell_end.second);
-
- xlsx_data_ranges_[it->second]->ref = ref1 + L":" + ref2;
- }
- }
- //--------------------------------------------------------
-
- size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
-
- std::wstring rId = L"tprtId" + std::to_wstring(id);
- std::wstring ref = L"../tables/table" + std::to_wstring(id) + L".xml";
-
- CP_XML_WRITER(_Wostream)
- {
- CP_XML_NODE(L"tablePart")
- {
- CP_XML_ATTR(L"r:id", rId);
- }
- }
- Rels.add( relationship(rId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", ref));
-//--------------------------------------------------------
- std::wstringstream strm;
- CP_XML_WRITER(strm)
- {
- CP_XML_NODE(L"table")
- {
- CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
-
- CP_XML_ATTR(L"id", id);
- CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->name);
- CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->name);
- CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
-
- if (xlsx_data_ranges_[it->second]->withHeader == false &&
- xlsx_data_ranges_[it->second]->filter == false)
- CP_XML_ATTR(L"headerRowCount", 0);
-
- //CP_XML_ATTR(L"totalsRowCount", 0);
- CP_XML_ATTR(L"totalsRowShown", 0);
-
- xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
- xlsx_data_ranges_[it->second]->serialize_sort(CP_XML_STREAM());
-
- CP_XML_NODE(L"tableColumns")
+ for (std::multimap::iterator it = range.first; it != range.second; ++it)
{
- CP_XML_ATTR(L"count", xlsx_data_ranges_[it->second]->cell_end.first -
- xlsx_data_ranges_[it->second]->cell_start.first + 1);
-
- for (int id = 0, i = xlsx_data_ranges_[it->second]->cell_start.first; i <= xlsx_data_ranges_[it->second]->cell_end.first; i++, id++)
+ if (xlsx_data_ranges_[it->second]->bTablePart)
{
- CP_XML_NODE(L"tableColumn")
+ if (std::wstring::npos != xlsx_data_ranges_[it->second]->name.find(L"__Anonymous_Sheet_DB__"))
+ xlsx_data_ranges_[it->second]->bTablePart = false;
+ else
+ xlsx_data_ranges_.back()->bTablePart = false;
+ break;
+ }
+
+ }
+ }
+ //-----------------------------------------------------------------------
+ xlsx_data_ranges_map_.insert(std::pair(xlsx_table_name, xlsx_data_ranges_.size() - 1));
+ }
+ return true;
+ }
+ void xlsx_table_context::set_database_orientation(bool val)
+ {
+ if (xlsx_data_ranges_.empty()) return;
+
+ xlsx_data_ranges_.back()->byRow = val;
+ }
+ void xlsx_table_context::set_database_header(bool val)
+ {
+ if (xlsx_data_ranges_.empty()) return;
+
+ xlsx_data_ranges_.back()->withHeader = val;
+ }
+ void xlsx_table_context::set_database_filter_button(bool val)
+ {
+ if (xlsx_data_ranges_.empty()) return;
+
+ xlsx_data_ranges_.back()->filter_button = val;
+ }
+ void xlsx_table_context::end_database_range()
+ {
+ if (!xlsx_data_ranges_.back()->bTablePart && !xlsx_data_ranges_.back()->filter_button && !xlsx_data_ranges_.back()->table_name.empty())
+ {
+ xlsx_conversion_context_->get_xlsx_defined_names().add(xlsx_data_ranges_.back()->name,
+ xlsx_data_ranges_.back()->table_name + L"!" + xlsx_data_ranges_.back()->ref, false, -1);
+ }
+ }
+
+ void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
+ {
+ if (index < 0 || index >(int)xlsx_data_ranges_.size()) return;
+
+ size_t col = state()->current_column();
+ size_t row = state()->current_row();
+
+ xlsx_data_ranges_[index]->set_header_value(col, row, value);
+ }
+ void xlsx_table_context::check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref)
+ {
+ std::wstring ref1, ref2;
+ size_t col_1, row_1, col_2, row_2;
+
+ size_t pos = ref.find(L":");
+ if (pos != std::wstring::npos)
+ {
+ ref1 = ref.substr(0, pos);
+ ref2 = ref.substr(pos + 1);
+ }
+ if (false == getCellAddressInv(ref1, col_1, row_1) ||
+ false == getCellAddressInv(ref2, col_2, row_2)) return;
+
+ for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
+ {
+ if (xlsx_data_ranges_[i]->table_name != table_name) continue;
+
+ //if ( xlsx_data_ranges_[i]->cell_start.second < row_2 || xlsx_data_ranges_[i]->cell_end.second > row_1
+ // || xlsx_data_ranges_[i]->cell_end.first < col_1 || xlsx_data_ranges_[i]->cell_start.first > col_2 )
+
+ if (((col_1 <= xlsx_data_ranges_[i]->cell_start.first && xlsx_data_ranges_[i]->cell_start.first <= col_2) ||
+ (xlsx_data_ranges_[i]->cell_start.first <= col_1 && col_1 <= xlsx_data_ranges_[i]->cell_end.first))
+ &&
+ ((row_1 <= xlsx_data_ranges_[i]->cell_start.second && xlsx_data_ranges_[i]->cell_start.second <= row_2) ||
+ (xlsx_data_ranges_[i]->cell_start.second <= row_1 && row_1 <= xlsx_data_ranges_[i]->cell_end.second)))
+ {
+ xlsx_data_ranges_[i]->bTablePart = false;
+ }
+ }
+ }
+ int xlsx_table_context::in_database_range()
+ {
+ int col = state()->current_column();
+ int row = state()->current_row();
+
+ for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
+ {
+ if (xlsx_data_ranges_[i]->table_name != state()->get_table_name()) continue;
+
+ if (/*(xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)&& */
+ xlsx_data_ranges_[i]->in_header(col, row))
+ {
+ return (int)i;
+ }
+ }
+ return -1;
+ }
+ void xlsx_table_context::add_database_filter_conditional(int field_number, int type, const std::wstring& value, int operator_)
+ {
+ xlsx_data_ranges_.back()->filter_conditions.emplace_back();
+ xlsx_data_ranges_.back()->filter_conditions.back().field_number = field_number;
+ xlsx_data_ranges_.back()->filter_conditions.back().type = type;
+ xlsx_data_ranges_.back()->filter_conditions.back().value = value;
+ xlsx_data_ranges_.back()->filter_conditions.back().operator_ = operator_;
+ }
+ void xlsx_table_context::start_filters_or()
+ {
+ xlsx_data_ranges_.back()->bFilterAndOr = true;
+ }
+ void xlsx_table_context::start_filters_and()
+ {
+ xlsx_data_ranges_.back()->bFilterAndOr = false;
+ }
+ void xlsx_table_context::end_filters_or()
+ {
+
+ }
+ void xlsx_table_context::end_filters_and()
+ {
+
+ }
+ void xlsx_table_context::add_database_sort(int field_number, int order, int type)
+ {
+ xlsx_data_ranges_.back()->bySort.push_back(std::pair(field_number, order == 1 ? false : true));
+ }
+ xlsx_table_context::xlsx_table_context(xlsx_conversion_context* Context, xlsx_text_context& textContext) :
+ xlsx_conversion_context_(Context), xlsx_text_context_(textContext)
+ {
+ }
+ void xlsx_table_context::start_table(const std::wstring& tableName, const std::wstring& tableStyleName, int id)
+ {
+ xlsx_table_state_ptr state = boost::make_shared(xlsx_conversion_context_, tableStyleName, tableName, id);
+ xlsx_table_states_.push_back(state);
+ }
+ void xlsx_table_context::set_protection(bool val, const std::wstring& key, const std::wstring& algorithm)
+ {
+ xlsx_table_states_.back()->set_protection(val, key, algorithm);
+ }
+ void xlsx_table_context::end_table()
+ {
+ xlsx_conversion_context_->get_dataValidations_context().clear();
+ }
+ void xlsx_table_context::start_cell(const std::wstring& formula, size_t columnsSpanned, size_t rowsSpanned)
+ {
+ state()->start_cell(columnsSpanned, rowsSpanned);
+ }
+
+ void xlsx_table_context::end_cell()
+ {
+ state()->end_cell();
+ }
+
+ void xlsx_table_context::set_current_cell_style_id(unsigned int xfId)
+ {
+ return state()->set_current_cell_style_id(xfId);
+ }
+
+ int xlsx_table_context::get_current_cell_style_id()
+ {
+ return state()->get_current_cell_style_id();
+ }
+
+ void xlsx_table_context::start_cell_content()
+ {
+ xlsx_text_context_.start_cell_content();
+ }
+
+ int xlsx_table_context::end_cell_content(bool need_cache)
+ {
+ return xlsx_text_context_.end_cell_content(need_cache);
+ }
+
+ void xlsx_table_context::start_covered_cell()
+ {
+ return state()->start_covered_cell();
+ }
+
+ void xlsx_table_context::end_covered_cell()
+ {
+ return state()->end_covered_cell();
+ }
+
+ void xlsx_table_context::start_column(unsigned int repeated, const std::wstring& defaultCellStyleName)
+ {
+ return state()->start_column(repeated, defaultCellStyleName);
+ }
+
+ unsigned int xlsx_table_context::columns_count()
+ {
+ return state()->columns_count();
+ }
+
+ void xlsx_table_context::set_header_page(_CP_OPT(double) val)
+ {
+ state()->header_page = val;
+ }
+ _CP_OPT(double) xlsx_table_context::get_header_page()
+ {
+ return state()->header_page;
+ }
+ void xlsx_table_context::set_footer_page(_CP_OPT(double) val)
+ {
+ state()->footer_page = val;
+ }
+ _CP_OPT(double) xlsx_table_context::get_footer_page()
+ {
+ return state()->footer_page;
+ }
+
+ std::wstring xlsx_table_context::default_row_cell_style()
+ {
+ return state()->default_row_cell_style();
+ }
+
+ std::wstring xlsx_table_context::default_column_cell_style()
+ {
+ return state()->default_column_cell_style();
+ }
+
+ int xlsx_table_context::current_column()
+ {
+ return state()->current_column();
+ }
+
+ int xlsx_table_context::current_row()
+ {
+ return state()->current_row();
+ }
+ void xlsx_table_context::serialize_sort(std::wostream& _Wostream)
+ {
+ if (xlsx_data_ranges_.empty()) return;
+
+ std::pair::iterator, std::multimap::iterator> range;
+
+ range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
+
+ for (std::multimap::iterator it = range.first; it != range.second; ++it)
+ {
+ if (xlsx_data_ranges_[it->second]->bTablePart) continue;
+
+ xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
+ }
+ }
+ void xlsx_table_context::serialize_tableParts(std::wostream& _Wostream, rels& Rels)
+ {
+ if (xlsx_data_ranges_.empty()) return;
+
+ std::pair::iterator, std::multimap::iterator> range;
+
+ range = xlsx_data_ranges_map_.equal_range(state()->get_table_name());
+
+ for (std::multimap::iterator it = range.first; it != range.second; ++it)
+ {
+ if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
+
+ // из за дебелизма мсофис которому ОБЯЗАТЕЛЬНО нужно прописывать имена колонок таблицы (и они должны быть еще
+ // прописаны и в самих данных таблицы !!
+
+ while (xlsx_data_ranges_[it->second]->header_values.size() > xlsx_data_ranges_[it->second]->cell_end.first -
+ xlsx_data_ranges_[it->second]->cell_start.first + 1)
+ {
+ xlsx_data_ranges_[it->second]->header_values.pop_back();
+ }
+ int i = xlsx_data_ranges_[it->second]->header_values.size() - 1;
+ for (; i >= 0; i--)
+ {
+ if (false == xlsx_data_ranges_[it->second]->header_values[i].empty())
+ {
+ break;
+ }
+ }
+
+ if (i == -1)
+ {
+ xlsx_data_ranges_[it->second]->bTablePart = false;
+ continue;
+ }
+ else
+ {
+ size_t erase = xlsx_data_ranges_[it->second]->header_values.size() - 1 - i;
+ if (erase > 0)
+ {
+ xlsx_data_ranges_[it->second]->header_values.erase(xlsx_data_ranges_[it->second]->header_values.begin() + i + 1, xlsx_data_ranges_[it->second]->header_values.end());
+ xlsx_data_ranges_[it->second]->cell_end.first -= erase;
+
+ std::wstring ref1 = getCellAddress(xlsx_data_ranges_[it->second]->cell_start.first, xlsx_data_ranges_[it->second]->cell_start.second);
+ std::wstring ref2 = getCellAddress(xlsx_data_ranges_[it->second]->cell_end.first, xlsx_data_ranges_[it->second]->cell_end.second);
+
+ xlsx_data_ranges_[it->second]->ref = ref1 + L":" + ref2;
+ }
+ }
+ //--------------------------------------------------------
+
+ size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
+
+ std::wstring rId = L"tprtId" + std::to_wstring(id);
+ std::wstring ref = L"../tables/table" + std::to_wstring(id) + L".xml";
+
+ CP_XML_WRITER(_Wostream)
+ {
+ CP_XML_NODE(L"tablePart")
+ {
+ CP_XML_ATTR(L"r:id", rId);
+ }
+ }
+ Rels.add(relationship(rId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", ref));
+ //--------------------------------------------------------
+ std::wstringstream strm;
+ CP_XML_WRITER(strm)
+ {
+ CP_XML_NODE(L"table")
+ {
+ CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
+
+ CP_XML_ATTR(L"id", id);
+ CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->name);
+ CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->name);
+ CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
+
+ if (xlsx_data_ranges_[it->second]->withHeader == false &&
+ xlsx_data_ranges_[it->second]->filter_button == false)
+ CP_XML_ATTR(L"headerRowCount", 0);
+
+ //CP_XML_ATTR(L"totalsRowCount", 0);
+ CP_XML_ATTR(L"totalsRowShown", 0);
+
+ xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
+ xlsx_data_ranges_[it->second]->serialize_sort(CP_XML_STREAM());
+
+ CP_XML_NODE(L"tableColumns")
+ {
+ CP_XML_ATTR(L"count", xlsx_data_ranges_[it->second]->cell_end.first -
+ xlsx_data_ranges_[it->second]->cell_start.first + 1);
+
+ for (int id = 0, i = xlsx_data_ranges_[it->second]->cell_start.first; i <= xlsx_data_ranges_[it->second]->cell_end.first; i++, id++)
{
- std::wstring column_name = xlsx_data_ranges_[it->second]->header_values[id];
- if (column_name.empty())
+ CP_XML_NODE(L"tableColumn")
{
- column_name = L"Column_" + std::to_wstring(id + 1);
+ std::wstring column_name = xlsx_data_ranges_[it->second]->header_values[id];
+ if (column_name.empty())
+ {
+ column_name = L"Column_" + std::to_wstring(id + 1);
+ }
+ CP_XML_ATTR(L"id", id + 1);
+ CP_XML_ATTR(L"name", column_name);
}
- CP_XML_ATTR(L"id", id + 1);
- CP_XML_ATTR(L"name", column_name);
}
}
- }
- CP_XML_NODE(L"tableStyleInfo")
- {
- CP_XML_ATTR(L"showFirstColumn", 0);
- CP_XML_ATTR(L"showLastColumn", 0);
- CP_XML_ATTR(L"showRowStripes", 1);
- CP_XML_ATTR(L"showColumnStripes", 0);
+ CP_XML_NODE(L"tableStyleInfo")
+ {
+ CP_XML_ATTR(L"showFirstColumn", 0);
+ CP_XML_ATTR(L"showLastColumn", 0);
+ CP_XML_ATTR(L"showRowStripes", 1);
+ CP_XML_ATTR(L"showColumnStripes", 0);
+ }
}
}
+ xlsx_conversion_context_->add_table_part(strm.str());
}
- xlsx_conversion_context_->add_table_part(strm.str());
}
-}
-void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
-{
- if (xlsx_data_ranges_.empty()) return;
-
- std::wstring ref;
-
- std::pair cell_start (-1, -1);
- std::pair cell_end (-1, -1);
-
- std::pair::iterator, std::multimap::iterator> range;
-
- range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
-
- for (std::multimap::iterator it = range.first; it != range.second; ++it)
+ void xlsx_table_context::serialize_autofilter(std::wostream& _Wostream)
{
- if (xlsx_data_ranges_[it->second]->bTablePart) continue;
- if (!xlsx_data_ranges_[it->second]->filter) continue;
+ if (xlsx_data_ranges_.empty()) return;
- if (cell_start.first < 0 || xlsx_data_ranges_[it->second]->cell_start.first < cell_start.first )
- cell_start.first = xlsx_data_ranges_[it->second]->cell_start.first;
+ std::wstring ref;
- if (cell_start.second < 0 || xlsx_data_ranges_[it->second]->cell_start.second < cell_start.second)
- cell_start.second = xlsx_data_ranges_[it->second]->cell_start.second;
+ std::pair cell_start(-1, -1);
+ std::pair cell_end(-1, -1);
- if (cell_end.first < 0 || xlsx_data_ranges_[it->second]->cell_end.first > cell_end.first)
- cell_end.first = xlsx_data_ranges_[it->second]->cell_end.first;
+ std::pair::iterator, std::multimap::iterator> range;
- if (cell_end.second < 0 || xlsx_data_ranges_[it->second]->cell_end.second > cell_end.second)
- cell_end.second = xlsx_data_ranges_[it->second]->cell_end.second;
+ range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
- ref = xlsx_data_ranges_[it->second]->ref + L";";
- }
- if (cell_end.first < 0 || cell_start.first < 0) return;
+ int ind_filter = -1;
- ref.erase(ref.size() - 1, 1);
-
- CP_XML_WRITER(_Wostream)
- {
- CP_XML_NODE(L"autoFilter")
+ for (std::multimap::iterator it = range.first; it != range.second; ++it)
{
- //в автофильтре тока простые диапазоны .. для сложных - tablePart
- CP_XML_ATTR(L"ref", getCellAddress(cell_start.first, cell_start.second) + L":" + getCellAddress(cell_end.first, cell_end.second));
- //CP_XML_ATTR(L"ref", ref);
+ if (xlsx_data_ranges_[it->second]->bTablePart) continue;
+ if (!xlsx_data_ranges_[it->second]->filter_button && xlsx_data_ranges_[it->second]->filter_conditions.empty()) continue;
+
+ if (cell_start.first < 0 || xlsx_data_ranges_[it->second]->cell_start.first < cell_start.first)
+ cell_start.first = xlsx_data_ranges_[it->second]->cell_start.first;
+
+ if (cell_start.second < 0 || xlsx_data_ranges_[it->second]->cell_start.second < cell_start.second)
+ cell_start.second = xlsx_data_ranges_[it->second]->cell_start.second;
+
+ if (cell_end.first < 0 || xlsx_data_ranges_[it->second]->cell_end.first > cell_end.first)
+ cell_end.first = xlsx_data_ranges_[it->second]->cell_end.first;
+
+ if (cell_end.second < 0 || xlsx_data_ranges_[it->second]->cell_end.second > cell_end.second)
+ cell_end.second = xlsx_data_ranges_[it->second]->cell_end.second;
+
+ ref = xlsx_data_ranges_[it->second]->ref + L";";
+ if (ind_filter < 0 && !xlsx_data_ranges_[it->second]->filter_conditions.empty())
+ ind_filter = it->second;
+
+ }
+ if (cell_end.first < 0 || cell_start.first < 0) return;
+
+ ref.erase(ref.size() - 1, 1);
+
+ CP_XML_WRITER(_Wostream)
+ {
+ CP_XML_NODE(L"autoFilter")
+ {
+ //в автофильтре тока простые диапазоны .. для сложных - tablePart
+ CP_XML_ATTR(L"ref", getCellAddress(cell_start.first, cell_start.second) + L":" + getCellAddress(cell_end.first, cell_end.second));
+ //CP_XML_ATTR(L"ref", ref);
+ if (ind_filter != -1)
+ xlsx_data_ranges_[ind_filter]->serialize_filterColumn(CP_XML_STREAM(), 0);
+ }
}
}
-}
-void xlsx_table_context::serialize_protection(std::wostream & _Wostream)
-{
- return state()->serialize_protection(_Wostream);
-}
-void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
-{
- return state()->serialize_conditionalFormatting(_Wostream);
-}
-void xlsx_table_context::serialize_merge_cells(std::wostream & _Wostream)
-{
- return state()->serialize_merge_cells(_Wostream);
-}
-void xlsx_table_context::serialize_table_format(std::wostream & _Wostream)
-{
- return state()->serialize_table_format(_Wostream);
-}
-void xlsx_table_context::serialize_page_properties(std::wostream & _Wostream)
-{
- return state()->serialize_page_properties(_Wostream);
-}
-void xlsx_table_context::serialize_header_footer(std::wostream & _Wostream)
-{
- return state()->serialize_header_footer(_Wostream);
-}
-void xlsx_table_context::serialize_background(std::wostream & _Wostream)
-{
- return state()->serialize_background(_Wostream);
-}
-void xlsx_table_context::serialize_data_validation(std::wostream & _Wostream)
-{
- return xlsx_conversion_context_->get_dataValidations_context().serialize(_Wostream);
-}
-void xlsx_table_context::serialize_data_validation_x14(std::wostream & _Wostream)
-{
- return xlsx_conversion_context_->get_dataValidations_context().serialize_x14(_Wostream);
-}
-void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
-{
- return state()->serialize_hyperlinks(_Wostream);
-}
-void xlsx_table_context::serialize_ole_objects(std::wostream & _Wostream)
-{
- return state()->serialize_ole_objects(_Wostream);
-}
-void xlsx_table_context::serialize_controls(std::wostream & _Wostream)
-{
- return state()->serialize_controls(_Wostream);
-}
-void xlsx_table_context::serialize_breaks(std::wostream & _Wostream)
-{
- return state()->serialize_breaks(_Wostream);
-}
-void xlsx_table_context::dump_rels_hyperlinks(rels & Rels)
-{
- return state()->dump_rels_hyperlinks(Rels);
-}
-void xlsx_table_context::dump_rels_ole_objects(rels & Rels)
-{
- return state()->dump_rels_ole_objects(Rels);
-}
-xlsx_table_metrics & xlsx_table_context::get_table_metrics()
-{
- return state()->get_table_metrics();
-}
+ void xlsx_table_context::serialize_protection(std::wostream& _Wostream)
+ {
+ return state()->serialize_protection(_Wostream);
+ }
+ void xlsx_table_context::serialize_conditionalFormatting(std::wostream& _Wostream)
+ {
+ return state()->serialize_conditionalFormatting(_Wostream);
+ }
+ void xlsx_table_context::serialize_merge_cells(std::wostream& _Wostream)
+ {
+ return state()->serialize_merge_cells(_Wostream);
+ }
+ void xlsx_table_context::serialize_table_format(std::wostream& _Wostream)
+ {
+ return state()->serialize_table_format(_Wostream);
+ }
+ void xlsx_table_context::serialize_page_properties(std::wostream& _Wostream)
+ {
+ return state()->serialize_page_properties(_Wostream);
+ }
+ void xlsx_table_context::serialize_header_footer(std::wostream& _Wostream)
+ {
+ return state()->serialize_header_footer(_Wostream);
+ }
+ void xlsx_table_context::serialize_background(std::wostream& _Wostream)
+ {
+ return state()->serialize_background(_Wostream);
+ }
+ void xlsx_table_context::serialize_data_validation(std::wostream& _Wostream)
+ {
+ return xlsx_conversion_context_->get_dataValidations_context().serialize(_Wostream);
+ }
+ void xlsx_table_context::serialize_data_validation_x14(std::wostream& _Wostream)
+ {
+ return xlsx_conversion_context_->get_dataValidations_context().serialize_x14(_Wostream);
+ }
+ void xlsx_table_context::serialize_hyperlinks(std::wostream& _Wostream)
+ {
+ return state()->serialize_hyperlinks(_Wostream);
+ }
+ void xlsx_table_context::serialize_ole_objects(std::wostream& _Wostream)
+ {
+ return state()->serialize_ole_objects(_Wostream);
+ }
+ void xlsx_table_context::serialize_controls(std::wostream& _Wostream)
+ {
+ return state()->serialize_controls(_Wostream);
+ }
+ void xlsx_table_context::serialize_breaks(std::wostream& _Wostream)
+ {
+ return state()->serialize_breaks(_Wostream);
+ }
+ void xlsx_table_context::dump_rels_hyperlinks(rels& Rels)
+ {
+ return state()->dump_rels_hyperlinks(Rels);
+ }
+ void xlsx_table_context::dump_rels_ole_objects(rels& Rels)
+ {
+ return state()->dump_rels_ole_objects(Rels);
+ }
+ xlsx_table_metrics& xlsx_table_context::get_table_metrics()
+ {
+ return state()->get_table_metrics();
+ }
-xlsx_drawing_context & xlsx_table_context::get_drawing_context()
-{
- return state()->get_drawing_context();
-}
+ xlsx_drawing_context& xlsx_table_context::get_drawing_context()
+ {
+ return state()->get_drawing_context();
+ }
-xlsx_comments_context & xlsx_table_context::get_comments_context()
-{
- return state()->get_comments_context();
-}
-void xlsx_table_context::table_column_last_width(double w)
-{
- return state()->table_column_last_width(w);
-}
+ xlsx_comments_context& xlsx_table_context::get_comments_context()
+ {
+ return state()->get_comments_context();
+ }
+ void xlsx_table_context::table_column_last_width(double w)
+ {
+ return state()->table_column_last_width(w);
+ }
-double xlsx_table_context::table_column_last_width()
-{
- return state()->table_column_last_width();
-}
+ double xlsx_table_context::table_column_last_width()
+ {
+ return state()->table_column_last_width();
+ }
-void xlsx_table_context::start_hyperlink()
-{
- return state()->start_hyperlink();
-}
+ void xlsx_table_context::start_hyperlink()
+ {
+ return state()->start_hyperlink();
+ }
- std::wstring xlsx_table_context::end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display)
-{
- return state()->end_hyperlink(ref, href, display);
-}
+ std::wstring xlsx_table_context::end_hyperlink(std::wstring const& ref, std::wstring const& href, std::wstring const& display)
+ {
+ return state()->end_hyperlink(ref, href, display);
+ }
}
diff --git a/OdfFile/Reader/Converter/xlsx_tablecontext.h b/OdfFile/Reader/Converter/xlsx_tablecontext.h
index 0a52ae929c..6c0c29d855 100644
--- a/OdfFile/Reader/Converter/xlsx_tablecontext.h
+++ b/OdfFile/Reader/Converter/xlsx_tablecontext.h
@@ -118,10 +118,15 @@ public:
void dump_rels_ole_objects (rels & Rels);
bool start_database_range(const std::wstring &table_name, const std::wstring &ref, bool bNamedRangeOnly);
- void set_database_orientation (bool val);
- void set_database_header (bool val);
- void set_database_filter (bool val);
- void add_database_sort (int field_number, int order);
+ void set_database_orientation (bool val);
+ void set_database_header (bool val);
+ void set_database_filter_button(bool val);
+ void add_database_filter_conditional(int field_number, int type, const std::wstring & value, int operator_);
+ void add_database_sort (int field_number, int order, int type);
+ void start_filters_or();
+ void start_filters_and();
+ void end_filters_or();
+ void end_filters_and();
void end_database_range();
int in_database_range();
diff --git a/OdfFile/Reader/Converter/xlsxconversioncontext.cpp b/OdfFile/Reader/Converter/xlsxconversioncontext.cpp
index 438fd3350c..eeae1278cd 100644
--- a/OdfFile/Reader/Converter/xlsxconversioncontext.cpp
+++ b/OdfFile/Reader/Converter/xlsxconversioncontext.cpp
@@ -724,6 +724,35 @@ int xlsx_conversion_context::get_current_cell_style_id()
{
return get_table_context().get_current_cell_style_id();
}
+int xlsx_conversion_context::add_dxfId_style(const std::wstring& color, bool cellColor)
+{
+ int dxfId = -1;
+ odf_reader::style_instance* instStyle =
+ root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::TableCell);
+
+ if (instStyle)
+ {
+ odf_reader::text_format_properties_ptr textFormats = calc_text_properties_content(instStyle);
+ odf_reader::graphic_format_properties_ptr graphicFormats = calc_graphic_properties_content(instStyle);
+ odf_reader::style_table_cell_properties_attlist cellFormats = calc_table_cell_properties(instStyle);
+
+ odf_types::color odf_color(color);
+ if (cellColor)
+ {
+ cellFormats.common_background_color_attlist_.fo_background_color_ = odf_color;
+ }
+ else
+ {
+ if (!textFormats)
+ textFormats = odf_reader::text_format_properties_ptr(new odf_reader::text_format_properties());
+
+ textFormats->fo_color_ = odf_color;
+ }
+
+ dxfId = get_style_manager().dxfId(textFormats, graphicFormats, &cellFormats);
+ }
+ return dxfId;
+}
int xlsx_conversion_context::get_dxfId_style(const std::wstring &style_name)
{
if (style_name.empty()) return -1;
diff --git a/OdfFile/Reader/Converter/xlsxconversioncontext.h b/OdfFile/Reader/Converter/xlsxconversioncontext.h
index e36ab636dd..5f92f5a73d 100644
--- a/OdfFile/Reader/Converter/xlsxconversioncontext.h
+++ b/OdfFile/Reader/Converter/xlsxconversioncontext.h
@@ -134,6 +134,7 @@ public:
size_t get_default_cell_style() const { return default_style_; }
int get_dxfId_style(const std::wstring &style_name);
+ int add_dxfId_style(const std::wstring& color, bool cellColor);
//------------------------------------------------------------------------------------
void add_pivot_sheet_source (const std::wstring & sheet_name, int index_table_view);
diff --git a/OdfFile/Reader/Format/calcext_elements.cpp b/OdfFile/Reader/Format/calcext_elements.cpp
index 4e10490938..d8b152833f 100644
--- a/OdfFile/Reader/Format/calcext_elements.cpp
+++ b/OdfFile/Reader/Format/calcext_elements.cpp
@@ -59,6 +59,7 @@ void calcext_data_bar_attr::add_attributes( const xml::attributes_wc_ptr & Attri
CP_APPLY_ATTR(L"calcext:negative-color", negative_color_);
CP_APPLY_ATTR(L"calcext:min-length", min_length_);
CP_APPLY_ATTR(L"calcext:max-length", max_length_);
+ CP_APPLY_ATTR(L"calcext:axis-position", axis_position_);
}
void calcext_icon_set_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
@@ -173,6 +174,11 @@ void calcext_data_bar::xlsx_convert(oox::xlsx_conversion_context & Context)
if (attr_.positive_color_)
Context.get_conditionalFormatting_context().add_color(L"ff" + attr_.positive_color_->get_hex_value());
+ if (attr_.negative_color_)
+ Context.get_conditionalFormatting_context().set_negative_color(L"ff" + attr_.negative_color_->get_hex_value());
+
+ if (attr_.axis_position_)
+ Context.get_conditionalFormatting_context().set_axis_position(*attr_.axis_position_);
Context.get_conditionalFormatting_context().set_dataBar(attr_.min_length_, attr_.max_length_);
@@ -208,7 +214,6 @@ const wchar_t * calcext_icon_set::name = L"icon-set";
void calcext_icon_set::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
- CP_APPLY_ATTR(L"calcext:show-value", show_value_);
attr_.add_attributes(Attributes);
}
void calcext_icon_set::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@@ -219,8 +224,8 @@ void calcext_icon_set::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_conditionalFormatting_context().add_rule(4);
- if (show_value_)
- Context.get_conditionalFormatting_context().set_showVal(*show_value_);
+ if (attr_.icon_set_type_)
+ Context.get_conditionalFormatting_context().set_icon_set_type(attr_.icon_set_type_->get_type());
for (size_t i = 0 ; i < content_.size(); i++)
{
@@ -237,6 +242,7 @@ void calcext_formatting_entry::add_attributes( const xml::attributes_wc_ptr & At
{
CP_APPLY_ATTR(L"calcext:value", value_);
CP_APPLY_ATTR(L"calcext:type", type_);
+ CP_APPLY_ATTR(L"calcext:show-value", show_value_);
}
void calcext_formatting_entry::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
@@ -246,6 +252,9 @@ void calcext_formatting_entry::xlsx_convert(oox::xlsx_conversion_context & Conte
{
calcext_type::type t = type_.get_value_or(calcext_type::Number).get_type();
Context.get_conditionalFormatting_context().add_sfv((int)t, value_.get_value_or(L""));
+
+ if (show_value_)
+ Context.get_conditionalFormatting_context().set_showVal(*show_value_);
}
// calcext_color_scale_entry
diff --git a/OdfFile/Reader/Format/calcext_elements.h b/OdfFile/Reader/Format/calcext_elements.h
index 585b1b3e3d..987d9150f7 100644
--- a/OdfFile/Reader/Format/calcext_elements.h
+++ b/OdfFile/Reader/Format/calcext_elements.h
@@ -56,7 +56,8 @@ public:
_CP_OPT(odf_types::color) axis_color_;
_CP_OPT(odf_types::color) positive_color_;
_CP_OPT(odf_types::color) negative_color_;
- _CP_OPT(int) max_length_;
+ _CP_OPT(std::wstring) axis_position_;
+ _CP_OPT(int) max_length_;
_CP_OPT(int) min_length_;
};
@@ -165,6 +166,7 @@ public:
_CP_OPT(std::wstring) value_;
_CP_OPT(odf_types::calcext_type) type_;
+ _CP_OPT(bool) show_value_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_formatting_entry);
diff --git a/OdfFile/Reader/Format/draw_common.cpp b/OdfFile/Reader/Format/draw_common.cpp
index 1eade83c1d..768bac78f9 100644
--- a/OdfFile/Reader/Format/draw_common.cpp
+++ b/OdfFile/Reader/Format/draw_common.cpp
@@ -295,91 +295,107 @@ void Compute_HatchFill(draw_hatch * image_style,oox::oox_hatch_fill_ptr fill)
break;
}
}
-void Compute_GradientFill(draw_gradient *image_style, oox::oox_gradient_fill_ptr fill)
+void Compute_GradientFill(draw_gradient* gradient_style, oox::oox_gradient_fill_ptr fill)
{
- int style =0;
- if (image_style->draw_style_)style = image_style->draw_style_->get_type();
+ int style = 0;
+ if (gradient_style->draw_style_) style = gradient_style->draw_style_->get_type();
- if (image_style->draw_angle_) fill->angle = 90 - image_style->draw_angle_->get_value();
- if (fill->angle < 0) fill->angle +=360;
+ if (gradient_style->draw_angle_) fill->angle = 90 - gradient_style->draw_angle_->get_value();
+ if (fill->angle < 0) fill->angle += 360;
- oox::oox_gradient_fill::_color_position point={};
- switch(style)
+ for (size_t i = 0; i < gradient_style->content_.size(); ++i)
{
- case gradient_style::linear:
- {
- fill->style = 0;
-
- point.pos = 0;
- if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value();
- //if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
-
- fill->colors.push_back(point);
-
- point.pos = 100;
- if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
- if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
-
- fill->colors.push_back(point);
- }break;
- case gradient_style::axial:
+ loext_gradient_stop* gradient_stop = dynamic_cast(gradient_style->content_[i].get());
+ if (gradient_stop)
{
- fill->style = 0;
-
- point.pos = 0;
- if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
- //if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
-
- fill->colors.push_back(point);
+ if (fill->colors.size() <= i) fill->colors.emplace_back();
- point.pos = 50;
- if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value();
- if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
+ if (gradient_stop->color_value_)
+ fill->colors[i].color_ref = gradient_stop->color_value_->get_hex_value();
+ if (gradient_stop->svg_offset_)
+ fill->colors[i].pos = 100 - *gradient_stop->svg_offset_ * 100;
+ }
+ }
+ fill->style = 0;
+ if (style == gradient_style::radial ||
+ style == gradient_style::ellipsoid) fill->style = 2;
+ else if (style == gradient_style::square) fill->style = 1;
+ else if (style == gradient_style::rectangular) fill->style = 3;
- fill->colors.push_back(point);
-
- point.pos = 100;
- if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
- //if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
-
- fill->colors.push_back(point);
- }break;
- case gradient_style::radial:
- case gradient_style::ellipsoid:
- case gradient_style::square:
- case gradient_style::rectangular:
+ if (fill->colors.empty())
+ {
+ oox::oox_gradient_fill::_color_position point = {};
+ switch (style)
{
- if (style == gradient_style::radial ||
- style == gradient_style::ellipsoid) fill->style = 2;
- if (style == gradient_style::square ) fill->style = 1;
- if (style == gradient_style::rectangular) fill->style = 3;
-
- point.pos = 0;
- if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value();
- //if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
+ case gradient_style::linear:
+ {
+ point.pos = 0;
+ if (gradient_style->draw_start_color_) point.color_ref = gradient_style->draw_start_color_->get_hex_value();
+ //if (gradient_style->draw_start_intensity_) point.opacity = gradient_style->draw_start_intensity_->get_value();
+
+ fill->colors.push_back(point);
+
+ point.pos = 100;
+ if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value();
+ if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value();
+
+ fill->colors.push_back(point);
+ }break;
+ case gradient_style::axial:
+ {
+ point.pos = 0;
+ if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value();
+ //if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value();
+
+ fill->colors.push_back(point);
+
+ point.pos = 50;
+ if (gradient_style->draw_start_color_) point.color_ref = gradient_style->draw_start_color_->get_hex_value();
+ if (gradient_style->draw_start_intensity_) point.opacity = gradient_style->draw_start_intensity_->get_value();
+
+ fill->colors.push_back(point);
+
+ point.pos = 100;
+ if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value();
+ //if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value();
+
+ fill->colors.push_back(point);
+ }break;
+ case gradient_style::radial:
+ case gradient_style::ellipsoid:
+ case gradient_style::square:
+ case gradient_style::rectangular:
+ {
+ point.pos = 0;
+ if (gradient_style->draw_start_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value();
+ //if (gradient_style->draw_start_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value();
+
+ fill->colors.push_back(point);
+
+ point.pos = 100;
+ if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_start_color_->get_hex_value();
+ //if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_start_intensity_->get_value();
+
+ fill->colors.push_back(point);
+ }break;
+ }
+ }
- fill->colors.push_back(point);
+ if (fill->style > 1)
+ {
+ fill->rect[0] = fill->rect[1] = 0;
+ fill->rect[2] = fill->rect[3] = 100;
- point.pos = 100;
- if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
- //if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
-
- fill->colors.push_back(point);
-
- fill->rect[0] = fill->rect[1] = 0;
- fill->rect[2] = fill->rect[3] = 100;
-
- if (image_style->draw_cx_)
- {
- fill->rect[0] = 100 - image_style->draw_cx_->get_value();
- fill->rect[2] = image_style->draw_cx_->get_value();
- }
- if (image_style->draw_cy_)
- {
- fill->rect[1] = 100 - image_style->draw_cy_->get_value();
- fill->rect[3] = image_style->draw_cy_->get_value();
- }
- }break;
+ if (gradient_style->draw_cx_)
+ {
+ fill->rect[0] = 100 - gradient_style->draw_cx_->get_value();
+ fill->rect[2] = gradient_style->draw_cx_->get_value();
+ }
+ if (gradient_style->draw_cy_)
+ {
+ fill->rect[1] = 100 - gradient_style->draw_cy_->get_value();
+ fill->rect[3] = gradient_style->draw_cy_->get_value();
+ }
}
}
@@ -401,15 +417,23 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
if (office_element_ptr style = styles.find_by_style_name(style_name))
{
- if (draw_opacity * image_style = dynamic_cast(style.get()))
+ if (draw_opacity * opacity_style = dynamic_cast(style.get()))
{
- //увы и ах но ms не поддерживает градиентную прозрачность - сделаем средненькую
- if (image_style->draw_start_ && image_style->draw_end_)
+ if (opacity_style->draw_start_ && opacity_style->draw_end_ || opacity_style->content_.size() > 1)
{
- fill.opacity = (image_style->draw_start_->get_value() + image_style->draw_end_->get_value())/2.;
+ fill.gradient = oox::oox_gradient_fill::create();
+ fill.type = 3; //?? градиентная прозрачность на картинку
+
+ for (size_t i = 0; i < opacity_style->content_.size(); ++i)
+ {
+ loext_opacity_stop* opacity_stop = dynamic_cast(opacity_style->content_[i].get());
+ fill.gradient->colors.emplace_back();
+ fill.gradient->colors.back().opacity = 100 * opacity_stop->stop_opacity_.get_value_or(0);
+ fill.gradient->colors.back().pos = opacity_stop->svg_offset_.get_value_or(0) * 100;
+ }
}
- else if (image_style->draw_start_)fill.opacity = image_style->draw_start_->get_value();
- else if (image_style->draw_end_)fill.opacity = image_style->draw_end_->get_value();
+ else if (opacity_style->draw_start_) fill.opacity = opacity_style->draw_start_->get_value();
+ else if (opacity_style->draw_end_) fill.opacity = opacity_style->draw_end_->get_value();
}
}
}
@@ -423,6 +447,14 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
fill.solid->color = props.draw_fill_color_->get_hex_value();
if (fill.type <= 0 && !txbx ) fill.type = 1; //в этом случае тип может и не быть задан явно
+
+ if (fill.gradient)
+ {
+ for (size_t i = 0; i < fill.gradient->colors.size(); ++i)
+ {
+ fill.gradient->colors[i].color_ref = props.draw_fill_color_->get_hex_value();
+ }
+ }
}
if (props.draw_fill_image_name_)
@@ -526,12 +558,13 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
const std::wstring style_name = L"gradient:" + *props.draw_fill_gradient_name_;
if (office_element_ptr style = styles.find_by_style_name(style_name))
{
- if (draw_gradient * image_style = dynamic_cast(style.get()))
+ if (draw_gradient *gradient_style = dynamic_cast(style.get()))
{
- fill.type = 3;
- fill.gradient = oox::oox_gradient_fill::create();
+ fill.type = 3;
+
+ if (!fill.gradient) fill.gradient = oox::oox_gradient_fill::create();
- Compute_GradientFill(image_style, fill.gradient);
+ Compute_GradientFill(gradient_style, fill.gradient);
if (fill.opacity)
{
diff --git a/OdfFile/Reader/Format/style_presentation.cpp b/OdfFile/Reader/Format/style_presentation.cpp
index 32e72f5947..fe1218f215 100644
--- a/OdfFile/Reader/Format/style_presentation.cpp
+++ b/OdfFile/Reader/Format/style_presentation.cpp
@@ -107,12 +107,12 @@ const wchar_t * style_drawing_page_properties::name = L"drawing-page-properties"
void style_drawing_page_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
- drawing_page_properties_.add_attributes(Attributes);
+ content_.add_attributes(Attributes);
}
void style_drawing_page_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"presentation", L"sound")
- CP_CREATE_ELEMENT(drawing_page_properties_.presentation_sound_);
+ CP_CREATE_ELEMENT(content_.presentation_sound_);
else
CP_NOT_APPLICABLE_ELM();
}
diff --git a/OdfFile/Reader/Format/style_presentation.h b/OdfFile/Reader/Format/style_presentation.h
index 9185539709..dc51d98728 100644
--- a/OdfFile/Reader/Format/style_presentation.h
+++ b/OdfFile/Reader/Format/style_presentation.h
@@ -138,14 +138,14 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
- drawing_page_properties & content() { return drawing_page_properties_; }
+ drawing_page_properties & content() { return content_; }
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
- drawing_page_properties drawing_page_properties_;
+ drawing_page_properties content_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_drawing_page_properties);
diff --git a/OdfFile/Reader/Format/styles.cpp b/OdfFile/Reader/Format/styles.cpp
index cc59f7ac72..28beb0aa24 100644
--- a/OdfFile/Reader/Format/styles.cpp
+++ b/OdfFile/Reader/Format/styles.cpp
@@ -545,7 +545,7 @@ void draw_gradient::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_gradient::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
- CP_NOT_APPLICABLE_ELM();
+ CP_CREATE_ELEMENT(content_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_hatch::ns = L"draw";
@@ -586,7 +586,7 @@ void draw_opacity::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_opacity::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
- CP_NOT_APPLICABLE_ELM();
+ CP_CREATE_ELEMENT(content_);
}
// style:style
//////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2157,6 +2157,28 @@ void style_presentation_page_layout::pptx_convert(oox::pptx_conversion_context &
content_[i]->pptx_convert(Context);
}
}
+//--------------------------------------------------------------------------------------------------
+const wchar_t* loext_gradient_stop::ns = L"loext";
+const wchar_t* loext_gradient_stop::name = L"gradient-stop";
+
+void loext_gradient_stop::add_attributes(const xml::attributes_wc_ptr& Attributes)
+{
+ CP_APPLY_ATTR(L"loext:color-type", color_type_);
+ CP_APPLY_ATTR(L"loext:color-value", color_value_);
+ CP_APPLY_ATTR(L"svg:offset", svg_offset_);
+}
+//--------------------------------------------------------------------------------------------------
+const wchar_t* loext_opacity_stop::ns = L"loext";
+const wchar_t* loext_opacity_stop::name = L"opacity-stop";
+
+void loext_opacity_stop::add_attributes(const xml::attributes_wc_ptr& Attributes)
+{
+ CP_APPLY_ATTR(L"svg:stop-opacity", stop_opacity_);
+ CP_APPLY_ATTR(L"svg:offset", svg_offset_);
+
+ //CP_APPLY_ATTR(L"loext:stop-opacity", stop_opacity_); //??
+}
+
}
}
diff --git a/OdfFile/Reader/Format/styles.h b/OdfFile/Reader/Format/styles.h
index ace746b870..8b78ced093 100644
--- a/OdfFile/Reader/Format/styles.h
+++ b/OdfFile/Reader/Format/styles.h
@@ -174,7 +174,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
- std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
+ std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(odf_types::length_or_percent) draw_distance_;
_CP_OPT(odf_types::length_or_percent) draw_dots1_length_;
@@ -205,7 +205,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
- std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
+ std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(odf_types::color) draw_start_color_;
_CP_OPT(odf_types::color) draw_end_color_;
@@ -220,17 +220,17 @@ public:
_CP_OPT(odf_types::draw_angle) draw_angle_;
_CP_OPT(odf_types::gradient_style) draw_style_;
-
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
+ office_element_ptr_array content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_gradient);
-/////////////////////////////////////////////////////////////////////////////////////////////////
+//------------------------------------------------------------------------------------------------
// draw:hatch
class draw_hatch : public office_element_impl
{
@@ -242,7 +242,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
- std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
+ std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(odf_types::hatch_style) draw_style_;
_CP_OPT(int) draw_rotation_;
@@ -254,11 +254,10 @@ public:
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
- virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
-
+ virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_hatch);
-/////////////////////////////////////////////////////////////////////////////////////////////////
+//------------------------------------------------------------------------------------------------
// style_draw_gradient
class draw_opacity : public office_element_impl
{
@@ -275,20 +274,22 @@ public:
_CP_OPT(odf_types::gradient_style) draw_style_;//linear, radial, ..
_CP_OPT(odf_types::draw_angle) draw_angle_;
- _CP_OPT(odf_types::percent) draw_start_;
- _CP_OPT(odf_types::percent) draw_end_;
+ _CP_OPT(odf_types::percent) draw_start_;
+ _CP_OPT(odf_types::percent) draw_end_;
- _CP_OPT(odf_types::percent) draw_border_;
+ _CP_OPT(odf_types::percent) draw_border_;
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
+ office_element_ptr_array content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_opacity);
+//------------------------------------------------------------------------------------------------
// style_draw_fill_image
class draw_fill_image : public office_element_impl
@@ -312,7 +313,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_fill_image);
-/////////////////////////////////////////////////////////////////////////////////////////////////
+//------------------------------------------------------------------------------------------------
class style;
typedef shared_ptr