Compare commits

..

5 Commits

14 changed files with 90 additions and 25 deletions

View File

@ -133,7 +133,8 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_drawing_context_ (Context->get_drawing_context_handle()),
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false)
in_cell(false),
bEndTable(false)
{
memset(&group_row_,0,sizeof(_group_row));

View File

@ -91,6 +91,9 @@ public:
void end_row ();
void add_empty_row(int count);
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
@ -153,6 +156,7 @@ public:
friend class xlsx_table_context;
private:
bool bEndTable;
xlsx_conversion_context * context_;
std::wstring tableName_;

View File

@ -195,7 +195,14 @@ std::wstring cellType2Str(XlsxCellType::type type)
boost::int64_t convertDate(int Year, int Month, int Day)
{
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
if (Year < 1400 || Year >10000)
return - 1;
if (Month < 1 || Month > 12)
return - 1;
if (Day < 1 || Day > 31)
return - 1;
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
if (Year <= 1900 &&
Month <= 2 &&

View File

@ -78,13 +78,16 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
{
bool bEndTable = Context.get_table_context().state()->get_end_table();
if (attlist_.table_number_rows_repeated_ > 1 && empty())
{
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
return;
}
if (attlist_.table_number_rows_repeated_ > 0xf000 && empty_content_cells())
if (attlist_.table_number_rows_repeated_ > 0x0f00 && empty_content_cells() || bEndTable)//0xf000 - conv_KDZO3J3xLIbZ5fC0HR0__xlsx.ods
{
Context.get_table_context().state()->set_end_table();
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods
}
@ -731,7 +734,15 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
int y, m, d;
if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
{
number_val = boost::lexical_cast<std::wstring>(oox::convertDate(y, m, d));
boost::int64_t intDate = oox::convertDate(y, m, d);
if (intDate > 0)
{
number_val = boost::lexical_cast<std::wstring>(intDate);
}
else
{
str_val = attr.office_date_value_.get();
}
}
}
}
@ -742,11 +753,19 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
if (attr.office_time_value_)
{
const std::wstring tv = attr.office_time_value_.get();
int h,m;
int h, m;
double s;
if (oox::parseTime(tv, h, m, s))
{
number_val = boost::lexical_cast<std::wstring>(oox::convertTime(h, m, s));
boost::int64_t intTime = oox::convertTime(h, m, s);
if (intTime > 0)
{
number_val = boost::lexical_cast<std::wstring>(intTime);
}
else
{
str_val = tv;
}
}
}
}
@ -999,7 +1018,15 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
int y, m, d;
if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
{
number_val = boost::lexical_cast<std::wstring>(oox::convertDate(y, m, d));
boost::int64_t intDate = oox::convertDate(y, m, d);
if (intDate > 0)
{
number_val = boost::lexical_cast<std::wstring>(intDate);
}
else
{
str_val = attr.office_date_value_.get();
}
}
}
}

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of ObjProtect record in BIFF8
class ObjProtect: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(ObjProtect)
@ -51,7 +49,7 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeObjProtect;
static const ElementType type = typeObjProtect;
//-----------------------------
Boolean<unsigned short> fLockObj;

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of Protect record in BIFF8
class Protect: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(Protect)

View File

@ -44,7 +44,6 @@ ScenarioProtect::~ScenarioProtect()
{
}
BaseObjectPtr ScenarioProtect::clone()
{
return BaseObjectPtr(new ScenarioProtect(*this));

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of ScenarioProtect record in BIFF8
class ScenarioProtect: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(ScenarioProtect)
@ -48,14 +46,12 @@ public:
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeScenarioProtect;
//-----------------------------
Boolean<unsigned short> fScenProtect;
};
} // namespace XLS

View File

