summaryrefslogtreecommitdiffstats
path: root/sc/source/filter/html/htmlpars.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/filter/html/htmlpars.cxx')
-rw-r--r--sc/source/filter/html/htmlpars.cxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index f5f8900815..be957b1851 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -61,6 +61,7 @@
#include <rangelst.hxx>
#include <orcus/css_parser.hpp>
+#include <boost/property_tree/json_parser.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
@@ -71,6 +72,48 @@
using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
+namespace
+{
+/// data-sheets-value from google sheets, value is a JSON.
+void ParseDataSheetsValue(const OUString& rDataSheetsValue, std::optional<OUString>& rVal, std::optional<OUString>& rNum)
+{
+ // data-sheets-value from google sheets, value is a JSON.
+ OString aEncodedOption = rDataSheetsValue.toUtf8();
+ const char* pEncodedOption = aEncodedOption.getStr();
+ std::stringstream aStream(pEncodedOption);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ // The "1" key describes the original data type.
+ auto it = aTree.find("1");
+ if (it != aTree.not_found())
+ {
+ int nValueType = std::stoi(it->second.get_value<std::string>());
+ switch (nValueType)
+ {
+ case 2:
+ {
+ // 2 is text.
+ // See SfxHTMLParser::GetTableDataOptionsValNum(), we leave the parse and a number
+ // language unspecified.
+ rNum = ";;@";
+ break;
+ }
+ case 4:
+ {
+ // 4 is boolean.
+ it = aTree.find("4");
+ if (it != aTree.not_found())
+ {
+ rVal = OUString::fromUtf8(it->second.get_value<std::string>());
+ }
+ rNum = ";;BOOLEAN";
+ break;
+ }
+ }
+ }
+}
+}
+
ScHTMLStyles::ScHTMLStyles() : maEmpty() {}
void ScHTMLStyles::add(const char* pElemName, size_t nElemName, const char* pClassName, size_t nClassName,
@@ -978,6 +1021,11 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* pInfo )
mxActEntry->pNumStr = rOption.GetString();
}
break;
+ case HtmlOptionId::DSVAL:
+ {
+ ParseDataSheetsValue(rOption.GetString(), mxActEntry->pValStr, mxActEntry->pNumStr);
+ }
+ break;
default: break;
}
}
@@ -2116,6 +2164,11 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo )
}
}
break;
+ case HtmlOptionId::DSVAL:
+ {
+ ParseDataSheetsValue(rOption.GetString(), pValStr, pNumStr);
+ }
+ break;
default: break;
}
}