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

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

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