Commit 6e04ec28 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFormat - фикс SchetPrintForm.xls ( шаредстринг в самих ячейках +...

XlsFormat - фикс SchetPrintForm.xls ( шаредстринг в самих ячейках + неотсортированые ячейки по строкам)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67945 954022d7-b5bf-4e40-9824-e11837661b57
parent e3217e3c
......@@ -6,6 +6,7 @@ namespace XLS
Label::Label()
{
isst_ = -1;
}
......@@ -28,9 +29,35 @@ void Label::writeFields(CFRecord& record)
void Label::readFields(CFRecord& record)
{
GlobalWorkbookInfoPtr pGlobalWorkbookInfoPtr = record.getGlobalWorkbookInfo();
record >> cell >> st;
isst_ = pGlobalWorkbookInfoPtr->startAddedSharedStrings + pGlobalWorkbookInfoPtr->arAddedSharedStrings.size();
pGlobalWorkbookInfoPtr->arAddedSharedStrings.push_back(st.value());
}
int Label::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
int row = cell.rw;
std::wstring ref = cell.getLocation().toString();// getColRowRef(i, row);
CP_XML_NODE(L"c")
{
CP_XML_ATTR(L"r", ref);
CP_XML_ATTR(L"t", L"s");
CP_XML_NODE(L"v")
{
CP_XML_STREAM() << isst_;
}
}
}
return 0;
}
} // namespace XLS
......@@ -22,11 +22,15 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
int serialize(std::wostream & stream);
static const ElementType type = typeLabel;
//-----------------------------
Cell cell;
XLUnicodeString st;
//-----------------------------
int isst_;
};
} // namespace XLS
......
......@@ -87,39 +87,33 @@ int SST::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"sst")
for (int i=0; i < rgb.size(); i++)
{
CP_XML_ATTR(L"uniqueCount", rgb.size());
CP_XML_ATTR(L"xmlns", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
for (int i=0; i < rgb.size(); i++)
{
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
if (richText == NULL) continue;
CP_XML_NODE(L"si")
{
try
{
// - r-rPr-t t
if (richText->rgRun.size() >0)
{
richText->serialize(CP_XML_STREAM());
}
else
{
CP_XML_NODE(L"t")
{
CP_XML_STREAM() << STR::escape_ST_Xstring(xml::utils::replace_text_to_xml(richText->str_));
}
}
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
if (richText == NULL) continue;
CP_XML_NODE(L"si")
{
try
{
// - r-rPr-t t
if (richText->rgRun.size() >0)
{
richText->serialize(CP_XML_STREAM());
}
catch(...)
else
{
CP_XML_NODE(L"t");
CP_XML_NODE(L"t")
{
CP_XML_STREAM() << STR::escape_ST_Xstring(xml::utils::replace_text_to_xml(richText->str_));
}
}
}
catch(...)
{
CP_XML_NODE(L"t");
}
}
}
}
......
......@@ -79,8 +79,38 @@ private:
std::vector<CellRangeRef>& shared_formulas_locations_ref_;
};
bool compare_row_in_cell(const XLS::BaseObjectPtr& first, const XLS::BaseObjectPtr& second)
{
CELL * cell_1 = dynamic_cast<CELL *>(first.get());
CELL * cell_2 = dynamic_cast<CELL *>(second.get());
if (cell_1->RowNumber <= cell_2->RowNumber)
return true;
else
return false;
}
struct _CompareRowNumber
{
bool operator()(XLS::BaseObjectPtr & first, XLS::BaseObjectPtr & second)
{
CELL * cell_1 = dynamic_cast<CELL *>(first.get());
CELL * cell_2 = dynamic_cast<CELL *>(second.get());
if (!cell_1 || !cell_2)
return true;
if (cell_1->RowNumber < cell_2->RowNumber)
return true;
else
return false;
}
}CompareRowNumber;
int CELL_GROUP::serialize(std::wostream & stream)
{
elements_.sort(CompareRowNumber);
CP_XML_WRITER(stream)
{
std::list<XLS::BaseObjectPtr>::iterator current_cell_start = elements_.begin();
......
......@@ -8,6 +8,7 @@
#include <Logic/Biff_records/BoolErr.h>
#include <Logic/Biff_records/Number.h>
#include <Logic/Biff_records/LabelSst.h>
#include <Logic/Biff_records/Label.h> // SchetPrintForm.xls
namespace XLS
{
......@@ -40,6 +41,7 @@ const bool CELL::loadContent(BinProcessor& proc)
BoolErr boolerr;
Number number;
LabelSst labelsst;
Label label;
if(proc.optional(formula_union))
{
......@@ -69,6 +71,10 @@ const bool CELL::loadContent(BinProcessor& proc)
{
RowNumber = number.getLocation().getRow();
}
else if(proc.optional(label))//
{
RowNumber = label.cell.getLocation().getRow();
}
else if(proc.optional(labelsst))
{
RowNumber = labelsst.getLocation().getRow();
......
......@@ -10,6 +10,7 @@ namespace XLS
SHAREDSTRINGS::SHAREDSTRINGS(const unsigned short code_page)
: code_page_(code_page)
{
size_ = 0 ;
}
......@@ -33,6 +34,8 @@ const bool SHAREDSTRINGS::loadContent(BinProcessor& proc)
return false;
}
proc.repeated<Continue>(0, 0);
size_ = sst.rgb.size();
return true;
}
......
......@@ -22,7 +22,8 @@ public:
int serialize(std::wostream & stream);
unsigned short code_page_;
unsigned short code_page_;
unsigned int size_;
};
} // namespace XLS
......
......@@ -21,6 +21,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
currentChartWidth = 1.;
currentChartHeight = 1.;
startAddedSharedStrings = 0;
}
......
......@@ -61,6 +61,9 @@ public:
std::multimap<std::wstring, std::wstring> mapDefineNames;
std::vector<std::wstring> arDefineNames;
unsigned int startAddedSharedStrings;
std::vector<std::wstring> arAddedSharedStrings;
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
std::map<int, double> customColumnsWidth;
......
......@@ -257,6 +257,8 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
{
m_SHAREDSTRINGS = elements_.back();
elements_.pop_back();
proc.getGlobalWorkbookInfo()->startAddedSharedStrings = shared_strings.size_;
}
proc.optional<ExtSST>(); // OpenOffice Calc stored files workaround (ExtSST is mandatory according to [MS-XLS])
......
......@@ -92,7 +92,15 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
m_GLOBALS = elements_.back();
elements_.pop_back();
}
//------------------------------ SchetPrintForm.xls
if (proc.optional<Dimensions>())
{
m_Dimensions = elements_.back();
elements_.pop_back();
}
count = proc.repeated<WINDOW>(1, 0);
//----------------------------------------------
// OpenOffice Calc stored files workaround (DefColWidth is mandatory and located inside COLUMNS according to [MS-XLS])
if (proc.optional<COLUMNS>())
{
......@@ -154,7 +162,6 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
elements_.pop_back();
}
}
OBJECTS objects(false);
if (proc.optional(objects))
{
......
......@@ -45,6 +45,7 @@
#include "xlsx_package.h"
#include <simple_xml_writer.h>
#include <utils.h>
#include <boost/lexical_cast.hpp>
#include <boost/utility.hpp>
......@@ -236,7 +237,7 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook)
for (int i=0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++)
{
xlsx_context->start_table(xls_global_info->sheets_names[i]);
xlsx_context->start_table(xls_global_info->sheets_names.size() > i ? xls_global_info->sheets_names[i] : L"Sheet_" + boost::lexical_cast<std::wstring>(i+1));
if (woorkbook->m_arWorksheetSubstream[i]->get_type() == XLS::typeWorksheetSubstream)
{
......@@ -1239,11 +1240,34 @@ void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
void XlsConverter::convert(XLS::SHAREDSTRINGS* sharedstrings)
{
if (sharedstrings == NULL) return;
for (std::list<XLS::BaseObjectPtr>::iterator it = sharedstrings->elements_.begin(); it != sharedstrings->elements_.end(); it++)
int count = xls_global_info->startAddedSharedStrings + xls_global_info->arAddedSharedStrings.size();
CP_XML_WRITER(xlsx_context->shared_strings())
{
(*it)->serialize(xlsx_context->shared_strings());
CP_XML_NODE(L"sst")
{
CP_XML_ATTR(L"uniqueCount", count);
CP_XML_ATTR(L"xmlns", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
if (sharedstrings)
{
for (std::list<XLS::BaseObjectPtr>::iterator it = sharedstrings->elements_.begin(); it != sharedstrings->elements_.end(); it++)
{
(*it)->serialize(CP_XML_STREAM());
}
}
for (int i = 0 ; i < xls_global_info->arAddedSharedStrings.size(); i++)
{
CP_XML_NODE(L"si")
{
CP_XML_NODE(L"t")
{
CP_XML_ATTR(L"xml:space", "preserve");
CP_XML_STREAM() << STR::escape_ST_Xstring(xml::utils::replace_text_to_xml(xls_global_info->arAddedSharedStrings[i]));
}
}
}
}
}
}
......
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