Commit 473e618d authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

XlsFormatReader - расширение/уточнение условного форматирования

parent e6292fb3
#include "CF.h" #include "CF.h"
#include "CFEx.h"
#include <utils.h> #include <utils.h>
namespace XLS namespace XLS
...@@ -66,6 +68,11 @@ int CF::serialize(std::wostream & stream) ...@@ -66,6 +68,11 @@ int CF::serialize(std::wostream & stream)
if (ct != 1 && ct != 2 && ct !=6) if (ct != 1 && ct != 2 && ct !=6)
return 0; return 0;
CFEx * cfEx = dynamic_cast<CFEx *>(m_CFEx.get());
if (cfEx)
{
}
CP_XML_WRITER(stream) CP_XML_WRITER(stream)
{ {
CP_XML_NODE(L"cfRule") CP_XML_NODE(L"cfRule")
...@@ -91,12 +98,23 @@ int CF::serialize(std::wostream & stream) ...@@ -91,12 +98,23 @@ int CF::serialize(std::wostream & stream)
case 8: CP_XML_ATTR(L"operator", L"lessThanOrEqual"); break; case 8: CP_XML_ATTR(L"operator", L"lessThanOrEqual"); break;
} }
} }
CP_XML_ATTR(L"priority", ipriority_);
CP_XML_ATTR(L"priority", cfEx ? cfEx->content.ipriority_ : ipriority_);
CP_XML_ATTR(L"stopIfTrue", 1); CP_XML_ATTR(L"stopIfTrue", 1);
CP_XML_ATTR(L"dxfId", dxfId_);
if ((cfEx) && (cfEx->content.fHasDXF))
{
cfEx->content.dxf.serialize(CP_XML_STREAM());
}
else
{
CP_XML_ATTR(L"dxfId", dxfId_);
}
std::wstring s1 = rgce1.getAssembledFormula(); std::wstring s1 = rgce1.getAssembledFormula();
std::wstring s2 = rgce2.getAssembledFormula(); std::wstring s2 = rgce2.getAssembledFormula();
CP_XML_NODE(L"formula") CP_XML_NODE(L"formula")
{ {
if (!s1.empty()) if (!s1.empty())
......
...@@ -28,15 +28,16 @@ public: ...@@ -28,15 +28,16 @@ public:
//----------------------------- //-----------------------------
unsigned char ct; unsigned char ct;
unsigned char cp; unsigned char cp;
int dxfId_;
int ipriority_;
DXFN rgbdxf; DXFN rgbdxf;
CFParsedFormulaNoCCE rgce1; CFParsedFormulaNoCCE rgce1;
CFParsedFormulaNoCCE rgce2; CFParsedFormulaNoCCE rgce2;
int dxfId_; BaseObjectPtr m_CFEx;
int ipriority_;
}; };
typedef boost::shared_ptr<CF> CFPtr; typedef boost::shared_ptr<CF> CFPtr;
......
#include "CF12.h" #include "CF12.h"
#include "CFEx.h"
#include <Logic/Biff_structures/CFMultistate.h> #include <Logic/Biff_structures/CFMultistate.h>
#include <Logic/Biff_structures/CFDatabar.h> #include <Logic/Biff_structures/CFDatabar.h>
#include <utils.h> #include <utils.h>
...@@ -90,6 +92,10 @@ void CF12::readFields(CFRecord& record) ...@@ -90,6 +92,10 @@ void CF12::readFields(CFRecord& record)
} }
int CF12::serialize(std::wostream & stream) int CF12::serialize(std::wostream & stream)
{ {
CFEx * cfEx = dynamic_cast<CFEx *>(m_CFEx.get());
if (cfEx)
{
}
CP_XML_WRITER(stream) CP_XML_WRITER(stream)
{ {
CP_XML_NODE(L"cfRule") CP_XML_NODE(L"cfRule")
...@@ -154,9 +160,10 @@ int CF12::serialize(std::wostream & stream) ...@@ -154,9 +160,10 @@ int CF12::serialize(std::wostream & stream)
} }
} }
} }
// ... todooo
std::wstring s = fmlaActive.getAssembledFormula();
std::wstring s1 = rgce1.getAssembledFormula(); std::wstring s1 = rgce1.getAssembledFormula();
std::wstring s2 = rgce1.getAssembledFormula(); std::wstring s2 = rgce2.getAssembledFormula();
if (!s1.empty() || !s2.empty()) if (!s1.empty() || !s2.empty())
{ {
......
...@@ -29,6 +29,7 @@ public: ...@@ -29,6 +29,7 @@ public:
static const ElementType type = typeCF12; static const ElementType type = typeCF12;
int serialize(std::wostream & stream); int serialize(std::wostream & stream);
FrtRefHeader frtRefHeader; FrtRefHeader frtRefHeader;
unsigned char ct; unsigned char ct;
...@@ -47,11 +48,11 @@ public: ...@@ -47,11 +48,11 @@ public:
BiffStructurePtr rgbCT; BiffStructurePtr rgbCT;
//----------------------------- //-----------------------------
bool fStopIfTrue; bool fStopIfTrue;
int ipriority_;
int ipriority_; int dxfId_;
int dxfId_; BaseObjectPtr m_CFEx;
}; };
typedef boost::shared_ptr<CF12> CF12Ptr; typedef boost::shared_ptr<CF12> CF12Ptr;
......
...@@ -32,15 +32,9 @@ void CFEx::readFields(CFRecord& record) ...@@ -32,15 +32,9 @@ void CFEx::readFields(CFRecord& record)
record >> fIsCF12 >> nID; record >> fIsCF12 >> nID;
if(!fIsCF12) if(!fIsCF12)
{ {
record >> rgbContent; record >> content;
} }
} }
const unsigned short CFEx::getID() const
{
return nID;
}
} // namespace XLS } // namespace XLS
...@@ -23,13 +23,12 @@ public: ...@@ -23,13 +23,12 @@ public:
void readFields(CFRecord& record); void readFields(CFRecord& record);
static const ElementType type = typeCFEx; static const ElementType type = typeCFEx;
const unsigned short getID() const;
//----------------------------- //-----------------------------
FrtRefHeaderU frtRefHeaderU; FrtRefHeaderU frtRefHeaderU;
Boolean<unsigned int> fIsCF12; unsigned int fIsCF12;
_UINT16 nID; _UINT16 nID;
CFExNonCF12 rgbContent; CFExNonCF12 content;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -107,8 +107,8 @@ int Legend::serialize(std::wostream & _stream, int size) ...@@ -107,8 +107,8 @@ int Legend::serialize(std::wostream & _stream, int size)
if (fAutoPosX == false) CP_XML_NODE(L"c:x") {CP_XML_ATTR(L"val", x / 4000.);} if (fAutoPosX == false) CP_XML_NODE(L"c:x") {CP_XML_ATTR(L"val", x / 4000.);}
if (fAutoPosY == false) CP_XML_NODE(L"c:y") {CP_XML_ATTR(L"val", y / 4000.);} if (fAutoPosY == false) CP_XML_NODE(L"c:y") {CP_XML_ATTR(L"val", y / 4000.);}
if (fAutoPosX == false) CP_XML_NODE(L"c:w") {CP_XML_ATTR(L"val", (dx )/ 4000. + 0.01);} if (fAutoPosX == false) CP_XML_NODE(L"c:w") {CP_XML_ATTR(L"val", (dx )/ 4000. /*+ 0.01*/);}
if (fAutoPosY == false) CP_XML_NODE(L"c:h") {CP_XML_ATTR(L"val", (dy )/ 4000. + 0.01);} if (fAutoPosY == false) CP_XML_NODE(L"c:h") {CP_XML_ATTR(L"val", (dy )/ 4000. /*+ 0.01*/);}
} }
} }
CP_XML_NODE(L"c:overlay") {CP_XML_ATTR(L"val", 0);} CP_XML_NODE(L"c:overlay") {CP_XML_ATTR(L"val", 0);}
......
...@@ -55,15 +55,15 @@ void Pos::readFields(CFRecord& record) ...@@ -55,15 +55,15 @@ void Pos::readFields(CFRecord& record)
int Pos::serialize(std::wostream & _stream) int Pos::serialize(std::wostream & _stream)
{ {
bool bPosition = true; bool bAutoPosition = true;
bool bSize = true; bool bAutoSize = true;
if (m_Frame) if (m_Frame)
{ {
Frame* Frame_ = dynamic_cast<Frame*>(m_Frame.get()); Frame* Frame_ = dynamic_cast<Frame*>(m_Frame.get());
bPosition = !Frame_->fAutoPosition; bAutoPosition = !Frame_->fAutoPosition;
bSize = !Frame_->fAutoSize; bAutoSize = !Frame_->fAutoSize;
} }
double x = x1 / 4000.; double x = x1 / 4000.;
double y = y1 / 4000.; double y = y1 / 4000.;
...@@ -75,12 +75,15 @@ int Pos::serialize(std::wostream & _stream) ...@@ -75,12 +75,15 @@ int Pos::serialize(std::wostream & _stream)
{ {
CP_XML_NODE(L"c:layout") CP_XML_NODE(L"c:layout")
{ {
if (bPosition || bSize) if (bAutoSize && bAutoPosition)
{
}
else
{ {
CP_XML_NODE(L"c:manualLayout") CP_XML_NODE(L"c:manualLayout")
{ {
if (m_iLinkObject == 1) x += 0.5 + (w > 0 ? w : 0); //if (m_iLinkObject == 1) x += 0.5 + (w > 0 ? w : 0);
if (m_iLinkObject == 2) x += 0.5 + (w > 0 ? w : 0); //if (m_iLinkObject == 2) x += 0.5 + (w > 0 ? w : 0);
if (m_iLinkObject == 3) y += 0 + (h > 0 ? h : 0); if (m_iLinkObject == 3) y += 0 + (h > 0 ? h : 0);
CP_XML_NODE(L"c:xMode") {CP_XML_ATTR(L"val", L"edge");} CP_XML_NODE(L"c:xMode") {CP_XML_ATTR(L"val", L"edge");}
...@@ -89,13 +92,13 @@ int Pos::serialize(std::wostream & _stream) ...@@ -89,13 +92,13 @@ int Pos::serialize(std::wostream & _stream)
//if (x < 0) x = 0; //if (x < 0) x = 0;
//if (y < 0) y = 0; //if (y < 0) y = 0;
if (bPosition) if (!bAutoPosition)
{ {
if (x >= 0 && x < 1) CP_XML_NODE(L"c:x") {CP_XML_ATTR(L"val", x);} if (x >= 0 && x < 1) CP_XML_NODE(L"c:x") {CP_XML_ATTR(L"val", x);}
if (y >= 0 && y < 1) CP_XML_NODE(L"c:y") {CP_XML_ATTR(L"val", y);} if (y >= 0 && y < 1) CP_XML_NODE(L"c:y") {CP_XML_ATTR(L"val", y);}
} }
if (bSize && m_iLinkObject != 1 && m_iLinkObject != 2 && m_iLinkObject != 3) if (!bAutoSize && m_iLinkObject != 1 && m_iLinkObject != 2 && m_iLinkObject != 3)
//title, axis title vert, axis title horiz //title, axis title vert, axis title horiz
{ {
if (w > 0 && w < 1) CP_XML_NODE(L"c:w") {CP_XML_ATTR(L"val", w);} if (w > 0 && w < 1) CP_XML_NODE(L"c:w") {CP_XML_ATTR(L"val", w);}
......
...@@ -23,11 +23,13 @@ void CFExNonCF12::store(CFRecord& record) ...@@ -23,11 +23,13 @@ void CFExNonCF12::store(CFRecord& record)
void CFExNonCF12::load(CFRecord& record) void CFExNonCF12::load(CFRecord& record)
{ {
unsigned char flags; unsigned char flags;
record >> icf >> cp >> icfTemplate >> ipriority >> flags; record >> icf >> cp >> icfTemplate >> ipriority_ >> flags;
fActive = GETBIT(flags, 0);
fActive = GETBIT(flags, 0);
fStopIfTrue = GETBIT(flags, 1); fStopIfTrue = GETBIT(flags, 1);
record >> fHasDXF; record >> fHasDXF;
if(fHasDXF) if(fHasDXF)
{ {
record >> dxf; record >> dxf;
......
...@@ -20,18 +20,18 @@ public: ...@@ -20,18 +20,18 @@ public:
virtual void load(CFRecord& record); virtual void load(CFRecord& record);
virtual void store(CFRecord& record); virtual void store(CFRecord& record);
unsigned short icf; unsigned short icf;
unsigned char cp; unsigned char cp;
unsigned char icfTemplate; unsigned char icfTemplate;
unsigned short ipriority; unsigned short ipriority_;
bool fActive; bool fActive;
bool fStopIfTrue; bool fStopIfTrue;
Boolean<unsigned char> fHasDXF; unsigned char fHasDXF;
DXFN12 dxf; DXFN12 dxf;
CFExTemplateParams rgbTemplateParms; CFExTemplateParams rgbTemplateParms;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -38,16 +38,19 @@ void DXFN12::load(CFRecord& record) ...@@ -38,16 +38,19 @@ void DXFN12::load(CFRecord& record)
if(cbDxf) if(cbDxf)
{ {
const size_t end_of_struct_pos = record.getRdPtr() + cbDxf; const size_t start_of_struct_pos = record.getRdPtr();
const size_t end_of_struct_pos = record.getRdPtr() + cbDxf;
dxfn = DXFNPtr(new DXFN); dxfn = DXFNPtr(new DXFN);
record >> *dxfn; record >> *dxfn;
if(record.getRdPtr() < end_of_struct_pos) if(record.getRdPtr() < end_of_struct_pos)
{ {
xfext = XFExtNoFRTPtr(new XFExtNoFRT); xfext = XFExtNoFRTPtr(new XFExtNoFRT);
record >> *xfext; record >> *xfext;
} }
record.resetPointerToBegin (); // file (42).xls (sheet2)
record.skipNunBytes (end_of_struct_pos);
} }
else else
{ {
...@@ -63,15 +66,17 @@ int DXFN12::serialize(std::wostream & stream) ...@@ -63,15 +66,17 @@ int DXFN12::serialize(std::wostream & stream)
} }
else else
{ {
CP_XML_WRITER(stream) dxfn->serialize(stream);
{ //todoooo - file (42).xls
CP_XML_NODE(L"dxf") //CP_XML_WRITER(stream)
{ //{
if (xfext) // CP_XML_NODE(L"dxf")
{ // {
} // if (xfext)
} // {
} // }
// }
//}
} }
return 0; return 0;
} }
......
...@@ -41,7 +41,7 @@ void DXFNum::store(CFRecord& record) ...@@ -41,7 +41,7 @@ void DXFNum::store(CFRecord& record)
void DXFNum::load(CFRecord& record) void DXFNum::load(CFRecord& record)
{ {
if(is_user_defined_) if ((is_user_defined_) && (*is_user_defined_))
{ {
record >> user_defined; record >> user_defined;
} }
......
#include "XFProps.h" #include "XFProps.h"
#include <Binary/CFRecord.h> #include <Binary/CFRecord.h>
#include <Logic/Biff_structures/BitMarkedStructs.h>
namespace XLS namespace XLS
{ {
...@@ -33,8 +34,14 @@ void XFProps::load(CFRecord& record) ...@@ -33,8 +34,14 @@ void XFProps::load(CFRecord& record)
XFProp prop; XFProp prop;
record >> prop; record >> prop;
if (prop.xfPropType >= 0 && prop.xfPropType <= 3) arXFPropFill.push_back(prop); if (prop.xfPropType >= 0 && prop.xfPropType <= 3)
else if (prop.xfPropType == 4) arXFPropGradient.push_back(prop); {
arXFPropFill.push_back(prop);
}
else if (prop.xfPropType == 4)
{
arXFPropGradient.push_back(prop);
}
else if (prop.xfPropType >= 6 && prop.xfPropType <= 14) else if (prop.xfPropType >= 6 && prop.xfPropType <= 14)
{ {
arXFPropBorder.is_present = true; arXFPropBorder.is_present = true;
...@@ -48,10 +55,36 @@ void XFProps::load(CFRecord& record) ...@@ -48,10 +55,36 @@ void XFProps::load(CFRecord& record)
arXFPropBorder.other.push_back(prop); arXFPropBorder.other.push_back(prop);
} }
} }
else if (prop.xfPropType >= 15 && prop.xfPropType <= 22 || prop.xfPropType == 42) arXFPropAlignment.push_back(prop); else if (prop.xfPropType >= 15 && prop.xfPropType <= 22 || prop.xfPropType == 42)
else if (prop.xfPropType >= 24 && prop.xfPropType <= 37 || prop.xfPropType == 5) arXFPropFont.push_back(prop); {
else if (prop.xfPropType >= 38 && prop.xfPropType <= 41) arXFPropNumFmt.push_back(prop); arXFPropAlignment.push_back(prop);
else if (prop.xfPropType >= 43 && prop.xfPropType <= 44) arXFPropProtection.push_back(prop); }
else if (prop.xfPropType >= 24 && prop.xfPropType <= 37 || prop.xfPropType == 5)
{
arXFPropFont.push_back(prop);
}
else if (prop.xfPropType >= 38 && prop.xfPropType <= 41)
{
bool skip_codes = false;
if (prop.xfPropType == 0x0029)
{
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop.xfPropDataBlob.get());
if ((word) && (word->value() == (_UINT16)30))
{
skip_codes = true;
}
}
if (!skip_codes)
arXFPropNumFmt.push_back(prop);
}
else if (prop.xfPropType >= 43 && prop.xfPropType <= 44)
{
arXFPropProtection.push_back(prop);
}
else
{
}
} }
} }
int XFProps::serialize(std::wostream & stream) int XFProps::serialize(std::wostream & stream)
......
...@@ -69,7 +69,7 @@ int CONDFMT12::serialize(std::wostream & stream) ...@@ -69,7 +69,7 @@ int CONDFMT12::serialize(std::wostream & stream)
{ {
if (!m_CondFmt12) return 0; if (!m_CondFmt12) return 0;
if (m_arCF12.size() < 1) return 0; if (m_arCF12.size() < 1) return 0;
CP_XML_WRITER(stream) CP_XML_WRITER(stream)
{ {
CP_XML_NODE(L"conditionalFormatting") CP_XML_NODE(L"conditionalFormatting")
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include <Logic/Biff_unions/CONDFMT12.h> #include <Logic/Biff_unions/CONDFMT12.h>
#include <Logic/Biff_records/CFEx.h> #include <Logic/Biff_records/CFEx.h>
#include <Logic/Biff_records/CF12.h> #include <Logic/Biff_records/CF12.h>
#include <Logic/Biff_records/CF.h>
#include <Logic/Biff_records/CondFmt.h>
#include <Logic/Biff_records/CondFmt12.h>
namespace XLS namespace XLS
{ {
...@@ -85,6 +88,46 @@ const bool CONDFMTS::loadContent(BinProcessor& proc) ...@@ -85,6 +88,46 @@ const bool CONDFMTS::loadContent(BinProcessor& proc)
elements_.pop_back(); elements_.pop_back();
count--; count--;
} }
for (int i = 0 ; i < m_arCFEx.size(); i++)
{
if (!m_arCFEx[i]) continue;
CFEx * cfEx = dynamic_cast<CFEx *>(m_arCFEx[i].get());
if (cfEx)
{
int ind_cf = cfEx->content.icf;
for (int j = 0 ; j < m_arCONDFMT.size(); j++)
{
CONDFMT * CONDFMT_ = dynamic_cast<CONDFMT *>(m_arCONDFMT[j].get());
if (CONDFMT_/* && cfEx->fIsCF12 == 0*/)
{
CondFmt *condFmt = dynamic_cast<CondFmt *>(CONDFMT_->m_CondFmt.get());
if ((condFmt->nID == cfEx->nID) && (ind_cf < CONDFMT_->m_arCF.size()))
{
CF* cf = dynamic_cast<CF *>(CONDFMT_->m_arCF[ind_cf].get());
if (cf)
cf->m_CFEx = m_arCFEx[i];
}
}
CONDFMT12 * CONDFMT12_ = dynamic_cast<CONDFMT12 *>(m_arCONDFMT[j].get());
if (CONDFMT12_ /*&& cfEx->fIsCF12 != 0*/)
{
CondFmt12 *condFmt12 = dynamic_cast<CondFmt12 *>(CONDFMT12_->m_CondFmt12.get());
if ((condFmt12->mainCF.nID == cfEx->nID) && (ind_cf < CONDFMT12_->m_arCF12.size()))
{
CF12* cf = dynamic_cast<CF12 *>(CONDFMT12_->m_arCF12[ind_cf].get());
if (cf)
cf->m_CFEx = m_arCFEx[i];
}
}
}
}
}
return res; return res;
} }
......
...@@ -81,10 +81,10 @@ int CONDFMT::serialize(std::wostream & stream) ...@@ -81,10 +81,10 @@ int CONDFMT::serialize(std::wostream & stream)
CP_XML_ATTR(L"sqref", condFmt->sqref.sqref); CP_XML_ATTR(L"sqref", condFmt->sqref.sqref);
//condition_id //condition_id
//condition_pos //condition_pos
for (int i = 0; i < m_arCF.size(); i++) for (int i = 0; i < m_arCF.size(); i++)
{ {
if (m_arCF[i] == NULL) continue; if (m_arCF[i] == NULL) continue;
m_arCF[i]->serialize(CP_XML_STREAM()); m_arCF[i]->serialize(CP_XML_STREAM());
} }
} }
......
...@@ -608,7 +608,7 @@ int ChartSheetSubstream::serialize_title (std::wostream & _stream) ...@@ -608,7 +608,7 @@ int ChartSheetSubstream::serialize_title (std::wostream & _stream)
AI* title_text = dynamic_cast<AI *>(title_label->m_AI.get()); AI* title_text = dynamic_cast<AI *>(title_label->m_AI.get());
if (title_text == NULL) return 0; if (title_text == NULL) return 0;
if (!title_text->m_SeriesText) return 0; // placeholder if (!title_text->m_SeriesText && !title_text->m_BRAI) return 0; // placeholder
CP_XML_WRITER(_stream) CP_XML_WRITER(_stream)
{ {
...@@ -616,6 +616,13 @@ int ChartSheetSubstream::serialize_title (std::wostream & _stream) ...@@ -616,6 +616,13 @@ int ChartSheetSubstream::serialize_title (std::wostream & _stream)
{ {
attached_label->serialize(CP_XML_STREAM()); attached_label->serialize(CP_XML_STREAM());
} }
if (!title_text->m_SeriesText)
{
CP_XML_NODE(L"c:autoTitleDeleted")
{
CP_XML_ATTR (L"val" , 0);
}
}
} }
return 0; return 0;
} }
......
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