Compare commits

...

7 Commits

Author SHA1 Message Date
51fe936e5f ... 2017-12-06 12:18:06 +03:00
d8b177411f x2t - options for check macro in file 2017-12-05 16:56:50 +03:00
717b628055 ... 2017-12-05 14:37:10 +03:00
e4f94646b6 x2t version up 2017-12-05 10:54:43 +03:00
dcec7447e4 XlsFormat - apply theme style from format office 2010 and later 2017-12-04 19:24:27 +03:00
5f12552f78 XlsFormat - theme 2017-12-03 16:09:35 +03:00
d293769c1f XlsFormat .. 2017-12-02 17:31:10 +03:00
73 changed files with 931 additions and 523 deletions

View File

@ -67,7 +67,9 @@ public:
}
HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros);
long OpenFile(const std::wstring & fileName, const std::wstring & password, bool &bMacros);
bool CloseFile();
private:
int m_Status;
@ -76,8 +78,7 @@ private:
std::wstring m_strTempDirectory;
std::wstring m_sTempDecryptFileName;
long OpenFile(const std::wstring & fileName, const std::wstring & password, bool &bMacros);
bool CloseFile();
std::wstring GetDirectory(std::wstring strFileName);
};

View File

@ -60,7 +60,7 @@ HRESULT convert_single(std::wstring srcFileName)
std::wstring dstPath;
bool bMacros = true;
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password", L"C:\\Windows\\Fonts", NULL, bMacros);
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password", L"C:\\Windows\\Fonts", L"C:\\Windows\\Temp", NULL, bMacros);
if (bMacros)
{

View File

@ -35,9 +35,6 @@
namespace XLS
{
// Logical representation of DataFormat record in BIFF8
class DataFormat: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(DataFormat)
@ -47,11 +44,10 @@ public:
~DataFormat();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeDataFormat;
static const ElementType type = typeDataFormat;
_UINT16 xi;
_UINT16 yi;

View File

@ -138,30 +138,13 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstr
}
else
CP_XML_ATTR(L"i", false);
//if (bCharSet.value())
//{
// CP_XML_NODE(L"charset")
// {
// CP_XML_ATTR(L"val", bCharSet);
// }
//}
switch(sss)
{
case 1: CP_XML_ATTR(L"cap", L"all");break;
case 2: CP_XML_ATTR(L"cap", L"small");break;
}
//if ((fCondense.value()) && (*fCondense.value()))
//{
// CP_XML_NODE(L"condense")
// {
// CP_XML_ATTR(L"val", (int)(*fCondense.value()));
// }
//}
//if ((fExtend.value()) && (fExtend))
// {
// CP_XML_NODE(L"extend")
// {
// CP_XML_ATTR(L"val", fExtend);
// }
// }
if ( (icv < 0x7fff) || color_ext.enabled )
{
if (color_ext.enabled )
@ -236,66 +219,7 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstr
{
CP_XML_NODE(namespace_ + L"rtl");
}
//if ((fOutline.value()) && (fOutline))
// {
// CP_XML_NODE(L"outline")
// {
// CP_XML_ATTR(L"val", fOutline);
// }
// }
//if (font.scheme)
//{
// CP_XML_NODE(L"scheme")
// {
// CP_XML_ATTR(L"val", *font.scheme);
// }
//}
//if ((fShadow.value()) && (fShadow))
// {
// CP_XML_NODE(L"shadow")
// {
// CP_XML_ATTR(L"val", fShadow);
// }
// }
//if ((fStrikeOut.value()) && (fStrikeOut))
//{
// CP_XML_NODE(L"strike")
// {
// CP_XML_ATTR(L"val", fStrikeOut);
// }
//}
// if ((uls.value()) && (*uls.value() > 0))
// {
// CP_XML_NODE(L"u")
// {
//switch(uls)
//{
// case 1: CP_XML_ATTR(L"val", "single");break;
// case 2: CP_XML_ATTR(L"val", "double");break;
// case 33: CP_XML_ATTR(L"val", "singleAccounting");break;
// case 34: CP_XML_ATTR(L"val", "doubleAccounting");break;
//}
// }
// }
// if ((sss.value()) && (*sss.value() > 0))
// {
// CP_XML_NODE(L"vertAlign")
// {
//switch(*sss.value())
//{
// case 1: CP_XML_ATTR(L"val", L"superscript");break;
// case 2: CP_XML_ATTR(L"val", L"subscript");break;
//}
//
// }
// }
}
}
return 0;

View File

