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

(1.2.0.76): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56679 954022d7-b5bf-4e40-9824-e11837661b57
parent 30a70889
......@@ -115,7 +115,7 @@ public:
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
{
boost::wregex re(L"([:$!])+");
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,2})\\:?([a-zA-Z$]+\\d{1,2})?");
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?");
// $ Sheet2 ! $ A1 : $ B5
//
......
......@@ -105,6 +105,7 @@
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include;..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat;..\..\ASCOfficeOdfFile\formulasconvert\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
......
......@@ -17,9 +17,9 @@ namespace cpdoccore {
struct oox_table_position
{
int col;
__int32 col;
double col_off;
int row;
__int32 row;
double row_off;
};
......@@ -48,14 +48,14 @@ namespace utils {
else
return std::wstring(1, (wchar_t)(L'A' + col));
}
static size_t getColAddressInv(const std::wstring & a_)
static __int32 getColAddressInv(const std::wstring & a_)
{
std::wstring a = a_;
::boost::algorithm::to_upper(a);
static const size_t r = (L'Z' - L'A' + 1);
size_t mul = 1;
bool f = true;
size_t res = 0;
__int32 res = 0;
BOOST_REVERSE_FOREACH(const wchar_t c, a)
{
size_t v = c - L'A';
......@@ -68,12 +68,12 @@ namespace utils {
}
return res;
}
static size_t getRowAdderssInv(const std::wstring & a_)
static __int32 getRowAdderssInv(const std::wstring & a_)
{
int sz = a_.length();
if (a_.length()>0)
{
return boost::lexical_cast<size_t>(a_)-1;
return boost::lexical_cast<__int32>(a_)-1;
}
else
return 0;
......@@ -98,7 +98,7 @@ namespace utils {
std::reverse(col.begin(), col.end());
std::reverse(row.begin(), row.end());
}
static void parsing_ref (const std::wstring & ref, int & col,int & row)
static void parsing_ref (const std::wstring & ref, __int32 & col,__int32 & row)
{
std::wstring strCol, strRow;
splitCellAddress(ref,strCol,strRow);
......@@ -112,22 +112,24 @@ struct ods_element_state
{
office_element_ptr elm;
int repeated;
__int16 repeated;
std::wstring style_name;
office_element_ptr style_elm;
double size;
int level;
__int16 level;
std::wstring cell_style_name;
};
struct ods_cell_state : ods_element_state
{
int col;
int row;
__int32 col;
__int32 row;
int hyperlink_idx;
int comment_idx;
__int16 hyperlink_idx;
__int16 comment_idx;
bool empty;
};
......@@ -135,14 +137,14 @@ struct ods_cell_state : ods_element_state
struct ods_hyperlink_state
{
std::wstring ref;
int col;
int row;
__int32 col;
__int32 row;
std::wstring link;
};
struct ods_comment_state
{
int col;
int row;
__int32 col;
__int32 row;
std::wstring author;
office_element_ptr elm;
......@@ -150,14 +152,14 @@ struct ods_comment_state
};
struct ods_shared_formula_state
{
int index;
short index;
std::wstring formula;
std::wstring ref;
int base_column;
int base_row;
__int32 base_column;
__int32 base_row;
int moving_type; //1 - col, 2 - row
__int32 moving_type; //1 - col, 2 - row
};
struct ods_array_formula_state
......@@ -176,20 +178,21 @@ public:
void set_table_master_page(std::wstring name);
void set_table_rtl(bool Val);
void set_table_tab_color(_CP_OPT(color) & _color);
void set_table_dimension(int col, int row);
void set_table_dimension(__int32 col, __int32 row);
void set_print_range(std::wstring range);
void add_column(office_element_ptr & elm, int repeated ,office_element_ptr & style);
void add_column(office_element_ptr & elm, __int16 repeated ,office_element_ptr & style);
void set_column_width(double width);
void set_column_optimal_width(bool val);
void set_column_default_cell_style(std::wstring & style_name);
std::wstring get_column_default_cell_style(__int32 column);
void start_group(office_element_ptr & elm);
void end_group();
int current_level() {return current_level_.size()-1;}
__int32 current_level() {return current_level_.size()-1;}
void add_row(office_element_ptr & elm, int repeated ,office_element_ptr & style);//const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
void add_row(office_element_ptr & elm, __int16 repeated ,office_element_ptr & style);//const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
void set_row_hidden(bool Val);
void set_row_optimal_height(bool val);
void set_row_height(double height);
......@@ -197,15 +200,15 @@ public:
void start_cell(office_element_ptr & elm ,office_element_ptr & style);
void end_cell();
void add_default_cell(int repeated);
void add_default_cell(__int16 repeated);
void set_cell_format_value(office_value_type::type value_type);
void set_cell_type(int type);
void set_cell_type(__int32 type);
void set_cell_value(std::wstring & value);
void set_cell_text(odf_text_context *text_context, bool cash_value = false);
void set_cell_formula(std::wstring &formula);
void set_cell_array_formula(std::wstring & formula, std::wstring ref);
void add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, int ind);
void add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, __int32 ind);
static std::wstring replace_cell_row(boost::wsmatch const & what);
static std::wstring replace_cell_column(boost::wsmatch const & what);
......@@ -214,10 +217,10 @@ public:
void start_conditional_formats();
void start_conditional_format(std::wstring ref);
void start_conditional_rule(int rule_type);
void start_conditional_rule(__int32 rule_type);
void set_conditional_formula(std::wstring formula);
void set_conditional_value(int type, std::wstring value );
void set_conditional_iconset(int type_iconset);
void set_conditional_value(__int32 type, std::wstring value );
void set_conditional_iconset(__int32 type_iconset);
void add_conditional_colorscale(_CP_OPT(color) color);
void set_conditional_databar_color(_CP_OPT(color) color);
void set_conditional_style_name(std::wstring style_name);
......@@ -226,30 +229,30 @@ public:
void end_conditional_formats();
///////////////////////////////
void add_hyperlink(std::wstring & ref,int col, int row, std::wstring & link);
void add_hyperlink(std::wstring & ref,__int32 col, __int32 row, std::wstring & link);
void add_definded_expression(office_element_ptr & elm);
void start_comment(int col, int row, std::wstring & author);
void start_comment(__int32 col, __int32 row, std::wstring & author);
void set_comment_rect(double l, double t, double w, double h);
void end_comment(odf_text_context *text_context);
void set_merge_cells(int start_col, int start_row, int end_col, int end_row);
void set_merge_cells(__int32 start_col, __int32 start_row, __int32 end_col, __int32 end_row);
office_element_ptr & current_row_element();
office_element_ptr & current_cell_element();
bool is_cell_hyperlink();
int is_cell_hyperlink(int col, int row);
__int32 is_cell_hyperlink(__int32 col, __int32 row);
bool is_cell_comment();
int is_cell_comment(int col, int row, int repeate_col = 1);
__int32 is_cell_comment(__int32 col, __int32 row, __int16 repeate_col = 1);
ods_hyperlink_state & current_hyperlink();
int current_column() const;
int current_row() const;
__int32 current_column() const;
__int32 current_row() const;
int dimension_columns;
int dimension_row;
__int32 dimension_columns;
__int32 dimension_row;
double defaut_column_width_;
double defaut_row_height_;
......@@ -270,18 +273,19 @@ private:
std::wstring row_default_cell_style_name_;
static int current_table_column_;
static int current_table_row_;
static __int32 current_table_column_;
static __int32 current_table_row_;
static int tmp_column_;
static int tmp_row_;
static __int32 tmp_column_;
static __int32 tmp_row_;
std::vector<ods_element_state> columns_;
std::vector<ods_element_state> rows_;
std::vector<office_element_ptr> current_level_;//ïîñòîÿííî ìåíÿþùèéñÿ ñïèñîê óðîâíåé ("0-é ýëåìåíò - ñàìà òàáëèöà)
std::vector<ods_cell_state> cells_;
std::list<ods_cell_state> cells_;
long cells_size_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::vector<ods_comment_state> comments_;
......
......@@ -40,6 +40,8 @@ void XlsxConverter::write(const std::wstring & path)
{
if (!output_document)return;
output_document->write(path);
delete output_document; output_document = NULL;
}
odf::odf_conversion_context* XlsxConverter::odf_context()
{
......@@ -97,6 +99,9 @@ void XlsxConverter::convertDocument()
convert_styles();
convert_sheets();
// xlsx
delete xlsx_document; xlsx_document = NULL;
ods_context->end_document();
}
......@@ -108,35 +113,30 @@ void XlsxConverter::convert_sheets()
if (!Workbook) return;
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*> &arrWorksheets = xlsx_document->GetWorksheets();
if(Workbook->m_oSheets.IsInit())
{
CSimpleArray<OOX::Spreadsheet::CSheet*>& aWs = Workbook->m_oSheets->m_arrItems;//
for(int i = 0, length = aWs.GetSize(); i < length; ++i)
{
for(int i = 0, length = Workbook->m_oSheets->m_arrItems.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::CSheet* pSheet = aWs[i];
OOX::Spreadsheet::CSheet* pSheet = Workbook->m_oSheets->m_arrItems[i];
if(pSheet->m_oRid.IsInit())
{
CString sSheetRId = pSheet->m_oRid.get2().ToString();
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*>::CPair* pPair = arrWorksheets.Lookup(sSheetRId);
if (NULL != pPair)
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*>::CPair* pPairWorksheet = arrWorksheets.Lookup(sSheetRId);
if ((pPairWorksheet) && (pPairWorksheet->m_value))
{
OOX::Spreadsheet::CWorksheet *pWorksheet = pPair->m_value;
if (pWorksheet)
{
ods_context->start_sheet();
ods_context->current_table().set_table_name(string2std_string(pSheet->m_oName.get2()));
if (pSheet->m_oState.IsInit() && ( pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleHidden ||
pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleVeryHidden))
ods_context->current_table().set_table_hidden(true);
convert(pWorksheet);
ods_context->end_sheet();
}
ods_context->start_sheet();
ods_context->current_table().set_table_name(string2std_string(pSheet->m_oName.get2()));
if (pSheet->m_oState.IsInit() && ( pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleHidden ||
pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleVeryHidden))
ods_context->current_table().set_table_hidden(true);
convert(pPairWorksheet->m_value);
delete pPairWorksheet->m_value; pPairWorksheet->m_value = NULL;
ods_context->end_sheet();
}
}
}
}
......@@ -172,6 +172,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined)
}
void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
{
if (!oox_sheet) return;
if (oox_sheet->m_oDimension.IsInit())
{
ods_context->set_sheet_dimension(string2std_string(oox_sheet->m_oDimension->m_oRef.get()));
......@@ -206,12 +208,21 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
ods_context->end_columns();
//
ods_context->start_rows();
for (long row = 0 ; oox_sheet->m_oSheetData.IsInit() && row < oox_sheet->m_oSheetData->m_arrItems.GetSize(); row++)
{
convert(oox_sheet->m_oSheetData->m_arrItems[row]);
}
ods_context->end_rows();
if (oox_sheet->m_oSheetData.IsInit() )
{
ods_context->start_rows();
for (long row = 0 ; row < oox_sheet->m_oSheetData->m_arrItems.GetSize(); row++)
{
convert(oox_sheet->m_oSheetData->m_arrItems[row]);
if ( oox_sheet->m_oSheetData->m_arrItems[row] )
delete oox_sheet->m_oSheetData->m_arrItems[row];
oox_sheet->m_oSheetData->m_arrItems[row] = NULL;
}
ods_context->end_rows();
// .. :( - 64 -
oox_sheet->m_oSheetData.reset();
}
//
for (long mrg = 0 ; oox_sheet->m_oMergeCells.IsInit() && mrg < oox_sheet->m_oMergeCells->m_arrItems.GetSize(); mrg++)
......@@ -253,7 +264,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
void XlsxConverter::convert(OOX::Spreadsheet::CCommentItem * oox_comment)
{
if (oox_comment == NULL)return;
if (!oox_comment) return;
int col = oox_comment->m_nCol.IsInit() ? oox_comment->m_nCol.get()+1 : -1;
int row = oox_comment->m_nRow.IsInit() ? oox_comment->m_nRow.get()+1 : -1;
......@@ -356,6 +367,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row)
}
void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
{
if (oox_cell == NULL)return;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCellMetadata;
//nullable<SimpleTypes::COnOff<>> m_oShowPhonetic;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oValueMetadata;
......@@ -386,8 +398,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
else
{
if (value_type >=0)
ods_context->current_table().set_cell_type (value_type);
ods_context->current_table().set_cell_value (string2std_string(oox_cell->m_oValue->m_sText));
ods_context->current_table().set_cell_type (value_type);
}
}
......@@ -1040,6 +1054,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf::style_pa
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::End); break;
}
}
if (!paragraph_properties->content().fo_text_align_)
paragraph_properties->content().fo_text_align_ = odf::text_align(odf::text_align::Start);
if (aligment->m_oWrapText.IsInit())
{
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//64
#define INTVER 1,2,0,64
#define STRVER "1,2,0,64\0"
//78
#define INTVER 1,2,0,78
#define STRVER "1,2,0,78\0"
......@@ -52,7 +52,7 @@ namespace OOX
while ( NULL != pos )
{
const CAtlMap<CString, CWorksheet*>::CPair* pPair = m_aWorksheets.GetNext( pos );
delete pPair->m_value;
if (pPair->m_value) delete pPair->m_value;
}
}
}
......
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