@ -83,10 +83,28 @@ const bool PROTECTION_COMMON::loadContent(BinProcessor& proc)
int PROTECTION_COMMON::serialize (std::wostream & _stream)
{
Protect *protect = dynamic_cast<Protect*> (m_Protect.get());
Password *password = dynamic_cast<Password*> (m_Password.get());
ScenarioProtect *scenario = dynamic_cast<ScenarioProtect*>(m_ScenarioProtect.get());
ObjProtect *object = dynamic_cast<ObjProtect*> (m_ObjProtect.get());
CP_XML_WRITER(_stream)
{
CP_XML_NODE(L"sheetProtection")
{
if (protect)
{
CP_XML_ATTR(L"sheet", protect->fLock);
}
if (object)
{
CP_XML_ATTR(L"objects", object->fLockObj);
}
if (scenario)
{
CP_XML_ATTR(L"scenarios", scenario->fScenProtect);
}
CP_XML_ATTR(L"selectLockedCells", 1);
}
}

View File

@ -309,7 +309,7 @@ XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring
// output_document->get_xl_files().add_attachedToolbars();
//}
NSFile::CFileBinary file;
if (file.CreateFile(sToolbarsFile))
if (file.CreateFileW(sToolbarsFile))
{
unsigned long size = toolbar_data->getStreamSize();
boost::shared_array<BYTE> buffer(new BYTE[size]);
@ -493,7 +493,7 @@ void XlsConverter::convert_common (XLS::CommonSubstream* sheet)
if (sheet->m_PROTECTION)
{
//sheet->m_PROTECTION->serialize(xlsx_context->current_sheet().protection());
sheet->m_PROTECTION->serialize(xlsx_context->current_sheet().protection());
}
if (sheet->m_COLUMNS)
{
@ -512,11 +512,6 @@ void XlsConverter::convert_common (XLS::CommonSubstream* sheet)
sheet->m_PAGESETUP->serialize(xlsx_context->current_sheet().pageProperties());
}
for (size_t i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
{
//convert(dynamic_cast<XLS::Note*>(sheet->sheet->m_arHFPictureDrawing[i].get(),
}
if (sheet->m_arCUSTOMVIEW.size() > 0)
{
CP_XML_WRITER(xlsx_context->current_sheet().customViews())

View File

@ -63,6 +63,7 @@ public:
std::wstringstream conditionalFormatting_;
std::wstringstream picture_background_;
std::wstringstream dataValidations_;
std::wstringstream protection_;
rels rels_;
@ -166,6 +167,11 @@ std::wostream & xlsx_xml_worksheet::dataValidations()
{
return impl_->dataValidations_;
}
std::wostream & xlsx_xml_worksheet::protection()
{
return impl_->protection_;
}
//-----------------------------------------------------------------
rels & xlsx_xml_worksheet::sheet_rels()
{
@ -209,6 +215,9 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_STREAM() << impl_->sheetData_.str();
}
CP_XML_STREAM() << impl_->protection_.str();
//оказывается порядок нахождения элементов важен !!! (для office 2010)
//объединенные ячейки раньше чем гиперлинки !!!

View File

@ -71,7 +71,8 @@ public:
std::wostream & conditionalFormatting();
std::wostream & picture_background();
std::wostream & dataValidations();
std::wostream & protection();
rels & sheet_rels();//hyperlink, background image, external, media ...
void write_to(std::wostream & strm);

View File

@ -4177,6 +4177,14 @@ namespace NExtractTools
{
result = fromMscrypt (sFileFrom, sFileTo, sTempDir, oInputParams);
}break;
case TCD_MSCRYPT2_RAW:
{
result = mscrypt2oox(sFileFrom, sFileTo, sTempDir, oInputParams);
}break;
case TCD_2MSCRYPT_RAW:
{
result = oox2mscrypt(sFileFrom, sFileTo, sTempDir, oInputParams);
}break;
case TCD_MSCRYPT2DOCT:
case TCD_MSCRYPT2XLST:
case TCD_MSCRYPT2PPTT:

View File

@ -165,6 +165,10 @@ namespace NExtractTools
TCD_MSCRYPT2XLST,
TCD_MSCRYPT2PPTT,
TCD_MSCRYPT2BIN,
TCD_MSCRYPT2_RAW,
TCD_2MSCRYPT_RAW,
//
TCD_HTML2DOCX,
TCD_HTML2DOCT,