@ -31,6 +31,7 @@
*/
#include "MsoDrawing.h"
#include "../Biff_structures/ODRAW/OfficeArtRecord.h"
namespace XLS
{
@ -78,13 +79,24 @@ void MsoDrawing::readFields()
void MsoDrawing::readFields(CFRecord& record)
{
record >> rgChildRec;
isReading = true;
if (record.getRdPtr() < record.getDataSize())
ODRAW::OfficeArtRecordHeader rh_test;
record >> rh_test;
record.RollRdPtrBack(8);//sizeof(OfficeArtRecordHeader)
if (rh_test.recType == 0xF002) //OfficeArtDgContainer
{
record >> rgChildRec;
isReading = true;
}
else if ((rh_test.recType & 0xF000) == 0xF000)
{
//074_JKH.OPEN.INFO.PRICE.VO_зПТПДУЛЙЕ ПЛТХЗБ юЕМСВЙОУЛПК ПВМБУФЙ_пбп юЕМСВЙОУЛПЕ БЧЙБРТЕДРТЙСФЙЕ.xls
rgChildRec.rh_own.recLen = record.getDataSize();
rgChildRec.loadFields(record);
isReading = true;
}
else
{
int g = 0;
}
}

View File

@ -32,7 +32,7 @@
#pragma once
#include "BiffRecordSplit.h"
#include <Logic/Biff_structures/ODRAW/OfficeArtDgContainer.h>
#include "../Biff_structures/ODRAW/OfficeArtDgContainer.h"
namespace XLS
{

View File

@ -31,7 +31,7 @@
*/
#include "PLV.h"
#include <Logic/Biff_structures/FrtHeader.h>
#include "../Biff_structures/FrtHeader.h"
namespace XLS
{

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of Password record in BIFF8
class Password: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(Password)
@ -47,7 +45,6 @@ public:
~Password();
BaseObjectPtr clone();
void readFields(CFRecord& record);

View File

@ -63,7 +63,7 @@ void SXVI::readFields(CFRecord& record)
if (cchName > 0 && cchName < 0xFFFF)
{
stName.setSize(cchName);
stName.load(record);
record >> stName;
}
}
@ -79,6 +79,11 @@ int SXVI::serialize(std::wostream & strm)
if (fHideDetail)CP_XML_ATTR(L"sd", 0);
if (fFormula) CP_XML_ATTR(L"f", 1);
if (!stName.value().empty())
{
CP_XML_ATTR(L"n", stName.value());
}
if (itmType == 0)
{
CP_XML_ATTR(L"x", iCache);

View File

@ -31,8 +31,7 @@
*/
#include "Theme.h"
#include <fstream>
#include <iostream> // endl
#include "../../../DesktopEditor/common/File.h"
namespace XLS
{
@ -59,13 +58,15 @@ void Theme::readFields(CFRecord& record)
{
//default theme
}
else if (dwThemeVersion == 0)
//else if (dwThemeVersion == 0)
else
{
nThemeDataSize = record.getDataSize() - record.getRdPtr();
pThemeData = boost::shared_array<char>(new char[nThemeDataSize]);
memcpy(pThemeData.get(), record.getCurData<char>(), nThemeDataSize);
record.skipNunBytes(nThemeDataSize);
}
}

View File

@ -32,7 +32,7 @@
#include "TxO.h"
#include <Logic/Biff_records/Font.h>
#include "Font.h"
#include <utils.h>
@ -184,9 +184,9 @@ int TxO::serialize_vml (std::wostream & _stream)
{
iFmt = run->formatRun.ifnt;
Font *font = NULL;
if ((global_info->m_arFonts) && (iFmt >=0 && iFmt < global_info->m_arFonts->size()))
if (iFmt >= 0 && iFmt < global_info->m_arFonts.size())
{
font = dynamic_cast<Font *>(global_info->m_arFonts->at(iFmt).get());
font = dynamic_cast<Font *>(global_info->m_arFonts[iFmt].get());
}
if (font)
{
@ -281,12 +281,11 @@ int TxO::serialize (std::wostream & _stream)
int TxO::serialize_rPr (std::wostream & _stream, int iFmt, std::wstring namespace_)
{
if (!global_info) return 0;
if (!global_info->m_arFonts) return 0;
int sz = global_info->m_arFonts->size();
int sz = global_info->m_arFonts.size();
if (iFmt - 1 >= sz || iFmt < 1) return 0;
Font * font = dynamic_cast<Font*>(global_info->m_arFonts->at(iFmt-1).get());
Font * font = dynamic_cast<Font*>(global_info->m_arFonts[iFmt-1].get());
if (!font) return 0;

View File

@ -35,11 +35,10 @@
namespace XLS
{
XF::XF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell(cell_xf_current_id, style_xf_current_id),
style(cell_xf_current_id, style_xf_current_id),
ixfParent(0)
XF::XF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell (cell_xf_current_id, style_xf_current_id),
style(cell_xf_current_id, style_xf_current_id)
{
ixfParent = 0;
}

View File

@ -32,15 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/FontIndex.h>
#include <Logic/Biff_structures/CellXF.h>
#include <Logic/Biff_structures/StyleXF.h>
#include "../Biff_structures/FontIndex.h"
#include "../Biff_structures/CellXF.h"
#include "../Biff_structures/StyleXF.h"
namespace XLS
{
// Logical representation of XF record in BIFF8
class XF: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(XF)

View File

@ -38,13 +38,12 @@ namespace XLS
struct FillInfoExt
{
FillInfoExt() {enabled = false; xclrType = icv = 0; nTintShade = 0; xclrValue = 0;}
bool enabled;
bool enabled =false;
unsigned char xclrType;
unsigned char icv;
short nTintShade;
unsigned int xclrValue;
unsigned char xclrType = 0;
unsigned char icv = 0;
short nTintShade = 0;
unsigned int xclrValue = 0;
};
struct FillInfo
@ -56,9 +55,9 @@ struct FillInfo
{
}
unsigned char fls;
unsigned char icvFore;
unsigned char icvBack;
unsigned char fls = 0;
unsigned char icvFore = 0;
unsigned char icvBack = 0;
bool operator < (const FillInfo& right) const
{
@ -84,17 +83,17 @@ struct FillInfo
struct BorderInfo
{
unsigned char dgLeft;
unsigned char dgRight;
unsigned char dgTop;
unsigned char dgBottom;
unsigned char dgDiag;
unsigned char grbitDiag;
unsigned char icvLeft;
unsigned char icvRight;
unsigned char icvTop;
unsigned char icvBottom;
unsigned char icvDiag;
unsigned char dgLeft = 0;
unsigned char dgRight = 0;
unsigned char dgTop = 0;
unsigned char dgBottom = 0;
unsigned char dgDiag = 0;
unsigned char grbitDiag = 0;
unsigned char icvLeft = 0;
unsigned char icvRight = 0;
unsigned char icvTop = 0;
unsigned char icvBottom = 0;
unsigned char icvDiag = 0;
FillInfoExt leftFillInfo_;
FillInfoExt rightFillInfo_;

View File

@ -38,10 +38,11 @@ namespace XLS
{
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell_xf_current_id_(cell_xf_current_id),
style_xf_current_id_(style_xf_current_id)
{
alc = alcV = 0;
font_id = 0xFFFF;
}
@ -152,6 +153,91 @@ void CellXF::load(CFRecord& record)
}
}
void CellXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void CellXF::Update(XFProps* xfProps)
{
if (!xfProps) return;
//
// std::wstringstream strm;
// xfProps->serialize_fill(strm);
// fill.ext = strm.str();
}
void CellXF::RegisterFillBorder()
{
for (size_t i = 0; i < ext_props.size(); i++ )
@ -231,6 +317,8 @@ void CellXF::RegisterFillBorder()
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
m_GlobalWorkbookInfo->RegisterFontColorId(font_id, font_color);
}

View File

@ -36,6 +36,8 @@
namespace XLS
{
class XFProps;
class ExtProp;
class CFRecord;
class GlobalWorkbookInfo;
@ -74,19 +76,23 @@ public:
BorderInfo border;
FillInfo fill;
BiffStructurePtrVector ext_props;
FillInfoExt font_color;
size_t font_id;
bool fHasXFExt;
bool fsxButton;
//------------------------------------------------------------------
BiffStructurePtrVector ext_props;
BiffStructurePtrVector xf_props;
size_t border_x_id;
size_t fill_x_id;
size_t& cell_xf_current_id_;
size_t& style_xf_current_id_;
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
};

View File

@ -57,11 +57,11 @@ void List12TableStyleClientInfo::load(CFRecord& record)
unsigned short flags;
record >> flags;
nFirstColumn = GETBITS(flags, 0, 1);
nLastColumn = GETBITS(flags, 1, 2);
nRowStripes = GETBITS(flags, 3, 4);
nColumnStripes = GETBITS(flags, 5, 6);
nDefaultStyle = GETBITS(flags, 9, 10);
fFirstColumn = GETBIT(flags, 0);
fLastColumn = GETBIT(flags, 1);
fRowStripes = GETBIT(flags, 2);
fColumnStripes = GETBIT(flags, 3);
fDefaultStyle = GETBIT(flags, 6);
record >> stListStyleName;
}

View File

@ -51,11 +51,11 @@ public:
virtual void load(CFRecord& record);
unsigned char nFirstColumn;
unsigned char nLastColumn;
unsigned char nRowStripes;
unsigned char nColumnStripes;
unsigned char nDefaultStyle;
bool fFirstColumn;
bool fLastColumn;
bool fRowStripes;
bool fColumnStripes;
bool fDefaultStyle;
XLUnicodeString stListStyleName;
};

View File

@ -37,24 +37,20 @@ namespace XLS
{
LongRGBA::LongRGBA()
: is_alpha(true)
LongRGBA::LongRGBA() : is_alpha(true)
{
}
LongRGBA::LongRGBA(const bool alpha_present)
: is_alpha(alpha_present)
LongRGBA::LongRGBA(const bool alpha_present) : is_alpha(alpha_present)
{
}
LongRGB::LongRGB()
: LongRGBA(false)
LongRGB::LongRGB() : LongRGBA(false)
{
}
BiffStructurePtr LongRGBA::clone()
{
return BiffStructurePtr(new LongRGBA(*this));
@ -78,9 +74,14 @@ void LongRGBA::load(CFRecord& record)
alpha = 0;
record.skipNunBytes(1); // reserved
}
strRGB = STR::toRGB (red, green, blue);
strARGB = STR::toARGB(red, green, blue, alpha);
}
_UINT32 LongRGBA::ToRGBA()
{
return ((unsigned int)( ( (unsigned char)(red) )| ( ( (unsigned char)(green) ) << 8 ) | ( ( (unsigned char)(blue) ) << 16 ) | ( (unsigned char)(alpha) << 24 ) ) );
}
} // namespace XLS

View File

@ -50,7 +50,6 @@ public:
virtual void load(CFRecord& record);
unsigned char red;
unsigned char green;
unsigned char blue;
@ -59,6 +58,8 @@ public:
std::wstring strARGB;
std::wstring strRGB;
_UINT32 ToRGBA();
bool is_alpha;
};

View File

@ -100,6 +100,27 @@ void PtgNameX::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu
else
{
name = global_info->arDefineNames[nameindex - 1];
std::map<std::wstring, std::vector<std::wstring>>::iterator pFind = global_info->mapDefineNames.find(name);
if (link.empty() && full_ref && pFind != global_info->mapDefineNames.end())
{
if (ixti < pFind->second.size() && ixti >= 0)
{
if (!pFind->second[ixti].empty())
name = pFind->second[ixti]; //значение
}
else
{
for (size_t i = 0; i < pFind->second.size(); i++)
{
if (pFind->second[i].empty() == false)
{
link = L"[" + std::to_wstring(i) + L"]";
break;
}
}
}
}
}
if (!link.empty() && !name.empty())
{

View File

@ -94,7 +94,8 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
{
_Name = field_db->stFieldName.value();
if (std::wstring::npos != _Name.find(L" "))
if (std::wstring::npos != _Name.find(L" ") ||
std::wstring::npos != _Name.find(L":"))
{
_Name = L"'" + _Name + L"'";
}
@ -104,7 +105,13 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
SXOPER* cache = dynamic_cast<SXOPER*>(field->m_arSRCSXOPER[pair->iCache].get());
if (cache)
{
_Name += L"[" + cache->value + L"]";
std::wstring value = cache->value;
if (std::wstring::npos != value.find(L" ") ||
std::wstring::npos != value.find(L":"))
{
value = L"'" + value + L"'";
}
_Name += L"[" + value + L"]";
}
}
}

View File

@ -29,23 +29,29 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "StyleXF.h"
#include "XFProps.h"
#include "ExtProp.h"
#include <Binary/CFRecord.h>
#include "XFProp.h"
#include "ExtProp.h"
#include "XFPropColor.h"
#include "BitMarkedStructs.h"
#include "XFPropBorder.h"
#include "../Biff_records/Font.h"
namespace XLS
{
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell_xf_current_id_(cell_xf_current_id),
style_xf_current_id_(style_xf_current_id)
{
font_id = -1;
font_id = 0xFFFF;
border_x_id = -1;
fill_x_id = -1;
font = NULL;
fill.fls = 0;
}
@ -58,9 +64,9 @@ BiffStructurePtr StyleXF::clone()
void StyleXF::load(CFRecord& record)
{
m_GlobalWorkbookInfo = record.getGlobalWorkbookInfo();
global_info = record.getGlobalWorkbookInfo();
if (m_GlobalWorkbookInfo->Version < 0x0600)
if (global_info->Version < 0x0600)
{
_UINT16 flags1;
_UINT32 flags2;
@ -146,86 +152,153 @@ void StyleXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
FillInfoExt color_out;
{
color_out.enabled = true;
color_out.icv = ext_prop->extPropData.color.icv;
color_out.xclrType = ext_prop->extPropData.color.xclrType;
color_out.nTintShade = ext_prop->extPropData.color.nTintShade;
color_out.xclrValue = ext_prop->extPropData.color.xclrValue;
}
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
fill.foreFillInfo_ = color_out;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
fill.backFillInfo_ = color_out;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.topFillInfo_ = color_out;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.bottomFillInfo_ = color_out;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.leftFillInfo_ = color_out;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.rightFillInfo_ = color_out;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
font_color = color_out;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void StyleXF::Update(XFProps* xfProps)
void StyleXF::Update(XFProp* xfProp)
{
if (!xfProps) return;
if (!xfProp) return;
std::wstringstream strm;
xfProps->serialize_fill(strm);
fill.ext = strm.str();
XFPropColor* color = dynamic_cast<XFPropColor*>(xfProp->xfPropDataBlob.get());
if (color)
{
FillInfoExt color_out;
color_out.enabled = true;
color_out.icv = color->icv;
color_out.xclrType = color->xclrType;
color_out.nTintShade = color->nTintShade;
if (color->xclrType == 3)color_out.xclrValue = color->icv;
else color_out.xclrValue = color->dwRgba.ToRGBA();
switch(xfProp->xfPropType)
{
case 0x0001: fill.foreFillInfo_ = color_out; break;
case 0x0002: fill.backFillInfo_ = color_out; break;
case 0x0005: font_color = color_out; break;
}
return;
}
BIFF_BYTE* byte_ = dynamic_cast<BIFF_BYTE*>(xfProp->xfPropDataBlob.get());
if (byte_)
{
switch(xfProp->xfPropType)
{
case 0x0025:
{
font_id = *byte_->value();
if (font_id >=0 && font_id < global_info->m_arFonts.size())
{
font = dynamic_cast<Font*>(global_info->m_arFonts[font_id].get());
}
}break;
case 0x001C: if (font) font->fItalic = *byte_->value(); break;
case 0x001D: if (font) font->fStrikeOut = *byte_->value(); break;
case 0x001E: if (font) font->fOutline = *byte_->value(); break;
case 0x001F: if (font) font->fShadow = *byte_->value(); break;
case 0x0022: if (font) font->bCharSet = *byte_->value(); break;
}
return;
}
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(xfProp->xfPropDataBlob.get());
if (word)
{
switch(xfProp->xfPropType)
{
case 0x0019: if (font) font->bls = *word->value(); break;
case 0x001A: if (font) font->uls = *word->value(); break;
case 0x001B: if (font) font->sss = *word->value(); break;
}
return;
}
BIFF_DWORD* dword = dynamic_cast<BIFF_DWORD*>(xfProp->xfPropDataBlob.get());
if (dword)
{
switch(xfProp->xfPropType)
{
case 0x0024: if (font) font->dyHeight = *dword->value(); break;
}
return;
}
XFPropBorder *brdr = dynamic_cast<XFPropBorder*>(xfProp->xfPropDataBlob.get());
if (brdr)
{
FillInfoExt color_out;
color_out.enabled = true;
color_out.icv = brdr->color.icv;
color_out.xclrType = brdr->color.xclrType;
color_out.nTintShade = brdr->color.nTintShade;
if (brdr->color.xclrType == 3) color_out.xclrValue = brdr->color.icv;
else color_out.xclrValue = brdr->color.dwRgba.ToRGBA();
switch(xfProp->xfPropType)
{
case 0x0006: border.topFillInfo_ = color_out; break;
case 0x0007: border.bottomFillInfo_ = color_out; break;
case 0x0008: border.leftFillInfo_ = color_out; break;
case 0x0009: border.rightFillInfo_ = color_out; break;
//horiz, vert, diag
}
return;
}
}
void StyleXF::RegisterFillBorder()
{
@ -234,9 +307,15 @@ void StyleXF::RegisterFillBorder()
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
Update (ext_prop);
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
for (size_t i = 0; i < xf_props.size(); i++ )
{
XFProp* xf_prop = dynamic_cast<XFProp*>(xf_props[i].get());
Update (xf_prop);
}
border_x_id = global_info->RegisterBorderId(border);
fill_x_id = global_info->RegisterFillId(fill);
global_info->RegisterFontColorId(font_id, font_color);
}

View File

@ -36,9 +36,10 @@
namespace XLS
{
class XFProps;
class XFProp;
class ExtProp;
class CFRecord;
class Font;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
@ -52,17 +53,10 @@ public:
virtual void load(CFRecord& record);
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
static const ElementType type = typeStyleXF;
int serialize(std::wostream & stream);
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
unsigned char alc;
bool fWrap;
unsigned char alcV;
@ -72,13 +66,22 @@ public:
bool fShrinkToFit;
unsigned char iReadOrder;
//------------------------------------------------------------------
GlobalWorkbookInfoPtr global_info;
BorderInfo border;
FillInfo fill;
FillInfoExt font_color;
size_t font_id;
Font *font;
BiffStructurePtrVector ext_props;
BiffStructurePtrVector xf_props;
void Update(ExtProp* extProp); // xls style
void Update(XFProp* xfProp); //xlsx style
void RegisterFillBorder();
size_t border_x_id;
size_t fill_x_id;

View File

@ -29,16 +29,15 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "XFProp.h"
#include <Binary/CFRecord.h>
#include "XFPropColor.h"
#include "XFPropGradient.h"
#include "XFPropGradientStop.h"
#include "XFPropBorder.h"
#include "BiffString.h"
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "BitMarkedStructs.h"
#include <utils.h>
@ -145,8 +144,7 @@ static void serialize_color_prop(std::wostream & stream, const std::wstring & na
XFPropColor * color = dynamic_cast<XFPropColor*>(val.get());
if (!color) return;
color->node_name = name;
color->serialize(stream);
color->serialize(stream, name);
}
static void serialize_val_prop(std::wostream & stream, const std::wstring & name, BiffStructurePtr & val)
@ -218,7 +216,7 @@ static void serialize_border_prop(std::wostream & stream, const std::wstring & n
}
if (border->dgBorder != 0)
{
border->color.serialize(CP_XML_STREAM());
border->color.serialize(CP_XML_STREAM(), L"color");
}
}
}

View File

@ -32,8 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/FullColorExt.h>
#include <Logic/Biff_structures/XFExtGradient.h>
#include "FullColorExt.h"
#include <simple_xml_writer.h>
@ -59,5 +58,6 @@ public:
unsigned short cb;
BiffStructurePtr xfPropDataBlob;
};
typedef boost::shared_ptr<XFProp> XFPropPtr;
} // namespace XLS

View File

@ -49,7 +49,6 @@ public:
virtual void load(CFRecord& record);
XFPropColor color;
unsigned short dgBorder;
};

View File

@ -47,8 +47,6 @@ BiffStructurePtr XFPropColor::clone()
void XFPropColor::load(CFRecord& record)
{
node_name = L"color";
unsigned char flags;
record >> flags;
@ -58,7 +56,7 @@ void XFPropColor::load(CFRecord& record)
record >> icv >> nTintShade >> dwRgba;
}
int XFPropColor::serialize(std::wostream & stream)
int XFPropColor::serialize(std::wostream & stream, const std::wstring &node_name)
{
if (xclrType > 3 )return 0;//not set
@ -68,11 +66,11 @@ int XFPropColor::serialize(std::wostream & stream)
{
switch(xclrType)
{
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 2:
case 3: CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
//CP_XML_ATTR(L"theme", icv); break;
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 3: CP_XML_ATTR(L"theme", icv); break;
default:
CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
}
if (nTintShade != 0)
{

View File

@ -47,10 +47,9 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeXFPropColor;
int serialize(std::wostream & stream);
int serialize(std::wostream & stream, const std::wstring &sNode);
bool fValidRGBA;
unsigned char xclrType;

View File

@ -32,7 +32,6 @@
#include "XFPropGradientStop.h"
#include <Binary/CFRecord.h>
#include <simple_xml_writer.h>
namespace XLS
@ -59,7 +58,7 @@ int XFPropGradientStop::serialize(std::wostream & stream)
CP_XML_NODE(L"stop")
{
CP_XML_ATTR(L"position", numPosition);
color.serialize(CP_XML_STREAM());
color.serialize(CP_XML_STREAM(), L"color");
}
}
return 0;

View File

@ -29,10 +29,15 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "XFProps.h"
#include <Binary/CFRecord.h>
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "XFProp.h"
#include "XFPropColor.h"
#include "XFPropGradient.h"
#include "XFPropGradientStop.h"
#include "BitMarkedStructs.h"
namespace XLS
{
@ -43,8 +48,6 @@ BiffStructurePtr XFProps::clone()
return BiffStructurePtr(new XFProps(*this));
}
void XFProps::load(CFRecord& record)
{
arXFPropBorder.is_present = false;
@ -54,21 +57,24 @@ void XFProps::load(CFRecord& record)
for(int i = 0; i < cprops; ++i)
{
XFProp prop;
record >> prop;
XFPropPtr prop(new XFProp);
if (!prop) continue;
if (prop.xfPropType >= 0 && prop.xfPropType <= 3)
prop->load(record);
rgExt.push_back(prop);
if (prop->xfPropType >= 0 && prop->xfPropType <= 3)
{
arXFPropFill.push_back(prop);
}
else if (prop.xfPropType == 4)
else if (prop->xfPropType == 4)
{
arXFPropGradient.push_back(prop);
}
else if (prop.xfPropType >= 6 && prop.xfPropType <= 14)
else if (prop->xfPropType >= 6 && prop->xfPropType <= 14)
{
arXFPropBorder.is_present = true;
switch(prop.xfPropType)
switch(prop->xfPropType)
{
case 6: arXFPropBorder.top = prop; break;
case 7: arXFPropBorder.bottom = prop; break;
@ -78,20 +84,20 @@ void XFProps::load(CFRecord& record)
arXFPropBorder.other.push_back(prop);
}
}
else if (prop.xfPropType >= 15 && prop.xfPropType <= 22 || prop.xfPropType == 42)
else if (prop->xfPropType >= 15 && prop->xfPropType <= 22 || prop->xfPropType == 42)
{
arXFPropAlignment.push_back(prop);
}
else if (prop.xfPropType >= 24 && prop.xfPropType <= 37 || prop.xfPropType == 5)
else if (prop->xfPropType >= 24 && prop->xfPropType <= 37 || prop->xfPropType == 5)
{
arXFPropFont.push_back(prop);
}
else if (prop.xfPropType >= 38 && prop.xfPropType <= 41)
else if (prop->xfPropType >= 38 && prop->xfPropType <= 41)
{
bool skip_codes = false;
if (prop.xfPropType == 0x0029)
if (prop->xfPropType == 0x0029)
{
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop.xfPropDataBlob.get());
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop->xfPropDataBlob.get());
if ((word) && (word->value() == (_UINT16)30))
{
skip_codes = true;
@ -101,7 +107,7 @@ void XFProps::load(CFRecord& record)
if (!skip_codes)
arXFPropNumFmt.push_back(prop);
}
else if (prop.xfPropType >= 43 && prop.xfPropType <= 44)
else if (prop->xfPropType >= 43 && prop->xfPropType <= 44)
{
arXFPropProtection.push_back(prop);
}
@ -115,23 +121,23 @@ int XFProps::serialize_fill(std::wostream & stream)
{
if (arXFPropFill.empty()) return 0;
CP_XML_WRITER(stream)
{
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
switch(arXFPropFill[i]->xfPropType)
{
switch(arXFPropFill[i].xfPropType)
{
case 1:
case 0: pPatternType = &arXFPropFill[i]; break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i].xfPropDataBlob.get()); break;
}
case 0: pPatternType = arXFPropFill[i].get(); break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i]->xfPropDataBlob.get()); break;
}
}
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"fill")
{
if (pGradient || arXFPropGradient.size() > 0)
{
if (pGradient || arXFPropGradient.size() > 0)
{
CP_XML_NODE(L"gradientFill")
{
@ -140,26 +146,37 @@ int XFProps::serialize_fill(std::wostream & stream)
for (size_t i = 0 ; i < arXFPropGradient.size(); i++)
{
if (arXFPropGradient[i].xfPropDataBlob == NULL) continue;
arXFPropGradient[i].xfPropDataBlob->serialize(CP_XML_STREAM());
if (arXFPropGradient[i]->xfPropDataBlob == NULL) continue;
arXFPropGradient[i]->xfPropDataBlob->serialize(CP_XML_STREAM());
}
}
}
else if (pPatternType)
else
{
CP_XML_NODE(L"patternFill")
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
if (pPatternType)
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
}
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
arXFPropFill[i].serialize(CP_XML_STREAM());
XFPropColor *pColor = dynamic_cast<XFPropColor*>(arXFPropFill[i]->xfPropDataBlob.get());
if (!pColor) continue;
std::wstring sNode = L"color";
switch(arXFPropFill[i]->xfPropType)
{
case 1: sNode = L"fgColor"; break;
case 2: sNode = L"bgColor"; break;
}
pColor->serialize(CP_XML_STREAM(), sNode);
}
}
}
}
}
return 0;
}
@ -173,7 +190,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
for (size_t i = 0; i < arXFPropFont.size(); i++)
{
arXFPropFont[i].serialize(CP_XML_STREAM());
arXFPropFont[i]->serialize(CP_XML_STREAM());
}
}
}
@ -185,11 +202,11 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
if (dxf)
{
arXFPropNumFmt[i].serialize_attr(CP_GET_XML_NODE());
arXFPropNumFmt[i]->serialize_attr(CP_GET_XML_NODE());
}
else
{
arXFPropNumFmt[i].serialize(CP_XML_STREAM());
arXFPropNumFmt[i]->serialize(CP_XML_STREAM());
}
}
}
@ -202,7 +219,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
for (size_t i = 0; i < arXFPropAlignment.size(); i++)
{
arXFPropAlignment[i].serialize(CP_XML_STREAM());
arXFPropAlignment[i]->serialize(CP_XML_STREAM());
}
}
}
@ -219,7 +236,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
//----------------------------------------
for (size_t i = 0; i < arXFPropBorder.other.size(); i++)
{
arXFPropBorder.other[i].serialize(CP_XML_STREAM());
arXFPropBorder.other[i]->serialize(CP_XML_STREAM());
}
}
}

