Commit d35619ee authored by Alexey.Musinov's avatar Alexey.Musinov

Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop

* 'develop' of https://github.com/ONLYOFFICE/core:
  x2t binary - fix convert ole without vml drawing
  OdsFormat - fix absolute anchor for ole
  XlsFormat - activeX, controls & ole embedded & links
  xml string as second command-line param(first - path to xml)
  .
  --all-fonts-path param
  Added empty files
  v8 (windows correct)
  Added docbuilder target
parents b38c552c 1b91ee57
......@@ -576,11 +576,31 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
}
void xlsx_drawing_context::process_object(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
bool isMediaInternal = true;
if (drawing.type_anchor == 2) // absolute
{
//пересчет нужен для оле
xlsx_table_position from, to;
process_position_properties (obj, table_metrics, from, to);
drawing.from_.type = xlsx_drawing_position::from;
drawing.from_.position.col = from.col;
drawing.from_.position.colOff = static_cast<size_t>(odf_types::length(from.colOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
drawing.from_.position.row = from.row;
drawing.from_.position.rowOff = static_cast<size_t>(odf_types::length(from.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
drawing.to_.type = xlsx_drawing_position::to;
drawing.to_.position.col = to.col;
drawing.to_.position.colOff = static_cast<size_t>(odf_types::length(to.colOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
drawing.to_.position.row = to.row;
drawing.to_.position.rowOff = static_cast<size_t>(odf_types::length(to.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
}
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
......@@ -602,7 +622,7 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
{
xlsx_drawings_ptr xlsx_drawings_child(xlsx_drawings::create(true));
process_objects ( obj.child_objects_, table_metrics, xlsx_drawings_child);
process_group_objects ( obj.child_objects_, table_metrics, xlsx_drawings_child);
std::wstringstream strm;
......@@ -620,9 +640,9 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
}
void xlsx_drawing_context::process_objects(xlsx_table_metrics & table_metrics)
{
process_objects(impl_->objects_, table_metrics, impl_->get_drawings());
process_group_objects(impl_->objects_, table_metrics, impl_->get_drawings());
}
void xlsx_drawing_context::process_objects(std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_)
void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_)
{
for (size_t i = 0 ; i < objects.size(); i++)
{
......@@ -661,7 +681,7 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeMsObject:
case typeOleObject:
process_object ( obj, drawing, xlsx_drawings_); break;
process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
}
}
}
......
......@@ -133,13 +133,13 @@ private:
class Impl;
_CP_PTR(Impl) impl_;
void process_objects (std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_);
void process_group (drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_group_objects (std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_);
void process_image (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_chart (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_shape (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_object (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_object (drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_common_properties (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics);
......
......@@ -65,7 +65,7 @@ public:
if (sheet_rel)
{
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
for (size_t i = 0 ; i < xlsx_sheet_rels_.size(); i++)
{
if (xlsx_sheet_rels_[i].rid == rid && xlsx_sheet_rels_[i].ref == ref)
present = true;
......@@ -75,7 +75,7 @@ public:
}
else
{
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
present = true;
......@@ -89,7 +89,7 @@ public:
{
if (inGroup)
{
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(strm);
}
......@@ -114,7 +114,7 @@ public:
}
void serialize_objects(std::wostream & strm)
{
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
{
if (xlsx_drawings_[i].type != typeOleObject && xlsx_drawings_[i].type != typeMsObject) continue;
......@@ -129,7 +129,7 @@ public:
void dump_rels_drawing(rels & Rels)
{
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].type == typeImage ||
xlsx_drawing_rels_[i].type == typeMedia ||
......@@ -146,7 +146,7 @@ public:
}
void dump_rels_sheet(rels & Rels)
{
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
for (size_t i = 0 ; i < xlsx_sheet_rels_.size(); i++)
{
Rels.add(relationship( xlsx_sheet_rels_[i].rid,
mediaitems::get_rel_type(xlsx_sheet_rels_[i].type),
......
......@@ -77,6 +77,8 @@ private:
std::map<std::string, CFStreamPtr> streams;
ReadWriteMode rwMode;
};
typedef boost::shared_ptr<CompoundFile> CompoundFilePtr;
} // namespace XLS
......@@ -67,8 +67,12 @@ void MsoDrawing::readFields()
rgChildRec.rh_own.recLen = stored_record->getDataSize();
rgChildRec.loadFields(*stored_record);
if (stored_record->getRdPtr() < stored_record->getDataSize())
{
int g = 0;
}
}
isReading = true;
}
......@@ -77,6 +81,11 @@ void MsoDrawing::readFields(CFRecord& record)
record >> rgChildRec;
isReading = true;
if (record.getRdPtr() < record.getDataSize())
{
int g = 0;
}
}
......
......@@ -57,9 +57,9 @@
#define OBJ_Label 0x000E
#define OBJ_DialogBox 0x000F
#define OBJ_SpinControl 0x0010
#define OBJ_Scrollbar 0x0011
#define OBJ_List 0x0012
#define OBJ_GroupBox 0x0013
#define OBJ_Scrollbar 0x0011
#define OBJ_DropdownList 0x0014
#define OBJ_Note 0x0019
......@@ -80,7 +80,6 @@ BaseObjectPtr Obj::clone()
void Obj::readFields(CFRecord& record)
{
record >> cmo;
size_t rdPtr = record.getRdPtr();
if (record.getGlobalWorkbookInfo()->Version >= 0x0600)
{
......@@ -88,62 +87,74 @@ void Obj::readFields(CFRecord& record)
{
record.skipNunBytes(6); // Skip FtGmo (obsolete)
}
if(OBJ_Picture == cmo.ot)
if( OBJ_Picture == cmo.ot)
{
record >> pictFormat;
record >> pictFlags;
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
if( OBJ_CheckBox == cmo.ot ||
OBJ_RadioButton == cmo.ot)
{
record.skipNunBytes(16); // Skip FtCbls (obsolete)
}
if(0x0C == cmo.ot)
if( OBJ_RadioButton == cmo.ot)
{
record.skipNunBytes(10); // Skip FtRbo (obsolete)
}
if(0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot || 0x14 == cmo.ot)
if( OBJ_SpinControl == cmo.ot ||
OBJ_Scrollbar == cmo.ot ||
OBJ_List == cmo.ot ||
OBJ_DropdownList == cmo.ot)
{
record >> sbs;
}
if(0x19 == cmo.ot)
if( OBJ_Note == cmo.ot)
{
record >> nts;
}
//if(false) // TODO: Find out the condition
//{
// macro.load(record);
//}
if(0x0B == cmo.ot || 0x0C == cmo.ot || 0x10 == cmo.ot || 0x11 == cmo.ot || 0x12 == cmo.ot /*|| 0x14 == cmo.ot*/)
macro.load(record);
if( OBJ_Picture == cmo.ot)
{
pictFmla.load(record, pictFlags);
}
if( OBJ_CheckBox == cmo.ot ||
OBJ_RadioButton == cmo.ot ||
OBJ_SpinControl == cmo.ot ||
OBJ_Scrollbar == cmo.ot ||
OBJ_List == cmo.ot /*|| OBJ_DropdownList == cmo.ot*/)
{
linkFmla.load(record);
}
if(0x0B == cmo.ot || 0x0C == cmo.ot)
if( OBJ_CheckBox == cmo.ot ||
OBJ_RadioButton == cmo.ot)
{
checkBox.load(record);
}
if(0x0C == cmo.ot)
if( OBJ_RadioButton == cmo.ot)
{
radioButton.load(record);
}
if(0x0D == cmo.ot)
if( OBJ_EditBox == cmo.ot)
{
edit.load(record);
}
if(0x12 == cmo.ot || 0x14 == cmo.ot)
if( OBJ_List == cmo.ot ||
OBJ_DropdownList == cmo.ot)
{
list.load(record, cmo.ot);
}
if(0x13 == cmo.ot)
if( OBJ_GroupBox == cmo.ot)
{
gbo.load(record);
}
if(0x12 != cmo.ot && 0x14 != cmo.ot)
}
if( OBJ_List != cmo.ot && OBJ_DropdownList != cmo.ot)
{
record.skipNunBytes(4); // reserved
}
//------------------------------------------------------------------------------------------------------
if (continue_records.size() > 0)
{
std::list<CFRecordPtr>& recs = continue_records[rt_Continue];
......
......@@ -32,27 +32,25 @@
#pragma once
#include "BiffRecordContinued.h"
#include <Logic/Biff_structures/FtCmo.h>
#include <Logic/Biff_structures/FtCf.h>
#include <Logic/Biff_structures/FtPioGrbit.h>
#include <Logic/Biff_structures/FtSbs.h>
#include <Logic/Biff_structures/FtNts.h>
#include <Logic/Biff_structures/FtMacro.h>
#include <Logic/Biff_structures/FtPictFmla.h>
#include <Logic/Biff_structures/ObjLinkFmla.h>
#include <Logic/Biff_structures/FtCblsData.h>
#include <Logic/Biff_structures/FtRboData.h>
#include <Logic/Biff_structures/FtEdoData.h>
#include <Logic/Biff_structures/FtLbsData.h>
#include <Logic/Biff_structures/FtGboData.h>
#include <Logic/Biff_records/MsoDrawing.h>
#include "MsoDrawing.h"
#include "../Biff_structures/FtCmo.h"
#include "../Biff_structures/FtCf.h"
#include "../Biff_structures/FtPioGrbit.h"
#include "../Biff_structures/FtSbs.h"
#include "../Biff_structures/FtNts.h"
#include "../Biff_structures/FtMacro.h"
#include "../Biff_structures/FtPictFmla.h"
#include "../Biff_structures/ObjLinkFmla.h"
#include "../Biff_structures/FtCblsData.h"
#include "../Biff_structures/FtRboData.h"
#include "../Biff_structures/FtEdoData.h"
#include "../Biff_structures/FtLbsData.h"
#include "../Biff_structures/FtGboData.h"
namespace XLS
{
// Logical representation of Obj record in BIFF8
class Obj : public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(Obj)
......@@ -65,11 +63,10 @@ public:
~Obj();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeObj;
static const ElementType type = typeObj;
//-----------------------------
FtCmo cmo;
......@@ -104,8 +101,6 @@ public:
_UINT16 flag;
_UINT16 flag2;
}old_version;
};
} // namespace XLS
......
......@@ -39,12 +39,10 @@ Pls::Pls()
{
}
Pls::~Pls()
{
}
BaseObjectPtr Pls::clone()
{
return BaseObjectPtr(new Pls());
......@@ -71,9 +69,9 @@ void Pls::readFields(CFRecord& record)
}
int size = record.getDataSize() - 2;
const char* data = record.getData() + 2;
const BYTE* data = (BYTE*)record.getData() + 2;
boost::shared_array<char> buffer(new char[size]);
boost::shared_array<BYTE> buffer(new BYTE[size]);
memcpy(buffer.get(), data, size);
bin_data_id = -1;
......@@ -81,7 +79,7 @@ void Pls::readFields(CFRecord& record)
GlobalWorkbookInfo* globla_info = record.getGlobalWorkbookInfo().get();
if (globla_info)
{
globla_info->bin_data.push_back(std::pair<boost::shared_array<char>, size_t>(buffer, size));
globla_info->bin_data.push_back(std::pair<boost::shared_array<BYTE>, size_t>(buffer, size));
bin_data_id = globla_info->bin_data.size() - 1;
}
......
......@@ -31,7 +31,7 @@
*/
#pragma once
#include <Logic/Biff_records/BiffRecordContinued.h>
#include "BiffRecordContinued.h"
#if !defined(_WIN32) && !defined(_WIN64)
......@@ -109,9 +109,7 @@
namespace XLS
{
// Logical representation of Pls record in BIFF8
class Pls : public BiffRecordContinued
class Pls : public BiffRecordContinued
{
BIFF_RECORD_DEFINE_TYPE_INFO(Pls)
BASE_OBJECT_DEFINE_CLASS_NAME(Pls)
......
......@@ -32,14 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/RkRec.h>
#include <Logic/Biff_structures/Cell.h>
#include "../Biff_structures/RkRec.h"
#include "../Biff_structures/Cell.h"
namespace XLS
{
// Logical representation of RK record in BIFF8
class RK: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(RK)
......@@ -49,7 +47,6 @@ public:
~RK();
BaseObjectPtr clone();
void readFields(CFRecord& record);
......
......@@ -31,7 +31,7 @@
*/
#include "Sync.h"
#include <Logic/Biff_structures/CellRef.h>
#include "../Biff_structures/CellRef.h"
namespace XLS
{
......
......@@ -37,16 +37,22 @@
namespace XLS
{
BiffStructurePtr FtCblsData::clone()
{
return BiffStructurePtr(new FtCblsData(*this));
}
void FtCblsData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000a && cb != 0x000c)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> fChecked >> accel;
record.skipNunBytes(2); // reserved
......
......@@ -42,16 +42,20 @@ class FtCblsData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtCblsData)
public:
FtCblsData() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtCblsData;
static const ElementType type = typeFtCblsData;
virtual void load(CFRecord& record);
unsigned short fChecked;
unsigned short accel;
bool fNo3d;
bool fExist;
};
} // namespace XLS
......
......@@ -46,8 +46,7 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeFtCmo;
static const ElementType type = typeFtCmo;
unsigned short ot;
unsigned short id;
......@@ -60,7 +59,6 @@ public:
bool fUIObj;
bool fRecalcObj;
bool fRecalcObjAlways;
};
} // namespace XLS
......
......@@ -36,16 +36,22 @@
namespace XLS
{
BiffStructurePtr FtEdoData::clone()
{
return BiffStructurePtr(new FtEdoData(*this));
}
void FtEdoData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x0010 && cb != 0x0008)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> ivtEdit >> fMultiLine >> fVScroll >> id;
}
......
......@@ -43,17 +43,21 @@ class FtEdoData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtEdoData)
public:
FtEdoData() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtEdoData;
static const ElementType type = typeFtEdoData;
virtual void load(CFRecord& record);
unsigned short ivtEdit;
Boolean<unsigned short> fMultiLine;
unsigned short fVScroll;
unsigned short id;
bool fExist;
};
} // namespace XLS
......
......@@ -36,7 +36,6 @@
namespace XLS
{
BiffStructurePtr FtGboData::clone()
{
return BiffStructurePtr(new FtGboData(*this));
......@@ -44,7 +43,15 @@ BiffStructurePtr FtGboData::clone()
void FtGboData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000F && cb != 0x0006)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> accel;
record.skipNunBytes(2); // reserved
......
......@@ -43,15 +43,19 @@ class FtGboData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtGboData)
public:
FtGboData() : fExist(false)
{
}
BiffStructurePtr clone();
virtual void load(CFRecord& record);
static const ElementType type = typeFtGboData;
static const ElementType type = typeFtGboData;
unsigned short accel;
bool fNo3d;
bool fExist;
};
} // namespace XLS
......
......@@ -36,12 +36,6 @@
namespace XLS
{
FtLbsData::FtLbsData()
: fmla(false)
{
}
BiffStructurePtr FtLbsData::clone()
{
return BiffStructurePtr(new FtLbsData(*this));
......@@ -49,19 +43,27 @@ BiffStructurePtr FtLbsData::clone()
void FtLbsData::load(CFRecord& record, const unsigned short ot)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x0013)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
fmla.load(record);
unsigned short flags;
record >> cLines >> iSel >> flags >> idEdit;
fUseCB = GETBIT(flags, 0);
fValidPlex = GETBIT(flags, 1);
fValidIds = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
fUseCB = GETBIT(flags, 0);
fValidPlex = GETBIT(flags, 1);
fValidIds = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
wListSelType = GETBITS(flags, 4, 5);
lct = GETBITS(flags, 8, 15);
lct = GETBITS(flags, 8, 15);
if(0x0014 == ot)
{
......
......@@ -46,10 +46,12 @@ class FtLbsData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtLbsData)
public:
FtLbsData();
FtLbsData() : fmla(false), fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtLbsData;
static const ElementType type = typeFtLbsData;
virtual void load(CFRecord& record, const unsigned short ot);
......@@ -72,6 +74,7 @@ public:
std::vector<XLUnicodeString> rgLines;
std::vector<Boolean<unsigned char>> bsels;
bool fExist;
};
} // namespace XLS
......
......@@ -36,9 +36,7 @@
namespace XLS
{
FtMacro::FtMacro()
: fmla(false)
FtMacro::FtMacro() : fmla(false), fExist(false)
{
}
......@@ -48,14 +46,18 @@ BiffStructurePtr FtMacro::clone()
}
void FtMacro::load(CFRecord& record)
{
record.skipNunBytes(2); // reserved
short ft;
record >> ft;
if (ft != 0x0004)
{
record.RollRdPtrBack(2);
return;
}
fExist = true;
fmla.load(record);
}
} // namespace XLS
......@@ -50,8 +50,8 @@ public:
virtual void load(CFRecord& record);
ObjFmla fmla;
bool fExist;
};
} // namespace XLS
......
......@@ -37,16 +37,22 @@
namespace XLS
{
BiffStructurePtr FtNts::clone()
{
return BiffStructurePtr(new FtNts(*this));
}
void FtNts::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000d && cb != 0x0016)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
_GUID_ guid_num;
record >> guid_num >> fSharedNote;
......
......@@ -43,15 +43,19 @@ class FtNts : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtNts)
public:
FtNts() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtNts;
static const ElementType type = typeFtNts;
virtual void load(CFRecord& record);
std::wstring guid;
Boolean<unsigned short> fSharedNote;
bool fExist;
};
} // namespace XLS
......
......@@ -36,18 +36,11 @@
namespace XLS
{
FtPictFmla::FtPictFmla()
: fmla(true)
{
}
BiffStructurePtr FtPictFmla::clone()
{
return BiffStructurePtr(new FtPictFmla(*this));
}
void FtPictFmla::load(CFRecord& record, int linkSize)
{
bool bLinked = false;
......@@ -74,11 +67,8 @@ void FtPictFmla::load(CFRecord& record, int linkSize)
record >> nNameIdx;
record.skipNunBytes(12);
//const ExtName* pExtName = GetOldRoot().pExtNameBuff->GetNameByIndex( nRefIdx, nNameIdx );
// if( pExtName && pExtName->IsOLE() )
// mnStorageId = pExtName->nStorageId;
}
else if( nToken == 2)//XclTokenArrayHelper::GetTokenId( EXC_TOKID_TBL, EXC_TOKCLASS_NONE ) )
else if( nToken == 2)
{
bEmbedded = true;
......@@ -103,7 +93,17 @@ void FtPictFmla::load(CFRecord& record, int linkSize)
void FtPictFmla::load(CFRecord& record, FtPioGrbit& pictFlags)
{
record.skipNunBytes(4); // reserved
short ft, size;
record >> ft; // must be
if (ft != 0x0009)
{
record.RollRdPtrBack(2);
return;
}
fExist = true;
record >> size;
if (size < 1) return;
fmla.load(record);
......@@ -111,12 +111,11 @@ void FtPictFmla::load(CFRecord& record, FtPioGrbit& pictFlags)
{
record >> lPosInCtlStm;
}
record >> lPosInCtlStm;
if(pictFlags.fPrstm)
{
record >> cbBufInCtlStm;
}
if(pictFlags.fPrstm)
if(pictFlags.fCtl)
{
key.load(record);
}
......
......@@ -45,20 +45,25 @@ class FtPictFmla : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtPictFmla)
public:
FtPictFmla();
BiffStructurePtr clone();
FtPictFmla() : fmla(true), cbBufInCtlStm(0xffffffff), lPosInCtlStm(0xffffffff), fExist(false)
{
}
BiffStructurePtr clone();
virtual void load(CFRecord& record){}
//biff5
virtual void load(CFRecord& record, int linkSize);
//biff8
virtual void load(CFRecord& record, FtPioGrbit& pictFlags);
static const ElementType type = typeFtPictFmla;
virtual void load(CFRecord& record){}
ObjFmla fmla;
_UINT32 lPosInCtlStm;
_UINT32 cbBufInCtlStm;
PictFmlaKey key;
PictFmlaKey key;
ObjFmla fmla;
bool fExist;
};
} // namespace XLS
......
......@@ -44,28 +44,28 @@ BiffStructurePtr FtPioGrbit::clone()
void FtPioGrbit::load(CFRecord& record)
{
//record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft;
record >> cb;
record >> ft >> cb;
if (record.getDataSize() == record.getRdPtr())
if ( ft != 0x0008 || cb != 2)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
unsigned short flags;
record >> flags;
fAutoPict = GETBIT(flags, 0);
fDde = GETBIT(flags, 1);
fPrintCalc = GETBIT(flags, 2);
fIcon = GETBIT(flags, 3);
fCtl = GETBIT(flags, 4);
fPrstm = GETBIT(flags, 5);
fCamera = GETBIT(flags, 7);
fAutoPict = GETBIT(flags, 0);
fDde = GETBIT(flags, 1);
fPrintCalc = GETBIT(flags, 2);
fIcon = GETBIT(flags, 3);
fCtl = GETBIT(flags, 4);
fPrstm = GETBIT(flags, 5);
fCamera = GETBIT(flags, 7);
fDefaultSize = GETBIT(flags, 8);
fAutoLoad = GETBIT(flags, 9);
fAutoLoad = GETBIT(flags, 9);
}
......
......@@ -42,13 +42,15 @@ class FtPioGrbit : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtPioGrbit)
public:
FtPioGrbit() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtPioGrbit;
virtual void load(CFRecord& record);
bool fAutoPict;
bool fDde;
bool fPrintCalc;
......@@ -58,6 +60,8 @@ public:
bool fCamera;
bool fDefaultSize;
bool fAutoLoad;
bool fExist;
};
} // namespace XLS
......
......@@ -45,7 +45,15 @@ BiffStructurePtr FtRboData::clone()
void FtRboData::load(CFRecord& record)
{
record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
if ( ft != 0x000b && cb != 0x0006)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record >> idRadNext >> fFirstBtn;
}
......
......@@ -43,15 +43,19 @@ class FtRboData : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtRboData)
public:
FtRboData() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtRboData;
static const ElementType type = typeFtRboData;
virtual void load(CFRecord& record);
unsigned short idRadNext;
Boolean<unsigned short> fFirstBtn;
bool fExist;
};
} // namespace XLS
......
......@@ -36,7 +36,6 @@
namespace XLS
{
BiffStructurePtr FtSbs::clone()
{
return BiffStructurePtr(new FtSbs(*this));
......@@ -44,10 +43,15 @@ BiffStructurePtr FtSbs::clone()
void FtSbs::load(CFRecord& record)
{
//record.skipNunBytes(4); // reserved
unsigned short ft, cb;
record >> ft >> cb;
record >> ft;
record >> cb;
if ( ft != 0x000c && cb != 0x0014)
{
record.RollRdPtrBack(4);
return;
}
fExist = true;
record.skipNunBytes(4); // unused1
......@@ -55,10 +59,10 @@ void FtSbs::load(CFRecord& record)
record >> iVal >> iMin >> iMax >> dInc >> dPage >> fHoriz >> dxScroll >> flags;
fDraw = GETBIT(flags, 0);
fDraw = GETBIT(flags, 0);
fDrawSliderOnly = GETBIT(flags, 1);
fTrackElevator = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
fTrackElevator = GETBIT(flags, 2);
fNo3d = GETBIT(flags, 3);
}
......
......@@ -43,16 +43,15 @@ class FtSbs : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(FtSbs)
public:
FtSbs() : fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeFtSbs;
static const ElementType type = typeFtSbs;
virtual void load(CFRecord& record);
unsigned short ft;
unsigned short cb;
short iVal;
short iMin;
short iMax;
......@@ -65,6 +64,8 @@ public:
bool fDrawSliderOnly;
bool fTrackElevator;
bool fNo3d;
bool fExist;
};
} // namespace XLS
......
......@@ -126,7 +126,8 @@ void OfficeArtDgContainer::loadFields(XLS::CFRecord& record)
// m_OfficeArtSpgrContainerFileBlock = OfficeArtContainerPtr(art_container);
// child_records.erase(child_records.begin() + i,child_records.begin() + i + 1);
// }break;
default:
break;
}
}
......
......@@ -49,6 +49,8 @@ void OfficeArtRecord::load(XLS::CFRecord& record)
record >> rh_own;
loadFields(record);
//Log::warning(STR::int2str(rh_own.recType, 16));
}
......
......@@ -37,8 +37,7 @@ namespace XLS
{
ObjFmla::ObjFmla(const bool is_part_of_FtPictFmla)
: is_part_of_FtPictFmla_(is_part_of_FtPictFmla)
ObjFmla::ObjFmla(const bool is_part_of_FtPictFmla) : is_part_of_FtPictFmla_(is_part_of_FtPictFmla), bFmlaExist(false), bInfoExist(false)
{
}
......@@ -47,7 +46,6 @@ BiffStructurePtr ObjFmla::clone()
return BiffStructurePtr(new ObjFmla(*this));
}
void ObjFmla::load(CFRecord& record)
{
unsigned short cbFmla;
......@@ -56,15 +54,17 @@ void ObjFmla::load(CFRecord& record)
if(0 != cbFmla)
{
bFmlaExist = true;
fmla.load(record);
if(is_part_of_FtPictFmla_ && fmla.HasPtgTbl())
{
record >> embedInfo;
bInfoExist = true;
}
}
size_t data_size = record.getRdPtr() - start_ptr;
size_t padding_size = cbFmla - data_size;
if(0 != padding_size && (record.getRdPtr() + padding_size) <= record.getDataSize())
......
......@@ -47,17 +47,18 @@ public:
ObjFmla(const bool is_part_of_FtPictFmla);
BiffStructurePtr clone();
static const ElementType type = typeObjFmla;
static const ElementType type = typeObjFmla;
virtual void load(CFRecord& record);
ObjectParsedFormula fmla;
bool is_part_of_FtPictFmla_;
bool fmla_found;
PictFmlaEmbedInfo embedInfo;
bool bFmlaExist;
bool bInfoExist;
PictFmlaEmbedInfo embedInfo;
private:
bool is_part_of_FtPictFmla_;
};
} // namespace XLS
......
......@@ -35,13 +35,6 @@
namespace XLS
{
ObjLinkFmla::ObjLinkFmla()
: fmla(false)
{
}
BiffStructurePtr ObjLinkFmla::clone()
{
return BiffStructurePtr(new ObjLinkFmla(*this));
......@@ -49,8 +42,15 @@ BiffStructurePtr ObjLinkFmla::clone()
void ObjLinkFmla::load(CFRecord& record)
{
record.skipNunBytes(2); // reserved
unsigned short ft;
record >> ft;
if ( ft != 0x0014)
{
record.RollRdPtrBack(2);
return;
}
fExist = true;
fmla.load(record);
}
......
......@@ -43,7 +43,9 @@ class ObjLinkFmla : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(ObjLinkFmla)
public:
ObjLinkFmla();
ObjLinkFmla(): fmla(false), fExist(false)
{
}
BiffStructurePtr clone();
static const ElementType type = typeObjLinkFmla;
......@@ -51,6 +53,7 @@ public:
virtual void load(CFRecord& record);
ObjFmla fmla;
bool fExist;
};
} // namespace XLS
......
......@@ -45,8 +45,6 @@ public:
ObjectParsedFormula();
BiffStructurePtr clone();
virtual void load(CFRecord& record);
};
} // namespace XLS
......
......@@ -32,7 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/BiffString.h>
#include "BiffString.h"
namespace XLS
{
......@@ -49,7 +49,6 @@ public:
virtual void load(CFRecord& record);
XLUnicodeStringNoCch strClass;
};
......
......@@ -36,9 +36,7 @@
namespace XLS
{
PictFmlaKey::PictFmlaKey()
: fmlaLinkedCell(false), fmlaListFillRange(false)
PictFmlaKey::PictFmlaKey() : fmlaLinkedCell(false), fmlaListFillRange(false)
{
}
......@@ -49,10 +47,16 @@ BiffStructurePtr PictFmlaKey::clone()
void PictFmlaKey::load(CFRecord& record)
{
_UINT32 cbKey;
record >> cbKey;
record.skipNunBytes(cbKey); // ActiveX license key is here
if (cbKey > 0)
{
char *buf = new char[cbKey];
memcpy(buf, record.getCurData<char>(), cbKey);
keyBuf = std::string(buf, cbKey);
record.skipNunBytes(cbKey);
delete []buf;
}
fmlaLinkedCell.load(record);
fmlaListFillRange.load(record);
......
......@@ -47,13 +47,15 @@ public:
PictFmlaKey();
BiffStructurePtr clone();
static const ElementType type = typePictFmlaKey;
static const ElementType type = typePictFmlaKey;
virtual void load(CFRecord& record);
_UINT32 cbKey;
std::string keyBuf; // ActiveX license key
ObjFmla fmlaLinkedCell;
ObjFmla fmlaListFillRange;
ObjFmla fmlaLinkedCell;
ObjFmla fmlaListFillRange;
};
} // namespace XLS
......
......@@ -36,9 +36,7 @@
namespace XLS
{
PtgTbl::PtgTbl()
: Ptg(fixed_id)
PtgTbl::PtgTbl() : Ptg(fixed_id)
{
}
......@@ -59,7 +57,11 @@ void PtgTbl::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full
{
// The reference coordinates shall be obtained from row/column values.
// No textual form need but the empty line.
ptg_stack.push(L"");
//CellRef ref(row, col, true, true);
//ptg_stack.push(ref.toString());
}
......
......@@ -302,8 +302,13 @@ const bool CELLTABLE::loadContent(BinProcessor& proc)
CELL_GROUP cell_group2(shared_formulas_locations_ref_);
m_count_CELL_GROUP = proc.repeated(cell_group2, 0, 0);
proc.repeated<EntExU2>(0, 0);
int count = proc.repeated<EntExU2>(0, 0);
while(count > 0)
{
m_arEntExU2.insert(m_arEntExU2.begin(), elements_.back());
elements_.pop_back();
count--;
}
return true;
}
......
......@@ -38,7 +38,6 @@ namespace XLS
class CellRef;
// Logical representation of CELLTABLE union of records
class CELLTABLE: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(CELLTABLE)
......@@ -50,13 +49,13 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeCELLTABLE;
static const ElementType type = typeCELLTABLE;
int serialize(std::wostream & stream);
std::vector<CellRangeRef>& shared_formulas_locations_ref_;
int m_count_CELL_GROUP;
int m_count_CELL_GROUP;
std::vector<BaseObjectPtr> m_arEntExU2;
};
} // namespace XLS
......
......@@ -123,7 +123,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
bVbaProjectExist = false;
bMacrosExist = false;
idPivotCache = 0;
idPivotCache = 0;
}
GlobalWorkbookInfo::~GlobalWorkbookInfo()
......
......@@ -121,8 +121,13 @@ public:
std::map<std::wstring, std::vector<std::wstring>> mapDefineNames;
std::vector<std::wstring> arDefineNames;
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
std::vector<std::pair<boost::shared_array<unsigned char>, size_t> > bin_data;
std::pair<boost::shared_array<unsigned char>, size_t> listdata_data;
std::pair<boost::shared_array<unsigned char>, size_t> controls_data;
std::map<int, std::pair<boost::shared_array<unsigned char>, size_t> > embeddings_data; //parsing ???
std::map<int, std::pair<boost::shared_array<unsigned char>, size_t> > link_data;
struct _xti
{
int iSup;
......
......@@ -275,6 +275,7 @@ namespace oox
case msosptRectangle : return L"rect";
case msosptRoundRectangle : return L"roundRect";
case msosptEllipse : return L"ellipse";
case msosptPictureFrame : return L"rect";
//case msosptDiamond : return L"diamond";
case msosptIsocelesTriangle : return L"triangle";
//case msosptRightTriangle : return L"rtTriangle";
......
......@@ -122,9 +122,9 @@ typedef struct tagBITMAPCOREHEADER {
} BITMAPCOREHEADER;
#endif
XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _xlsx_path, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* CallBack, bool & bMacros)
XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* CallBack, bool & bMacros)
{
xlsx_path = _xlsx_path;
xlsx_path = xlsxFilePath;
output_document = NULL;
xlsx_context = NULL;
......@@ -136,9 +136,9 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
try
{
XLS::CompoundFile cfile(xls_file, XLS::CompoundFile::cf_ReadMode);
xls_file = boost::shared_ptr<XLS::CompoundFile>(new XLS::CompoundFile(xlsFileName, XLS::CompoundFile::cf_ReadMode));
if (cfile.isError())
if (xls_file->isError())
{
return;
}
......@@ -148,7 +148,7 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
try
{
summary = cfile.getNamedStream("SummaryInformation");
summary = xls_file->getNamedStream("SummaryInformation");
}
catch (...)
{
......@@ -156,7 +156,7 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
try
{
doc_summary = cfile.getNamedStream("DocumentSummaryInformation");
doc_summary = xls_file->getNamedStream("DocumentSummaryInformation");
}
catch (...)
{
......@@ -184,7 +184,7 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
xls_global_info->fontsDirectory = fontsPath;
xls_global_info->password = password;
XLS::CFStreamCacheReader stream_reader(cfile.getWorkbookStream(), xls_global_info);
XLS::CFStreamCacheReader stream_reader(xls_file->getWorkbookStream(), xls_global_info);
xls_document = boost::shared_ptr<XLS::WorkbookStreamObject>(new XLS::WorkbookStreamObject(workbook_code_page));
......@@ -197,38 +197,38 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
if (xls_global_info->decryptor->IsVerify() == false) return;
}
if (cfile.storage_->isDirectory("_SX_DB_CUR"))
if (xls_file->storage_->isDirectory("_SX_DB_CUR"))
{
std::list<std::string> listStream = cfile.storage_->entries("_SX_DB_CUR");
std::list<std::string> listStream = xls_file->storage_->entries("_SX_DB_CUR");
int last_index = 0;
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
{
XLS::CFStreamCacheReader pivot_cache_reader(cfile.getNamedStream("_SX_DB_CUR/" + *it), xls_global_info);
XLS::CFStreamCacheReader pivot_cache_reader(xls_file->getNamedStream("_SX_DB_CUR/" + *it), xls_global_info);
XLS::BaseObjectPtr pivot_cache = boost::shared_ptr<XLS::PIVOTCACHE>(new XLS::PIVOTCACHE());
XLS::BinReaderProcessor proc(pivot_cache_reader , pivot_cache.get() , true);
proc.mandatory(*pivot_cache.get());
int index = XmlUtils::GetHex(*it);
int index = XmlUtils::GetHex(*it); //hexadecimal digits uniquely identifying
xls_global_info->mapPivotCacheStream.insert(std::make_pair(index, pivot_cache));
last_index = index;
}
}
if (bMacros && cfile.storage_->isDirectory("_VBA_PROJECT_CUR"))
if (bMacros && xls_file->storage_->isDirectory("_VBA_PROJECT_CUR"))
{
std::wstring xl_path = xlsx_path + FILE_SEPARATOR_STR + L"xl";
NSDirectory::CreateDirectory(xl_path.c_str());
std::wstring sVbaProjectFile = xl_path + FILE_SEPARATOR_STR + L"vbaProject.bin";
POLE::Storage *storageVbaProject = new POLE::Storage(sVbaProjectFile.c_str());
POLE::Storage *storageVbaProject = new POLE::Storage(sVbaProjectFile.c_str());
if ((storageVbaProject) && (storageVbaProject->open(true, true)))
{
cfile.copy(0, "_VBA_PROJECT_CUR/", storageVbaProject, false);
xls_file->copy(0, "_VBA_PROJECT_CUR/", storageVbaProject, false);
storageVbaProject->close();
delete storageVbaProject;
......@@ -238,6 +238,27 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
}
else
bMacros = false;
XLS::CFStreamPtr controls = xls_file->getNamedStream("Ctls");
if(controls)
{
unsigned long size = controls->getStreamSize();
boost::shared_array<BYTE> buffer(new BYTE[size]);
controls->read(buffer.get(), size);
xls_global_info->controls_data = std::make_pair(buffer, size);
}
XLS::CFStreamPtr listdata = xls_file->getNamedStream("List Data");
if(listdata)
{
unsigned long size = controls->getStreamSize();
boost::shared_array<BYTE> buffer(new BYTE[size]);
listdata->read(buffer.get(), size);
xls_global_info->listdata_data = std::make_pair(buffer, size);
}
}
catch(...)
{
......@@ -340,6 +361,11 @@ void XlsConverter::convert(XLS::BaseObject *xls_unknown)
XLS::TxO * txo = dynamic_cast<XLS::TxO *>(xls_unknown);
convert(txo);
}break;
case XLS::typeObj:
{
XLS::Obj * obj = dynamic_cast<XLS::Obj *>(xls_unknown);
convert(obj);
}break;
case XLS::typeAnyObject:
default:
{
......@@ -673,7 +699,6 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ
bool res = false;
std::wstring file_name = L"image" + std::to_wstring(id);
if (type_ext == L"dib_data")
{
bool bPNG = false;
......@@ -925,17 +950,6 @@ void XlsConverter::convert_old(XLS::OBJECTS* objects, XLS::WorksheetSubstream *
if (type_object == 0)
continue;
//{
// _group_object gr;
// if (group_objects.back().ind < group_objects.back().spgr->child_records.size())
// {
// gr.spgr = dynamic_cast<ODRAW::OfficeArtSpgrContainer*>(group_objects.back().spgr->child_records[group_objects.back().ind++].get());
// gr.count = gr.spgr->child_records.size();
// group_objects.push_back(gr);
// }
// else //сюда попадать не должно !!!!
// continue;
//}
if (xlsx_context->get_drawing_context().start_drawing(type_object))
{
......@@ -954,9 +968,9 @@ void XlsConverter::convert_old(XLS::OBJECTS* objects, XLS::WorksheetSubstream *
{
convert(obj->old_version.additional[i].get());
}
convert(image_obj);
convert(chart);
convert(obj);
xlsx_context->get_drawing_context().end_drawing();
}
......@@ -965,13 +979,6 @@ void XlsConverter::convert_old(XLS::OBJECTS* objects, XLS::WorksheetSubstream *
elem++;
count++;
}
//while ((group_objects.size() >0) && (group_objects.back().ind >= group_objects.back().count))
//{
// group_objects.back().spgr = NULL;
// group_objects.pop_back();
//
// xlsx_context->get_drawing_context().end_group();
//}
}
}
void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * sheet)
......@@ -1086,6 +1093,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
}
convert(text_obj);
convert(chart);
convert(obj);
xlsx_context->get_drawing_context().end_drawing();
}
......@@ -1882,7 +1890,6 @@ void XlsConverter::convert(XLS::SHAREDSTRINGS* sharedstrings)
}
}
}
void XlsConverter::convert(XLS::TxO * text_obj)
{
if (text_obj == NULL) return;
......@@ -1924,6 +1931,76 @@ void XlsConverter::convert(XLS::TxO * text_obj)
xlsx_context->get_drawing_context().set_text(strm.str());
}
void XlsConverter::convert(XLS::Obj * obj)
{
if (obj == NULL) return;
//controls & objects
if (!obj->pictFlags.fExist || !obj->pictFmla.fExist || obj->cmo.ot != 8) return;
std::wstring link_cell, fill_range, fmla, info;
if (obj->pictFmla.fmla.bFmlaExist)
{
fmla = obj->pictFmla.fmla.fmla.getAssembledFormula();
if (obj->pictFmla.fmla.bInfoExist)
info = obj->pictFmla.fmla.embedInfo.strClass.value();
}
if (obj->pictFmla.key.fmlaLinkedCell.bFmlaExist)
{
link_cell = obj->pictFmla.key.fmlaLinkedCell.fmla.getAssembledFormula();
}
if (obj->pictFmla.key.fmlaListFillRange.bFmlaExist)
{
fill_range = obj->pictFmla.key.fmlaListFillRange.fmla.getAssembledFormula();
}
if (obj->pictFlags.fCtl && obj->pictFlags.fPrstm)//Controls Storage
{
xlsx_context->get_mediaitems().create_activeX_path(xlsx_path);
int id = ++xlsx_context->get_mediaitems().count_activeX;
std::wstring file_name = xlsx_context->get_mediaitems().activeX_path() + L"activeX" + std::to_wstring(id) + L".bin";
NSFile::CFileBinary file;
if ( file.CreateFileW(file_name) )
{
file.WriteFile(xls_global_info->controls_data.first.get() + obj->pictFmla.lPosInCtlStm, obj->pictFmla.cbBufInCtlStm);
file.CloseFile();
}
}
else if (!obj->pictFlags.fPrstm)
{
std::string object_stream;
if (obj->pictFlags.fDde) object_stream = "LNK";
else object_stream = "MBD";
object_stream += XmlUtils::IntToString(obj->pictFmla.lPosInCtlStm, "%08X") + "/";
if (xls_file->storage_->isDirectory(object_stream))
{
xlsx_context->get_mediaitems().create_embeddings_path(xlsx_path);
int id = ++xlsx_context->get_mediaitems().count_embeddings;
std::wstring file_name = L"oleObject" + std::to_wstring(id) + L".bin";
POLE::Storage *storageOle = new POLE::Storage((xlsx_context->get_mediaitems().embeddings_path() + file_name).c_str());
if ((storageOle) && (storageOle->open(true, true)))
{
xls_file->copy(0, object_stream, storageOle, false);
storageOle->close();
delete storageOle;
}
std::wstring objectId = L"objId" + std::to_wstring(id);
xlsx_context->current_sheet().sheet_rels().add(oox::relationship(
objectId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject", L"../embeddings/" + file_name));
xlsx_context->get_drawing_context().set_ole_object(objectId, info);
}
}
}
void XlsConverter::convert_chart_sheet(XLS::ChartSheetSubstream * chart)
{
if (chart == NULL) return;
......
......@@ -48,9 +48,12 @@ namespace oox
}
namespace XLS
{
class BaseObject;
class BiffStructure;
class CompoundFile;
typedef boost::shared_ptr<CompoundFile> CompoundFilePtr;
class BaseObject;
typedef boost::shared_ptr<BaseObject> BaseObjectPtr;
class GlobalWorkbookInfo;
......@@ -76,6 +79,7 @@ namespace XLS
class Note;
class TxO;
class Obj;
}
namespace ODRAW
......@@ -94,7 +98,7 @@ namespace ODRAW
class XlsConverter
{
public:
XlsConverter(const std::wstring & xls_file, const std::wstring & xlsx_path, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* ffCallBack, bool & bMacros);
XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* ffCallBack, bool & bMacros);
~XlsConverter() ;
oox::xlsx_conversion_context * xlsx_context;
......@@ -118,6 +122,7 @@ public:
void convert(XLS::OBJECTS * objects, XLS::WorksheetSubstream * sheet);
void convert(XLS::MSODRAWINGGROUP * mso_drawing);
void convert(XLS::TxO * text_obj);
void convert(XLS::Obj * obj);
void convert(XLS::Note * note);
void convert(XLS::IMDATA * imadata);
void convert(XLS::PIVOTVIEW * pivot_view);
......@@ -163,4 +168,6 @@ private:
XLS::BaseObjectPtr xls_document;
XLS::GlobalWorkbookInfoPtr xls_global_info;
XLS::CompoundFilePtr xls_file;
};
......@@ -169,6 +169,35 @@ void external_items::create_media_path(const std::wstring & out_path)
media_path_ = xl_path + FILE_SEPARATOR_STR + L"media" + FILE_SEPARATOR_STR;
}
std::wstring external_items::activeX_path()
{
return activeX_path_;
}
void external_items::create_activeX_path(const std::wstring & out_path)
{
if (!activeX_path_.empty()) return;
std::wstring xl_path = out_path + FILE_SEPARATOR_STR + L"xl";
NSDirectory::CreateDirectory(xl_path.c_str());
NSDirectory::CreateDirectory((xl_path + FILE_SEPARATOR_STR + L"activeX").c_str());
activeX_path_ = xl_path + FILE_SEPARATOR_STR + L"activeX" + FILE_SEPARATOR_STR;
}
void external_items::create_embeddings_path(const std::wstring & out_path)
{
if (!embeddings_path_.empty()) return;
std::wstring xl_path = out_path + FILE_SEPARATOR_STR + L"xl";
NSDirectory::CreateDirectory(xl_path.c_str());
NSDirectory::CreateDirectory((xl_path + FILE_SEPARATOR_STR + L"embeddings").c_str());
embeddings_path_ = xl_path + FILE_SEPARATOR_STR + L"embeddings" + FILE_SEPARATOR_STR;
}
std::wstring external_items::embeddings_path()
{
return embeddings_path_;
}
}
......@@ -41,16 +41,17 @@ class rels;
class external_items
{
public:
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroup, typeExternalLink};
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroup, typeExternalLink, typeOleObject};
external_items()
{
count_charts =0;
count_shape =0;
count_image =0;
count_tables =0;
count_media =0;
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_activeX = 0;
count_embeddings= 0;
}
struct item
......@@ -76,6 +77,8 @@ public:
size_t count_media;
size_t count_shape;
size_t count_tables;
size_t count_activeX;
size_t count_embeddings;
//std::wstring add_or_find(const std::wstring & href, Type type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_image (const std::wstring & file_name, int bin_id);
......@@ -88,13 +91,20 @@ public:
items_array & items() { return items_; }
void create_media_path(const std::wstring & out_path);
void create_activeX_path(const std::wstring & out_path);
void create_embeddings_path(const std::wstring & out_path);
std::wstring activeX_path();
std::wstring media_path();
std::wstring embeddings_path();
private:
std::wstring create_file_name(const std::wstring & uri, external_items::Type type, size_t Num);
std::wstring media_path_;
std::wstring activeX_path_;
std::wstring embeddings_path_;
items_array items_;
};
......
......@@ -152,7 +152,10 @@ void xlsx_conversion_context::end_external()
void xlsx_conversion_context::end_table()
{
get_table_context().serialize_hyperlinks(current_sheet().hyperlinks());
get_table_context().serialize_ole_objects(current_sheet().ole_objects());
get_table_context().dump_rels_ole_objects(current_sheet().sheet_rels());
get_table_context().serialize_hyperlinks(current_sheet().hyperlinks());
get_table_context().dump_rels_hyperlinks(current_sheet().sheet_rels());
get_table_context().end_table();
......
......@@ -289,6 +289,7 @@ xlsx_drawing_context::xlsx_drawing_context(xlsx_conversion_context & Context) :
, rels_ (xlsx_drawings_rels::create())
, vml_HF_rels_ (xlsx_drawings_rels::create())
, vml_comments_rels_(xlsx_drawings_rels::create())
, sheet_rels_ (xlsx_drawings_rels::create())
{
in_chart_ = false;
count_object = 0;
......@@ -534,6 +535,10 @@ void xlsx_drawing_context::end_drawing(_drawing_state_ptr & drawing_state)
else
drawing_state->type = external_items::typeShape;
}
if ( drawing_state->type == external_items::typeOleObject )
{
serialize_shape(drawing_state);
}
if ( drawing_state->type == external_items::typeChart )
{
//функциональная часть
......@@ -595,7 +600,10 @@ void xlsx_drawing_context::serialize_group()
{
CP_XML_ATTR(L"descr", drawing_state->description);
}
if (drawing_state->hidden)
{
CP_XML_ATTR(L"hidden", 1);
}
if (!drawing_state->hyperlink.empty())
{
CP_XML_NODE(L"a:hlinkClick")
......@@ -796,20 +804,25 @@ void xlsx_drawing_context::serialize_pic(_drawing_state_ptr & drawing_state, std
{
CP_XML_NODE(L"xdr:pic")
{
CP_XML_ATTR(L"macro", drawing_state->macro);
CP_XML_NODE(L"xdr:nvPicPr")
{
CP_XML_NODE(L"xdr:cNvPr")
{
CP_XML_ATTR(L"id", drawing_state->id);
if (drawing_state->name.empty())
drawing_state->name = L"Picture_" + rId.substr(5);
CP_XML_ATTR(L"name", drawing_state->name);
CP_XML_ATTR(L"name", drawing_state->name);
if (!drawing_state->description.empty())
{
CP_XML_ATTR(L"descr", drawing_state->description);
}
if (drawing_state->hidden)
{
CP_XML_ATTR(L"hidden", 1);
}
if (!drawing_state->hyperlink.empty())
{
......@@ -872,6 +885,10 @@ void xlsx_drawing_context::serialize_chart(_drawing_state_ptr & drawing_state, s
{
CP_XML_ATTR(L"descr", drawing_state->description);
}
if (drawing_state->hidden)
{
CP_XML_ATTR(L"hidden", 1);
}
}
CP_XML_NODE(L"xdr:cNvGraphicFramePr");
......@@ -932,6 +949,8 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
{
CP_XML_NODE(L"xdr:sp")
{
CP_XML_ATTR(L"macro", drawing_state->macro);
CP_XML_NODE(L"xdr:nvSpPr")
{
CP_XML_NODE(L"xdr:cNvPr")
......@@ -942,6 +961,8 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
{
if (drawing_state->wordart.is)
drawing_state->name = L"WordArt_" + std::to_wstring(count_object);
else if ( drawing_state->type == external_items::typeOleObject )
drawing_state->name = L"Object_" + std::to_wstring(count_object);
else
drawing_state->name = L"Shape_" + std::to_wstring(count_object);
}
......@@ -951,7 +972,10 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
{
CP_XML_ATTR(L"descr", drawing_state->description);
}
if (drawing_state->hidden)
{
CP_XML_ATTR(L"hidden", 1);
}
if (!drawing_state->hyperlink.empty())
{
CP_XML_NODE(L"a:hlinkClick")
......@@ -961,6 +985,22 @@ void xlsx_drawing_context::serialize_shape(_drawing_state_ptr & drawing_state)
CP_XML_ATTR(L"r:id", drawing_state->hyperlink);
}
}
//if ( drawing_state->type == external_items::typeOleObject ) + VmlDrawing
//{
// CP_XML_NODE(L"a:extLst")
// {
// CP_XML_NODE(L"a:ext")
// {
// CP_XML_ATTR(L"uri", L"{63B3BB69-23CF-44E3-9099-C40C66FF867C}");
// CP_XML_ATTR(L"xmlns:a14", L"http://schemas.microsoft.com/office/drawing/2010/main");
// CP_XML_NODE(L"a14:compatExt")
// {
// CP_XML_ATTR(L"spid", L"_x0000_s" + std::to_wstring(drawing_state->id));
// }
// }
// }
//}
}
CP_XML_NODE(L"xdr:cNvSpPr")
{
......@@ -1338,20 +1378,20 @@ void xlsx_drawing_context::serialize_gradient_fill(std::wostream & stream, _draw
}
}
void xlsx_drawing_context::serialize_anchor (std::wostream & stream, _drawing_state_ptr & drawing_state)
void xlsx_drawing_context::serialize_anchor (std::wostream & stream, _drawing_state_ptr & drawing_state, std::wstring ns)
{
CP_XML_WRITER(stream)
{
if (drawing_state->type_anchor == 1)
{
CP_XML_NODE(L"xdr:from")
CP_XML_NODE(ns + L"from")
{
CP_XML_NODE(L"xdr:col") { CP_XML_CONTENT (drawing_state->sheet_anchor.colFrom); }
CP_XML_NODE(L"xdr:colOff") { CP_XML_CONTENT (drawing_state->sheet_anchor.xFrom) ; }
CP_XML_NODE(L"xdr:row") { CP_XML_CONTENT (drawing_state->sheet_anchor.rwFrom); }
CP_XML_NODE(L"xdr:rowOff") { CP_XML_CONTENT (drawing_state->sheet_anchor.yFrom) ; }
}
CP_XML_NODE(L"xdr:to")
CP_XML_NODE(ns + L"to")
{
CP_XML_NODE(L"xdr:col") { CP_XML_CONTENT (drawing_state->sheet_anchor.colTo); }
CP_XML_NODE(L"xdr:colOff") { CP_XML_CONTENT (drawing_state->sheet_anchor.xTo); }
......@@ -1361,12 +1401,12 @@ void xlsx_drawing_context::serialize_anchor (std::wostream & stream, _drawing_st
}
if (drawing_state->type_anchor == 3)
{
CP_XML_NODE(L"xdr:pos")//in emu (1 pt = 12700)
CP_XML_NODE(ns + L"pos")//in emu (1 pt = 12700)
{
CP_XML_ATTR(L"x", (int)(drawing_state->absolute_anchor.x * 12700));
CP_XML_ATTR(L"y", (int)(drawing_state->absolute_anchor.y * 12700));
}
CP_XML_NODE(L"xdr:ext") //in emu (1 pt = 12700)
CP_XML_NODE(ns + L"ext") //in emu (1 pt = 12700)
{
CP_XML_ATTR(L"cx", (int)(drawing_state->absolute_anchor.cx * 12700));
CP_XML_ATTR(L"cy", (int)(drawing_state->absolute_anchor.cy * 12700));
......@@ -1739,6 +1779,46 @@ void xlsx_drawing_context::serialize(std::wostream & stream, _drawing_state_ptr
}
}
}
void xlsx_drawing_context::serialize_object(std::wostream & stream, _drawing_state_ptr & drawing_state)
{
if (drawing_state->type != external_items::typeOleObject) return;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"oleObject")
{
if (!drawing_state->objectProgId.empty())
{
CP_XML_ATTR(L"progId", drawing_state->objectProgId);
}
CP_XML_ATTR(L"shapeId", drawing_state->id);
CP_XML_ATTR(L"r:id", drawing_state->objectId);
CP_XML_NODE(L"objectPr")
{
CP_XML_ATTR(L"defaultSize", 0);
//CP_XML_ATTR(L"autoPict", 0);
if (!drawing_state->fill.texture_target.empty())
{
bool isIternal = false;
std::wstring rId = handle_.impl_->get_mediaitems().find_image( drawing_state->fill.texture_target, isIternal);
CP_XML_ATTR(L"r:id", rId);
sheet_rels_->add(isIternal, rId , drawing_state->fill.texture_target, external_items::typeImage);
}
CP_XML_NODE(L"anchor")
{
CP_XML_ATTR(L"moveWithCells", 1);
serialize_anchor(CP_XML_STREAM(), drawing_state, L"");
}
}
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------
void xlsx_drawing_context::set_name(const std::wstring & str)
{
......@@ -1752,6 +1832,21 @@ void xlsx_drawing_context::set_description(const std::wstring & str)
current_drawing_states->back()->description = str;
}
void xlsx_drawing_context::set_macro(const std::wstring & str)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->macro = str;
}
void xlsx_drawing_context::set_ole_object(const std::wstring & id, const std::wstring & info)
{
if (current_drawing_states == NULL) return;
current_drawing_states->back()->type = external_items::typeOleObject;
current_drawing_states->back()->objectId = id;
current_drawing_states->back()->objectProgId = info;
}
void xlsx_drawing_context::set_sheet_anchor(int colFrom, int xFrom, int rwFrom, int yFrom, int colTo, int xTo, int rwTo,int yTo)
{
if (current_drawing_states == NULL) return;
......@@ -2487,6 +2582,10 @@ xlsx_drawings_rels_ptr xlsx_drawing_context::get_vml_comments_rels()
{
return vml_comments_rels_;
}
xlsx_drawings_rels_ptr xlsx_drawing_context::get_sheet_rels()
{
return sheet_rels_;
}
bool xlsx_drawing_context::ChangeBlack2ColorImage(std::wstring sRgbColor1, std::wstring sRgbColor2, _drawing_state_ptr & drawing_state)
{
if (drawing_state->fill.texture_target.length() < 6) return false;
......@@ -2500,7 +2599,15 @@ bool xlsx_drawing_context::ChangeBlack2ColorImage(std::wstring sRgbColor1, std::
return bgraFrame.ReColorPatternImage(image_path, rgbColor1, rgbColor2);
}
void xlsx_drawing_context::serialize_objects(std::wostream & strm)
{
for (size_t i = 0; i < drawing_states.size(); i++)
{
if (drawing_states[i]->type != external_items::typeOleObject) continue;
serialize_object(strm, drawing_states[i]);
}
}
void xlsx_drawing_context::serialize_vml_HF(std::wostream & strm)
{
CP_XML_WRITER(strm)
......@@ -2565,6 +2672,7 @@ void xlsx_drawing_context::serialize(std::wostream & strm)
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:mc" , L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_ATTR(L"xmlns:a14", L"http://schemas.microsoft.com/office/drawing/2010/main");
for (size_t i = 0 ; i < drawing_states.size(); i++)
{
......
......@@ -135,7 +135,8 @@ public:
flipH(false), flipV(false),
bTextBox(false),
type_anchor(0),
vmlwrite_mode_(false)
vmlwrite_mode_(false),
hidden(false)
{
id = -1;
rotation = 0;
......@@ -146,20 +147,24 @@ public:
}
external_items::Type type;
bool hidden;
std::wstring name;
std::wstring description;
std::wstring macro;
std::wstring objectId;
std::wstring objectProgId;
struct _anchor
{
_anchor() : colFrom(-1), rwFrom(-1), colTo(-1), rwTo(0), xFrom(0), yFrom(0),xTo(0),yTo(0){}
int colFrom;
int xFrom;
int rwFrom;
int yFrom;
int colTo;
int xTo;
int rwTo;
int yTo;
int colFrom = -1;
int xFrom = 0;
int rwFrom = -1;
int yFrom = 0;
int colTo = 0;
int xTo = 0;
int rwTo = 0;
int yTo = 0;
} sheet_anchor;
_rect child_anchor;
_rect group_anchor;
......@@ -313,6 +318,7 @@ public:
xlsx_drawings_rels_ptr get_rels();
xlsx_drawings_rels_ptr get_vml_HF_rels();
xlsx_drawings_rels_ptr get_vml_comments_rels();
xlsx_drawings_rels_ptr get_sheet_rels();
bool empty();
bool empty_vml_HF();
......@@ -335,6 +341,8 @@ public:
//--------------------------------------------------------------------------------------
void set_name (const std::wstring & str);
void set_description (const std::wstring & str);
void set_macro (const std::wstring & str);
void set_ole_object (const std::wstring & id, const std::wstring & info);
void set_crop_top (double val);
void set_crop_bottom (double val);
......@@ -422,6 +430,7 @@ public:
void serialize_shape (_drawing_state_ptr & drawing_state);
void serialize_chart (_drawing_state_ptr & drawing_state, std::wstring rId );
void serialize_pic (_drawing_state_ptr & drawing_state, std::wstring rId );
void serialize_object (_drawing_state_ptr & drawing_state, std::wstring rId );
void serialize_shape_comment(_drawing_state_ptr & drawing_state); //part of vml shape
//-----------------------------------------------------------------------------------
......@@ -432,10 +441,12 @@ public:
void serialize_fill (std::wostream & stream);
//-----------------------------------------------------------------------------------
void serialize (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_vml (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_vml (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_object (std::wostream & stream, _drawing_state_ptr & drawing_state);
//-----------------------------------------------------------------------------------
void serialize_vml_HF (std::wostream & stream);
void serialize_vml_comments (std::wostream & stream);
void serialize_objects (std::wostream & stream);
void serialize (std::wostream & stream);
//-----------------------------------------------------------------------------------
bool is_lined_shape (_drawing_state_ptr & drawing_state);
......@@ -450,6 +461,7 @@ private:
xlsx_drawings_rels_ptr rels_;
xlsx_drawings_rels_ptr vml_comments_rels_;
xlsx_drawings_rels_ptr vml_HF_rels_;
xlsx_drawings_rels_ptr sheet_rels_;
int count_object;
bool in_chart_;
......@@ -474,7 +486,7 @@ private:
void serialize_line (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_xfrm (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_anchor (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_anchor (std::wostream & stream, _drawing_state_ptr & drawing_state, std::wstring ns = L"xdr:");
void serialize_text (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_color (std::wostream & stream, const _color &color, double opacity = 0);
......
......@@ -54,6 +54,7 @@ public:
std::wstringstream sheetFormatPr_;
std::wstringstream sheetData_;
std::wstringstream mergeCells_;
std::wstringstream ole_objects_;
std::wstringstream drawing_;
std::wstringstream hyperlinks_;
std::wstringstream comments_;
......@@ -132,6 +133,10 @@ std::wostream & xlsx_xml_worksheet::mergeCells()
{
return impl_->mergeCells_;
}
std::wostream & xlsx_xml_worksheet::ole_objects()
{
return impl_->ole_objects_;
}
std::wostream & xlsx_xml_worksheet::drawing()
{
......@@ -183,6 +188,8 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
CP_XML_ATTR(L"xmlns:x14", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"mc:Ignorable", L"x14ac");
CP_XML_ATTR(L"xmlns:x14ac", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
......@@ -230,7 +237,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_ATTR(L"r:id", impl_->vml_drawingId_HF_);
}
}
if (!impl_->ole_objects_.str().empty())
{
CP_XML_NODE(L"oleObjects")
{
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
CP_XML_STREAM() << impl_->picture_background_.str();
//CP_XML_NODE(L"rowBreaks){}
......
......@@ -60,6 +60,7 @@ public:
std::wostream & hyperlinks();
std::wostream & mergeCells();
std::wostream & drawing();
std::wostream & ole_objects();
//std::wostream & comments();
std::wostream & sheetSortAndFilters();
std::wostream & pageProperties();
......
......@@ -143,12 +143,21 @@ std::wstring xlsx_table_context::add_hyperlink(std::wstring const & ref, std::ws
}
void xlsx_table_context::dump_rels_hyperlinks(rels & Rels)
{
return state()->hyperlinks_.dump_rels(Rels);
state()->hyperlinks_.dump_rels(Rels);
}
void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
{
return state()->hyperlinks_.serialize(_Wostream);
state()->hyperlinks_.serialize(_Wostream);
}
void xlsx_table_context::dump_rels_ole_objects(rels & Rels)
{
xlsx_drawings_rels_ptr ole_rels = state()->drawing_context_.get_sheet_rels();
ole_rels->dump_rels(Rels);
}
void xlsx_table_context::serialize_ole_objects(std::wostream & strm)
{
state()->drawing_context_.serialize_objects(strm);
}
}
......@@ -71,6 +71,9 @@ public:
std::wstring add_hyperlink(std::wstring const & ref, std::wstring const & target, std::wstring const & display, bool bExternal);
void dump_rels_hyperlinks(rels & Rels);
void serialize_hyperlinks(std::wostream & _Wostream);
void dump_rels_ole_objects(rels & Rels);
void serialize_ole_objects(std::wostream & _Wostream);
private:
xlsx_conversion_context & context_;
......
......@@ -5,6 +5,9 @@ if exist "depot_tools" (
echo "depot_tools already fetched"
) else (
call git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
CD depot_tools
git reset --hard e29cf7cb78009c80b04ddeab04763e8d218937c2
CD ../
call powershell -File .\fix-depot_tools.ps1
)
......
......@@ -255,7 +255,13 @@ namespace XmlUtils
sstream << boost::wformat(format) % value;
return sstream.str();
}
AVSINLINE static std::string IntToString( int value, const char* format )
{
if ( format == NULL ) return "";
std::stringstream sstream;
sstream << boost::format(format) % value;
return sstream.str();
}
AVSINLINE static std::wstring DoubleToString( double value, wchar_t* format )
{
if ( format == NULL ) return L"";
......
......@@ -154,6 +154,7 @@ namespace OOX
smart_ptr<PPTX::Logic::Shape> shape = m_oElement->GetElem().smart_dynamic_cast<PPTX::Logic::Shape>();
if (shape.IsInit())
{
m_nId = shape->nvSpPr.cNvPr.id;
if (shape->nvSpPr.cNvPr.oleSpid.IsInit())
{
//ссылка на объект
......@@ -162,7 +163,7 @@ namespace OOX
}
}
smart_ptr<PPTX::Logic::GraphicFrame> frame = m_oElement->GetElem().smart_dynamic_cast<PPTX::Logic::GraphicFrame>();
if ((frame.IsInit()) && (frame->oleSpid.IsInit()))
if ((frame.IsInit()) && (frame->oleSpid.IsInit()))
{
//ссылка на объект или шейп в vmlDrawing
m_sSpId = frame->oleSpid.get();
......@@ -221,6 +222,7 @@ namespace OOX
//для удобства
nullable<std::wstring> m_sSpId;
nullable<int> m_nId;
};
} //Spreadsheet
} // namespace OOX
......
......@@ -546,6 +546,7 @@ namespace NSDoctRenderer
std::wstring m_strFilePath;
std::wstring m_strAllFonts;
bool m_bIsNotUseConfigAllFontsDir;
std::wstring m_sTmpFolder;
std::wstring m_sFileDir;
......@@ -585,6 +586,8 @@ namespace NSDoctRenderer
m_sGlobalVariable = "";
m_bIsGlobalVariableUse = false;
m_bIsNotUseConfigAllFontsDir = false;
}
void Init()
......@@ -634,7 +637,7 @@ namespace NSDoctRenderer
oNodes.GetAt(i, _node);
std::wstring strFilePath = _node.GetText();
if (std::wstring::npos != strFilePath.find(L"AllFonts.js"))
if (std::wstring::npos != strFilePath.find(L"AllFonts.js") && !m_bIsNotUseConfigAllFontsDir)
{
m_strAllFonts = strFilePath;
......@@ -1717,6 +1720,11 @@ namespace NSDoctRenderer
m_pInternal->m_bIsCacheScript = (std::wstring(value) == L"true");
else if (sParam == "--save-use-only-names")
m_pInternal->m_sFolderForSaveOnlyUseNames = std::wstring(value);
else if (sParam == "--all-fonts-path")
{
m_pInternal->m_strAllFonts = std::wstring(value);
m_pInternal->m_bIsNotUseConfigAllFontsDir = true;
}
else if (sParam == "--argument")
{
std::wstring sArg(value);
......
......@@ -43,9 +43,11 @@ endif
TARGET := $(PLATFORM)_$(ARCHITECTURE)
LIBDIR := build/lib/$(TARGET)
BINDIR := build/bin/$(TARGET)
ALLFONTSGEN := build/bin/AllFontsGen/$(TARGET)$(EXEC_EXT)
X2T := build/bin/$(TARGET)/x2t$(EXEC_EXT)
X2T := $(BINDIR)/x2t$(EXEC_EXT)
DOCBUILDER := $(BINDIR)/docbuilder$(EXEC_EXT)
HTMLFILEINTERNAL := $(LIBDIR)/HtmlFileInternal$(EXEC_EXT)
XLSFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)XlsFormatLib$(LIB_EXT)
ODFFILEWRITERLIB := $(LIBDIR)/$(LIB_PREFIX)OdfFileWriterLib$(LIB_EXT)
......@@ -75,6 +77,7 @@ HUNSPELL := $(LIBDIR)/$(LIB_PREFIX)hunspell$(SHARED_EXT)
TARGETS += $(ALLFONTSGEN)
TARGETS += $(X2T)
TARGETS += $(DOCBUILDER)
TARGETS += $(HTMLFILEINTERNAL)
TARGETS += $(XLSFORMATLIB)
TARGETS += $(ODFFILEWRITERLIB)
......@@ -105,6 +108,7 @@ TARGETS += $(HUNSPELL)
X2T_PRO := $(abspath X2tConverter/build/Qt/X2tSLN.pro)
HTMLFILEINTERNAL_PRO := $(abspath ../desktop-sdk/HtmlFile/Internal/Internal.pro)
ALLFONTSGEN_PRO := $(abspath DesktopEditor/AllFontsGen/AllFontsGen.pro)
DOCBUILDER_PRO := $(abspath ../core-ext/docbuilder/test_builder/docbuilder.pro)
XLSFORMATLIB_PRO := $(abspath ASCOfficeXlsFile2/source/linux/XlsFormatLib.pro)
ODFFILEWRITERLIB_PRO := $(abspath ASCOfficeOdfFileW/linux/OdfFileWriterLib.pro)
ODFFILEREADERLIB_PRO := $(abspath ASCOfficeOdfFile/linux/OdfFileReaderLib.pro)
......@@ -157,6 +161,7 @@ HUNSPELL_PRO := $(abspath DesktopEditor/hunspell-1.3.3/src/qt/hunspell.pro)
QT_PROJ += X2T
QT_PROJ += HTMLFILEINTERNAL
QT_PROJ += ALLFONTSGEN
QT_PROJ += DOCBUILDER
QT_PROJ += XLSFORMATLIB
QT_PROJ += ODFFILEWRITERLIB
QT_PROJ += ODFFILEREADERLIB
......@@ -214,6 +219,8 @@ ALLFONTSGEN_DEP += $(GRAPHICS)
ALLFONTSGEN_DEP += $(OFFICEUTILS)
ALLFONTSGEN_DEP += $(UNICODECONVERTER)
DOCBUILDER_DEP += $(DOCTRENDERER)
HTMLFILE_DEP += $(UNICODECONVERTER)
RTFFORMATLIB_DEP += $(UNICODECONVERTER)
......@@ -271,7 +278,7 @@ bin: $(X2T) $(ALLFONTSGEN)
lib: $(PDFWRITER) $(DOCTRENDERER) $(HTMLRENDERER) $(PDFREADER) $(DJVUFILE) $(XPSFILE) $(HTMLFILE) $(UNICODECONVERTER)
ext: $(ASCDOCUMENTSCORE) $(HTMLFILEINTERNAL)
ext: $(ASCDOCUMENTSCORE) $(HTMLFILEINTERNAL) $(DOCBUILDER)
$(foreach proj, $(QT_PROJ), $(eval $(call build_proj_tmpl, $(proj))))
......@@ -283,6 +290,8 @@ $(XPSFILE): $(XPSFILE_DEP)
$(ALLFONTSGEN): $(ALLFONTSGEN_DEP)
$(DOCBUILDER): $(DOCBUILDER_DEP)
$(HTMLFILE): $(HTMLFILE_DEP)
$(RTFFORMATLIB): $(RTFFORMATLIB_DEP)
......
......@@ -5,19 +5,22 @@
int _tmain(int argc, _TCHAR* argv[])
{
std::wstring srcFileName = L"D:\\test\\_crypted\\test-password-2016.docx";
std::wstring dstFileName = srcFileName + L".oox";
std::wstring dstFileName2 = dstFileName + L"-mycrypt.docx";
//std::wstring srcFileName = L"D:\\test\\_crypted\\test-password-2016.docx";
//std::wstring dstFileName = srcFileName + L".oox";
//std::wstring dstFileName2 = dstFileName + L"-mycrypt.docx";
std::wstring srcFileName = L"D:\\test\\_crypted\\test.docx";
std::wstring dstFileName2 = srcFileName + L"-mycrypt.docx";
std::wstring password = L"password";
std::wstring password = L"password132eqdqdwewedwdwwskskms09elzwewedskjsdnkjsdnjksjsnkcsdncskjdnss";
ECMACryptFile crypt_file;
bool result, bDataIntegrity;
result = crypt_file.DecryptOfficeFile(srcFileName, dstFileName, password, bDataIntegrity);
result = crypt_file.EncryptOfficeFile(dstFileName, dstFileName2, password);
//result = crypt_file.DecryptOfficeFile(srcFileName, dstFileName, password, bDataIntegrity);
//result = crypt_file.EncryptOfficeFile(dstFileName, dstFileName2, password);
result = crypt_file.EncryptOfficeFile(srcFileName, dstFileName2, password);
return 0;
}
......@@ -40,6 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......
......@@ -471,11 +471,13 @@ namespace NExtractTools
std::wstring sName = oXmlNode.GetName();
if(_T("m_oMailMergeSend") == sName)
{
RELEASEOBJECT(m_oMailMergeSend);
m_oMailMergeSend = new InputParamsMailMerge();
m_oMailMergeSend->FromXmlNode(oXmlNode);
}
else if(_T("m_oThumbnail") == sName)
{
RELEASEOBJECT(m_oThumbnail);
m_oThumbnail = new InputParamsThumbnail();
m_oThumbnail->FromXmlNode(oXmlNode);
}
......@@ -485,49 +487,107 @@ namespace NExtractTools
if(oXmlNode.GetTextIfExist(sValue))
{
if(_T("m_sKey") == sName)
{
RELEASEOBJECT(m_sKey);
m_sKey = new std::wstring(sValue);
}
else if(_T("m_sFileFrom") == sName)
{
RELEASEOBJECT(m_sFileFrom);
m_sFileFrom = new std::wstring(sValue);
}
else if(_T("m_sFileTo") == sName)
{
RELEASEOBJECT(m_sFileTo);
m_sFileTo = new std::wstring(sValue);
}
else if(_T("m_nFormatFrom") == sName)
{
RELEASEOBJECT(m_nFormatFrom);
m_nFormatFrom = new int(XmlUtils::GetInteger(sValue));
}
else if(_T("m_nFormatTo") == sName)
{
RELEASEOBJECT(m_nFormatTo);
m_nFormatTo = new int(XmlUtils::GetInteger(sValue));
}
else if(_T("m_nCsvTxtEncoding") == sName)
{
RELEASEOBJECT(m_nCsvTxtEncoding);
m_nCsvTxtEncoding = new int(XmlUtils::GetInteger(sValue));
}
else if(_T("m_nCsvDelimiter") == sName)
{
RELEASEOBJECT(m_nCsvDelimiter);
m_nCsvDelimiter = new int(XmlUtils::GetInteger(sValue));
}
else if(_T("m_nCsvDelimiterChar") == sName)
{
RELEASEOBJECT(m_sCsvDelimiterChar);
m_sCsvDelimiterChar = new std::wstring(sValue);
}
else if(_T("m_bPaid") == sName)
{
RELEASEOBJECT(m_bPaid);
m_bPaid = new bool(XmlUtils::GetBoolean2(sValue));
}
else if(_T("m_bFromChanges") == sName)
{
RELEASEOBJECT(m_bFromChanges);
m_bFromChanges = new bool(XmlUtils::GetBoolean2(sValue));
}
else if(_T("m_sAllFontsPath") == sName)
{
RELEASEOBJECT(m_sAllFontsPath);
m_sAllFontsPath = new std::wstring(sValue);
}
else if(_T("m_sFontDir") == sName)
{
RELEASEOBJECT(m_sFontDir);
m_sFontDir = new std::wstring(sValue);
}
else if(_T("m_sThemeDir") == sName)
{
RELEASEOBJECT(m_sThemeDir);
m_sThemeDir = new std::wstring(sValue);
}
else if(_T("m_bDontSaveAdditional") == sName)
{
RELEASEOBJECT(m_bDontSaveAdditional);
m_bDontSaveAdditional = new bool(XmlUtils::GetBoolean2(sValue));
}
else if(_T("m_nDoctParams") == sName)
{
RELEASEOBJECT(m_nDoctParams);
m_nDoctParams = new int(XmlUtils::GetInteger(sValue));
}
else if(_T("m_sHtmlFileInternalPath") == sName)
{
RELEASEOBJECT(m_sHtmlFileInternalPath);
m_sHtmlFileInternalPath = new std::wstring(sValue);
}
else if(_T("m_sPassword") == sName)
{
RELEASEOBJECT(m_sPassword);
m_sPassword = new std::wstring(sValue);
}
else if(_T("m_sTempDir") == sName)
{
RELEASEOBJECT(m_sTempDir);
m_sTempDir = new std::wstring(sValue);
}
else if(_T("m_bIsNoBase64") == sName)
{
RELEASEOBJECT(m_bIsNoBase64);
m_bIsNoBase64 = new bool(XmlUtils::GetBoolean2(sValue));
}
}
else if(_T("m_nCsvDelimiterChar") == sName)
{
std::wstring sNil;
if (!oXmlNode.GetAttributeIfExist(L"xsi:nil", sNil))
{
RELEASEOBJECT(m_sCsvDelimiterChar);
m_sCsvDelimiterChar = new std::wstring(L"");
}
}
......
......@@ -104,33 +104,41 @@ static std::wstring utf8_to_unicode(const char *src)
return getReturnErrorCode(AVS_FILEUTILS_ERROR_CONVERT_PARAMS);
}
std::wstring sArg1, sExePath;
std::wstring sArg1, sArg2, sExePath;
#if !defined(_WIN32) && !defined (_WIN64)
sExePath = utf8_to_unicode(argv [0]);
sArg1 = utf8_to_unicode(argv [1]);
if (argc >= 3) sArg2 = utf8_to_unicode(argv [2]);
#else
sExePath = std::wstring(argv [0]);
sArg1 = std::wstring(argv [1]);
if (argc >= 3) sArg2 = std::wstring(argv [2]);
#endif
int result = 0;
std::wstring sXmlExt = _T(".xml");
if(sXmlExt == sArg1.substr(sArg1.length() - sXmlExt.length(), sXmlExt.length()))
{
result = NExtractTools::FromFile(sArg1);
NExtractTools::InputParams oInputParams;
if (oInputParams.FromXmlFile(sArg1) && (sArg2.empty() || oInputParams.FromXml(sArg2)))
{
result = NExtractTools::fromInputParams(oInputParams);
}
else
{
result = AVS_FILEUTILS_ERROR_CONVERT_PARAMS;
}
}
else
{
std::wstring sArg2, sArg3, sArg4, sArg5;
std::wstring sArg3, sArg4, sArg5;
#if !defined(_WIN32) && !defined (_WIN64)
if (argc >= 3) sArg2 = utf8_to_unicode(argv [2]);
if (argc >= 4) sArg3 = utf8_to_unicode(argv [3]);
if (argc >= 5) sArg4 = utf8_to_unicode(argv [4]);
if (argc >= 6) sArg5 = utf8_to_unicode(argv [5]);
#else
if (argc >= 3) sArg2 = std::wstring(argv [2]);
if (argc >= 4) sArg3 = std::wstring(argv [3]);
if (argc >= 5) sArg4 = std::wstring(argv [4]);
if (argc >= 6) sArg5 = std::wstring(argv [5]);
......
......@@ -2956,6 +2956,15 @@ namespace BinXlsxRW
if (!pCellAnchor->m_bShapeOle && pCellAnchor->isValid())
{
if(oWorksheet.m_oOleObjects.IsInit() && pCellAnchor->m_nId.IsInit())
{
std::map<int, COleObject*>::const_iterator pFind = oWorksheet.m_oOleObjects->m_mapOleObjects.find(pCellAnchor->m_nId.get());
if (pFind != oWorksheet.m_oOleObjects->m_mapOleObjects.end())
{
pCellAnchor->m_bShapeOle = true;
continue;
}
}
int nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawing);
WriteDrawing(oWorksheet, pDrawing, pCellAnchor, pVmlDrawing);
m_oBcw.WriteItemEnd(nCurPos);
......
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