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

XlsFile2 bug 24747

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63981 954022d7-b5bf-4e40-9824-e11837661b57
parent 9c84b61c
......@@ -29,7 +29,10 @@ void DefColWidth::writeFields(CFRecord& record)
void DefColWidth::readFields(CFRecord& record)
{
GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo();
record >> cchdefColWidth;
global_info->defaultColumnWidth = cchdefColWidth ;
}
} // namespace XLS
......
......@@ -41,6 +41,8 @@ void DefaultRowHeight::writeFields(CFRecord& record)
void DefaultRowHeight::readFields(CFRecord& record)
{
GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo();
unsigned short flags;
record >> flags;
fUnsynced = GETBIT(flags, 0);
......@@ -50,10 +52,12 @@ void DefaultRowHeight::readFields(CFRecord& record)
if(!fDyZero)
{
record >> miyRw;
global_info->defaultRowHeight = miyRw / 20.;
}
else
{
record >> miyRwHidden;
global_info->defaultRowHeight = miyRwHidden / 20.;
}
}
......
......@@ -81,7 +81,7 @@ int XF::serialize(std::wostream & stream)
if (ifmt.value())
{
CP_XML_ATTR(L"numFmtId" , *ifmt.value());
CP_XML_ATTR(L"numFmtId" , ifmt);
}
if(fStyle)
......@@ -91,7 +91,7 @@ int XF::serialize(std::wostream & stream)
}
else
{
CP_XML_ATTR(L"xfId" , *ixfParent.value() );
CP_XML_ATTR(L"xfId" , ixfParent );
CP_XML_ATTR(L"borderId" , cell.border_x_id);
CP_XML_ATTR(L"fillId" , cell.fill_x_id);
}
......
......@@ -69,8 +69,8 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
// read OfficeArtBlipPNG, OfficeArtBlipJPG ...
record >> rc_header;
size_t skipLen = 0;
bool isCompressed = false;
bool dumpToFile = true;
recType = rc_header.recType;
switch (rc_header.recType)
......@@ -135,6 +135,7 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
isCompressed = true;
readCompressedData(record, metafileHeader);
}
pict_type = L".wmf";///???? todooo
}
break;
case OfficeArtRecord::BlipJPEG:
......@@ -169,6 +170,7 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
}
break;
case OfficeArtRecord::BlipDIB:
pict_type = L"dib_data";
if (rc_header.recInstance == 0x7A8)
{
skipLen = 17;
......@@ -183,7 +185,6 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
record.RollRdPtrBack(32);
}
dumpToFile = false;
break;
case OfficeArtRecord::BlipTIFF:
pict_type = L".tiff";
......@@ -217,7 +218,6 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
else
result = true;
if (dumpToFile)
{
pict_data = new char[data_size];
memcpy(pict_data, record.getCurData<char>(), data_size);
......
......@@ -23,6 +23,7 @@ XLS::BiffStructurePtr OfficeArtClientAnchorSheet::clone()
int OfficeArtClientAnchorSheet::serialize(std::wostream &stream)
{
//-------------------------------------------------
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"xdr:from")
......@@ -33,7 +34,7 @@ int OfficeArtClientAnchorSheet::serialize(std::wostream &stream)
}
CP_XML_NODE(L"xdr:colOff")
{
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(dxL * 256);
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(_dxL );
}
CP_XML_NODE(L"xdr:row")
{
......@@ -41,7 +42,7 @@ int OfficeArtClientAnchorSheet::serialize(std::wostream &stream)
}
CP_XML_NODE(L"xdr:rowOff")
{
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(dyT * 256);
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(_dyT);
}
}
CP_XML_NODE(L"xdr:to")
......@@ -52,7 +53,7 @@ int OfficeArtClientAnchorSheet::serialize(std::wostream &stream)
}
CP_XML_NODE(L"xdr:colOff")
{
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(dxR * 256);
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(_dxR );
}
CP_XML_NODE(L"xdr:row")
{
......@@ -60,7 +61,7 @@ int OfficeArtClientAnchorSheet::serialize(std::wostream &stream)
}
CP_XML_NODE(L"xdr:rowOff")
{
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(dyB * 256);
CP_XML_STREAM() << boost::lexical_cast<std::wstring>(_dyB);
}
}
}
......@@ -78,15 +79,31 @@ void OfficeArtClientAnchorSheet::storeFields(XLS::CFRecord& record)
void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record)
{
XLS::GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo();
unsigned short flags;
record >> flags >> colL >> dxL >> rwT >> dyT >> colR >> dxR >> rwB >> dyB;
fMove = GETBIT(flags, 0);
fSize = GETBIT(flags, 1);
_dxL = dxL * 595;
_dyT = dyT * 744;
_dxR = dxR * 595;
_dyB = dyB * 744;
double kfRow = (global_info->defaultRowHeight * 360000 * 2.54 / 72);
double kfColumn = ( 360000 * 2.54 / 72) / 256.;
if (colL < global_info->customColumnsWidth.size())
_dxL = dxL * kfColumn * global_info->customColumnsWidth[colL];
else
_dxL = dxL * kfColumn * global_info->defaultColumnWidth;
if (colR < global_info->customColumnsWidth.size())
_dxR = dxR * kfColumn * global_info->customColumnsWidth[colR];
else
_dxR = dxR * kfColumn * global_info->defaultColumnWidth;
_dyT = dyT * kfRow / 256. ;
_dyB = dyB * kfRow / 256 ; //744;
}
......
......@@ -25,6 +25,8 @@ void OfficeArtRecord::store(XLS::CFRecord& record)
void OfficeArtRecord::load(XLS::CFRecord& record)
{
m_pGlobalWorkbookInfoPtr = record.getGlobalWorkbookInfo();
record >> rh_own;
loadFields(record);
}
......
......@@ -6,6 +6,9 @@
namespace XLS
{
class CFRecord;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
}
......@@ -81,6 +84,8 @@ public:
CA_Chart,
CA_HF
};
XLS::GlobalWorkbookInfoPtr m_pGlobalWorkbookInfoPtr;
};
typedef boost::shared_ptr<OfficeArtRecord> OfficeArtRecordPtr;
......
......@@ -56,7 +56,7 @@ BiffStructurePtr XLUnicodeRichExtendedString::clone()
int XLUnicodeRichExtendedString::serialize (std::wostream & _stream)
{
int start_string = 0;
int Fmt = 0;
int Fmt = 0; // !!! .. - .
CP_XML_WRITER(_stream)
{
......
......@@ -75,21 +75,101 @@ int CELL_GROUP::serialize(std::wostream & stream)
CP_XML_WRITER(stream)
{
std::list<XLS::BaseObjectPtr>::iterator current_cell_start = elements_.begin();
int current_row = 0;
for (std::list<XLS::BaseObjectPtr>::iterator it_row = m_rows.begin(); it_row != m_rows.end(); it_row++)
std::list<XLS::BaseObjectPtr>::iterator current_row = m_rows.begin();
int current_row_number = 0;
//for (std::list<XLS::BaseObjectPtr>::iterator it_row = m_rows.begin(); it_row != m_rows.end(); it_row++)
//{
// Row * row = dynamic_cast<Row *>(it_row->get());
//
// if (row == NULL) continue;
// CP_XML_NODE(L"row")
// {
// current_row = *row->rw.value();
//
// CP_XML_ATTR(L"r", current_row + 1);
//
// bool xf_set = true;
// if ((row->fGhostDirty.value()) && ( *row->fGhostDirty.value()== false)) xf_set = false;
//
// if (row->ixfe_val.value() && xf_set)
// {
// CP_XML_ATTR(L"s", row->ixfe_val - cellStyleXfs_count);
// CP_XML_ATTR(L"customFormat", true);
// }
// if (row->miyRw.value())
// {
// CP_XML_ATTR(L"ht", row->miyRw / 20.);
// CP_XML_ATTR(L"customHeight", true);
// }
// if ((row->iOutLevel.value()) && (row->iOutLevel > 0))
// {
// CP_XML_ATTR(L"outlineLevel", row->iOutLevel);
// }
// if ((row->fCollapsed.value()) && (row->fCollapsed))
// {
// CP_XML_ATTR(L"collapsed", row->fCollapsed);
// }
// std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start;
// while(true)
// {
// if (it_cell == elements_.end())
// {
// current_cell_start = it_cell;
// break;
// }
// CELL * cell = dynamic_cast<CELL *>(it_cell->get());
// if (cell == NULL) continue;
// if (cell->RowNumber >current_row)
// {
// current_cell_start = it_cell;
// break;
// }
// cell->serialize(CP_XML_STREAM());
// it_cell++;
// }
// }
//}
while(current_row_number == 0)
{
Row * row = dynamic_cast<Row *>(it_row->get());
CP_XML_NODE(L"row")
{
std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start;
while(true)
{
if (it_cell == elements_.end())
{
current_cell_start = it_cell;
current_row_number = -1;
break;
}
CELL * cell = dynamic_cast<CELL *>(it_cell->get());
if (row == NULL) continue;
if (cell == NULL) continue;
CP_XML_NODE(L"row")
if (current_row_number < 1) //
{
current_row = *row->rw.value();
current_row_number = cell->RowNumber + 1; //
CP_XML_ATTR(L"r", current_row + 1);
bool skip_cells = false;
if (current_row != m_rows.end())
{
Row * row = dynamic_cast<Row *>(current_row->get());
if (row->rw + 1 < current_row_number)
{
current_row_number = row->rw + 1;
skip_cells = true;
}
CP_XML_ATTR(L"r", current_row_number);
if (row->rw + 1 == current_row_number)
{
bool xf_set = true;
if ((row->fGhostDirty.value()) && ( *row->fGhostDirty.value()== false)) xf_set = false;
......@@ -98,7 +178,6 @@ int CELL_GROUP::serialize(std::wostream & stream)
CP_XML_ATTR(L"s", row->ixfe_val - cellStyleXfs_count);
CP_XML_ATTR(L"customFormat", true);
}
if (row->miyRw.value())
{
CP_XML_ATTR(L"ht", row->miyRw / 20.);
......@@ -112,21 +191,23 @@ int CELL_GROUP::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"collapsed", row->fCollapsed);
}
std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start;
while(true)
}
current_row ++;
}
else
{
if (it_cell == elements_.end())
CP_XML_ATTR(L"r", current_row_number);
}
if (skip_cells)
{
current_cell_start = it_cell;
current_row = 0;
break;
}
CELL * cell = dynamic_cast<CELL *>(it_cell->get());
if (cell == NULL) continue;
if (cell->RowNumber >current_row)
}
if (cell->RowNumber + 1 > current_row_number)
{
current_cell_start = it_cell;
current_row_number = 0;
break;
}
cell->serialize(CP_XML_STREAM());
......@@ -134,40 +215,41 @@ int CELL_GROUP::serialize(std::wostream & stream)
}
}
}
if (current_row < 1 )//order_history.xls - Row,
if ( current_row != m_rows.end())
{
while(current_row ==0)
for (std::list<XLS::BaseObjectPtr>::iterator it_row = current_row; it_row != m_rows.end(); it_row++)
{
Row * row = dynamic_cast<Row *>(it_row->get());
if (row == NULL) continue;
CP_XML_NODE(L"row")
{
std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start;
while(true)
{
if (it_cell == elements_.end())
{
current_cell_start = it_cell;
current_row = -1;
break;
}
CELL * cell = dynamic_cast<CELL *>(it_cell->get());
current_row_number = row->rw + 1;
if (cell == NULL) continue;
CP_XML_ATTR(L"r", current_row_number);
if (current_row < 1)
bool xf_set = true;
if ((row->fGhostDirty.value()) && ( *row->fGhostDirty.value()== false)) xf_set = false;
if (row->ixfe_val.value() && xf_set)
{
current_row = cell->RowNumber + 1;
CP_XML_ATTR(L"r", current_row);
CP_XML_ATTR(L"s", row->ixfe_val - cellStyleXfs_count);
CP_XML_ATTR(L"customFormat", true);
}
if (cell->RowNumber > current_row - 1)
if (row->miyRw.value())
{
current_cell_start = it_cell;
current_row = 0;
break;
CP_XML_ATTR(L"ht", row->miyRw / 20.);
CP_XML_ATTR(L"customHeight", true);
}
cell->serialize(CP_XML_STREAM());
it_cell++;
if ((row->iOutLevel.value()) && (row->iOutLevel > 0))
{
CP_XML_ATTR(L"outlineLevel", row->iOutLevel);
}
if ((row->fCollapsed.value()) && (row->fCollapsed))
{
CP_XML_ATTR(L"collapsed", row->fCollapsed);
}
}
}
......
......@@ -29,6 +29,8 @@ BaseObjectPtr COLUMNS::clone()
// COLUMNS = DefColWidth *255ColInfo
const bool COLUMNS::loadContent(BinProcessor& proc)
{
GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo();
bool def_ok = proc.optional<DefColWidth>();
// OpenOffice Calc stored files workaround (DefColWidth is mandatory according to [MS-XLS])
......@@ -40,6 +42,30 @@ const bool COLUMNS::loadContent(BinProcessor& proc)
bool col_ok = proc.repeated<ColInfo>(0, 255);
int last_add = 0;
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
ColInfo* column_info = dynamic_cast<ColInfo*>(it->get());
for (int i = last_add ; i < column_info->colFirst; i++)
{
global_info->customColumnsWidth.push_back(global_info->defaultColumnWidth);
}
for (int i = column_info->colFirst; i <= column_info->colLast; i++)
{
if (column_info->coldx.value())
{
global_info->customColumnsWidth.push_back(column_info->coldx / 256.);
}
else
{
global_info->customColumnsWidth.push_back(global_info->defaultColumnWidth);
}
}
}
return def_ok || col_ok;
}
......
......@@ -9,7 +9,6 @@
#include <Logic/Biff_records/ClrtClient.h>
#include <Logic/Biff_records/TableStyles.h>
#include <Logic/Biff_unions/TABLESTYLES.h>
#include <Logic/Biff_unions/TABLESTYLES.h>
#include <simple_xml_writer.h>
......@@ -69,7 +68,8 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
elements_.pop_back();
}
proc.repeated<DXF>(0, 0);
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
if (proc.optional<STYLES>())
{
m_Styles = elements_.back();
......
......@@ -48,9 +48,9 @@ BaseObjectPtr STYLES::clone()
// STYLES = 1*(Style [StyleExt])
const bool STYLES::loadContent(BinProcessor& proc)
{
styles_count = proc.repeated<Parenthesis_STYLES_1>(1, 0);
styles_count = proc.repeated<Parenthesis_STYLES_1>(0, 0);
return styles_count > 0 ? true : false;
return true;
}
int STYLES::serialize(std::wostream & stream)
......@@ -58,6 +58,8 @@ int STYLES::serialize(std::wostream & stream)
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"cellStyles")
{
if (styles_count > 0)
{
CP_XML_ATTR(L"count", styles_count);
......@@ -111,7 +113,17 @@ int STYLES::serialize(std::wostream & stream)
CP_XML_ATTR(L"xfId", xfId);
}
}
}
}
}
else
{
CP_XML_ATTR(L"count",1);
CP_XML_NODE(L"cellStyle")
{
CP_XML_ATTR(L"xfId", 0);
CP_XML_ATTR(L"builtinId", 0);
CP_XML_ATTR(L"name", L"");
}
}
}
......
......@@ -12,6 +12,8 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page)
last_AXES_id = initial_AXES_id;
defaultColumnWidth = 8;
defaultRowHeight = 14.4;
Version = 0x0600; // xls
}
......
......@@ -42,6 +42,11 @@ public:
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
std::vector<double> customColumnsWidth;
std::vector<double> customRowHeight;
double defaultColumnWidth;
double defaultRowHeight;
int Version;
......
......@@ -71,6 +71,8 @@ WORKSHEET = BOF WORKSHEETCONTENT
*/
const bool WorksheetSubstream::loadContent(BinProcessor& proc)
{
GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo();
int count = 0;
if(!proc.mandatory<BOF>())
......@@ -195,6 +197,8 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
proc.mandatory<EOF_T>();
global_info->customColumnsWidth.clear();
return true;
}
......
......@@ -43,6 +43,8 @@
#include <boost/lexical_cast.hpp>
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/raster/BgraFrame.h"
XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _xlsx_path, const ProgressCallback* CallBack)
{
......@@ -392,17 +394,40 @@ void XlsConverter::convert(ODRAW::OfficeArtBStoreContainer* art_bstore)
for (long i =0 ; i < art_bstore->rgfb.size(); i++)
{
int bin_id = i + 1;
if (art_bstore->rgfb[i]->data_size > 0)
if (art_bstore->rgfb[i]->data_size > 0 && art_bstore->rgfb[i]->pict_data)
{
bool res = false;
std::wstring file_name = L"image" + boost::lexical_cast<std::wstring>(bin_id);
if (art_bstore->rgfb[i]->pict_type == L"dib_data")
{
std::wstring file_name = L"image" + boost::lexical_cast<std::wstring>(bin_id) + art_bstore->rgfb[i]->pict_type;
file_name += std::wstring(L".png");
BITMAPINFOHEADER * header = (BITMAPINFOHEADER *)art_bstore->rgfb[i]->pict_data;
CBgraFrame frame;
frame.put_Data((BYTE*)art_bstore->rgfb[i]->pict_data + header->biSize);
frame.put_Height(header->biHeight);
frame.put_Width (header->biWidth);
frame.put_Stride(-header->biBitCount / 8 * header->biWidth);
res = frame.SaveFile(xl_path + FILE_SEPARATOR_STR + L"media" + FILE_SEPARATOR_STR + file_name, 4);
frame.put_Data(NULL);
}
else
{
file_name += art_bstore->rgfb[i]->pict_type;
NSFile::CFileBinary file;
if (file.CreateFileW(xl_path + FILE_SEPARATOR_STR + L"media" + FILE_SEPARATOR_STR + file_name))
{
file.WriteFile((BYTE*)art_bstore->rgfb[i]->pict_data, art_bstore->rgfb[i]->data_size);
file.CloseFile();
res = true;
}
}
if (res)
xlsx_context->get_mediaitems().add_image(L"media/" + file_name, bin_id);
}
else
......@@ -532,6 +557,22 @@ void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
{
switch(fort->fopt.rgfopte[i]->opid)
{
case 0x100:
{
xlsx_context->get_drawing_context().set_crop_top(fort->fopt.rgfopte[i]->op);
}break;
case 0x101:
{
xlsx_context->get_drawing_context().set_crop_bottom(fort->fopt.rgfopte[i]->op);
}break;
case 0x102:
{
xlsx_context->get_drawing_context().set_crop_left(fort->fopt.rgfopte[i]->op);
}break;
case 0x103:
{
xlsx_context->get_drawing_context().set_crop_right(fort->fopt.rgfopte[i]->op);
}break;
case 0x104:
{
bool isIternal = false;
......@@ -539,6 +580,17 @@ void XlsConverter::convert(ODRAW::OfficeArtFOPT * fort)
std::wstring rId = xlsx_context->get_mediaitems().find_image(fort->fopt.rgfopte[i]->op , target, isIternal);
xlsx_context->get_drawing_context().set_image(target);
}break;
case 0x105://
case 0x380:
{
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(fort->fopt.rgfopte[i].get());
xlsx_context->get_drawing_context().set_name(str->string_);
}break;
case 0x381:
{
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(fort->fopt.rgfopte[i].get());
xlsx_context->get_drawing_context().set_description(str->string_);
}break;
case 0x0382:
{
ODRAW::pihlShape *pihlShape = dynamic_cast<ODRAW::pihlShape*>(fort->fopt.rgfopte[i].get());
......
......@@ -130,7 +130,7 @@ void xlsx_drawing_context::start_shape(int type)
count_object++;
}
void xlsx_drawing_context::set_id(int id)
void xlsx_drawing_context::set_id(long id)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().id = id;
......@@ -188,7 +188,13 @@ void xlsx_drawing_context::serialize_pic(std::wstring rId)
CP_XML_NODE(L"xdr:cNvPr")
{
if (drawing_state.back().id >= 0) CP_XML_ATTR(L"id", drawing_state.back().id);
CP_XML_ATTR(L"name", L"Picture_" + rId.substr(5));
if (drawing_state.back().name.empty()) drawing_state.back().name = L"Picture_" + rId.substr(5);
CP_XML_ATTR(L"name", drawing_state.back().name);
if (!drawing_state.back().description.empty())
{
CP_XML_ATTR(L"desc", drawing_state.back().description);
}
if (!drawing_state.back().hyperlink.empty())
{
......@@ -205,7 +211,6 @@ void xlsx_drawing_context::serialize_pic(std::wstring rId)
{
CP_XML_NODE(L"a:picLocks")
{
CP_XML_ATTR(L"noChangeArrowheads", 1);
CP_XML_ATTR(L"noChangeAspect", 1);
}
}
......@@ -217,8 +222,17 @@ void xlsx_drawing_context::serialize_pic(std::wstring rId)
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:embed", rId);
}
CP_XML_NODE(L"a:srcRect");
CP_XML_NODE(L"a:srcRect")
{
if (drawing_state.back().image_crop_enabled)
{
CP_XML_ATTR(L"l", static_cast<size_t>(drawing_state.back().image_crop[0]));
CP_XML_ATTR(L"t", static_cast<size_t>(drawing_state.back().image_crop[1]));
CP_XML_ATTR(L"r", static_cast<size_t>(drawing_state.back().image_crop[2]));
CP_XML_ATTR(L"b", static_cast<size_t>(drawing_state.back().image_crop[3]));
}
}
CP_XML_NODE(L"a:stretch")
{
CP_XML_NODE(L"a:fillRect");
......@@ -258,7 +272,7 @@ void xlsx_drawing_context::serialize(std::wostream & stream)
{
CP_XML_NODE(L"xdr:twoCellAnchor")
{
CP_XML_ATTR(L"editAs", L"oneCell");
//CP_XML_ATTR(L"editAs", L"oneCell");
CP_XML_STREAM() << drawing_state.back().anchor;
CP_XML_STREAM() << drawing_state.back().shape;
......@@ -267,7 +281,16 @@ void xlsx_drawing_context::serialize(std::wostream & stream)
}
}
}
void xlsx_drawing_context::set_name(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().name = str;
}
void xlsx_drawing_context::set_description(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().description = str;
}
void xlsx_drawing_context::set_anchor(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
......@@ -279,6 +302,26 @@ void xlsx_drawing_context::set_image(std::wstring & str)
drawing_state.back().image_target = str;
}
void xlsx_drawing_context::set_crop_top (long val)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().image_crop[1] = val;
}
void xlsx_drawing_context::set_crop_bottom(long val)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().image_crop[3] = val;
}
void xlsx_drawing_context::set_crop_left (long val)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().image_crop[0]= val;
}
void xlsx_drawing_context::set_crop_right (long val)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().image_crop[2] = val;
}
void xlsx_drawing_context::set_hyperlink(std::wstring & str)
{
if (drawing_state.size() < 1 )return;
......
......@@ -27,16 +27,27 @@ private:
class _drawing_state
{
public:
_drawing_state() {isInternal = false; id = shape_id = -1; flipV = flipH = false;}
_drawing_state()
{
isInternal = false; id = shape_id = -1;
flipV = flipH = false;
memset(image_crop, 0, 4 * sizeof(int));
}
external_items::Type type;
std::wstring name;
std::wstring description;
std::wstring anchor;
std::wstring shape;
std::wstring image_target;
int image_crop[4];
bool image_crop_enabled;
int id;
int shape_id;
bool flipV;
bool flipH;
std::wstring hyperlink;
......@@ -52,8 +63,6 @@ struct _hlink_desc
class xlsx_drawing_context
{
public:
xlsx_drawing_context(xlsx_drawing_context_handle & h);
~xlsx_drawing_context(){}
......@@ -64,16 +73,23 @@ public:
void start_image();
void start_shape(int type);
void set_id ( int id);
void set_FlipH();
void set_FlipV();
void set_shape_id(int id);
void set_id (long id);
void set_FlipH ();
void set_FlipV ();
void set_shape_id (int id);
void set_name (std::wstring & str);
void set_description(std::wstring & str);
void set_crop_top (long val);
void set_crop_bottom(long val);
void set_crop_left (long val);
void set_crop_right (long val);
void set_image(std::wstring & str);
void set_anchor(std::wstring & str);
void set_properties(std::wstring & str);
void set_hyperlink(std::wstring & str);
void set_image (std::wstring & str);
void set_anchor (std::wstring & str);
void set_properties (std::wstring & str);
void set_hyperlink (std::wstring & str);
void serialize(std::wostream & stream);
......
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