View File

@ -32,11 +32,13 @@
#pragma once
#include "BiffStructure.h"
#include "XFProp.h"
namespace XLS
{
class XFProp;
typedef boost::shared_ptr<XFProp> XFPropPtr;
class CFRecord;
class XFProps : public BiffStructure
@ -56,27 +58,31 @@ public:
int serialize_fill(std::wostream & stream);
std::vector<XFProp> arXFPropFont;
std::vector<XFProp> arXFPropNumFmt;
std::vector<XFProp> arXFPropFill;
std::vector<XFProp> arXFPropAlignment;
std::vector<XFPropPtr> arXFPropFont;
std::vector<XFPropPtr> arXFPropNumFmt;
std::vector<XFPropPtr> arXFPropFill;
std::vector<XFPropPtr> arXFPropAlignment;
struct _b
{
bool is_present;
bool is_present = false;
_CP_OPT(XFProp) left;
_CP_OPT(XFProp) right;
_CP_OPT(XFProp) top;
_CP_OPT(XFProp) bottom;
std::vector<XFProp> other;
XFPropPtr left;
XFPropPtr right;
XFPropPtr top;
XFPropPtr bottom;
std::vector<XFPropPtr> other;
}arXFPropBorder;
std::vector<XFProp> arXFPropProtection;
std::vector<XFProp> arXFPropGradient;
std::vector<XFPropPtr> arXFPropProtection;
std::vector<XFPropPtr> arXFPropGradient;
//-----------------------------------------------------
BiffStructurePtrVector rgExt;
bool fNewBorder;
bool bPresent;
};
} // namespace XLS

