Commit 3a10eabf authored by ElenaSubbotina's avatar ElenaSubbotina

fix bugs after testing

parent f9e80f36
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector>
#include "../include/cpdoccore/CPScopedPtr.h" #include "../include/cpdoccore/CPScopedPtr.h"
namespace cpdoccore { namespace cpdoccore {
...@@ -58,6 +59,8 @@ public: ...@@ -58,6 +59,8 @@ public:
//Sheet2.C3:Sheet2.C19 -> Sheet2!C3:C19 //Sheet2.C3:Sheet2.C19 -> Sheet2!C3:C19
std::wstring convert_chart_distance(std::wstring const & expr); std::wstring convert_chart_distance(std::wstring const & expr);
void split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out);
std::wstring convert_ref(std::wstring const & expr); std::wstring convert_ref(std::wstring const & expr);
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "formulasconvert.h" #include "formulasconvert.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include"../../Common/DocxFormat/Source/XML/Utils.h" #include"../../Common/DocxFormat/Source/XML/Utils.h"
...@@ -46,6 +45,9 @@ namespace formulasconvert { ...@@ -46,6 +45,9 @@ namespace formulasconvert {
std::wstring convert(const std::wstring& expr); std::wstring convert(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr); std::wstring convert_chart_distance(const std::wstring& expr);
void split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out);
void replace_cells_range(std::wstring& expr, bool withTableName); void replace_cells_range(std::wstring& expr, bool withTableName);
bool check_formula(std::wstring& expr); bool check_formula(std::wstring& expr);
void replace_semicolons(std::wstring& expr); void replace_semicolons(std::wstring& expr);
...@@ -189,7 +191,7 @@ namespace formulasconvert { ...@@ -189,7 +191,7 @@ namespace formulasconvert {
if (convert_with_TableName) if (convert_with_TableName)
{ {
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c3) ); return (sheet1 + L"!") + c1 + (c3.empty() ? L"" : (L":" + c3) );
} }
else else
{ {
...@@ -389,25 +391,24 @@ namespace formulasconvert { ...@@ -389,25 +391,24 @@ namespace formulasconvert {
std::wstring forbidden_formulas[] = std::wstring forbidden_formulas[] =
{ {
L"NULLFORMULA" L"NULLFORMULA"
/* //L"BETADIST",
L"BETADIST", //L"CEILING",
L"CEILING", //L"FLOOR",
L"FLOOR", //L"RANK",
L"RANK", //L"ROUND",
L"ROUND", //L"ROUNDDOWN",
L"ROUNDDOWN", //L"ROUNDUP",
L"ROUNDUP", //L"SUBTOTAL",
L"SUBTOTAL", //L"FORMULA",
L"FORMULA", //L"ISREF"
L"ISREF"*/
}; };
bool is_forbidden(const std::wstring & formula) bool is_forbidden(const std::wstring & formula)
{ {
BOOST_FOREACH(const std::wstring & s, forbidden_formulas) for (size_t i = 0; i < 1/*forbidden_formulas.size()*/; i++)
{ {
if (boost::algorithm::contains(formula, s)) if (boost::algorithm::contains(formula, forbidden_formulas[i]))
return true; return true;
} }
return false; return false;
...@@ -490,10 +491,30 @@ namespace formulasconvert { ...@@ -490,10 +491,30 @@ namespace formulasconvert {
return workstr; return workstr;
} }
void odf2oox_converter::Impl::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
{
std::wstring workstr = expr;
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
boost::algorithm::split(out, workstr, boost::algorithm::is_any_of(by), boost::algorithm::token_compress_on);
for (size_t i = 0; i < out.size(); i++)
{
XmlUtils::replace_all( out[i], L"PROBEL", L" ");
XmlUtils::replace_all( out[i], L"TOCHKA", L".");
}
}
//Sheet2.C3:Sheet2.C19 Sheet2.L29:Sheet2.L36 //Sheet2.C3:Sheet2.C19 Sheet2.L29:Sheet2.L36
//в //в
//Sheet2!C3:C19,Sheet2!L27:L34 //Sheet2!C3:C19,Sheet2!L27:L34
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr) std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
{ {
if (is_forbidden(expr)) if (is_forbidden(expr))
...@@ -515,25 +536,27 @@ namespace formulasconvert { ...@@ -515,25 +536,27 @@ namespace formulasconvert {
boost::algorithm::split(distance_inp, workstr, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on); boost::algorithm::split(distance_inp, workstr, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &d,distance_inp) for (size_t i = 0; i < distance_inp.size(); i++)
{ {
std::wstring sheet; std::wstring sheet;
std::vector<std::wstring> range; std::vector<std::wstring> range;
std::vector<std::wstring> cells; std::vector<std::wstring> cells;
boost::algorithm::split(range,d, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on); boost::algorithm::split(range, distance_inp[i], boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &c,range) for (size_t j = 0; j < range.size(); j++)
{ {
const std::string::size_type colon = c.find('.'); const std::string::size_type colon = range[j].find('.');
cells.push_back(c.substr(colon+1)); cells.push_back(range[j].substr(colon + 1));
if (sheet.size()<1) if (sheet.size() < 1)
sheet=c.substr(0, colon); {
sheet = range[j].substr(0, colon);
}
} }
std::wstring cells_out; std::wstring cells_out;
BOOST_FOREACH(std::wstring &c,cells) for (size_t j = 0; j < cells.size(); j++)
{ {
cells_out.append(c); cells_out.append(cells[j]);
cells_out.append(L":"); cells_out.append(L":");
} }
int res1 = sheet.find(L"-"); int res1 = sheet.find(L"-");
...@@ -544,19 +567,19 @@ namespace formulasconvert { ...@@ -544,19 +567,19 @@ namespace formulasconvert {
sheet = L"'" + sheet + L"'"; sheet = L"'" + sheet + L"'";
} }
distance_out.push_back(sheet+L"!" + cells_out.substr(0, cells_out.size()-1)); distance_out.push_back(sheet + L"!" + cells_out.substr(0, cells_out.size()-1));
} }
std::wstring result; std::wstring result;
BOOST_FOREACH(std::wstring &d, distance_out) for (size_t i = 0; i < distance_out.size(); i++)
{ {
result.append(d); result.append(distance_out[i]);
result.append(L","); result.append(L",");
} }
XmlUtils::replace_all( result, L"PROBEL" , L" "); XmlUtils::replace_all( result, L"PROBEL" , L" ");
XmlUtils::replace_all( result, L"TOCHKA" , L"."); XmlUtils::replace_all( result, L"TOCHKA", L".");
return result.substr(0, result.size()-1);// минус последняя лишняя запятая return result.substr(0, result.size() - 1);// минус последняя лишняя запятая
} }
odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl) odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl)
{ {
...@@ -579,6 +602,10 @@ namespace formulasconvert { ...@@ -579,6 +602,10 @@ namespace formulasconvert {
{ {
return impl_->convert_chart_distance(expr); return impl_->convert_chart_distance(expr);
} }
void odf2oox_converter::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
{
return impl_->split_distance_by(expr, by, out);
}
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator) std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
{ {
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
......
...@@ -111,16 +111,18 @@ namespace OOX ...@@ -111,16 +111,18 @@ namespace OOX
std::wstring sResult = _T("<"); std::wstring sResult = _T("<");
sResult += sNamespace; sResult += sNamespace;
sResult += _T("ext"); sResult += _T("ext");
sResult += m_sAdditionalNamespace;
if ( m_sUri.IsInit() ) if ( m_sUri.IsInit() )
{ {
sResult += _T(" uri=\""); sResult += L" uri=\"" + m_sUri.get2() + L"\"";
sResult += m_sUri.get2();
sResult += _T("\">");
} }
else
sResult += _T(">"); if (!m_sAdditionalNamespace.empty())
{
sResult += L" " + m_sAdditionalNamespace;
}
sResult += _T(">");
if(m_oCompatExt.IsInit()) if(m_oCompatExt.IsInit())
{ {
......
...@@ -110,6 +110,8 @@ namespace OOX ...@@ -110,6 +110,8 @@ namespace OOX
} }
virtual void toXML(NSStringUtils::CStringBuilder& writer) const virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{ {
if (m_arrItems.empty()) return;
writer.WriteString(_T("<externalReferences>")); writer.WriteString(_T("<externalReferences>"));
for(size_t i = 0, length = m_arrItems.size(); i < length; ++i) for(size_t i = 0, length = m_arrItems.size(); i < length; ++i)
......
...@@ -67,7 +67,7 @@ namespace OOX ...@@ -67,7 +67,7 @@ namespace OOX
WritingStringAttrString(L"type", m_oType->ToString()); WritingStringAttrString(L"type", m_oType->ToString());
if (m_oGte.IsInit() && false == m_oGte->ToBool()) if (m_oGte.IsInit() && false == m_oGte->ToBool())
writer.WriteString(L" gte=\"0\""); writer.WriteString(L" gte=\"0\"");
WritingStringNullableAttrString(L"val", m_oVal, m_oVal.get()); WritingStringNullableAttrEncodeXmlString(L"val", m_oVal, m_oVal.get());
writer.WriteString(_T("/>")); writer.WriteString(_T("/>"));
} }
} }
......
...@@ -433,8 +433,8 @@ namespace OOX ...@@ -433,8 +433,8 @@ namespace OOX
writer.WriteString(_T("<selection")); writer.WriteString(_T("<selection"));
WritingStringNullableAttrString(L"activeCell", m_oActiveCell, m_oActiveCell.get()); WritingStringNullableAttrString(L"activeCell", m_oActiveCell, m_oActiveCell.get());
WritingStringNullableAttrInt(L"activeCellId", m_oActiveCellId, m_oActiveCellId->GetValue()); WritingStringNullableAttrInt(L"activeCellId", m_oActiveCellId, m_oActiveCellId->GetValue());
WritingStringNullableAttrString(L"sqref", m_oSqref, m_oSqref.get());
WritingStringNullableAttrString(L"pane", m_oPane, m_oPane->ToString()); WritingStringNullableAttrString(L"pane", m_oPane, m_oPane->ToString());
WritingStringNullableAttrString(L"sqref", m_oSqref, m_oSqref.get());
writer.WriteString(_T("/>")); writer.WriteString(_T("/>"));
} }
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
......
...@@ -212,7 +212,7 @@ namespace BinXlsxRW { ...@@ -212,7 +212,7 @@ namespace BinXlsxRW {
pOfficeArtExtension->m_sUri.Init(); pOfficeArtExtension->m_sUri.Init();
pOfficeArtExtension->m_sUri->append(_T("{504A1905-F514-4f6f-8877-14C23A59335A}")); pOfficeArtExtension->m_sUri->append(_T("{504A1905-F514-4f6f-8877-14C23A59335A}"));
pOfficeArtExtension->m_sAdditionalNamespace = _T(" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\""); pOfficeArtExtension->m_sAdditionalNamespace = _T("xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\"");
pTable->m_oExtLst.Init(); pTable->m_oExtLst.Init();
pTable->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension); pTable->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension);
} }
...@@ -2580,7 +2580,7 @@ namespace BinXlsxRW { ...@@ -2580,7 +2580,7 @@ namespace BinXlsxRW {
pOfficeArtExtension->m_sUri.Init(); pOfficeArtExtension->m_sUri.Init();
pOfficeArtExtension->m_sUri->append(_T("{05C60535-1F16-4fd2-B633-F4F36F0B64E0}")); pOfficeArtExtension->m_sUri->append(_T("{05C60535-1F16-4fd2-B633-F4F36F0B64E0}"));
pOfficeArtExtension->m_sAdditionalNamespace = _T(" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\""); pOfficeArtExtension->m_sAdditionalNamespace = _T("xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\"");
m_pCurWorksheet->m_oExtLst.Init(); m_pCurWorksheet->m_oExtLst.Init();
m_pCurWorksheet->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension); m_pCurWorksheet->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment