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

OdfFile Writer

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62596 954022d7-b5bf-4e40-9824-e11837661b57
parent 17991310
#include "precompiled_cpodf.h"
#include "abstract_xml.h" #include "abstract_xml.h"
......
#include "precompiled_cpodf.h"
#include "calcext_elements.h" #include "calcext_elements.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "draw_base.h" #include "draw_base.h"
#include <ostream> #include <ostream>
......
#include "precompiled_cpodf.h"
#include "draw_frame.h" #include "draw_frame.h"
#include <ostream> #include <ostream>
......
#include "precompiled_cpodf.h"
#include "draw_shapes.h" #include "draw_shapes.h"
#include <ostream> #include <ostream>
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost_string.h> #include <boost_string.h>
#include <regex.h> #include <regex.h>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/xml/xmlchar.h> #include <cpdoccore/xml/xmlchar.h>
......
#include "precompiled_cpodf.h"
#include "header_footer.h" #include "header_footer.h"
#include <cpdoccore/xml/attributes.h> #include <cpdoccore/xml/attributes.h>
......
#include "precompiled_cpodf.h"
#include "list.h" #include "list.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <iostream> #include <iostream>
......
#include "precompiled_cpodf.h"
#include "mediaitems.h" #include "mediaitems.h"
#include "odf_rels.h" #include "odf_rels.h"
#include <regex.h> #include <regex.h>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp> #include <boost/algorithm/string/case_conv.hpp>
#include <cpdoccore/xml/utils.h> #include <cpdoccore/xml/utils.h>
#include "mediaitems_utils.h" #include "mediaitems_utils.h"
#include <cpdoccore/common/boost_filesystem_version.h>
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
using boost::filesystem::wpath;
_mediaitems::item::item( std::wstring const & _oox_ref, _mediaitems::item::item( std::wstring const & _oox_ref,
Type _type, Type _type,
std::wstring const & _odf_ref std::wstring const & _odf_ref
...@@ -30,8 +26,6 @@ _mediaitems::item::item( std::wstring const & _oox_ref, ...@@ -30,8 +26,6 @@ _mediaitems::item::item( std::wstring const & _oox_ref,
} }
namespace fs = boost::filesystem;
void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wstring & odf_ref) void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wstring & odf_ref)
{ {
std::wstring output_sub_path;// std::wstring output_sub_path;//
......
#include "precompiled_cpodf.h"
#include "mediaitems_utils.h" #include "mediaitems_utils.h"
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
namespace cpdoccore { namespace cpdoccore {
namespace odf{ namespace odf{
...@@ -13,8 +11,6 @@ namespace utils { ...@@ -13,8 +11,6 @@ namespace utils {
namespace media { namespace media {
using boost::filesystem::wpath;
std::wstring get_rel_type(_mediaitems::Type type) std::wstring get_rel_type(_mediaitems::Type type)
{ {
switch (type) switch (type)
...@@ -39,11 +35,12 @@ std::wstring get_default_file_name(_mediaitems::Type type) ...@@ -39,11 +35,12 @@ std::wstring get_default_file_name(_mediaitems::Type type)
std::wstring create_file_name(const std::wstring & uri, _mediaitems::Type type, size_t Num) std::wstring create_file_name(const std::wstring & uri, _mediaitems::Type type, size_t Num)
{ {
#ifdef BOOST_FILESYSTEM_LEGACY std::wstring sExt;
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + wpath(uri).extension(); int n = uri.rfind(L".");
#else if (n>=0) sExt = uri.substr(n);
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + wpath(uri).extension().string<std::wstring>(); //todooo
#endif
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + sExt;
} }
......
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <cpdoccore/utf8cpp/utf8.h> #include <cpdoccore/utf8cpp/utf8.h>
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include "../../../DesktopEditor/common/File.h" #include "../../../DesktopEditor/common/File.h"
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
namespace cpdoccore namespace cpdoccore
{ {
namespace odf namespace odf
...@@ -26,7 +29,7 @@ namespace odf ...@@ -26,7 +29,7 @@ namespace odf
void simple_element::write(const std::wstring & RootPath) void simple_element::write(const std::wstring & RootPath)
{ {
NSFile::CBinaryFile file; NSFile::CFileBinary file;
if (file.CreateFileW( RootPath + FILE_SEPARATOR_STR + file_name_ ) == true) if (file.CreateFileW( RootPath + FILE_SEPARATOR_STR + file_name_ ) == true)
{ {
...@@ -94,10 +97,10 @@ namespace odf ...@@ -94,10 +97,10 @@ namespace odf
rels_.serialize(CP_XML_STREAM()); rels_.serialize(CP_XML_STREAM());
} }
} }
fs::wpath path = fs::wpath(RootPath) / L"META-INF"; std::wstring path = RootPath + FILE_SEPARATOR + L"META-INF";
fs::create_directory(path); FileSystem::Directory::CreateDirectory(path);
simple_element elm(L"manifest.xml", resStream.str()); simple_element elm(L"manifest.xml", resStream.str());
elm.write(path.string()); elm.write(path);
} }
void meta_file::write(const std::wstring & RootPath) void meta_file::write(const std::wstring & RootPath)
...@@ -186,7 +189,7 @@ namespace odf ...@@ -186,7 +189,7 @@ namespace odf
try try
{ {
boost::filesystem::copy_file(item.oox_ref, file_name_out); NSFile::CFileBinary::Copy(item.oox_ref, file_name_out);
}catch (...) }catch (...)
{ {
} }
...@@ -255,10 +258,10 @@ namespace odf ...@@ -255,10 +258,10 @@ namespace odf
long count = 0; long count = 0;
BOOST_FOREACH(const element_ptr & item, objects_) BOOST_FOREACH(const element_ptr & item, objects_)
{ {
fs::wpath path = fs::wpath(RootPath) / item->local_path; std::wstring path = RootPath + FILE_SEPARATOR_STR + item->local_path;
fs::create_directory(path); FileSystem::Directory::CreateDirectory(path);
item->write(path.string()); item->write(path);
} }
if (manifest_) manifest_->write(RootPath); if (manifest_) manifest_->write(RootPath);
if (mimetype_) mimetype_->write(RootPath); if (mimetype_) mimetype_->write(RootPath);
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
......
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include "office_spreadsheet.h" #include "office_spreadsheet.h"
#include "office_chart.h" #include "office_chart.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream> #include <iostream>
#include "odf_drawing_context.h" #include "odf_drawing_context.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include "odf_page_layout_state.h" #include "odf_page_layout_state.h"
......
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#pragma once #pragma once
#include <vector>
#include <string> #include <string>
#include <iosfwd>
//#include <iosfwd>
#include <cpdoccore/xml/xmlelement.h> #include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/CPSharedPtr.h> #include <cpdoccore/CPSharedPtr.h>
......
#include "precompiled_cpodf.h"
#include "odf_style_context.h" #include "odf_style_context.h"
#include "ods_conversion_context.h" #include "ods_conversion_context.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include "odf_style_state.h" #include "odf_style_state.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <iostream> #include <iostream>
#include "odf_text_context.h" #include "odf_text_context.h"
......
#include "precompiled_cpodf.h"
#include "../utils.h" #include "../utils.h"
...@@ -94,7 +94,7 @@ void ods_conversion_context::start_sheet() ...@@ -94,7 +94,7 @@ void ods_conversion_context::start_sheet()
void ods_conversion_context::set_sheet_dimension(std::wstring & ref) void ods_conversion_context::set_sheet_dimension(std::wstring & ref)
{ {
std::vector<std::wstring> ref_cells; std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on); boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
int max_col = 0, max_row = 0; int max_col = 0, max_row = 0;
for (long i=0; i<ref_cells.size(); i++) for (long i=0; i<ref_cells.size(); i++)
...@@ -215,7 +215,7 @@ void ods_conversion_context::add_hyperlink(std::wstring & ref, std::wstring & li ...@@ -215,7 +215,7 @@ void ods_conversion_context::add_hyperlink(std::wstring & ref, std::wstring & li
{ {
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
std::vector<std::wstring> ref_cells; std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on); boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size()>1) if (ref_cells.size()>1)
{ {
// x , - , // x , - ,
...@@ -245,7 +245,7 @@ void ods_conversion_context::add_hyperlink(std::wstring & ref, std::wstring & li ...@@ -245,7 +245,7 @@ void ods_conversion_context::add_hyperlink(std::wstring & ref, std::wstring & li
void ods_conversion_context::add_merge_cells(std::wstring & ref) void ods_conversion_context::add_merge_cells(std::wstring & ref)
{ {
std::vector<std::wstring> ref_cells; std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on); boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size() !=2) return;// .. if (ref_cells.size() !=2) return;// ..
......
#include "precompiled_cpodf.h"
#include "ods_table_context.h" #include "ods_table_context.h"
#include "table.h" #include "table.h"
......
#include "precompiled_cpodf.h"
#include "logging.h" #include "logging.h"
#include "../../../ASCOfficeOdfFile/formulasconvert/include/cpdoccore/formulasconvert.h" #include "../../../ASCOfficeOdfFile/formulasconvert/include/cpdoccore/formulasconvert.h"
...@@ -40,15 +40,16 @@ std::wstring convert_date(std::wstring & oox_date) ...@@ -40,15 +40,16 @@ std::wstring convert_date(std::wstring & oox_date)
{ {
return oox_date; return oox_date;
} }
//todoooo !!!!
boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate-2); //boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate-2);
//to for example, "1899-12-31T05:37:46.66569 ////to for example, "1899-12-31T05:37:46.66569
std::wstring date_str = boost::lexical_cast<std::wstring>(date_.year()) std::wstring date_str = L"";//boost::lexical_cast<std::wstring>(date_.year())
+ L"-" + // + L"-" +
(date_.month() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.month()) // (date_.month() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.month())
+ L"-" + // + L"-" +
(date_.day() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.day()); // (date_.day() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.day());
return date_str; return date_str;
} }
...@@ -68,14 +69,16 @@ std::wstring convert_time(std::wstring & oox_time) ...@@ -68,14 +69,16 @@ std::wstring convert_time(std::wstring & oox_time)
int hours=0, minutes=0; int hours=0, minutes=0;
double sec=0; double sec=0;
boost::posix_time::time_duration day(24, 0, 0); //todooo !!!
//boost::posix_time::time_duration day(24, 0, 0);
double millisec = day.total_milliseconds() * dTime; //
//double millisec = day.total_milliseconds() * dTime;
sec = millisec /1000.; //sec = millisec /1000.;
hours = sec/60./60.; //hours = sec/60./60.;
minutes = (sec - (hours * 60 * 60))/60.; //minutes = (sec - (hours * 60 * 60))/60.;
sec = sec - (hours *60 + minutes) * 60.; //sec = sec - (hours *60 + minutes) * 60.;
int sec1 = sec; int sec1 = sec;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include "odf_drawing_context.h" #include "odf_drawing_context.h"
......
#include "precompiled_cpodf.h"
#include <boost/regex.hpp>
#include "../utils.h" #include "../utils.h"
......
#include "precompiled_cpodf.h"
#include "office_annotation.h" #include "office_annotation.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "office_body.h" #include "office_body.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "office_chart.h" #include "office_chart.h"
......
#include "precompiled_cpodf.h"
#include "office_elements_create.h" #include "office_elements_create.h"
#include <iostream> #include <iostream>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include "logging.h" #include "logging.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
namespace {
static boost::mutex create_lock_;
}
office_element_creator * office_element_creator::instance_ = NULL; office_element_creator * office_element_creator::instance_ = NULL;
office_element_creator::office_element_creator() : rw_lock_( new boost::shared_mutex() ) office_element_creator::office_element_creator()
{ {
} }
...@@ -24,8 +18,6 @@ office_element_ptr office_element_creator::create(const ::std::wstring & ns, con ...@@ -24,8 +18,6 @@ office_element_ptr office_element_creator::create(const ::std::wstring & ns, con
{ {
const std::wstring fullName = ns + (ns.size() > 0 ? L":" : L"") + name; const std::wstring fullName = ns + (ns.size() > 0 ? L":" : L"") + name;
boost::shared_lock< boost::shared_mutex > lock( *rw_lock_ );
MapType::const_iterator i = map_.find( fullName ); MapType::const_iterator i = map_.find( fullName );
if (i != map_.end() ) if (i != map_.end() )
{ {
...@@ -53,7 +45,6 @@ office_element_creator * office_element_creator::get() ...@@ -53,7 +45,6 @@ office_element_creator * office_element_creator::get()
{ {
if (!instance_) if (!instance_)
{ {
boost::mutex::scoped_lock lock(create_lock_);
if (!instance_) if (!instance_)
{ {
office_element_creator * temp = new office_element_creator(); office_element_creator * temp = new office_element_creator();
...@@ -68,8 +59,6 @@ bool office_element_creator::register_element(const std::wstring &ns, const std: ...@@ -68,8 +59,6 @@ bool office_element_creator::register_element(const std::wstring &ns, const std:
{ {
const std::wstring fullName = ns + (ns.size() > 0 ? L":" : L"") + name; const std::wstring fullName = ns + (ns.size() > 0 ? L":" : L"") + name;
boost::unique_lock< boost::shared_mutex > lock( *rw_lock_ );
MapType::iterator i = map_.find( fullName ); MapType::iterator i = map_.find( fullName );
if ( i == map_.end() ) if ( i == map_.end() )
{ {
......
...@@ -2,16 +2,11 @@ ...@@ -2,16 +2,11 @@
#include <string> #include <string>
#include <map> #include <map>
#include <boost/function.hpp>
#include <cpdoccore/CPAssert.h> #include <cpdoccore/CPAssert.h>
#include <cpdoccore/CPSharedPtr.h> #include <cpdoccore/CPSharedPtr.h>
#include "office_elements.h" #include "office_elements.h"
namespace boost {
class shared_mutex;
}
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
...@@ -49,7 +44,6 @@ public: ...@@ -49,7 +44,6 @@ public:
private: private:
office_element_creator(); office_element_creator();
static office_element_creator * instance_; static office_element_creator * instance_;
shared_ptr<boost::shared_mutex>::Type rw_lock_;
}; };
/// , /// ,
...@@ -73,7 +67,6 @@ public: ...@@ -73,7 +67,6 @@ public:
{ {
if (class_registered_++ == 0) if (class_registered_++ == 0)
{ {
// Jerry Schwarz counter
office_element_creator::get()->register_element(T::ns, T::name, &CreateImpl_<T>::create); office_element_creator::get()->register_element(T::ns, T::name, &CreateImpl_<T>::create);
} }
}; };
......
#include "precompiled_cpodf.h"
#include "office_spreadsheet.h" #include "office_spreadsheet.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "office_text.h" #include "office_text.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include "Shapes\oox_shapeMaths.h" #include "Shapes\oox_shapeMaths.h"
#include "Shapes\oox_shapeSnipRoundRects.h" #include "Shapes\oox_shapeSnipRoundRects.h"
......
#include "precompiled_cpodf.h"
#include "paragraph_elements.h" #include "paragraph_elements.h"
#include <ostream> #include <ostream>
......
#include "precompiled_cpodf.h"
\ No newline at end of file
#pragma once
#include <string>
#include <map>
#include <vector>
#include <ostream>
#include <boost/optional.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
static float getDefaultDpi(){return 96;}
#include "precompiled_cpodf.h"
#include "style_chart_properties.h" #include "style_chart_properties.h"
#include <iostream> #include <iostream>
......
#include "precompiled_cpodf.h"
#include <iostream> #include <iostream>
#include "style_graphic_properties.h" #include "style_graphic_properties.h"
......
#include "precompiled_cpodf.h"
#include "style_map.h" #include "style_map.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "precompiled_cpodf.h"
#include <cpdoccore/xml/xmlchar.h> #include <cpdoccore/xml/xmlchar.h>
......
#include "precompiled_cpodf.h"
#include <iostream> #include <iostream>
#include "style_paragraph_properties.h" #include "style_paragraph_properties.h"
......
#include "precompiled_cpodf.h"
#include <cpdoccore/xml/xmlchar.h> #include <cpdoccore/xml/xmlchar.h>
......
#include "precompiled_cpodf.h"
#include <iostream> #include <iostream>
#include "style_table_properties.h" #include "style_table_properties.h"
#include "borderstyle.h" #include "borderstyle.h"
......
#include "precompiled_cpodf.h"
#include <iostream> #include <iostream>
#include "style_text_properties.h" #include "style_text_properties.h"
......
#include "precompiled_cpodf.h"
#include "styles.h" #include "styles.h"
#include <cpdoccore/xml/xmlchar.h> #include <cpdoccore/xml/xmlchar.h>
......
#include "precompiled_cpodf.h"
#include "styles_list.h" #include "styles_list.h"
......
#pragma once #pragma once
#include "precompiled_cpodf.h"
#include "svg_creator.h" #include "svg_creator.h"
......
#include "precompiled_cpodf.h"
#include "table.h" #include "table.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
......
#include "precompiled_cpodf.h"
#include "table_database_ranges.h" #include "table_database_ranges.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
......
#include "precompiled_cpodf.h"
#include "table_named_expressions.h" #include "table_named_expressions.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
......
#include "precompiled_cpodf.h"
#include "text_elements.h" #include "text_elements.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
#include "Oox2OdfConverter.h"
#include "Converter.h" #include "Converter.h"
#include "../utils.h" #include "../utils.h"
#include <boost/lexical_cast.hpp>
#include "XlsxConverter.h" #include "XlsxConverter.h"
#include "DocxConverter.h" #include "DocxConverter.h"
...@@ -53,7 +59,7 @@ namespace Oox2Odf ...@@ -53,7 +59,7 @@ namespace Oox2Odf
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL OoxConverter::UpdateProgress(long nComplete) bool OoxConverter::UpdateProgress(long nComplete)
{ {
if (pCallBack) if (pCallBack)
{ {
......
#pragma once #pragma once
#include <boost/lexical_cast.hpp>
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
#include "../progressCallback.h" #include "../progressCallback.h"
...@@ -12,6 +11,8 @@ ...@@ -12,6 +11,8 @@
#include "../../../Common/DocxFormat/Source/Base/ASCString.h" #include "../../../Common/DocxFormat/Source/Base/ASCString.h"
#endif #endif
#include <vector>
namespace cpdoccore namespace cpdoccore
{ {
namespace odf namespace odf
...@@ -298,9 +299,9 @@ public: ...@@ -298,9 +299,9 @@ public:
pCallBack = CallBack; pCallBack = CallBack;
bUserStopConvert = 0;} bUserStopConvert = 0;}
const ProgressCallback* pCallBack; const ProgressCallback* pCallBack;
short bUserStopConvert; short bUserStopConvert;
BOOL UpdateProgress(long nComplete); bool UpdateProgress(long nComplete);
//....................................................................................................................... //.......................................................................................................................
virtual cpdoccore::odf::odf_conversion_context *odf_context() = 0; virtual cpdoccore::odf::odf_conversion_context *odf_context() = 0;
...@@ -436,22 +437,4 @@ public: ...@@ -436,22 +437,4 @@ public:
void convert(OOX::Vml::CVmlCommonElements *vml_attr); void convert(OOX::Vml::CVmlCommonElements *vml_attr);
}; };
class Converter } // namespace Oox2Odf
{
public:
Converter(const std::wstring & path, std::wstring type, const ProgressCallback* ffCallBack);
virtual ~Converter();
public:
void convert();
void write(const std::wstring & path) const;
OoxConverter * get_ooxConverter() { return impl_; }
private:
OoxConverter* impl_;
};
} // namespace Oox2Odf:Convert
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "VmlShapeTypes2Oox.h" #include "VmlShapeTypes2Oox.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include "../OdfFormat/odt_conversion_context.h" #include "../OdfFormat/odt_conversion_context.h"
......
#pragma once
#include "../progressCallback.h"
#include <string>
namespace Oox2Odf
{
class OoxConverter;
class Converter
{
public:
Converter(const std::wstring & path, std::wstring type, const ProgressCallback* ffCallBack);
virtual ~Converter();
public:
void convert();
void write(const std::wstring & path) const;
OoxConverter * get_ooxConverter() { return impl_; }
private:
OoxConverter* impl_;
};
} // namespace Oox2Odf
#pragma once #pragma once
typedef void (*OdfOnProgressCallback)( LPVOID lpParam, long nID, long nPercent ); typedef void (*OdfOnProgressCallback)( void* lpParam, long nID, long nPercent );
typedef void (*OdfOnProgressExCallback)( LPVOID lpParam, long nID, long nPercent, short* Cancel ); typedef void (*OdfOnProgressExCallback)( void* lpParam, long nID, long nPercent, short* Cancel );
struct ProgressCallback struct ProgressCallback
{ {
OdfOnProgressCallback OnProgress; OdfOnProgressCallback OnProgress;
OdfOnProgressExCallback OnProgressEx; OdfOnProgressExCallback OnProgressEx;
LPVOID caller; void* caller;
}; };
#pragma once #pragma once
#include <atlbase.h> #include <string>
#include <gdiplus.h> #include <vector>
#pragma comment(lib, "gdiplus.lib")
#import "../../../Redist/ASCGraphics.dll" rename_namespace("ASCGraphics") #if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
#import "../../../Redist/ASCGraphics.dll" rename_namespace("ASCGraphics")
#endif
namespace _gdi_graphics_ namespace _gdi_graphics_
{ {
//todoooo !!!
std::pair<double,double> static GetMaxDigitSizePixelsImpl(const wchar_t * fontName, float fontSize, float dpi, long fontStyle) std::pair<double,double> static GetMaxDigitSizePixelsImpl(const wchar_t * fontName, float fontSize, float dpi, long fontStyle)
{ {
float width = 70, height = 80;
#if defined(_WIN32) || defined(_WIN64)
CComPtr<ASCGraphics::IASCFontManager> fontMan; CComPtr<ASCGraphics::IASCFontManager> fontMan;
HRESULT hr; HRESULT hr;
...@@ -33,14 +42,14 @@ namespace _gdi_graphics_ ...@@ -33,14 +42,14 @@ namespace _gdi_graphics_
return std::pair<double,double>(7,8); return std::pair<double,double>(7,8);
} }
} }
double maxWidth=0; double maxWidth=0 ;
float x, y;
std::wstring TestString = L"0123456789"; std::wstring TestString = L"0123456789";
if (S_OK != (hr = fontMan->LoadString2( TestString.c_str(), 0, 0))) if (S_OK != (hr = fontMan->LoadString2( TestString.c_str(), 0, 0)))
return std::pair<double,double>(7,8); return std::pair<double,double>(7,8);
float x, y, width, height;
try try
{ {
hr = fontMan->MeasureString(&x, &y, &width, &height); hr = fontMan->MeasureString(&x, &y, &width, &height);
...@@ -48,7 +57,7 @@ namespace _gdi_graphics_ ...@@ -48,7 +57,7 @@ namespace _gdi_graphics_
{ {
return std::pair<double,double>(7,8); return std::pair<double,double>(7,8);
} }
#endif
return std::pair<double,double>(width/10.,height/10.); return std::pair<double,double>(width/10.,height/10.);
} }
...@@ -56,6 +65,7 @@ namespace _gdi_graphics_ ...@@ -56,6 +65,7 @@ namespace _gdi_graphics_
bool static GetResolution(const WCHAR* fileName, double & Width, double &Height) //pt bool static GetResolution(const WCHAR* fileName, double & Width, double &Height) //pt
{ {
bool result =false; bool result =false;
#if defined(_WIN32) || defined(_WIN64)
Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken=0; ULONG_PTR gdiplusToken=0;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
...@@ -79,11 +89,13 @@ namespace _gdi_graphics_ ...@@ -79,11 +89,13 @@ namespace _gdi_graphics_
delete file; delete file;
} }
Gdiplus::GdiplusShutdown(gdiplusToken); Gdiplus::GdiplusShutdown(gdiplusToken);
#endif
return result; return result;
} }
double static calculate_size_symbol(std::wstring name, double size, bool italic, bool bold, std::wstring test_str = L"") double static calculate_size_symbol(std::wstring name, double size, bool italic, bool bold, std::wstring test_str = L"")
{ {
double result =0; double result =0;
#if defined(_WIN32) || defined(_WIN64)
Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken=0; ULONG_PTR gdiplusToken=0;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
...@@ -125,6 +137,7 @@ namespace _gdi_graphics_ ...@@ -125,6 +137,7 @@ namespace _gdi_graphics_
delete gr; delete gr;
} }
Gdiplus::GdiplusShutdown(gdiplusToken); Gdiplus::GdiplusShutdown(gdiplusToken);
#endif
return result; return result;
} }
double static calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold) double static calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold)
......
...@@ -360,6 +360,10 @@ ...@@ -360,6 +360,10 @@
> >
</File> </File>
</Filter> </Filter>
<File
RelativePath="..\Oox2OdfConverter\Oox2OdfConverter.h"
>
</File>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
......
// OfficeOdfFileW.cpp : Implementation of COfficeOdfFileW // OfficeOdfFileW.cpp : Implementation of COfficeOdfFileW
#include "stdafx.h"
#include "OfficeOdfFileW.h" #include "OfficeOdfFileW.h"
#include "../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h" #include "../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
...@@ -6,11 +7,12 @@ ...@@ -6,11 +7,12 @@
#include <string> #include <string>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/random_generator.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "../source/Oox2OdfConverter/Converter.h" #include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../source/Oox2OdfConverter/Oox2OdfConverter.h"
#ifndef STANDALONE_USE #ifndef STANDALONE_USE
...@@ -19,13 +21,7 @@ ...@@ -19,13 +21,7 @@
// - uuid // - uuid
boost::filesystem::wpath MakeTempDirectoryName(const std::wstring& Dst)
{
boost::uuids::random_generator gen;
boost::uuids::uuid u = gen();
boost::filesystem::wpath path = boost::filesystem::wpath(Dst) / boost::lexical_cast<std::wstring>(u);
return path;
}
std::wstring bstr2wstring(BSTR str) std::wstring bstr2wstring(BSTR str)
{ {
return str ? std::wstring(&str[0], &str[::SysStringLen(str)]) : L""; return str ? std::wstring(&str[0], &str[::SysStringLen(str)]) : L"";
...@@ -45,32 +41,33 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR ...@@ -45,32 +41,33 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
} }
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1) #if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
boost::filesystem::wpath inputDir = boost::filesystem::wpath(CString(sSrcPath)).parent_path(); std::wstring inputDir = FileSystem::Directory::GetFolderPath(std::wstring(sSrcPath));
#else #else
boost::filesystem::wpath inputDir = boost::filesystem::wpath(CString(sSrcPath)); std::wstring inputDir = sSrcPath;
#endif #endif
boost::filesystem::wpath outputDir = boost::filesystem::wpath(CString(sDstFileName)).parent_path(); std::wstring outputDir = FileSystem::Directory::GetFolderPath(std::wstring(sDstFileName));
// //
boost::filesystem::wpath dstTempPath = MakeTempDirectoryName(outputDir.string()); std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1) #if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
boost::filesystem::wpath srcTempPath = MakeTempDirectoryName(BOOST_STRING_PATH(outputDir)); std::wstring srcTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
#else #else
boost::filesystem::wpath srcTempPath = inputDir.string(); std::wstring srcTempPath = inputDir;
#endif #endif
try try
{ {
boost::filesystem::create_directory(dstTempPath); FileSystem::Directory::CreateDirectory(dstTempPath);
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1) #if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
boost::filesystem::create_directory(srcTempPath); // FileSystem::Directory::CreateDirectory(srcTempPath); //
#endif #endif
hr = SaveToFileImpl(bstr2wstring(sSrcPath),srcTempPath.string(), dstTempPath.string(), bstr2wstring(sDstFileName)); hr = SaveToFileImpl(bstr2wstring(sSrcPath),srcTempPath, dstTempPath, bstr2wstring(sDstFileName));
} }
catch(...) catch(...)
...@@ -81,7 +78,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR ...@@ -81,7 +78,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
// //
try try
{ {
boost::filesystem::remove_all(dstTempPath); FileSystem::Directory::DeleteDirectory(dstTempPath);
} }
catch(...) catch(...)
{ {
...@@ -91,7 +88,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR ...@@ -91,7 +88,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
// ( ) // ( )
try try
{ {
boost::filesystem::remove_all(srcTempPath); FileSystem::Directory::DeleteDirectory(srcTempPath);
} }
catch(...) catch(...)
{ {
...@@ -141,53 +138,12 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const std::wstring & srcPath, ...@@ -141,53 +138,12 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const std::wstring & srcPath,
return S_OK; return S_OK;
} }
namespace fs = boost::filesystem;
//FileChecker !!
std::wstring COfficeOdfFileW::DetectTypeDocument(const std::wstring & Path) std::wstring COfficeOdfFileW::DetectTypeDocument(const std::wstring & Path)
{ {
fs::wpath full_path(/* fs::initial_path<fs::wpath>()*/ Path); return L"text";
//return L"spreadsheet";
//full_path = fs::system_complete( fs::wpath( Path ) );
unsigned long file_count = 0;
unsigned long dir_count = 0;
unsigned long other_count = 0;
unsigned long err_count = 0;
if (!fs::exists( full_path ) )return L"";
if (!fs::is_directory( full_path ) )return L"";
fs::wdirectory_iterator end_iter;
for ( fs::wdirectory_iterator dir_itr( full_path ); dir_itr != end_iter; ++dir_itr )
{
try
{
if ( fs::is_directory( dir_itr->status() ) )
{
++dir_count;
std::wstring tmp = dir_itr->path().filename();
boost::algorithm::to_lower(tmp);
if (tmp == L"word") return L"text";
if (tmp == L"xl") return L"spreadsheet";
}
else if ( fs::is_regular_file( dir_itr->status() ) )
{
++file_count;
}
else
{
++other_count;
}
}
catch ( const std::exception & ex )
{
++err_count;
}
}
return L"";
} }
void COfficeOdfFileW::OnProgressFunc (LPVOID lpParam, long nID, long nPercent) void COfficeOdfFileW::OnProgressFunc (LPVOID lpParam, long nID, long nPercent)
......
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