View File

@ -150,16 +150,15 @@ int XLUnicodeRichExtendedString::serialize (std::wostream & _stream)
int XLUnicodeRichExtendedString::serialize_rPr (std::wostream & _stream, int iFmt)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
int sz = pGlobalWorkbookInfoPtr->m_arFonts.size();
if (iFmt -1 > sz || iFmt < 1) return 0;
CP_XML_WRITER(_stream)
{
CP_XML_NODE(L"rPr")
{
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts[iFmt-1].get());
if (font) font->serialize_properties(CP_XML_STREAM(), true);
}

View File

@ -347,12 +347,11 @@ int ATTACHEDLABEL::serialize(std::wostream & _stream, bool isPosition)
int ATTACHEDLABEL::serialize_rPr (std::wostream & _stream, int iFmt, bool rtl, bool defRPr)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
int sz = pGlobalWorkbookInfoPtr->m_arFonts.size();
if (iFmt -1 > sz || iFmt < 1) return 0;
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts[iFmt-1].get());
Text * text_props = dynamic_cast<Text*>(m_TextProperties.get());

View File

@ -259,14 +259,13 @@ int AXS::serialize(std::wostream & _stream)
int AXS::serialize_rPr (std::wostream & _stream, int iFmt, _CP_OPT(unsigned int) color, bool rtl, bool defRPr)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
if (!pGlobalWorkbookInfoPtr) return 0;
Font * font = NULL;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
int sz = pGlobalWorkbookInfoPtr->m_arFonts.size();
if (iFmt > 0 && iFmt <= sz)
font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts.at(iFmt-1).get());
if (font)
{

View File

@ -31,6 +31,12 @@
*/
#include "CRT.h"
#include "LD.h"
#include "DROPBAR.h"
#include "SS.h"
#include "SHAPEPROPS.h"
#include "DFTTEXT.h"
#include "../Biff_records/ChartFormat.h"
#include "../Biff_records/Begin.h"
#include "../Biff_records/Bar.h"
@ -46,14 +52,9 @@
#include "../Biff_records/CrtLink.h"
#include "../Biff_records/SeriesList.h"
#include "../Biff_records/Chart3d.h"
#include "../Biff_unions/LD.h"
#include "../Biff_unions/DROPBAR.h"
#include "../Biff_records/CrtLine.h"
#include "../Biff_records/LineFormat.h"
#include "../Biff_unions/DFTTEXT.h"
#include "../Biff_records/DataLabExtContents.h"
#include "../Biff_unions/SS.h"
#include "../Biff_unions/SHAPEPROPS.h"
#include "../Biff_records/End.h"
#include "../Biff_records/ValueRange.h"
#include "../Biff_records/Tick.h"
@ -65,6 +66,7 @@
#include "../Biff_records/PlotArea.h"
#include "../Biff_records/DropBar.h"
#include "../Biff_records/CrtMlFrt.h"
#include "../Biff_records/DataFormat.h"
#include "../Biff_records/StartObject.h"
#include "../Biff_records/EndObject.h"

View File

@ -39,6 +39,7 @@
#include "../Biff_records/DBQueryExt.h"
#include "../Biff_records/ExtString.h"
#include "../Biff_records/DConn.h"
#include "../Biff_records/Qsi.h"
#include "../Biff_structures/DConnConnectionWeb.h"
#include "../Biff_structures/DConnConnectionOleDb.h"
@ -224,11 +225,24 @@ int DBQUERY::serialize_connection(std::wstring & name)
{
name = dcon->rgchConnectionName.strTotal;
}
//имена уникальны должны быть!!!
if (name.empty())
name = L"Connection" + std::to_wstring(global_info->connectionId);
DBQUERYEXT *query_ext = dynamic_cast<DBQUERYEXT*>(m_DBQUERYEXT.get());
DBQueryExt *dbQry_ext = query_ext ? dynamic_cast<DBQueryExt*>(query_ext->m_DBQueryExt.get()) : NULL;
std::map<std::wstring, int>::iterator pFind = global_info->connectionNames.find(name);
if (pFind == global_info->connectionNames.end())
{
global_info->connectionNames.insert(std::make_pair(name, 1));
}
else
{
name = name + L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
DBQUERYEXT *query_ext = dynamic_cast<DBQUERYEXT*>(m_DBQUERYEXT.get());
DBQueryExt *dbQry_ext = query_ext ? dynamic_cast<DBQueryExt*>(query_ext->m_DBQueryExt.get()) : NULL;
Qsi *info = dynamic_cast<Qsi*>(m_Qsi.get());
DConnConnectionWeb *webDb = dcon ? dynamic_cast<DConnConnectionWeb*>(dcon->connection.get()) : NULL;
DConnConnectionOleDb *oleDb = dcon ? dynamic_cast<DConnConnectionOleDb*>(dcon->connection.get()) : NULL;
@ -243,11 +257,12 @@ int DBQUERY::serialize_connection(std::wstring & name)
CP_XML_NODE(L"connection")
{
CP_XML_ATTR(L"id", global_info->connectionId);
CP_XML_ATTR(L"name", name);
if ( dbQry->query.dbt == 5 )
{
CP_XML_ATTR(L"keepAlive", 1);
}
CP_XML_ATTR(L"name", name);
if ((dcon) && (!dcon->rgchConnectionDesc.strTotal.empty()))
{
@ -255,13 +270,16 @@ int DBQUERY::serialize_connection(std::wstring & name)
}
CP_XML_ATTR(L"type", dbQry->query.dbt);
//background="1"
//saveData="1"
CP_XML_ATTR(L"refreshedVersion", 2);
if (info)
{
CP_XML_ATTR(L"background", info->fAsync);
CP_XML_ATTR(L"saveData", info->fSaveData);
}
if (dbQry->query.fSavePwd) CP_XML_ATTR(L"savePassword", 1);
CP_XML_ATTR(L"refreshedVersion", 1);
if (dbQry->typeRecord == 1)
{
}
@ -270,21 +288,30 @@ int DBQUERY::serialize_connection(std::wstring & name)
if ( dbQry->query.dbt == 6 )
{
TxtQry *query_txt = query_ext ? dynamic_cast<TxtQry*>(query_ext->m_TxtQry.get()) : NULL;
if (query_txt)
{
CP_XML_NODE(L"textPr")
{
CP_XML_ATTR(L"codePage", 1148);
CP_XML_ATTR(L"sourceFile", query_txt->rgchFile.value());
//delimited="0"
CP_XML_ATTR(L"delimited", query_txt->fDelimited);
wchar_t v = query_txt->chDecimal;
CP_XML_ATTR(L"decimal", std::wstring(&v, 1));
v = query_txt->chThousSep;
CP_XML_ATTR(L"thousands", std::wstring(&v, 1));
CP_XML_NODE(L"textFields")
{
CP_XML_ATTR(L"count", query_txt->rgtxtwf.size());
for (size_t i = 0; i < query_txt->rgtxtwf.size(); i++)
{
CP_XML_NODE(L"textField")
{
switch(query_txt->rgtxtwf[i].fieldType)
{
case 0: CP_XML_ATTR(L"type", L"general"); break;
//case 0: CP_XML_ATTR(L"type", L"general"); break;
case 1: CP_XML_ATTR(L"type", L"text"); break;
case 2: CP_XML_ATTR(L"type", L"MDY"); break;
case 3: CP_XML_ATTR(L"type", L"DMY"); break;
@ -303,7 +330,7 @@ int DBQUERY::serialize_connection(std::wstring & name)
}
}
else
{
{
size_t index = 0;
size_t commandType = 1;

View File

@ -66,6 +66,7 @@ public:
std::vector<std::wstring> m_arSXString;
//------------------------------------------------------
BaseObjectPtr m_DBQUERYEXT;
BaseObjectPtr m_Qsi;
BaseObjectPtr m_DConn;
GlobalWorkbookInfoPtr global_info;

View File

@ -76,11 +76,16 @@ const bool DFTTEXT::loadContent(BinProcessor& proc)
m_DefaultText = elements_.back();
elements_.pop_back();
}
if (proc.optional<DataLabExtContents>())
{
m_DataLabExtContents = elements_.back();
elements_.pop_back();
}
if (!m_DefaultText && !m_DataLabExtContents)
return false;
if (proc.mandatory<ATTACHEDLABEL>())
{
m_ATTACHEDLABEL = elements_.back();
@ -89,10 +94,7 @@ const bool DFTTEXT::loadContent(BinProcessor& proc)
if (proc.optional<EndObject>()) elements_.pop_back();
if (m_DefaultText || m_DataLabExtContents)
return true;
else
return false;
return true;
}
} // namespace XLS

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of DROPBAR union of records
class DROPBAR: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(DROPBAR)

View File

@ -31,15 +31,17 @@
*/
#include "DROPBAR.h"
#include <Logic/Biff_records/DropBar.h>
#include <Logic/Biff_records/Begin.h>
#include <Logic/Biff_records/LineFormat.h>
#include <Logic/Biff_records/AreaFormat.h>
#include <Logic/Biff_unions/GELFRAME.h>
#include <Logic/Biff_unions/SHAPEPROPS.h>
#include <Logic/Biff_records/End.h>
#include <Logic/Biff_records/StartObject.h>
#include <Logic/Biff_records/EndObject.h>
#include "GELFRAME.h"
#include "SHAPEPROPS.h"
#include "../Biff_records/DropBar.h"
#include "../Biff_records/LineFormat.h"
#include "../Biff_records/AreaFormat.h"
#include "../Biff_records/Begin.h"
#include "../Biff_records/End.h"
#include "../Biff_records/StartObject.h"
#include "../Biff_records/EndObject.h"
namespace XLS
{
@ -72,7 +74,7 @@ const bool DROPBAR::loadContent(BinProcessor& proc)
if (proc.mandatory<Begin>()) elements_.pop_back();
if (proc.mandatory<LineFormat>())
if (proc.optional<LineFormat>())
{
m_LineFormat = elements_.back(); elements_.pop_back();
}
@ -81,11 +83,10 @@ const bool DROPBAR::loadContent(BinProcessor& proc)
elements_.pop_back();
if (proc.mandatory<EndObject>()) elements_.pop_back();
}
if (proc.mandatory<AreaFormat>())
if (proc.optional<AreaFormat>())
{
m_AreaFormat = elements_.back(); elements_.pop_back();
}
if (proc.optional<GELFRAME>())
{
m_GELFRAME = elements_.back(); elements_.pop_back();

View File

@ -210,7 +210,7 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
if (!block_level->stData.value().empty())
CP_XML_ATTR(L"dataCellStyle", block_level->stData.value());
}
if (feature11->rgbFeat.fAutoFilter && (filter || sort))
if (feature11->rgbFeat.fAutoFilter)
{
if(sort)
{
@ -236,7 +236,7 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
}
}
}
else
else if (filter)
{
CP_XML_NODE(L"autoFilter")
{
@ -254,6 +254,13 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
}
}
}
else
{
CP_XML_NODE(L"autoFilter")
{
CP_XML_ATTR(L"ref", feature11->sqref);
}
}
}
CP_XML_NODE(L"tableColumns")
@ -269,6 +276,9 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
CP_XML_ATTR(L"id", field->idField);
CP_XML_ATTR(L"name", field->strCaption.value());
if (!field->strTotal.value().empty())
CP_XML_ATTR(L"totalsRowLabel", field->strTotal.value());
if (field->dxfFmtAgg.bExist ||
field->dxfFmtInsertRow.bExist)
{
@ -287,11 +297,11 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
{
CP_XML_NODE(L"tableStyleInfo")
{
CP_XML_ATTR(L"name", table_style->stListStyleName.value());
CP_XML_ATTR(L"showFirstColumn", table_style->nFirstColumn);
CP_XML_ATTR(L"showLastColumn", table_style->nLastColumn);
CP_XML_ATTR(L"showRowStripes", table_style->nRowStripes);
CP_XML_ATTR(L"showColumnStripes", table_style->nColumnStripes);
CP_XML_ATTR(L"name", table_style->stListStyleName.value());
CP_XML_ATTR(L"showFirstColumn", table_style->fFirstColumn);
CP_XML_ATTR(L"showLastColumn", table_style->fLastColumn);
CP_XML_ATTR(L"showRowStripes", table_style->fRowStripes);
CP_XML_ATTR(L"showColumnStripes", table_style->fColumnStripes);
}
}
}

View File

@ -79,7 +79,7 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
Font *font = dynamic_cast<Font *>(elements_.front().get());
if ((font) && (font->correct))
{
m_arFonts.push_back(elements_.front());
global_info->m_arFonts.push_back(elements_.front());
}
elements_.pop_front();
count--;
@ -94,10 +94,10 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
}
//----------------------------------------------------------------------------------------------------
count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally Font follows by Format)
int countFonts = m_arFonts.size();
int countFonts = global_info->m_arFonts.size();
while(count > 0)
{
m_arFonts.insert(m_arFonts.begin()+countFonts, elements_.back());
global_info->m_arFonts.insert(global_info->m_arFonts.begin() + countFonts, elements_.back());
elements_.pop_back();
count--;
}
@ -156,40 +156,40 @@ void FORMATTING::update_xfs()
if (!xfs) return;
//for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
//{
// XLS::Style * style = dynamic_cast<Style*>(st->m_arStyles[i].first.get());
// XLS::StyleExt * styleExt = dynamic_cast<StyleExt*>(st->m_arStyles[i].second.get());
//
// if (styleExt && style)
// {
// if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
// {
// bool bFound = false;
// for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
// {
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
{
XLS::Style *style = dynamic_cast<Style*> (st->m_arStyles[i].first.get());
XLS::StyleExt *styleExt = dynamic_cast<StyleExt*> (st->m_arStyles[i].second.get());
if (styleExt && style)
{
if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
{
bool bFound = false;
for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
{
XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->style.Update(&styleExt->xfProps);
// bFound = true;
// break;
// }
// }
// //for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++)
// //{
// // XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// // if (xf->ind_xf == style->ixfe)
// // {
// // xf->cell.Update(&styleExt->xfProps);
// // bFound = true;
// // break;
// // }
// //}
// }
// }
//}
if (xf->ind_xf == style->ixfe)
{
xf->style.xf_props = styleExt->xfProps.rgExt;
bFound = true;
break;
}
}
//for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++) небывает совпадений
//{
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->cell.xf_props = styleExt->xfProps.rgExt;
// bFound = true;
// break;
// }
//}
}
}
}
xfs->RegisterFillBorder();
}
void FORMATTING::concatinate(FORMATTING* ext)
@ -234,20 +234,23 @@ int FORMATTING::serialize1(std::wostream & stream)
}
}
}
if (m_arFonts.size() > 0)
if (!global_info->m_arFonts.empty())
{
CP_XML_NODE(L"fonts")
{
CP_XML_ATTR(L"count", m_arFonts.size());
for (size_t i = 0 ; i < m_arFonts.size(); i++)
CP_XML_ATTR(L"count", global_info->m_arFonts.size());
for (size_t i = 0; i < global_info->m_arFonts.size(); i++)
{
Font * font = dynamic_cast<Font*>(m_arFonts[i].get());
Font * font = dynamic_cast<Font*>(global_info->m_arFonts[i].get());
std::map<int, FillInfoExt>::iterator it = global_info->fonts_color_ext.find(i);
if (font && (it!=global_info->fonts_color_ext.end()))
if (font && (it != global_info->fonts_color_ext.end()))
{
font->set_color_ext(it->second);
}
m_arFonts[i]->serialize(CP_XML_STREAM());
global_info->m_arFonts[i]->serialize(CP_XML_STREAM());
}
}
}

