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

формулы xlsx->ods

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55390 954022d7-b5bf-4e40-9824-e11837661b57
parent 274f2b59
......@@ -39,7 +39,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(ProjectDir)include&quot;;&quot;$(SolutionDir)include&quot;;&quot;$(SolutionDir)3dparty\gtest\include\&quot;;&quot;$(SolutionDir)3dparty\utf8cpp\include&quot;"
AdditionalIncludeDirectories="&quot;$(ProjectDir)include&quot;;..\include;..\3dparty\gtest\include\;..\dparty\utf8cpp\include"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
......@@ -102,7 +102,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(ProjectDir)include&quot;;&quot;$(SolutionDir)include&quot;;&quot;$(SolutionDir)3dparty\gtest\include\&quot;;&quot;$(SolutionDir)3dparty\utf8cpp\include&quot;"
AdditionalIncludeDirectories="&quot;$(ProjectDir)include&quot;;..\include;..\3dparty\gtest\include\;..\3dparty\utf8cpp\include"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
......@@ -148,7 +148,11 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\formulasconvert.cpp"
RelativePath=".\src\formulasconvert_odf.cpp"
>
</File>
<File
RelativePath=".\src\formulasconvert_oox.cpp"
>
</File>
</Filter>
......
#ifndef _CPDOCCORE_FORMULASCONVERT_H_
#define _CPDOCCORE_FORMULASCONVERT_H_
#pragma once
#include <string>
#include <cpdoccore/CPScopedPtr.h>
......@@ -41,8 +40,37 @@ private:
_CP_SCOPED_PTR(Impl) impl_;
};
class oox2odf_converter
{
public:
oox2odf_converter();
~oox2odf_converter();
// SUM(DDA1:BA3) -> of:=SUM([.DDA1:.BA3])
std::wstring convert(std::wstring const & expr);
std::wstring convert_formula(std::wstring const & expr);
// 1!$A$1 -> $1.$A$1
std::wstring convert_named_ref(std::wstring const & expr);
//Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19
std::wstring convert_chart_distance(std::wstring const & expr);
std::wstring convert_ref(std::wstring const & expr);
std::wstring convert_spacechar(std::wstring expr);
// // =[.A1]+[.B1] -> table = ""; ref = "A1"
// // of:=['Sheet2 A'.B2] -> table= "Sheet2 A"; ref = "B2"
// bool find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref);
////ref $A$1 -> ref $A$2 -> Table!.$A$1:$A2
//bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}
#endif
This diff is collapsed.
......@@ -9,11 +9,14 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormat", "source\OdfFormat.vcproj", "{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}"
ProjectSection(ProjectDependencies) = postProject
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oox2OdfConverter", "source\Oox2OdfConverter.vcproj", "{BEE01B53-244A-44E6-8947-ED9342D9247E}"
ProjectSection(ProjectDependencies) = postProject
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeOdfFileWTest", "ASCOfficeOdfFileWTest\ASCOfficeOdfFileWTest.vcproj", "{FBA8446A-150F-4A10-B4DA-1022048D6473}"
......@@ -21,6 +24,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeOdfFileWTest", "AS
{6258296E-ABCE-4BC6-9F4A-8522CD615603} = {6258296E-ABCE-4BC6-9F4A-8522CD615603}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpformulasconvert", "..\ASCOfficeOdfFile\formulasconvert\formulasconvert.vcproj", "{94954A67-A853-43B1-A727-6EF2774C5A6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
......@@ -47,6 +52,10 @@ Global
{FBA8446A-150F-4A10-B4DA-1022048D6473}.Debug|Win32.Build.0 = Debug|Win32
{FBA8446A-150F-4A10-B4DA-1022048D6473}.Release|Win32.ActiveCfg = Release|Win32
{FBA8446A-150F-4A10-B4DA-1022048D6473}.Release|Win32.Build.0 = Release|Win32
{94954A67-A853-43B1-A727-6EF2774C5A6A}.Debug|Win32.ActiveCfg = Debug|Win32
{94954A67-A853-43B1-A727-6EF2774C5A6A}.Debug|Win32.Build.0 = Debug|Win32
{94954A67-A853-43B1-A727-6EF2774C5A6A}.Release|Win32.ActiveCfg = Release|Win32
{94954A67-A853-43B1-A727-6EF2774C5A6A}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include;..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include;..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat;..\..\ASCOfficeOdfFile\formulasconvert\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -105,7 +105,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include;..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include;..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat;..\..\ASCOfficeOdfFile\formulasconvert\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......
#include "precompiled_cpodf.h"
#include "logging.h"
#include <cpdoccore/formulasconvert.h>
#include "ods_table_state.h"
#include "odf_text_context.h"
#include "ods_conversion_context.h"
......@@ -23,7 +25,15 @@ namespace utils
{
std::wstring convert_date(std::wstring & oox_date)
{
int iDate = boost::lexical_cast<int>(oox_date);
int iDate = 0;
try
{
iDate = boost::lexical_cast<int>(oox_date);
}catch(...)
{
return oox_date;
}
boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate-2);
......@@ -38,10 +48,19 @@ std::wstring convert_date(std::wstring & oox_date)
std::wstring convert_time(std::wstring & oox_time)
{
double dTime = 0;
try
{
dTime = boost::lexical_cast<double>(oox_time);
}catch(...)
{
return oox_time;
}
//PT12H15M42S
int hours=0, minutes=0;
double sec=0;
double dTime = boost::lexical_cast<double>(oox_time);
boost::posix_time::time_duration day(24, 0, 0);
......@@ -447,6 +466,17 @@ void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col,
}
}
}
static formulasconvert::oox2odf_converter formulas_converter;
void ods_table_state::set_cell_formula(std::wstring & formula)
{
std::wstring odfFormula = formulas_converter.convert_formula(formula);
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_.table_formula_ = odfFormula;
}
void ods_table_state::set_cell_text(odf_text_context* text_context)
{
......
......@@ -83,9 +83,9 @@ public:
void set_cell_format_value(office_value_type::type value_type);
void set_cell_type(int type);
void set_cell_value(std::wstring & value);
void set_cell_value(std::wstring & value);
void set_cell_text(odf_text_context *text_context);
void set_cell_formula(std::wstring &formula);
///////////////////////////////
void add_hyperlink(std::wstring & ref,int col, int row, std::wstring & link);
......
......@@ -385,6 +385,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFormula *oox_formula)
{
if (oox_formula == NULL)return;
ods_context->current_table().set_cell_formula(string2std_string(oox_formula->m_sText));
}
void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
{
......
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