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

XlsFormat - autofilters & custom views

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68020 954022d7-b5bf-4e40-9824-e11837661b57
parent 86274b3b
......@@ -34,21 +34,19 @@ void AutoFilter::readFields(CFRecord& record)
unsigned short flags;
record >> iEntry >> flags;
wJoin = static_cast<unsigned char>(GETBITS(flags, 0, 1));
fSimple1 = GETBIT(flags, 2);
fSimple2 = GETBIT(flags, 3);
fTopN = GETBIT(flags, 4);
fTop = GETBIT(flags, 5);
fTop = GETBIT(flags, 5); //top(1) or bottom(0)
fPercent = GETBIT(flags, 6);
wTopN = static_cast<unsigned short>(GETBITS(flags, 7, 15));
unsigned short _iEntry = iEntry;
unsigned char _wJoin = wJoin;
unsigned char _fSimple1 = fSimple1;
unsigned char _fSimple2 = fSimple2;
unsigned char _fTopN = fTopN;
unsigned char _fTop = fTop;
unsigned char _fPercent = fPercent;
unsigned short _wTopN = wTopN;
if (fTopN != 1)
......@@ -64,14 +62,31 @@ void AutoFilter::readFields(CFRecord& record)
if (doper1.vt == BIFF_BYTE(0x06))
{
str1.setSize(doper1.vtValue.cch);
record >> str1;
XLUnicodeStringNoCch s;
s.setSize(doper1.vtValue.cch);
record >> s;
str1 = s.value();
}
if (doper2.vt == BIFF_BYTE(0x06))
{
str2.setSize(doper2.vtValue.cch);
record >> str2;
XLUnicodeStringNoCch s;
s.setSize(doper2.vtValue.cch);
record >> s;
str2 = s.value();
}
if (record.getRdPtr() < record.getDataSize())
{
int sz = record.getDataSize() - record.getRdPtr();
char *dd = new char [sz];
memcpy(dd, record.getCurData<char>(), sz);
record.skipNunBytes(sz);
delete []dd;
}
}
......
......@@ -24,39 +24,25 @@ public:
static const ElementType type = typeAutoFilter;
BIFF_WORD iEntry;
BIFF_BYTE wJoin;
BIFF_BYTE fSimple1;
BIFF_BYTE fSimple2;
BIFF_BYTE fTopN;
bool fSimple1;
bool fSimple2;
bool fTopN;
bool fPercent;
BIFF_BYTE fTop;
BIFF_BYTE fPercent;
BIFF_WORD wTopN;
AFDOper doper1;
AFDOper doper2;
bool m_bAutoFilter12;
XLUnicodeStringNoCch str1;
XLUnicodeStringNoCch str2;
//-----------------------------
//if (!m_bAutoFilter12)
//{
// if (fSimple1)
// {
// //BO_ATTRIB_MARKUP_ATTRIB(str1)
// //BO_ATTRIB_MARKUP_COMPLEX(doper1)
// }
// if (fSimple2)
// {
// //BO_ATTRIB_MARKUP_ATTRIB(str2)
// //BO_ATTRIB_MARKUP_COMPLEX(doper2)
// }
//}
std::wstring str1;
std::wstring str2;
};
......
......@@ -35,17 +35,12 @@ public:
BIFF_DWORD cCriteria;
BIFF_DWORD cDateGroupings;
BIFF_DWORD idList;
BiffStructurePtrVector rgbAF12Criteries;
//-----------------------------
// BIFF_WORD userName;
//if ( (ft == BIFF_DWORD(0)) && (cCriteria > 0) )
//{
// //BO_ATTRIB_MARKUP_VECTOR_COMPLEX(rgbAF12Criteries, AF12Criteria)
//}
std::vector<BaseObjectPtr> m_arContinueFrt12;
};
......
......@@ -56,5 +56,37 @@ void Selection::readFields(CFRecord& record)
sqref = sqref_str;
}
int Selection::serialize(std::wostream & stream)
{
if (pnn == (unsigned char)PaneType::REVTPNNTOPLEFT &&
activeCell == L"A1" &&
irefAct == (_INT16)0 &&
sqref == L"A1") return 0;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"selection")
{
switch(pnn)
{
case PaneType::REVTPNNBOTRIGHT: CP_XML_ATTR(L"pane", L"bottomRight"); break;
case PaneType::REVTPNNTOPRIGHT: CP_XML_ATTR(L"pane", L"topRight"); break;
case PaneType::REVTPNNBOTLEFT: CP_XML_ATTR(L"pane", L"bottomLeft"); break;
// default: CP_XML_ATTR(L"pane", L"topLeft");
}
if (*activeCell.value() != L"A1")
CP_XML_ATTR(L"activeCell", *activeCell.value());
if (irefAct != 0)
CP_XML_ATTR(L"activeCellId", irefAct);
if (*sqref.value() != L"A1")
CP_XML_ATTR(L"sqref", *sqref.value());
}
}
return 0;
}
} // namespace XLS
......@@ -24,6 +24,8 @@ public:
static const ElementType type = typeSelection;
int serialize(std::wostream & stream);
//-----------------------------
PaneType pnn;
......
......@@ -110,6 +110,7 @@ void UserBView::readFields(CFRecord& record)
record.skipNunBytes(4); // unused1
record >> tabId;
record.skipNunBytes(2); // reserved1
_GUID_ guid_num;
record >> guid_num >> x >> y >> dx >> dy >> wTabRatio;
guid = STR::guid2bstr(guid_num);
......@@ -118,39 +119,39 @@ void UserBView::readFields(CFRecord& record)
record >> flags1;
fDspFmlaBar = GETBIT(flags1, 0);
fDspStatus = GETBIT(flags1, 1);
unsigned char mdNoteDisp_num = GETBITS(flags1, 2, 3);
switch(mdNoteDisp_num)
{
case 0x0:
mdNoteDisp = std::wstring (L"commNone");
break;
case 0x1:
mdNoteDisp = std::wstring (L"commIndicator");
break;
case 0x2:
mdNoteDisp = std::wstring (L"commIndAndComment");
break;
case 0x1:
default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of mdNoteDisp.", record.getTypeString());
mdNoteDisp = std::wstring (L"commIndicator");
break;
}
fDspHScroll = GETBIT(flags1, 4);
fDspVScroll = GETBIT(flags1, 5);
fBotAdornment = GETBIT(flags1, 6);
fZoom = GETBIT(flags1, 7);
unsigned char fHideObj_num = GETBITS(flags1, 8, 9);
switch(fHideObj_num)
{
case 0x0:
fHideObj = std::wstring (L"all");
break;
case 0x1:
fHideObj = std::wstring (L"placeholders");
break;
case 0x2:
fHideObj = std::wstring (L"none");
break;
case 0x0:
default:
throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of fHideObj.", record.getTypeString());
fHideObj = std::wstring (L"all");
break;
}
fPrintIncl = GETBIT(flags1, 10);
fRowColIncl = GETBIT(flags1, 11);
......@@ -162,11 +163,53 @@ void UserBView::readFields(CFRecord& record)
record.skipNunBytes(2); // unused2
unsigned short flags2;
record >> flags2;
fPersonalView = GETBIT(flags2, 0);
fIconic = GETBIT(flags2, 1);
record >> wMergeInterval >> st;
}
int UserBView::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"customWorkbookView")
{
if (!st.value().empty())
{
CP_XML_ATTR(L"name", st.value());
}
CP_XML_ATTR(L"windowWidth", dx);
CP_XML_ATTR(L"windowHeight", dy);
CP_XML_ATTR(L"activeSheetId", tabId);
CP_XML_ATTR(L"guid", *guid.value());
CP_XML_ATTR(L"mergeInterval", wMergeInterval);
if (fTimedUpdate) CP_XML_ATTR(L"autoUpdate" , true);
if (fAllMemChanges) CP_XML_ATTR(L"changesSavedWin" , true);
if (!fRowColIncl) CP_XML_ATTR(L"includeHiddenRowCol", false);
if (!fPrintIncl) CP_XML_ATTR(L"includePrintSettings",false);
if (fZoom) CP_XML_ATTR(L"maximized" , true);
if (fIconic) CP_XML_ATTR(L"minimized" , true);
if (fOnlySync) CP_XML_ATTR(L"onlySync" , true);
if (fPersonalView) CP_XML_ATTR(L"personalView" , true);
if (!fDspFmlaBar) CP_XML_ATTR(L"showFormulaBar" , false);
if (!fDspHScroll) CP_XML_ATTR(L"showHorizontalScroll",false);
if (!fDspVScroll) CP_XML_ATTR(L"showVerticalScroll", false);
if (!fBotAdornment) CP_XML_ATTR(L"showSheetTabs" , false);
if (!fDspStatus) CP_XML_ATTR(L"showStatusbar" , false);
if (mdNoteDisp != L"commIndicator") CP_XML_ATTR(L"showComments", mdNoteDisp);
if (fHideObj != L"all") CP_XML_ATTR(L"showObjects" , fHideObj);
if (wTabRatio != 600) CP_XML_ATTR(L"tabRatio" , wTabRatio);
if (x != 0) CP_XML_ATTR(L"xWindow" , x);
if (y != 0) CP_XML_ATTR(L"yWindow" , y);
}
}
return 0;
}
} // namespace XLS
......@@ -23,23 +23,30 @@ public:
static const ElementType type = typeUserBView;
int serialize(std::wostream & stream);
//-----------------------------
BIFF_WORD tabId;
BIFF_BSTR guid;
BIFF_DWORD x;
BIFF_DWORD y;
BIFF_DWORD dx;
BIFF_DWORD dy;
BIFF_WORD wTabRatio;
bool fDspFmlaBar;
bool fDspStatus;
BIFF_BSTR mdNoteDisp;
std::wstring mdNoteDisp;
bool fDspHScroll;
bool fDspVScroll;
bool fBotAdornment;
bool fZoom;
BIFF_BSTR fHideObj;
std::wstring fHideObj;
bool fPrintIncl;
bool fRowColIncl;
bool fInvalidTabId;
......@@ -48,14 +55,10 @@ public:
bool fOnlySync;
bool fPersonalView;
bool fIconic;
BIFF_WORD wMergeInterval;
XLUnicodeString st;
//if(fPersonalView && fTimedUpdate)
//{
// //BO_ATTRIB_MARKUP_ATTRIB(wMergeInterval)
//}
};
} // namespace XLS
......
......@@ -143,8 +143,7 @@ void UserSViewBegin::readFields(CFRecord& record)
record >> operNumX >> operNumY >> colRPane >> rwBPane;
//todooo
//pane_top_left_cell = std::wstring (CellRef(fSplitH ? rwBPane : 0 , fSplitV ? colRPane : 0, true, true).toString().c_str());
pane_top_left_cell = CellRef(fSplitH ? rwBPane : 0 , fSplitV ? colRPane : 0, true, true).toString();
}
} // namespace XLS
......
......@@ -57,13 +57,14 @@ public:
bool fPageLayoutView;
bool fRuler;
BIFF_BSTR ref8TopLeft;
std::wstring ref8TopLeft;
BIFF_DOUBLE operNumX;
BIFF_DOUBLE operNumY;
ForwardOnlyParam<unsigned short> colRPane;
ForwardOnlyParam<unsigned short> rwBPane;
BIFF_BSTR pane_top_left_cell;
std::wstring pane_top_left_cell;
};
......
......@@ -20,17 +20,6 @@ AF12Criteria::~AF12Criteria()
{
}
//
//void AF12Criteria::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// xml_tag->setAttribute(L"str", _str);
//}
//
//
//void AF12Criteria::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
//}
void AF12Criteria::store(CFRecord& record)
{
......
......@@ -24,6 +24,7 @@ public:
AFDOper doper;
XLUnicodeStringNoCch str;
BIFF_BSTR _str;
};
......
......@@ -18,6 +18,16 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & stream);
BaseObjectPtr m_AutoFilterInfo;
std::vector<BaseObjectPtr> m_arFilters;
std::map<int, std::vector<BaseObjectPtr>> m_mapFilters12;
std::vector<BaseObjectPtr> m_arSORTDATA12;
GlobalWorkbookInfoPtr pGlobalWorkbookInfoPtr;
};
} // namespace XLS
......
......@@ -37,7 +37,15 @@ public:
{
return false;
}
proc.repeated<ContinueFrt12>(0, 0);
AutoFilter12 * af12 = dynamic_cast<AutoFilter12*>(elements_.back().get());
int count = proc.repeated<ContinueFrt12>(0, 0);
while(count > 0)
{
af12->m_arContinueFrt12.insert(af12->m_arContinueFrt12.begin(), elements_.back());
elements_.pop_back();
count--;
}
}
return true;
};
......@@ -57,11 +65,132 @@ const bool AUTOFILTER::loadContent(BinProcessor& proc)
{
return false;
}
proc.repeated<Parenthesis_AUTOFILTER_1>(0, 0);
proc.repeated<SORTDATA12>(0, 0);
pGlobalWorkbookInfoPtr = proc.getGlobalWorkbookInfo();
m_AutoFilterInfo = elements_.back();
elements_.pop_back();
int count = proc.repeated<Parenthesis_AUTOFILTER_1>(0, 0);
while(count > 0)
{
if (elements_.back()->get_type() == typeAutoFilter)
{
m_arFilters.insert(m_arFilters.begin(), elements_.back());
}
else
{
AutoFilter12* af12 = dynamic_cast<AutoFilter12*>(elements_.back().get());
if (af12)
{
int ind = af12->iEntry;
std::map<int, std::vector<BaseObjectPtr>>::iterator it = m_mapFilters12.find(ind);
if (it != m_mapFilters12.end())
{
it->second.push_back(elements_.back());
}
else
{
std::vector<BaseObjectPtr> ar;
ar.push_back(elements_.back());
m_mapFilters12.insert(std::pair<int, std::vector<BaseObjectPtr>>(ind, ar));
}
}
}
elements_.pop_back();
count--;
}
count = proc.repeated<SORTDATA12>(0, 0);
while(count > 0)
{
m_arSORTDATA12.insert(m_arSORTDATA12.begin(), elements_.back());
elements_.pop_back();
count--;
}
return true;
}
int AUTOFILTER::serialize(std::wostream & stream)
{
if (m_AutoFilterInfo == NULL) return 0;
AutoFilterInfo *info = dynamic_cast<AutoFilterInfo*>(m_AutoFilterInfo.get());
std::map<std::wstring, std::vector<std::wstring>>::iterator it = pGlobalWorkbookInfoPtr->mapDefineNames.find(L"_xlnm._FilterDatabase");
if (it == pGlobalWorkbookInfoPtr->mapDefineNames.end()) return 0;
int count_columns = info->cEntries;
int ind = pGlobalWorkbookInfoPtr->current_sheet;
std::wstring ref;
if (ind < it->second.size())
ref = it->second[ind]; //from current worksheet
if (ref.empty())
{
ref = it->second[0]; //from workbook
}
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"autoFilter")
{
CP_XML_ATTR(L"ref", ref);
for (int i = 0 ; i < m_arFilters.size(); i++)//todooo - count_columns (hidden)
{
AutoFilter * filter = dynamic_cast<AutoFilter*>(m_arFilters[i].get());
CP_XML_NODE(L"filterColumn")
{
CP_XML_ATTR(L"colId", filter->iEntry);
CP_XML_NODE(L"filters")
{
if (filter->fSimple1 && !filter->str1.empty())
{
CP_XML_NODE(L"filter")
{
CP_XML_ATTR(L"val", filter->str1);
}
}
if (filter->fSimple2 && !filter->str2.empty())
{
CP_XML_NODE(L"filter")
{
CP_XML_ATTR(L"val", filter->str2);
}
}
std::map<int, std::vector<BaseObjectPtr>>::iterator itF = m_mapFilters12.find(filter->iEntry);
if (itF != m_mapFilters12.end())
{
for (int j = 0 ; j < itF->second.size(); j++)
{
AutoFilter12* af12 = dynamic_cast<AutoFilter12*>(itF->second[j].get());
if (af12 == NULL) continue;
for (int k = 0 ; k < af12->rgbAF12Criteries.size(); k++)
{
AF12Criteria * af12Criteria = dynamic_cast<AF12Criteria *>(af12->rgbAF12Criteries[k].get());
if (af12Criteria == NULL) continue;
CP_XML_NODE(L"filter")
{
CP_XML_ATTR(L"val", *af12Criteria->_str.value());
}
}
}
}
}
}
}
}
}
return 0;
}
} // namespace XLS
......@@ -50,29 +50,119 @@ const bool CUSTOMVIEW::loadContent(BinProcessor& proc)
{
return false;
}
proc.repeated<Selection>(0, 2);
m_UserSView = elements_.back();
elements_.pop_back();
int count = proc.repeated<Selection>(0, 0);
while(count > 0)
{
m_arSelection.insert(m_arSelection.begin(), elements_.back());
elements_.pop_back();
count--;
}
proc.optional<HorizontalPageBreaks>();
proc.optional<VerticalPageBreaks>();
proc.optional<Header>();
proc.optional<Footer>();
proc.optional<HCenter>();
proc.optional<VCenter>();
proc.optional<LeftMargin>();
proc.optional<RightMargin>();
proc.optional<TopMargin>();
proc.optional<BottomMargin>();
Pls pls(proc.getParent());
proc.optional(pls);//??????
if (proc.optional(pls))//??????
{
m_pls = elements_.back();
elements_.pop_back();
}
proc.optional<Setup>();
proc.optional<PrintSize>();
proc.optional<HeaderFooter>();
proc.optional<AUTOFILTER>();
if (proc.optional<AUTOFILTER>())
{
m_AUTOFILTER = elements_.back();
elements_.pop_back();
}
proc.mandatory<UserSViewEnd>();
return true;
}
int CUSTOMVIEW::serialize(std::wostream & stream)
{
if (m_UserSView == NULL) return 0;
UserSViewBegin* userSView = dynamic_cast<UserSViewBegin*>(m_UserSView.get());
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"customSheetView")
{
CP_XML_ATTR(L"guid", *userSView->guid.value());
CP_XML_ATTR(L"showGridLines", userSView->fDspGridSv);
if (userSView->wScale != 100) CP_XML_ATTR(L"scale", userSView->wScale);
if (userSView->icvHdr != 64) CP_XML_ATTR(L"colorId", userSView->icvHdr);
if (userSView->fShowBrks) CP_XML_ATTR(L"showPageBreaks", true);
if (userSView->fDspFmlaSv) CP_XML_ATTR(L"showFormulas", true);
if (userSView->fFitToPage) CP_XML_ATTR(L"fitToPage", true);
if (!userSView->fDspRwColSv) CP_XML_ATTR(L"showRowCol", false);
if (!userSView->fDspGutsSv) CP_XML_ATTR(L"outlineSymbols", false);
if (!userSView->fDspZerosSv) CP_XML_ATTR(L"zeroValues", false);
if (!userSView->fPrintArea) CP_XML_ATTR(L"printArea", false);
if (!userSView->fFilterMode) CP_XML_ATTR(L"filter", false);
if (userSView->fEzFilter) CP_XML_ATTR(L"showAutoFilter", true);
if (userSView->fHiddenRw) CP_XML_ATTR(L"hiddenRows", true);
if (userSView->fFilterUnique) CP_XML_ATTR(L"filterUnique", true);
if (!userSView->fRuler) CP_XML_ATTR(L"showRuler", false);
if (userSView->fSheetLayoutView) CP_XML_ATTR(L"view", L"pageBreakPreview");
else if (userSView->fPageLayoutView)CP_XML_ATTR(L"view", L"pageLayout");
else CP_XML_ATTR(L"view", L"normal");
if (userSView->ref8TopLeft != L"A1")CP_XML_ATTR(L"topLeftCell", userSView->ref8TopLeft);
CP_XML_NODE(L"pane")
{
if (userSView->operNumX != 0) CP_XML_ATTR(L"xSplit", userSView->operNumX);
if (userSView->operNumY != 0) CP_XML_ATTR(L"ySplit", userSView->operNumY);
if (userSView->pane_top_left_cell != L"A1")CP_XML_ATTR(L"topLeftCell", userSView->pane_top_left_cell);
switch(userSView->pnnSel)
{
case PaneType::REVTPNNBOTRIGHT: CP_XML_ATTR(L"activePane", L"bottomRight"); break;
case PaneType::REVTPNNTOPRIGHT: CP_XML_ATTR(L"activePane", L"topRight"); break;
case PaneType::REVTPNNBOTLEFT: CP_XML_ATTR(L"activePane", L"bottomLeft"); break;
//default: CP_XML_ATTR(L"activePane", L"topLeft");
}
if (userSView->fFrozen && userSView->fFrozenNoSplit)
CP_XML_ATTR(L"state", L"frozen");
else if (userSView->fFrozen && !userSView->fFrozenNoSplit)
CP_XML_ATTR(L"state", L"frozenSplit");
else
CP_XML_ATTR(L"state", L"split");
}
for (int i = 0; i < m_arSelection.size(); i++)
{
if (m_arSelection[i] == NULL) continue;
m_arSelection[i]->serialize(CP_XML_STREAM());
}
//todooo ref
//if (m_AUTOFILTER)
// m_AUTOFILTER->serialize(CP_XML_STREAM());
}
}
return 0;
}
} // namespace XLS
......@@ -20,6 +20,12 @@ public:
static const ElementType type = typeCUSTOMVIEW;
int serialize(std::wostream & stream);
BaseObjectPtr m_UserSView;
std::vector<BaseObjectPtr> m_arSelection;
BaseObjectPtr m_pls;
BaseObjectPtr m_AUTOFILTER;
};
} // namespace XLS
......
......@@ -68,28 +68,29 @@ const bool LBL::loadContent(BinProcessor& proc)
if (!value.empty() && !name.empty())
{
//bool insert = false;
//std::multimap<std::wstring, std::wstring>::iterator it = global_info_->mapDefineNames.find(name);
//
//if (it == global_info_->mapDefineNames.end())
//{
// insert = true;
//}
//else
//{
// while (it != global_info_->mapDefineNames.end())//
// {
// if (it->second != value) insert = true;
// else break;
// it++;
// }
//}
//if (insert)
int ind_sheet = lbl->itab;
std::map<std::wstring, std::vector<std::wstring>>::iterator it = global_info_->mapDefineNames.find(name);
if (it != global_info_->mapDefineNames.end())
{
global_info_->mapDefineNames.insert(std::pair<std::wstring, std::wstring>(name, value)); //
isSerialize = true;
if (ind_sheet >= it->second.size())
{
it->second.reserve(ind_sheet + 1);
}
it->second[ind_sheet] = value;
//it->second.push_back(value);
}
else
{
std::vector<std::wstring> ar(ind_sheet + 1);
ar[ind_sheet] = value;
//ar.push_back(value);
global_info_->mapDefineNames.insert(std::pair<std::wstring, std::vector<std::wstring>>(name, ar));
}
isSerialize = true;
}
else
{
......
......@@ -30,13 +30,46 @@ BaseObjectPtr SORTANDFILTER::clone()
const bool SORTANDFILTER::loadContent(BinProcessor& proc)
{
bool res1 = proc.optional<Sort>();
if (res1)
{
m_Sort = elements_.back();
elements_.pop_back();
}
bool res2 = proc.optional<SORTDATA12>();
if (res2)
{
m_SORTDATA12 = elements_.back();
elements_.pop_back();
}
bool res3 = proc.optional<FilterMode>();
if (res3)
{
m_FilterMode = elements_.back();
elements_.pop_back();
}
bool res4 = proc.optional<DropDownObjIds>();
if (res3)
{
m_DropDownObjIds = elements_.back();
elements_.pop_back();
}
bool res5 = proc.optional<AUTOFILTER>();
if (res5)
{
m_AUTOFILTER = elements_.back();
elements_.pop_back();
}
return res1 || res2 || res3 || res4 || res5;
}
int SORTANDFILTER::serialize(std::wostream & stream)
{
if (m_AUTOFILTER)
{
m_AUTOFILTER->serialize(stream);
}
return 0;
}
} // namespace XLS
......@@ -18,8 +18,15 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & stream);
static const ElementType type = typeSORTANDFILTER;
BaseObjectPtr m_Sort;
BaseObjectPtr m_SORTDATA12;
BaseObjectPtr m_FilterMode;
BaseObjectPtr m_DropDownObjIds;
BaseObjectPtr m_AUTOFILTER;
};
} // namespace XLS
......
......@@ -148,34 +148,8 @@ int WINDOW::serialize(std::wostream & stream)
}
for (int i = 0; i < m_arSelection.size(); i++)
{
Selection * selection = dynamic_cast<Selection*>(m_arSelection[i].get());
if (selection == NULL) continue;
if (selection->pnn == (unsigned char)PaneType::REVTPNNTOPLEFT &&
selection->activeCell == L"A1" &&
selection->irefAct == (_INT16)0 &&
selection->sqref == L"A1") continue;
CP_XML_NODE(L"selection")
{
switch(selection->pnn)
{
case PaneType::REVTPNNBOTRIGHT: CP_XML_ATTR(L"pane", L"bottomRight"); break;
case PaneType::REVTPNNTOPRIGHT: CP_XML_ATTR(L"pane", L"topRight"); break;
case PaneType::REVTPNNBOTLEFT: CP_XML_ATTR(L"pane", L"bottomLeft"); break;
// default: CP_XML_ATTR(L"pane", L"topLeft");
}
if (*selection->activeCell.value() != L"A1")
CP_XML_ATTR(L"activeCell", *selection->activeCell.value());
if (selection->irefAct != 0)
CP_XML_ATTR(L"activeCellId", selection->irefAct);
if (*selection->sqref.value() != L"A1")
CP_XML_ATTR(L"sqref", *selection->sqref.value());
}
if (m_arSelection[i] == NULL) continue;
m_arSelection[i]->serialize(CP_XML_STREAM());
}
}
}
......
......@@ -162,8 +162,23 @@ const bool ChartSheetSubstream::loadContent(BinProcessor& proc)
recalc((SERIESDATA*)m_SERIESDATA.get());
}
proc.repeated<WINDOW>(0, 0);
proc.repeated<CUSTOMVIEW>(0, 0);
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>();
......
......@@ -40,7 +40,8 @@ public:
BaseObjectPtr m_CHARTFORMATS;
BaseObjectPtr m_SERIESDATA;
BaseObjectPtr m_OBJECTSCHART;
std::vector<BaseObjectPtr> m_arWINDOW;
std::vector<BaseObjectPtr> m_arCUSTOMVIEW;
private:
void recalc(CHARTFORMATS* charts);
......
......@@ -19,6 +19,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
xls_converter = xls_converter_;
startAddedSharedStrings = 0;
current_sheet = 0;
}
......
......@@ -55,10 +55,11 @@ public:
std::vector<BaseObjectPtr> *m_arFonts;
unsigned int current_sheet;
unsigned int last_AXES_id;
const static unsigned int initial_AXES_id = 0x2000000;
std::multimap<std::wstring, std::wstring> mapDefineNames;
std::map<std::wstring, std::vector<std::wstring>> mapDefineNames;
std::vector<std::wstring> arDefineNames;
unsigned int startAddedSharedStrings;
......
......@@ -182,6 +182,7 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
proc.mandatory<CalcPrecision>();
proc.mandatory<RefreshAll>();
proc.mandatory<BookBool>();
if (proc.optional<Country>()) // OpenOffice Calc stored files workaround
{
m_Country = elements_.back();
......@@ -198,8 +199,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
}
proc.optional<UsesELFs>(); // OpenOffice Calc stored files workaround
proc.optional<RecalcId>(); // OpenOffice Calc stored files workaround
proc.repeated<Window1>(0, 0); // OpenOffice Calc stored files workaround
count = proc.repeated<Window1>(0, 0); // OpenOffice Calc stored files workaround
while(count > 0)
{
m_arWindow1.insert(m_arWindow1.begin(), elements_.back());
elements_.pop_back();
count--;
}
if (proc.mandatory<FORMATTING>())
{
......@@ -215,7 +222,14 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
proc.repeated<PIVOTCACHEDEFINITION>(0, 0);
proc.optional<DOCROUTE>();
proc.repeated<UserBView>(0, 0);
count = proc.repeated<UserBView>(0, 0);
while(count > 0)
{
m_arUserBView.insert(m_arUserBView.begin(), elements_.back());
elements_.pop_back();
count--;
}
proc.optional<UsesELFs>();
proc.repeated<BUNDLESHEET>(1, 0);
......
......@@ -36,6 +36,7 @@ public:
std::vector<BaseObjectPtr> m_arLBL;
std::vector<BaseObjectPtr> m_arMSODRAWINGGROUP;
std::vector<BaseObjectPtr> m_arWindow1;
std::vector<BaseObjectPtr> m_arUserBView;
unsigned short code_page_;
};
......
......@@ -70,7 +70,12 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
proc.optional<Intl>();
GLOBALS globals(false);
proc.mandatory(globals); // not dialog
if (proc.mandatory(globals)) // not dialog
{
m_GLOBALS = elements_.back();
elements_.pop_back();
}
int count = 0;
proc.mandatory<PAGESETUP>();
proc.optional<HeaderFooter>();
......@@ -78,6 +83,7 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
proc.repeated<BIGNAME>(0, 0);
proc.optional<PROTECTION_COMMON>();
proc.mandatory<COLUMNS>();
proc.mandatory<MACROSORTANDFILTER>();
proc.mandatory<Dimensions>();
......@@ -86,13 +92,24 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
proc.optional(cell_table);
OBJECTS objects(false);
proc.mandatory(objects);
if (proc.mandatory(objects))
{
m_OBJECTS = elements_.back();
elements_.pop_back();
}
proc.repeated<HFPicture>(0, 0);
proc.repeated<Note>(0, 0);
proc.optional<DCON>();
proc.repeated<WINDOW>(1, 0);
proc.repeated<CUSTOMVIEW>(0, 0);
count = proc.repeated<CUSTOMVIEW>(0, 0);
while(count > 0)
{
m_arCUSTOMVIEW.insert(m_arCUSTOMVIEW.begin(), elements_.back());
elements_.pop_back();
count--;
}
proc.repeated<SORT>(0, 2);
proc.optional<DxGCol>();
proc.optional<PHONETICINFO>();
......
......@@ -20,6 +20,10 @@ public:
static const ElementType type = typeMacroSheetSubstream;
BaseObjectPtr m_GLOBALS;
BaseObjectPtr m_OBJECTS;
std::vector<BaseObjectPtr> m_arCUSTOMVIEW;
};
} // namespace XLS
......
......@@ -249,6 +249,7 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook)
for (int i=0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++)
{
xls_global_info->current_sheet = i + 1;
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)
......@@ -322,12 +323,33 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
{
convert((XLS::HLINK*)sheet->m_arHLINK[i].get());
}
if (sheet->m_SORTANDFILTER)
{
sheet->m_SORTANDFILTER->serialize(xlsx_context->current_sheet().sheetSortAndFilters());
}
convert((XLS::OBJECTS*)sheet->m_OBJECTS.get());
if (sheet->m_PAGESETUP)
{
sheet->m_PAGESETUP->serialize(xlsx_context->current_sheet().pageProperties());
}
if (sheet->m_arCUSTOMVIEW.size() > 0)
{
CP_XML_WRITER(xlsx_context->current_sheet().customViews())
{
CP_XML_NODE(L"customSheetViews")
{
for (int i = 0 ; i < sheet->m_arCUSTOMVIEW.size(); i++)
{
sheet->m_arCUSTOMVIEW[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
void XlsConverter::convert(XLS::GlobalsSubstream* global)
......@@ -353,6 +375,10 @@ void XlsConverter::convert(XLS::GlobalsSubstream* global)
{
global->m_arWindow1[i]->serialize(xlsx_context->workbook_views());
}
for (int i = 0 ; i < global->m_arUserBView.size(); i++)
{
global->m_arUserBView[i]->serialize(xlsx_context->custom_views());
}
}
typedef boost::unordered_map<XLS::FillInfo, int> mapFillInfo;
......
......@@ -173,8 +173,8 @@ void core_file::write(const std::wstring & RootPath)
L"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" "
L"xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" >";
resStream << L"<dc:creator>ONLYOFFICE Online Editor</dc:creator>";
resStream << L"<cp:lastModifiedBy>ONLYOFFICE Online Editor</cp:lastModifiedBy>";
resStream << L"<dc:creator>ONLYOFFICE</dc:creator>";
resStream << L"<cp:lastModifiedBy>ONLYOFFICE</cp:lastModifiedBy>";
resStream << L"<cp:revision>1</cp:revision>";
resStream << L"</cp:coreProperties>";
......@@ -189,7 +189,7 @@ void app_file::write(const std::wstring & RootPath)
resStream << L"<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" "
L"xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\" >";
resStream << L"<Application>ONLYOFFICE Online Editor</Application>";
resStream << L"<Application>ONLYOFFICE Editor</Application>";
resStream << L"</Properties>";
simple_element elm(L"app.xml", resStream.str());
......
......@@ -194,6 +194,10 @@ void xlsx_conversion_context::end_document()
{
CP_XML_STREAM() << xlsx_defined_names_.str();
}
CP_XML_NODE(L"customWorkbookViews")
{
CP_XML_STREAM() << xlsx_custom_views_.str();
}
}
}
......
......@@ -38,6 +38,7 @@ public:
std::wostream & shared_strings() { return xlsx_shared_strings_; }
std::wostream & defined_names() { return xlsx_defined_names_; }
std::wostream & workbook_views() { return xlsx_workbook_views_; }
std::wostream & custom_views() { return xlsx_custom_views_; }
xlsx_text_context & get_text_context() { return xlsx_text_context_; }
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
......@@ -74,6 +75,7 @@ private:
std::wstringstream xlsx_shared_strings_;
std::wstringstream xlsx_defined_names_;
std::wstringstream xlsx_workbook_views_;
std::wstringstream xlsx_custom_views_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
//xlsx_comments_context_handle xlsx_comments_context_handle_;
......
......@@ -253,11 +253,11 @@ bool xlsx_drawing_context::start_drawing(int type)
case 0x000E: // Label
case 0x000F: // Dialog box
case 0x0010: // Spin control
case 0x0011: // Scrollbar
case 0x0012: // List
case 0x0013: // Group box
case 0x0014: // Dropdown list
start_shape(0x0002); return true;
case 0x0011: // Scrollbar
case 0x0014: // Dropdown list
case 0x0019: // Note
break;
}
......
......@@ -24,6 +24,8 @@ public:
std::wstringstream dimension_;
std::wstringstream sheetViews_;
std::wstringstream pageProperties_;
std::wstringstream sortAndFilters_;
std::wstringstream customViews_;
rels hyperlinks_rels_;
......@@ -102,6 +104,15 @@ std::wostream & xlsx_xml_worksheet::hyperlinks()
{
return impl_->hyperlinks_;
}
std::wostream & xlsx_xml_worksheet::sheetSortAndFilters()
{
return impl_->sortAndFilters_;
}
std::wostream & xlsx_xml_worksheet::customViews()
{
return impl_->customViews_;
}
//-----------------------------------------------------------------
rels & xlsx_xml_worksheet::hyperlinks_rels()
{
return impl_->hyperlinks_rels_;
......@@ -133,8 +144,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
// !!!
CP_XML_STREAM() << impl_->mergeCells_.str();
CP_XML_STREAM() << impl_->hyperlinks_.str();
CP_XML_STREAM() << impl_->sortAndFilters_.str();
CP_XML_STREAM() << impl_->customViews_.str();
CP_XML_STREAM() << impl_->pageProperties_.str();
CP_XML_STREAM() << impl_->drawing_.str();
......
......@@ -32,7 +32,9 @@ public:
std::wostream & mergeCells();
std::wostream & drawing();
std::wostream & comments();
std::wostream & sheetSortAndFilters();
std::wostream & pageProperties();
std::wostream & customViews();
rels & hyperlinks_rels();
......
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