View File

@ -60,7 +60,7 @@ public:
BaseObjectPtr m_Styles;
BaseObjectPtr m_XFS;
std::vector<BaseObjectPtr> m_arFormats;
std::vector<BaseObjectPtr> m_arFonts;
//std::vector<BaseObjectPtr> m_arFonts; in global
BaseObjectPtr m_Palette;
BaseObjectPtr m_ClrtClient;
std::vector<BaseObjectPtr> m_arDXF;

View File

@ -92,6 +92,10 @@ int PROTECTION_COMMON::serialize (std::wostream & _stream)
{
CP_XML_NODE(L"sheetProtection")
{
if (password)
{
CP_XML_ATTR(L"password", password->wPassword);
}
if (protect)
{
CP_XML_ATTR(L"sheet", (protect->fLock ? 1 : 0));
@ -105,6 +109,7 @@ int PROTECTION_COMMON::serialize (std::wostream & _stream)
CP_XML_ATTR(L"scenarios", (scenario->fScenProtect ? 1 : 0));
}
CP_XML_ATTR(L"selectLockedCells", 1);
CP_XML_ATTR(L"selectUnlockedCells", 1);
}
}

View File

@ -42,6 +42,8 @@
#include "../Biff_records/DbOrParamQry.h"
#include "../Biff_records/SXString.h"
#include "../../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace XLS
{
@ -107,8 +109,10 @@ int QUERYTABLE::serialize(std::wostream & strm)
if (!query) return -1;
std::wstring name = info->rgchName.value();
query->m_DBQUERYEXT = m_DBQUERYEXT;
query->m_Qsi = m_Qsi;
int connectionId = query->serialize_connection(name);
if (connectionId < 1) return 0;
@ -121,16 +125,16 @@ int QUERYTABLE::serialize(std::wostream & strm)
CP_XML_ATTR(L"connectionId", connectionId);
CP_XML_ATTR(L"name", name);
if (info->fAutoFormat)
if (!info->fAutoFormat)
{
CP_XML_ATTR(L"autoFormatId", info->itblAutoFmt);
}
CP_XML_ATTR(L"applyNumberFormats", info->fibitAtrNum);//0"
CP_XML_ATTR(L"applyBorderFormats", info->fibitAtrBdr);//0"
CP_XML_ATTR(L"applyFontFormats", info->fibitAtrFnt);//1"
CP_XML_ATTR(L"applyPatternFormats", info->fibitAtrPat);//1"
CP_XML_ATTR(L"applyAlignmentFormats", info->fibitAtrAlc);//0"
//CP_XML_ATTR(L"applyWidthHeightFormats", info->);//0"/>
CP_XML_ATTR(L"applyNumberFormats", info->fibitAtrNum);
CP_XML_ATTR(L"applyBorderFormats", info->fibitAtrBdr);
CP_XML_ATTR(L"applyFontFormats", info->fibitAtrFnt);
CP_XML_ATTR(L"applyPatternFormats", info->fibitAtrPat);
CP_XML_ATTR(L"applyAlignmentFormats", info->fibitAtrAlc);
CP_XML_ATTR(L"applyWidthHeightFormats", 0);
}
}

