Commit e1ca5a53 authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

XlsFormat - правка багов по результатам тестирования + условное форматирование (гистограмма)

parent 44e483a0
......@@ -42,6 +42,8 @@ void BoundSheet8::writeFields(CFRecord& record)
{
throw;// EXCEPT::LE::AttributeDataWrong(L"hsState", record.getTypeString().c_str(), hsState);
}
ShortXLUnicodeString stName = name_;
SETBITS(flags, 0, 1, hsState_num);
SETBITS(flags, 8, 15, dt);
record << flags << stName;
......@@ -55,13 +57,15 @@ void BoundSheet8::readFields(CFRecord& record)
if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{
ShortXLAnsiString name;
record >> name;
stName = name;
ShortXLAnsiString stName;
record >> stName;
name_ = stName.value();
}
else
{
ShortXLUnicodeString stName;
record >> stName;
name_ = stName.value();
}
switch(GETBITS(flags, 0, 1))
......@@ -76,7 +80,13 @@ void BoundSheet8::readFields(CFRecord& record)
hsState = std::wstring (L"hidden");//(L"veryHidden");
break;
}
record.getGlobalWorkbookInfo()->sheets_names.push_back(stName);
if (name_.length() > 31)
{
name_ = name_.substr(0, 31);
//cell_links_broken.xls
}
record.getGlobalWorkbookInfo()->sheets_names.push_back(name_);
record.getGlobalWorkbookInfo()->sheets_state.push_back(hsState);
dt = GETBITS(flags, 8, 15);
......
......@@ -23,11 +23,11 @@ public:
static const ElementType type = typeBoundSheet8;
//-----------------------------
ForwardOnlyParam<_UINT32> lbPlyPos;
std::wstring hsState;
unsigned char dt;
ShortXLUnicodeString stName;
//-----------------------------
std::wstring name_;
};
} // namespace XLS
......
......@@ -63,6 +63,9 @@ void CF::readFields(CFRecord& record)
int CF::serialize(std::wostream & stream)
{
if (ct != 1 && ct != 2 && ct !=6)
return 0;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"cfRule")
......
#include "CF12.h"
#include <Logic/Biff_structures/CFMultistate.h>
#include <Logic/Biff_structures/CFDatabar.h>
#include <utils.h>
namespace XLS
......@@ -64,20 +65,14 @@ void CF12::readFields(CFRecord& record)
switch(ct)
{
case 0x03:
#pragma message("####################### CFGradient structure is not implemented")
Log::info("CFGradient structure is not implemented.");
//rgbCT = BiffStructurePtr(new CFGradient);
//rgbCT->load(record);
break;
case 0x04:
#pragma message("####################### CFDatabar structure is not implemented")
Log::info("CFDatabar structure is not implemented.");
//rgbCT = BiffStructurePtr(new CFDatabar);
//rgbCT->load(record);
rgbCT = BiffStructurePtr(new CFDatabar);
rgbCT->load(record);
break;
case 0x05:
#pragma message("####################### CFFilter structure is not implemented")
Log::info("CFFilter structure is not implemented.");
//rgbCT = BiffStructurePtr(new CFFilter);
//rgbCT->load(record);
break;
......@@ -103,9 +98,10 @@ int CF12::serialize(std::wostream & stream)
{
case 1: CP_XML_ATTR(L"type", L"cellIs"); break;
case 2: CP_XML_ATTR(L"type", L"expression"); break;
case 4: CP_XML_ATTR(L"type", L"dataBar"); break;
case 6: CP_XML_ATTR(L"type", L"iconSet"); break;
}
if (ct == (unsigned char)1)
if (ct == 1)
{
switch(cp)
{
......@@ -122,16 +118,54 @@ int CF12::serialize(std::wostream & stream)
CP_XML_ATTR(L"priority", ipriority_);
CP_XML_ATTR(L"stopIfTrue", fStopIfTrue);
CP_XML_ATTR(L"dxfId", dxfId_);
CP_XML_ATTR(L"dxfId", dxfId_);
if (ct == 4)
{
CFDatabar *dataBar = dynamic_cast<CFDatabar*>(rgbCT.get());
CP_XML_NODE(L"dataBar")
{
CP_XML_NODE(L"cfvo")
{
if (dataBar->iPercentMin > 0)
CP_XML_ATTR(L"percent", dataBar->iPercentMin);
else
CP_XML_ATTR(L"type", L"min");
}
CP_XML_NODE(L"cfvo")
{
if (dataBar->iPercentMax < 100)
CP_XML_ATTR(L"percent", dataBar->iPercentMax);
else
CP_XML_ATTR(L"type", L"max");
}
CP_XML_NODE(L"color")
{
switch(dataBar->color.xclrType.type)
{
case 1: CP_XML_ATTR(L"indexed", dataBar->color.icv); break;
case 2: CP_XML_ATTR(L"rgb", dataBar->color.rgb.strARGB); break;
case 3: CP_XML_ATTR(L"theme", dataBar->color.theme);
CP_XML_ATTR(L"tint", dataBar->color.numTint); break;
default: CP_XML_ATTR(L"auto", true);
}
}
}
}
std::wstring s1 = rgce1.getAssembledFormula();
std::wstring s2 = rgce1.getAssembledFormula();
CP_XML_NODE(L"formula")
if (!s1.empty() || !s2.empty())
{
if (!s1.empty())
CP_XML_STREAM() << xml::utils::replace_text_to_xml(s1);
else if(!s2.empty())
CP_XML_STREAM() << xml::utils::replace_text_to_xml(s2);
CP_XML_NODE(L"formula")
{
if (!s1.empty())
CP_XML_STREAM() << xml::utils::replace_text_to_xml(s1);
else if(!s2.empty())
CP_XML_STREAM() << xml::utils::replace_text_to_xml(s2);
}
}
}
}
......
......@@ -23,7 +23,7 @@ BaseObjectPtr SXAddl::clone()
void SXAddl::writeFields(CFRecord& record)
{
#pragma message("####################### SXAddl record is not implemented")
Log::error("SXAddl record is not implemented.");
//Log::error("SXAddl record is not implemented.");
//record << some_value;
}
......@@ -31,7 +31,7 @@ void SXAddl::writeFields(CFRecord& record)
void SXAddl::readFields(CFRecord& record)
{
#pragma message("####################### SXAddl record is not implemented")
Log::error("SXAddl record is not implemented.");
//Log::error("SXAddl record is not implemented.");
//record >> some_value;
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
}
......
......@@ -31,7 +31,7 @@ void SXVDEx::writeFields(CFRecord& record)
void SXVDEx::readFields(CFRecord& record)
{
#pragma message("####################### SXVDEx record is not implemented")
Log::error("SXVDEx record is not implemented.");
//Log::error("SXVDEx record is not implemented.");
//record >> some_value;
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
}
......
......@@ -31,7 +31,7 @@ void SXVI::writeFields(CFRecord& record)
void SXVI::readFields(CFRecord& record)
{
#pragma message("####################### SXVI record is not implemented")
Log::error("SXVI record is not implemented.");
//Log::error("SXVI record is not implemented.");
//record >> some_value;
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
}
......
......@@ -31,7 +31,7 @@ void Sxvd::writeFields(CFRecord& record)
void Sxvd::readFields(CFRecord& record)
{
#pragma message("####################### Sxvd record is not implemented")
Log::error("Sxvd record is not implemented.");
//Log::error("Sxvd record is not implemented.");
//record >> some_value;
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
......
......@@ -25,15 +25,13 @@ BiffStructurePtr CFColor::clone()
void CFColor::store(CFRecord& record)
{
#pragma message("####################### CFColor record has no BiffStructure::store() implemented")
Log::error(" Error!!! CFColor record has no BiffStructure::store() implemented.");
//record << something;
}
void CFColor::load(CFRecord& record)
{
record >> xclrType;
switch(xclrType.type)
{
case XColorType::XCLRINDEXED:
......@@ -50,7 +48,6 @@ void CFColor::load(CFRecord& record)
record.skipNunBytes(4); // ignored
break;
default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported type of XColorType.", record.getTypeString());
break;
}
record >> numTint;
......
......@@ -22,11 +22,11 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
XColorType xclrType;
ColorICV icv;
LongRGBA rgb;
ColorTheme theme;
double numTint;
XColorType xclrType;
ColorICV icv;
LongRGBA rgb;
ColorTheme theme;
double numTint;
};
} // namespace XLS
......
#include "CFDatabar.h"
#include <Binary/CFRecord.h>
namespace XLS
{
BiffStructurePtr CFDatabar::clone()
{
return BiffStructurePtr(new CFDatabar(*this));
}
void CFDatabar::store(CFRecord& record)
{
}
void CFDatabar::load(CFRecord& record)
{
record.skipNunBytes(3); // unused
unsigned char flags;
record >> flags;
fRightToLeft = GETBIT(flags, 0);
fShowValue = GETBIT(flags, 1);
record >> iPercentMin >> iPercentMax;
record >> color;
cfvoDB1.load(record);
cfvoDB2.load(record);
}
} // namespace XLS
#pragma once
#include "BiffStructure.h"
#include "CFVO.h"
#include "CFColor.h"
namespace XLS
{
class CFRecord;
class CFDatabar : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(CFDatabar)
public:
BiffStructurePtr clone();
static const ElementType type = typeCFMultistate;//todoooo
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
unsigned char iPercentMin;
unsigned char iPercentMax;
bool fShowValue;
bool fRightToLeft;
CFColor color;
CFVO cfvoDB1;
CFVO cfvoDB2;
};
typedef boost::shared_ptr<CFDatabar> CFDatabarPtr;
} // namespace XLS
......@@ -19,10 +19,9 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
private:
unsigned char cfvoType;
CFVOParsedFormula fmla;
double numValue;
unsigned char cfvoType;
CFVOParsedFormula fmla;
double numValue;
};
typedef boost::shared_ptr<CFVO> CFVOPtr;
......
......@@ -120,10 +120,7 @@ OfficeArtRecordPtr OfficeArtContainer::CreateOfficeArt(unsigned short type)
art_record = OfficeArtRecordPtr(new OfficeArtTertiaryFOPT);
break;
default:
{
Log::warning(std::wstring(L"Unknown OfficeArt record of type 0x") +
STR::int2hex_wstr(type, sizeof(type)));
}break;
break;
}
return art_record;
}
......@@ -151,28 +148,32 @@ void OfficeArtContainer::loadFields(XLS::CFRecord& record)
if(record.getRdPtr() != child_beginning_ptr + rh_child.recLen)
{
size_t record_pos = record.getRdPtr();
OfficeArtRecordHeader rh_test;
record >> rh_test;
record.RollRdPtrBack(8);//sizeof(OfficeArtRecordHeader)
OfficeArtRecordPtr test_officeArt = CreateOfficeArt(rh_test.recType);
if(record.getRdPtr() < child_beginning_ptr + rh_child.recLen)
{
Log::warning(STR::int2wstr(child_beginning_ptr + rh_child.recLen - record.getRdPtr(), 10) +
L" unsigned chars were not processed while reading from OfficeArt record of type 0x" +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)));
record.skipNunBytes(child_beginning_ptr + rh_child.recLen - record.getRdPtr());
if (record_pos + 8 < child_beginning_ptr + rh_child.recLen)
{
Log::warning(STR::int2wstr(child_beginning_ptr + rh_child.recLen - record_pos, 10) +
L" unsigned chars were not processed while reading from OfficeArt record of type 0x" +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)));
}
if (child_beginning_ptr + rh_child.recLen - record_pos == 8 && test_officeArt)
record.skipNunBytes(8);
}
else if(record.getRdPtr() > child_beginning_ptr + rh_child.recLen)
{
//throw EXCEPT::RT::WrongBiffRecord("Wrong data parsed in OfficeArt record of type 0x" +
//STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)), record.getTypeString());
Log::warning(std::wstring(L"Wrong data parsed in OfficeArt record of type 0x") +
STR::int2hex_wstr(rh_child.recType, sizeof(rh_child.recType)));
//Calculadora.xls
//test next record !!!
size_t record_pos = record.getRdPtr();
OfficeArtRecordHeader rh_test;
record >> rh_test;
record.RollRdPtrBack(8);//sizeof(OfficeArtRecordHeader)
OfficeArtRecordPtr test_officeArt = CreateOfficeArt(rh_test.recType);
if (!test_officeArt)
{
record.RollRdPtrBack( record_pos - (child_beginning_ptr + rh_child.recLen));
......
......@@ -67,7 +67,8 @@ const bool CONDFMT12::loadContent(BinProcessor& proc)
}
int CONDFMT12::serialize(std::wostream & stream)
{
if (!m_CondFmt12) return 0;
if (!m_CondFmt12) return 0;
if (m_arCF12.size() < 1) return 0;
CP_XML_WRITER(stream)
{
......
......@@ -69,7 +69,8 @@ const bool CONDFMT::loadContent(BinProcessor& proc)
}
int CONDFMT::serialize(std::wostream & stream)
{
if (!m_CondFmt) return 0;
if (!m_CondFmt) return 0;
if (m_arCF.size() < 1) return 0;
CP_XML_WRITER(stream)
{
......
......@@ -93,6 +93,104 @@ CHARTSHEETCONTENT = [WriteProtect] [SheetExt] [WebPub] *HFPicture PAGESETUP Prin
*/
const bool ChartSheetSubstream::loadContent(BinProcessor& proc)
{
// pGlobalWorkbookInfo = proc.getGlobalWorkbookInfo();
//
// if(!proc.mandatory<BOF>())
// {
// return false;
// }
// int count = 0 ;
//
// proc.optional<WriteProtect>();
// proc.optional<SheetExt>();
// proc.optional<WebPub>();
// proc.repeated<HFPicture>(0, 0);
// proc.mandatory<PAGESETUP>();
// proc.mandatory<PrintSize>();
// proc.optional<HeaderFooter>();
//
// if (proc.optional<BACKGROUND>())
// {
// m_BACKGROUND = elements_.back();
// elements_.pop_back();
// }
//
// count = proc.repeated<Fbi>(0, 0);
// while(count > 0)
// {
// m_arFbi.insert(m_arFbi.begin(), elements_.back());
// elements_.pop_back();
// count--;
// }
// count = proc.repeated<Fbi2>(0, 0);
//
// while(count > 0 && m_arFbi.empty())//???
// {
// m_arFbi.insert(m_arFbi.begin(), elements_.back());
// elements_.pop_back();
// count--;
// }
//
// proc.optional<ClrtClient>();
// proc.optional<PROTECTION_COMMON>();
// proc.optional<Palette>();
// proc.optional<SXViewLink>();
// proc.optional<PivotChartBits>();
// proc.optional<SBaseRef>();
//
// MsoDrawingGroup mso_drawing_group(true);
// proc.optional(mso_drawing_group);
//
// OBJECTS objects(true);
// if (proc.mandatory(objects))
// {
// m_OBJECTSCHART = elements_.back();
// elements_.pop_back();
// }
//
// proc.mandatory<Units>();
// if ( proc.mandatory<CHARTFORMATS>() )
// {
// m_CHARTFORMATS = elements_.back();
// elements_.pop_back();
//
// recalc((CHARTFORMATS*)m_CHARTFORMATS.get());
// }
// if ( proc.mandatory<SERIESDATA>() )
// {
// m_SERIESDATA = elements_.back();
// elements_.pop_back();
//
// recalc((SERIESDATA*)m_SERIESDATA.get());
// }
//
// count = proc.repeated<WINDOW>(0, 0);
// while(count > 0)
// {
// m_arWINDOW.insert(m_arWINDOW.begin(), elements_.back());
// elements_.pop_back();
// count--;
// }
//
// count = proc.repeated<CUSTOMVIEW>(0, 0);
// while(count > 0)
// {
// m_arCUSTOMVIEW.insert(m_arCUSTOMVIEW.begin(), elements_.back());
// elements_.pop_back();
// count--;
// }
//
// proc.optional<CodeName>();
// proc.optional<CRTMLFRT>();
//
//#pragma message("####################### Some trash records may be skipped here")
// proc.SeekToEOF(); // Thus we skip problems with the trash at the end of the stream (found in Domens.xls)
//
// proc.mandatory<EOF_T>();
//
// return true;
//------------------------------------------------------------------------------
pGlobalWorkbookInfo = proc.getGlobalWorkbookInfo();
int count = 0 ;
......@@ -106,7 +204,9 @@ const bool ChartSheetSubstream::loadContent(BinProcessor& proc)
{
CFRecordType::TypeId type = proc.getNextRecordType();
if (type == rt_NONE) break;
//Log::warning(CFRecordType::getStringById(type));
if (type == rt_NONE || type == rt_BOF ) break;
if (type == rt_EOF)
{
proc.mandatory<EOF_T>();
......@@ -248,14 +348,6 @@ const bool ChartSheetSubstream::loadContent(BinProcessor& proc)
}
}
#pragma message("####################### Some trash records may be skipped here")
proc.SeekToEOF(); // Thus we skip problems with the trash at the end of the stream (found in Domens.xls)
proc.mandatory<EOF_T>();
return true;
}
......
......@@ -3145,6 +3145,14 @@
RelativePath="..\XlsFormat\Logic\Biff_structures\CFColor.h"
>
</File>
<File
RelativePath="..\XlsFormat\Logic\Biff_structures\CFDatabar.cpp"
>
</File>
<File
RelativePath="..\XlsFormat\Logic\Biff_structures\CFDatabar.h"
>
</File>
<File
RelativePath="..\XlsFormat\Logic\Biff_structures\CFExNonCF12.cpp"
>
......
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