View File

@ -127,7 +127,8 @@ void SXFMLA::serialize_attr(CP_ATTR_NODE)
global_info->arPivotSxNames = m_arPivotSxNames;
CP_XML_ATTR(L"formula", sx_fmla->fmla.getAssembledFormula());
std::wstring fmla = sx_fmla->fmla.getAssembledFormula();
CP_XML_ATTR(L"formula", fmla);
}

View File

@ -31,11 +31,11 @@
*/
#include "WINDOW.h"
#include <Logic/Biff_records/Window2.h>
#include <Logic/Biff_records/PLV.h>
#include <Logic/Biff_records/Scl.h>
#include <Logic/Biff_records/Pane.h>
#include <Logic/Biff_records/Selection.h>
#include "../Biff_records/Window2.h"
#include "../Biff_records/PLV.h"
#include "../Biff_records/Scl.h"
#include "../Biff_records/Pane.h"
#include "../Biff_records/Selection.h"
namespace XLS
{

View File

@ -586,7 +586,7 @@ int ChartSheetSubstream::serialize_3D (std::wostream & _stream)
if (ax_parent->iax == 0) //primary axes
{
for (int i = 0 ; i < parent->m_arCRT.size() ; i++)
for (size_t i = 0 ; i < parent->m_arCRT.size() ; i++)
{
CRT* crt = dynamic_cast<CRT*>(parent->m_arCRT[i].get());
if((crt) && (crt->m_Chart3d))
@ -1217,7 +1217,7 @@ int ChartSheetSubstream::serialize_ser (std::wstring sNodeSer, std::wostream & _
AI * ai = dynamic_cast<AI *>(ai_.get());
BRAI * brai = dynamic_cast<BRAI *>(ai->m_BRAI.get());
std::wstring formula = brai->formula.getAssembledFormula();
std::wstring formula = brai->formula.getAssembledFormula(true);
int rt = brai->rt;
bool b = brai->fUnlinkedIfmt;

View File

@ -87,8 +87,6 @@ int CommonSubstream::serialize_format(std::wostream & strm)
SheetExt *sheet_ext = dynamic_cast<SheetExt*>(m_SheetExt.get());
CodeName *code_name = dynamic_cast<CodeName*>(m_CodeName.get());
if (!code_name || !sheet_ext) return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"sheetPr")

View File

@ -94,8 +94,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
return std::pair<float, float>(width, maxHeight);
}
GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConverter * xls_converter_)
: CodePage(code_page)
GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConverter * converter) : CodePage(code_page), xls_converter(converter)
{
fill_x_ids[FillInfo(0, 0, 0)] = 0;
fill_x_ids[FillInfo(17, 64, 65)] = 1;
@ -105,8 +104,6 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
Version = 0x0600;
xls_converter = xls_converter_;
startAddedSharedStrings = 0;
current_sheet = 0;
cmt_rules = 0;
@ -122,6 +119,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
bVbaProjectExist = false;
bMacrosExist = false;
bThemePresent = false;
idPivotCache = 0;
}
@ -188,9 +186,9 @@ void GlobalWorkbookInfo::GetDigitFontSizePixels()
}
defaultDigitFontSize = std::pair<float, float>(7,8);
if (m_arFonts->size() < 1) return;
if (m_arFonts.empty()) return;
Font * font = dynamic_cast<Font*>(m_arFonts->at(0).get());
Font * font = dynamic_cast<Font*>(m_arFonts[0].get());
if (!font) return;
std::wstring fontName = font->fontName.value();

View File

@ -84,6 +84,7 @@ public:
//-----------------------------------------------------------------------------
bool bVbaProjectExist;
bool bMacrosExist;
bool bThemePresent;
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
@ -96,7 +97,7 @@ public:
std::map<int, int> fonts_charsets;
std::map<int, std::wstring> colors_palette;
std::vector<BaseObjectPtr> *m_arFonts;
std::vector<BaseObjectPtr> m_arFonts;
unsigned int current_sheet;
@ -155,6 +156,8 @@ public:
CApplicationFonts *applicationFonts;
std::wstring fontsDirectory;
std::wstring tempDirectory;
int Version;
int cmt_rules;
@ -166,6 +169,7 @@ public:
std::wstringstream connections_stream;
int connectionId;
std::map<std::wstring, int> connectionNames;
XlsConverter *xls_converter;

View File

@ -333,7 +333,6 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
if (fmts)
{
global_info_->cellStyleDxfs_count = fmts->m_arDXF.size();
global_info_->m_arFonts = &fmts->m_arFonts;
}
}
//else

View File

@ -52,6 +52,8 @@
#include "Biff_records/DefaultRowHeight.h"
#include "Biff_records/Label.h"
#include "Biff_records/List12.h"
#include "Biff_records/PLV.h"
#include "Biff_records/CFEx.h"
#include "Biff_unions/BACKGROUND.h"
#include "Biff_unions/BIGNAME.h"
@ -455,6 +457,18 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
count--;
}
}break;
case rt_CFEx: //Calculadora.xls не в FORMATING
{
count = proc.repeated<CFEx> (0, 0);
}break;
case rt_PLV: //Calculadora.xls не в FORMATING
{
if (proc.optional<PLV>())
{
m_PLV = elements_.back();
elements_.pop_back();
}
}break;
case rt_HeaderFooter:
{
count = proc.repeated<RECORD12> (0, 0);

View File

@ -59,6 +59,7 @@ public:
BaseObjectPtr m_DxGCol;
BaseObjectPtr m_DVAL;
BaseObjectPtr m_LRng;
BaseObjectPtr m_PLV;
std::vector<BaseObjectPtr> m_arMergeCells;
std::vector<BaseObjectPtr> m_arPIVOTVIEW;

View File

@ -36,9 +36,9 @@
#include "../../../Common/OfficeFileErrorDescription.h"
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* pCallBack, bool &bMacros)
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring & fontsPath, const std::wstring & tempPath, const ProgressCallback* pCallBack, bool &bMacros)
{
XlsConverter converter(srcFile, dstPath, password, fontsPath, pCallBack, bMacros);
XlsConverter converter(srcFile, dstPath, password, fontsPath, tempPath, pCallBack, bMacros);
if (converter.isError())
{

View File

@ -33,4 +33,4 @@
struct ProgressCallback;
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring& fontsPath, const ProgressCallback* CallBack, bool & bMacros);
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring& fontsPath, const std::wstring & tempPath, const ProgressCallback* CallBack, bool & bMacros);

View File

@ -75,6 +75,7 @@
#include "../XlsFormat/Logic/Biff_records/IMDATA.h"
#include "../XlsFormat/Logic/Biff_records/Note.h"
#include "../XlsFormat/Logic/Biff_records/WsBool.h"
#include "../XlsFormat/Logic/Biff_records/Theme.h"
#include "../XlsFormat/Logic/Biff_structures/URLMoniker.h"
#include "../XlsFormat/Logic/Biff_structures/FileMoniker.h"
@ -94,9 +95,9 @@
#include <simple_xml_writer.h>
#include <utils.h>
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include <boost/lexical_cast.hpp>
#include <boost/utility.hpp>
//#include <boost/utility.hpp>
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/raster/BgraFrame.h"
@ -127,7 +128,7 @@ typedef struct tagBITMAPCOREHEADER {
} BITMAPCOREHEADER;
#endif
XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, 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 std::wstring & tempPath, const ProgressCallback* CallBack, bool & bMacros)
{
xlsx_path = xlsxFilePath;
output_document = NULL;
@ -174,6 +175,7 @@ XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring
xls_global_info->fontsDirectory = fontsPath;
xls_global_info->password = password;
xls_global_info->tempDirectory = tempPath;
XLS::CFStreamCacheReader stream_reader(xls_file->getWorkbookStream(), xls_global_info);
@ -687,9 +689,9 @@ void XlsConverter::convert(XLS::GlobalsSubstream* globals)
{
if (globals == NULL) return;
convert((XLS::FORMATTING*)globals->m_Formating.get());
convert((XLS::THEME*)globals->m_THEME.get());
convert((XLS::FORMATTING*)globals->m_Formating.get());
convert((XLS::SHAREDSTRINGS*)globals->m_SHAREDSTRINGS.get());
@ -1086,9 +1088,45 @@ void XlsConverter::convert(XLS::BACKGROUND * back)
}
void XlsConverter::convert(XLS::THEME* theme)
void XlsConverter::convert(XLS::THEME* THEME_)
{
if (theme == NULL) return;
if (THEME_ == NULL) return;
XLS::Theme *theme = dynamic_cast<XLS::Theme*>(THEME_->m_Theme.get());
if (!theme) return;
if (theme->nThemeDataSize < 1) return;
std::wstring tempThemePath = xls_global_info->tempDirectory + FILE_SEPARATOR_STR + L"theme.temp";
NSFile::CFileBinary file;
if (!file.CreateFileW(tempThemePath)) return;
file.WriteFile((BYTE*)theme->pThemeData.get(), theme->nThemeDataSize);
file.CloseFile();
COfficeUtils OfficeUtils(NULL);
ULONG nBufferSize = 0;
BYTE *pBuffer = NULL;
HRESULT hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme1.xml", &pBuffer, nBufferSize);// todooo - parsing ThemeManager
if (hresult != S_OK || pBuffer == NULL)
hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme/theme1.xml", &pBuffer, nBufferSize);
if (hresult != S_OK || pBuffer == NULL)
hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme/theme/theme1.xml", &pBuffer, nBufferSize);
//??? переписать по нормальному
if (hresult == S_OK && pBuffer != NULL)
{
xls_global_info->bThemePresent = true;
oox::package::theme_content_ptr content = oox::package::theme_content::create((char*)pBuffer, nBufferSize);
output_document->get_xl_files().add_theme(content);
delete []pBuffer;
pBuffer = NULL;
}
}
struct _group_object

View File

@ -102,7 +102,7 @@ namespace ODRAW
class XlsConverter
{
public:
XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, 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 std::wstring & tempPath, const ProgressCallback* ffCallBack, bool & bMacros);
~XlsConverter() ;
oox::xlsx_conversion_context * xlsx_context;

View File

@ -201,7 +201,23 @@ void rels_files::add(std::wstring const & Id,
{
return add(relationship(Id, Type, Target, TargetMode));
}
//--------------------------------------------------------------------------------------------
customXml_content::customXml_content()
{
}
_CP_PTR(customXml_content) customXml_content::create()
{
return boost::make_shared<customXml_content>();
}
//--------------------------------------------------------------------------------------------
theme_content::theme_content(char* data, size_t size)
{
content_ = std::string(data, size);
}
_CP_PTR(theme_content) theme_content::create(char* data, size_t size)
{
return boost::make_shared<theme_content>(data, size);
}
//----------------------------------------------------------------------------------------
chart_content::chart_content() : rels_file_(rels_file::create(L""))
{

View File

@ -215,6 +215,22 @@ private:
std::string content_props;
};
//------------------------------------------------------------------------
class theme_content;
typedef _CP_PTR(theme_content) theme_content_ptr;
class theme_content : boost::noncopyable
{
public:
theme_content(char* data, size_t size);
static _CP_PTR(theme_content) create(char* data, size_t size);
std::string content() { return content_; }
friend class xl_theme_files;
private:
std::string content_;
};
//------------------------------------------------------------------------
class document : public element
{
public:

View File

@ -229,9 +229,15 @@ void xlsx_conversion_context::add_query_table (const std::wstring & query_table)
{
if (query_table.empty()) return;
std::wstring rid = L"qtId" + std::to_wstring(query_tables_.size() + 1);
std::wstring target = L"queryTable" + std::to_wstring(query_tables_.size() + 1) + L".xml";
query_tables_.insert(std::make_pair(target, query_table));
current_sheet().sheet_rels().add(oox::relationship(rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable",
L"../queryTables/" + target));
}
void xlsx_conversion_context::add_control_props(const std::wstring & target, const std::wstring & props)

View File

@ -550,33 +550,33 @@ void xlsx_drawing_context::end_group()
{
if (current_level < 1) return;
std::vector<_drawing_state_ptr>* cur_states = NULL;
for (size_t i = 0; i < current_drawing_states->size(); i++)
{
if (!current_drawing_states->empty())
{
int level = current_level;
cur_states = current_drawing_states;
while (level > 0)
{
_drawing_state_ptr & drawing_state = cur_states->front();
//std::vector<_drawing_state_ptr>* cur_states = NULL;
//for (size_t i = 0; i < current_drawing_states->size(); i++)
//{
// if (!current_drawing_states->empty())
// {
// int level = current_level;
// cur_states = current_drawing_states;
// while (level > 0)
// {
// _drawing_state_ptr & drawing_state = cur_states->front();
if (i != 0 || level != current_level) // группа сама себя
{
double kf_x = (double)drawing_state->child_anchor.cx / drawing_state->group_anchor.cx;
double kf_y = (double)drawing_state->child_anchor.cy / drawing_state->group_anchor.cy;
// if (i != 0 || level != current_level) // группа сама себя
// {
// double kf_x = (double)drawing_state->child_anchor.cx / drawing_state->group_anchor.cx;
// double kf_y = (double)drawing_state->child_anchor.cy / drawing_state->group_anchor.cy;
current_drawing_states->at(i)->child_anchor.cx *= kf_x;
current_drawing_states->at(i)->child_anchor.cy *= kf_y;
current_drawing_states->at(i)->child_anchor.x = current_drawing_states->at(i)->child_anchor.x * kf_x + drawing_state->child_anchor.x;
current_drawing_states->at(i)->child_anchor.y = current_drawing_states->at(i)->child_anchor.y * kf_y + drawing_state->child_anchor.y;
}
level--;
cur_states = cur_states->front()->parent_drawing_states;
}
}
}
// current_drawing_states->at(i)->child_anchor.cx *= kf_x;
// current_drawing_states->at(i)->child_anchor.cy *= kf_y;
//
// current_drawing_states->at(i)->child_anchor.x = current_drawing_states->at(i)->child_anchor.x * kf_x + drawing_state->child_anchor.x;
// current_drawing_states->at(i)->child_anchor.y = current_drawing_states->at(i)->child_anchor.y * kf_y + drawing_state->child_anchor.y;
// }
// level--;
// cur_states = cur_states->front()->parent_drawing_states;
// }
// }
//}
serialize_group();
current_drawing_states = current_drawing_states->front()->parent_drawing_states;
@ -2146,6 +2146,7 @@ void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state
if (drawing_state->wordart.italic) CP_XML_ATTR(L"i", 1);
if (drawing_state->wordart.underline) CP_XML_ATTR(L"u", L"sng");
if (drawing_state->wordart.strike) CP_XML_ATTR(L"strike", L"sngStrike");
//if (drawing_state->wordart.cap) CP_XML_ATTR(L"cap", *cap);
CP_XML_ATTR(L"kern", 10);

View File

@ -137,14 +137,6 @@ _CP_PTR(activeX_content) activeX_content::create()
return boost::make_shared<activeX_content>();
}
//--------------------------------------------------------------------------------------------
customXml_content::customXml_content()
{
}
_CP_PTR(customXml_content) customXml_content::create()
{
return boost::make_shared<customXml_content>();
}
//--------------------------------------------------------------------------------------------
sheet_content::sheet_content() : rels_(rels_file::create(L""))
{
@ -300,11 +292,15 @@ void xl_files::write(const std::wstring & RootPath)
contentTypes.add_override(L"/xl/connections.xml", L"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml");
}
{
theme_files_.set_rels(&rels_files_);
theme_files_.set_main_document( this->get_main_document() );
theme_files_.write(path);
}
if (styles_)
{
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
}
if (workbook_)
@ -329,11 +325,6 @@ void xl_files::write(const std::wstring & RootPath)
contentTypes.add_override(L"/xl/attachedToolbars.bin", L"application/vnd.ms-excel.attachedToolbars");
}
if (theme_)
{
theme_->write(path);
}
if (media_)
{
media_->set_main_document(get_main_document());
@ -398,7 +389,6 @@ void xl_files::set_connections(element_ptr Element)
{
connections_ = Element;
}
void xl_files::add_sheet(int type, sheet_content_ptr sheet)
{
sheets_files_.add_sheet(type, sheet);
@ -422,6 +412,10 @@ void xl_files::set_vml_drawings(element_ptr Element)
xl_drawings* d = dynamic_cast<xl_drawings*>(vml_drawings_.get());
d->vml = true;
}
void xl_files::add_theme(theme_content_ptr theme)
{
theme_files_.add_theme(theme);
}
void xl_files::add_chart(chart_content_ptr chart)
{
charts_files_.add_chart(chart);
@ -702,6 +696,44 @@ void xl_customXml_files::write(const std::wstring & RootPath)
}
}
//----------------------------------------------------------------------------------------
void xl_theme_files::add_theme(theme_content_ptr themeXml)
{
themes_.push_back(themeXml);
}
void xl_theme_files::write(const std::wstring & RootPath)
{
if (themes_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme";
NSDirectory::CreateDirectory(path.c_str());
std::wstring path_rels = path + FILE_SEPARATOR_STR + L"_rels";
NSDirectory::CreateDirectory(path_rels.c_str());
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
for (size_t i = 0; i < themes_.size(); i++)
{
if (!themes_[i])continue;
const std::wstring fileName = std::wstring(L"theme") + std::to_wstring(i + 1) + L".xml";
contentTypes.add_override(std::wstring(L"/xl/theme/") + fileName, kWSConType);
package::simple_element(fileName, themes_[i]->content()).write(path);
if (rels_)
{
const std::wstring id = std::wstring(L"thmId") + std::to_wstring(i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
const std::wstring fileRef = std::wstring(L"theme/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
}
}
//----------------------------------------------------------------------------------------
void xl_externals_files::add_external(external_content_ptr external)
{
externals_.push_back(external);

View File

@ -208,6 +208,21 @@ public:
std::vector<customXml_content_ptr> customXmls_;
rels_files * rels_;
};
class xl_theme_files : public element
{
public:
xl_theme_files(){}
void set_rels(rels_files * rels)
{
rels_ = rels;
}
void add_theme(theme_content_ptr themeXml);
virtual void write(const std::wstring & RootPath);
std::vector<theme_content_ptr> themes_;
rels_files * rels_;
};
class xl_query_table_files : public element
{
public:
@ -344,6 +359,7 @@ public:
void set_vml_drawings (element_ptr Element);
void set_comments (element_ptr Element);
void add_theme (theme_content_ptr theme);
void add_chart (chart_content_ptr chart);
void add_activeX (activeX_content_ptr activeX);
void add_external (external_content_ptr external);
@ -357,6 +373,7 @@ public:
private:
rels_files rels_files_;
sheets_files sheets_files_;
xl_theme_files theme_files_;
xl_charts_files charts_files_;
xl_externals_files externals_files_;
xl_pivot_cache_files pivot_cache_files_;
@ -366,11 +383,10 @@ private:
xl_control_props_files control_props_files_;
xl_table_part_files table_part_files_;
element_ptr theme_;
element_ptr workbook_;
element_ptr connections_;
element_ptr styles_;
element_ptr styles_;
element_ptr sharedStrings_;
element_ptr media_;
element_ptr drawings_;

View File

@ -44,6 +44,7 @@
#define AVS_ERROR_FILEFORMAT (AVS_ERROR_FIRST + 0x0004)
#define AVS_ERROR_PASSWORD (AVS_ERROR_FIRST + 0x0005)
#define AVS_ERROR_DRM (AVS_ERROR_FIRST + 0x0006)
#define AVS_ERROR_MACRO (AVS_ERROR_FIRST + 0x0007)
// AVSOfficeUniversalConverter 0x0050 - 0x0075
#define AVS_UNIVERSALDOCUMENTCONVERTER_ERROR_FIRST (AVS_ERROR_FIRST + 0x0050)

View File

@ -42,11 +42,13 @@ namespace POLE
class COfficeFileFormatChecker
{
public:
int nFileType;
int nFileType;
bool bMacroEnabled;
COfficeFileFormatChecker()
{
nFileType = AVS_OFFICESTUDIO_FILE_UNKNOWN;
nFileType = AVS_OFFICESTUDIO_FILE_UNKNOWN;
bMacroEnabled = false;
}
COfficeFileFormatChecker(std::wstring sFileName)
{

View File

@ -34,6 +34,10 @@
#include "../DesktopEditor/common/File.h"
#include "../OfficeUtils/src/OfficeUtils.h"
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
#include "../ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h"
#endif
#include "3dParty/pole/pole.h"
#include <algorithm>
@ -145,6 +149,12 @@ bool COfficeFileFormatChecker::isDocFormatFile (POLE::Storage * storage)
if (entries.size() > 0)
return false;
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
if (storage->isDirectory(L"Macros"))
{
bMacroEnabled = true;
}
#endif
return true;
}
@ -158,31 +168,37 @@ bool COfficeFileFormatChecker::isXlsFormatFile (POLE::Storage * storage)
POLE::Stream stream(storage, L"Workbook");
if (stream.read(buffer,10) >0)
return true;
if (stream.read(buffer,10) < 1)
{
POLE::Stream stream2(storage, L"Book");
POLE::Stream stream2(storage, L"Book");
if (stream2.read(buffer,10) < 1)
{
POLE::Stream stream3(storage, L"WORKBOOK");
if (stream2.read(buffer,10) > 0)
return true;
if (stream3.read(buffer,10) < 1)
{
POLE::Stream stream4(storage, L"BOOK");
POLE::Stream stream3(storage, L"WORKBOOK");
if (stream4.read(buffer,10) < 1)
{
POLE::Stream stream5(storage, L"book");
if (stream3.read(buffer,10) > 0)
return true;
POLE::Stream stream4(storage, L"BOOK");
if (stream4.read(buffer,10) > 0)
return true;
POLE::Stream stream5(storage, L"book");
if (stream5.read(buffer,10) > 0)
return true;
return false;
if (stream5.read(buffer,10) < 1)
return false;
}
}
}
}
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
if (storage->isDirectory(L"_VBA_PROJECT_CUR"))
{
bMacroEnabled = true;
}
#endif
return true;
}
bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
{
if (storage == NULL) return false;
@ -190,10 +206,10 @@ bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
POLE::Stream stream(storage, L"PowerPoint Document");
unsigned char buffer[10];
if (stream.read(buffer,10) >0)
return true;
if (stream.read(buffer,10) < 1)
return false;
return false;
return true;
}
bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage)
{
@ -227,7 +243,18 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName)
}
else if ( isPptFormatFile(&storage) )
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
COfficePPTFile pptFile;
bMacroEnabled = true;
long nResult = pptFile.OpenFile(fileName, L"", bMacroEnabled);
if (nResult != S_OK)
{
return false;
}
pptFile.CloseFile();
#endif
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
return true;
}
else if ( isMS_OFFCRYPTOFormatFile(&storage) )
@ -380,6 +407,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(docmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(dotxFormatLine))
{
@ -388,6 +416,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(dotmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(xlsxFormatLine))
{
@ -396,6 +425,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(xlsmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(xltxFormatLine))
{
@ -404,6 +434,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(xltmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(pptxFormatLine))
{
@ -412,10 +443,12 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(pptmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(ppsmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(ppsxFormatLine))
{
@ -428,6 +461,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(potmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM;
bMacroEnabled = true;
}
delete []pBuffer;
pBuffer = NULL;

View File

@ -7,7 +7,7 @@
QT -= core
QT -= gui
VERSION = 2.4.489.0
VERSION = 2.4.490.0
DEFINES += INTVER=$$VERSION
TARGET = x2t
@ -60,6 +60,7 @@ DEFINES += DJVU_USE_DYNAMIC_LIBRARY
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY
DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY
DEFINES += FILE_FORMAT_CHECKER_WITH_MACRO
core_windows {
INCLUDEPATH += ../../../OfficeUtils/src/zlib-1.2.3

View File

@ -3661,7 +3661,7 @@ namespace NExtractTools
{
bool bMacros = false;
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), NULL, bMacros);
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros);
if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
@ -3696,7 +3696,7 @@ namespace NExtractTools
{
bool bMacros = true;
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), NULL, bMacros);
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros);
if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
@ -3740,7 +3740,7 @@ namespace NExtractTools
bool bMacros = true;
if (ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), NULL, bMacros)== S_OK)
if (ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros)== S_OK)
{
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
@ -3801,6 +3801,23 @@ namespace NExtractTools
}
//------------------------------------------------------------------------------------------------------------------
int detectMacroInFile(InputParams& oInputParams)
{
int nRes = 0;// no macro
std::wstring sFileFrom = *oInputParams.m_sFileFrom;
COfficeFileFormatChecker OfficeFileFormatChecker;
if (OfficeFileFormatChecker.isOfficeFile(sFileFrom))
{
if (OfficeFileFormatChecker.bMacroEnabled)
{
nRes = AVS_ERROR_MACRO;
}
}
return nRes;
}
int fromInputParams(InputParams& oInputParams)
{
TConversionDirection conversion = oInputParams.getConversionDirection();

View File

@ -199,6 +199,7 @@ namespace NExtractTools
int fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, InputParams& params);
int fromInputParams(InputParams& oInputParams);
int detectMacroInFile(InputParams& oInputParams);
X2T_DECL_EXPORT int FromFile(const std::wstring& file);
X2T_DECL_EXPORT int FromXml(const std::wstring& xml);

View File

@ -118,7 +118,7 @@ static std::wstring utf8_to_unicode(const char *src)
int result = 0;
std::wstring sXmlExt = _T(".xml");
if(sXmlExt == sArg1.substr(sArg1.length() - sXmlExt.length(), sXmlExt.length()))
if((sArg1.length() > 3) && (sXmlExt == sArg1.substr(sArg1.length() - sXmlExt.length(), sXmlExt.length())))
{
NExtractTools::InputParams oInputParams;
if (oInputParams.FromXmlFile(sArg1) && (sArg2.empty() || oInputParams.FromXml(sArg2)))
@ -143,20 +143,30 @@ static std::wstring utf8_to_unicode(const char *src)
if (argc >= 5) sArg4 = std::wstring(argv [4]);
if (argc >= 6) sArg5 = std::wstring(argv [5]);
#endif
InputParams oInputParams;
oInputParams.m_sFileFrom = new std::wstring(sArg1);
oInputParams.m_sFileTo = new std::wstring(sArg2);
if (sArg1 == L"-detectmacro")
{
InputParams oInputParams;
oInputParams.m_sFileFrom = new std::wstring(sArg2);
result = NExtractTools::detectMacroInFile(oInputParams);
}
else
{
InputParams oInputParams;
oInputParams.m_sFileFrom = new std::wstring(sArg1);
oInputParams.m_sFileTo = new std::wstring(sArg2);
if (argc > 3)
{
oInputParams.m_sFontDir = new std::wstring(sArg3);
if (argc > 3)
{
oInputParams.m_sFontDir = new std::wstring(sArg3);
}
if (argc > 4)
{
oInputParams.m_sPassword = new std::wstring(sArg4);
oInputParams.m_sSavePassword = new std::wstring(sArg4);
}
result = NExtractTools::fromInputParams(oInputParams);
}
if (argc > 4)
{
oInputParams.m_sPassword = new std::wstring(sArg4);
oInputParams.m_sSavePassword = new std::wstring(sArg4);
}
result = NExtractTools::fromInputParams(oInputParams);
}
return getReturnErrorCode(result);

View File

@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;../../../DesktopEditor/agg-2.4/include&quot;;../../../DesktopEditor/xml/build/vs2005;../../../DesktopEditor/xml/libxml2/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;FILE_FORMAT_CHECKER_WITH_MACRO;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"