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

..... Odf File

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62594 954022d7-b5bf-4e40-9824-e11837661b57
parent e2bf78c5
......@@ -2,48 +2,15 @@
#include "OfficeSvmFile.h"
#include "ATLDefine.h"
#define USE_IMAGESTUDIO
#ifdef USE_IMAGESTUDIO
#import "../../../Redist/ASCImageStudio3.dll" rename_namespace("ImageStudio")
#endif
void ConvertSvmToImage( const boost::filesystem::wpath & oSource, const boost::filesystem::wpath & oDestination )
void ConvertSvmToImage( const std::wstring & oSource, const std::wstring & oDestination )
{
#ifdef USE_IMAGESTUDIO
std::wstring sXmlExt = L"";
std::wstring sExt = oDestination.extension();
std::transform( sExt.begin(), sExt.end(), sExt.begin(), tolower);
if( L".png" == sExt )
sXmlExt = L"Png";
else if( L".jpg" == sExt || L"jpeg" == sExt )
sXmlExt = L"Jpeg";
else if( L".bmp" == sExt )
sXmlExt = L"Bmp";
else if( L".gif" == sExt )
sXmlExt = L"Gif";
else if( L".tif" == sExt || L"tiff" == sExt )
sXmlExt = L"Tiff";
else if( L".wmf" == sExt )
sXmlExt = L"Wmf";
else if( L".emf" == sExt )
sXmlExt = L"Emf";
else if( L".pcx" == sExt )
sXmlExt = L"Pcx";
else if( L".tga" == sExt )
sXmlExt = L"Tga";
else if( L".ras" == sExt )
sXmlExt = L"Ras";
else if( L".ipod" == sExt )
sXmlExt = L"IPod";
else if( L".psd" == sExt )
sXmlExt = L"Psd";
if( L"" == sXmlExt )
return;
std::wstring sXmlExt = L"Jpeg";
CoInitialize( NULL );
OfficeSvmFile oSvmFile;
BSTR bstrSource = SysAllocString(oSource.string().c_str()) ;
BSTR bstrSource = SysAllocString(oSource.c_str()) ;
int nRes = oSvmFile.Open(bstrSource);
SysFreeString(bstrSource);
if( NOERROR != nRes )
......@@ -61,20 +28,22 @@ void ConvertSvmToImage( const boost::filesystem::wpath & oSource, const boost::f
vImage.punkVal = piImage;
vImage.vt = VT_UNKNOWN;
piTransform->SetSource( 0, vImage );
std::wstring sXml;
sXml.append( L"<ImageFile-SaveAs" );
sXml.append( sXmlExt );
sXml.append( L" destinationpath=\"" );
sXml.append( oDestination.string() );
sXml.append( oDestination );
sXml.append( L"\" format=\"8888\"/>" );
if( piTransform->SetXml( sXml.c_str() ) )
if(piTransform->Transform())
piTransform->GetResult( 0, &vImage );
RELEASEINTERFACE( vImage.punkVal );
RELEASEINTERFACE( piTransform );
RELEASEINTERFACE( piImage );
oSvmFile.Close();
CoUninitialize();
#endif
}
\ No newline at end of file
#ifndef SVM_COVERTER
#define SVM_COVERTER
#pragma once
#include <string>
#include "../../../Common/boost_filesystem_version.h"
void ConvertSvmToImage( const boost::filesystem::wpath & oSource, const boost::filesystem::wpath & oDestination );
#endif
\ No newline at end of file
void ConvertSvmToImage( const std::wstring & oSource, const std::wstring & oDestination );
......@@ -122,7 +122,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
UseOfATL="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
......@@ -325,7 +325,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
UseOfATL="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
WholeProgramOptimization="1"
......@@ -421,7 +421,7 @@
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\..\Redist\x64&quot;&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\..\Redist\x64&quot;&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
......@@ -530,7 +530,7 @@
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
UseOfATL="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
WholeProgramOptimization="1"
......@@ -640,7 +640,7 @@
>
</File>
<File
RelativePath=".\ConvertOO2OOX.cpp"
RelativePath=".\OfficeOdfFile.cpp"
>
</File>
</Filter>
......@@ -649,10 +649,6 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\ConvertOO2OOX.h"
>
</File>
<File
RelativePath=".\OfficeOdfFile.h"
>
......@@ -728,10 +724,6 @@
>
</File>
</Filter>
<File
RelativePath=".\OfficeOdfFile.cpp"
>
</File>
<File
RelativePath=".\ReadMe.txt"
>
......
#include "stdafx.h"
#include "ConvertOO2OOX.h"
#include "../../Common/OfficeFileErrorDescription.h"
......@@ -47,7 +45,7 @@ HRESULT ConvertOdp2Pptx(cpdoccore::odf::odf_document & inputOdf, const std::wstr
return S_OK;
}
HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation, const ProgressCallback* CallBack)
HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation, const ProgressCallback* CallBack)
{
HRESULT hr = S_OK;
......@@ -60,13 +58,13 @@ HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, con
if (encrypted) return AVS_ERROR_DRM;
if (type<1)
{
if (ext == L".odt")type = 1;
if (ext == L".ods")type = 2;
if (ext == L".odp")type = 3;
//if (type<1)
//{
// if (ext == L".odt")type = 1;
// if (ext == L".ods")type = 2;
// if (ext == L".odp")type = 3;
}
//}
if (bOnlyPresentation && type != 3)return AVS_ERROR_UNEXPECTED;
......
......@@ -3,4 +3,4 @@
struct ProgressCallback;
HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation, const ProgressCallback* CallBack);
\ No newline at end of file
HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation, const ProgressCallback* CallBack);
\ No newline at end of file
/// \file OfficeOdfFile.cpp
#include "stdafx.h"
#include "OfficeOdfFile.h"
#include "../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
#include <string>
#include <boost/uuid/uuid.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
#pragma warning(push)
#pragma warning(disable : 4244)
#include <boost/uuid/random_generator.hpp>
#pragma warning(pop)
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <lexical_cast.h>
#include <boost/filesystem.hpp>
#include <iostream>
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "ConvertOO2OOX.h"
......@@ -26,6 +16,8 @@
#include "../../Common/ASCATLError.h"
#include <string>
// : 1 , xlsx docx
// 0 , package
#ifndef STANDALONE_USE
......@@ -40,24 +32,12 @@ COfficeOdfFile::COfficeOdfFile()
namespace {
// - 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)
{
return str ? std::wstring(&str[0], &str[::SysStringLen(str)]) : L"";
}
boost::filesystem::wpath MakeTempDirectoryName(BSTR Dst)
{
return MakeTempDirectoryName(bstr2wstring(Dst));
}
}
......@@ -83,44 +63,35 @@ bool COfficeOdfFile::loadOptionFromXML(CString parametr,BSTR sXMLOptions)
HRESULT COfficeOdfFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions)
{
HRESULT hr;
if (!sDstPath)
{
_ASSERTE(!!sDstPath);
return E_FAIL;
}
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
boost::filesystem::wpath outputDir = boost::filesystem::wpath(bstr2wstring(sDstPath)).parent_path();
std::wstring outputDir = FileSystem::Directory::GetFolderPath(std::wstring(sDstPath));
#else
boost::filesystem::wpath outputDir = boost::filesystem::wpath(bstr2wstring(sDstPath));
std::wstring outputDir = sDstPath;
#endif
// , ,
//
//boost::filesystem::wpath srcTempPath = MakeTempDirectoryName(outputDir.string<std::wstring>());
boost::filesystem::wpath srcTempPath = MakeTempDirectoryName(BOOST_STRING_PATH(outputDir));
std::wstring srcTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
//boost::filesystem::wpath dstTempPath = MakeTempDirectoryName(outputDir.string<std::wstring>());
boost::filesystem::wpath dstTempPath = MakeTempDirectoryName(BOOST_STRING_PATH(outputDir));
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
#else
boost::filesystem::wpath dstTempPath = outputDir.string();
std::wstring dstTempPath = outputDir;
#endif
bOnlyPresentation = loadOptionFromXML(L"onlyPresentation", sXMLOptions);
try
HRESULT hr;
try
{
boost::filesystem::create_directory(srcTempPath);
FileSystem::Directory::CreateDirectory(srcTempPath);
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
//
boost::filesystem::create_directory(dstTempPath);
FileSystem::Directory::CreateDirectory(dstTempPath);
#endif
//hr = LoadFromFileImpl(bstr2wstring(sSrcFileName), srcTempPath.string<std::wstring>(), dstTempPath.string<std::wstring>(), bstr2wstring(sDstPath));
hr = LoadFromFileImpl(bstr2wstring(sSrcFileName), BOOST_STRING_PATH(srcTempPath), BOOST_STRING_PATH(dstTempPath), bstr2wstring(sDstPath));
hr = LoadFromFileImpl(bstr2wstring(sSrcFileName), srcTempPath, dstTempPath, bstr2wstring(sDstPath));
}
catch(...)
......@@ -131,7 +102,7 @@ HRESULT COfficeOdfFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXML
//
try
{
boost::filesystem::remove_all(srcTempPath);
FileSystem::Directory::DeleteDirectory(srcTempPath);
}
catch(...)
{
......@@ -141,7 +112,7 @@ HRESULT COfficeOdfFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXML
// ( )
try
{
boost::filesystem::remove_all(dstTempPath);
FileSystem::Directory::DeleteDirectory(dstTempPath);
}
catch(...)
{
......@@ -158,12 +129,6 @@ HRESULT COfficeOdfFile::LoadFromFileImpl(const std::wstring & srcFileName,
{
HRESULT hr = AVS_ERROR_UNEXPECTED;
#ifdef BOOST_FILESYSTEM_LEGACY
const std::wstring ext = boost::algorithm::to_lower_copy(boost::filesystem::wpath(srcFileName).extension());
#else
const std::wstring ext = boost::algorithm::to_lower_copy(boost::filesystem::wpath(srcFileName).extension().string<std::wstring>());
#endif
//
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
......@@ -175,7 +140,7 @@ HRESULT COfficeOdfFile::LoadFromFileImpl(const std::wstring & srcFileName,
ffCallBack.OnProgressEx = OnProgressExFunc;
ffCallBack.caller = this;
hr = ConvertOO2OOX(ext,srcTempPath, dstTempPath,bOnlyPresentation, &ffCallBack);
hr = ConvertOO2OOX(srcTempPath, dstTempPath,bOnlyPresentation, &ffCallBack);
if (hr != S_OK) return hr;
......
......@@ -36,13 +36,13 @@
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
//#include <atlwin.h>
//#include <atltypes.h>
//#include <atlctl.h>
//#include <atlhost.h>
#include <windef.h>
#include <wingdi.h>
//#include <windef.h>
//#include <wingdi.h>
using namespace ATL;
typedef void (*OdfOnProgressCallback)( LPVOID lpParam, long nID, long nPercent );
......
#ifndef CPDOCCORE_BOOST_FILESYSTEM_VERSION_
#define CPDOCCORE_BOOST_FILESYSTEM_VERSION_
#include <boost/filesystem.hpp>
// boost-filesystem
#if (BOOST_FILESYSTEM_VERSION == 2 || !defined(BOOST_FILESYSTEM_VERSION))
#define BOOST_FILESYSTEM_LEGACY
#define BOOST_STRING_PATH(A) (A).string()
#else
#undef BOOST_FILESYSTEM_LEGACY
#define BOOST_STRING_PATH(A) (A).string<std::wstring>()
#endif
//const boost::filesystem::wpath replace_extension(const boost::filesystem::wpath& filename, const std::wstring& extension);
//const boost::filesystem::wpath replace_extension(const boost::filesystem::wpath& filename, const std::wstring& old_extension, const std::wstring& new_extension);
#endif
#include "precompiled_cpcommon.h"
#include <boost/program_options/detail/convert.hpp>
#include "../../include/cpdoccore/CPString.h"
#include <cstdlib>
#include "../../../DesktopEditor/common/File.h"
namespace cpdoccore {
std::string ansi_to_utf8(const std::string & _AnsiString)
{
char * currentLocale = ::setlocale(LC_ALL, NULL);
std::string currentLocaleStr = currentLocale;
::setlocale(LC_ALL, "");
size_t size = mbstowcs(NULL, _AnsiString.c_str(), 0);
std::wstring utf16;
utf16.resize(size);
size = mbstowcs(&utf16[0], _AnsiString.c_str(), utf16.length());
::setlocale(LC_ALL, currentLocaleStr.c_str());
return boost::to_utf8(utf16);
//char * currentLocale = ::setlocale(LC_ALL, NULL);
//std::string currentLocaleStr = currentLocale;
//::setlocale(LC_ALL, "");
//size_t size = mbstowcs(NULL, _AnsiString.c_str(), 0);
//std::wstring utf16;
//utf16.resize(size);
//size = mbstowcs(&utf16[0], _AnsiString.c_str(), utf16.length());
//::setlocale(LC_ALL, currentLocaleStr.c_str());
//return boost::to_utf8(utf16);
return "";
}
std::wstring utf8_to_utf16(const std::string & _Utf8String)
{
return boost::from_utf8(_Utf8String);
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_Utf8String.c_str(), _Utf8String.length());
//return boost::from_utf8(_Utf8String);
}
std::string utf16_to_utf8(const std::wstring & _Utf16String)
{
return boost::to_utf8(_Utf16String);
return NSFile::CUtf8Converter::GetUtf8StringFromUnicode(_Utf16String);
//return boost::to_utf8(_Utf16String);
}
}
#include "../odf/precompiled_cpodf.h"
#include "docx_package.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include "docx_conversion_context.h"
#include "headers_footers.h"
#include <cpdoccore/common/boost_filesystem_version.h>
namespace cpdoccore {
namespace oox {
namespace package {
namespace fs = boost::filesystem;
docx_content_types_file::docx_content_types_file()
{
content_type_.add_default(L"rels", L"application/vnd.openxmlformats-package.relationships+xml");
......@@ -45,61 +41,61 @@ word_files::word_files()
void word_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"word";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"word";
FileSystem::Directory::CreateDirectory(path.c_str());
if (document_)
document_->write( BOOST_STRING_PATH(path) );
document_->write( path );
if (styles_)
{
rels_files_.add( relationship(L"rId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
styles_->write( BOOST_STRING_PATH(path) );
styles_->write( path );
}
if (fontTable_)
{
rels_files_.add( relationship(L"rId2", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", L"fontTable.xml" ) );
fontTable_->write( BOOST_STRING_PATH(path) );
fontTable_->write( path );
}
if (numbering_)
{
rels_files_.add( relationship(L"rId3", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", L"numbering.xml" ) );
numbering_->write( BOOST_STRING_PATH(path) );
numbering_->write( path );
}
if (media_)
{
media_->write( BOOST_STRING_PATH(path) );
media_->write( path );
}
if (headers_footers_)
{
headers_footers_->write( BOOST_STRING_PATH(path) );
headers_footers_->write( path );
}
if (notes_)
{
notes_->write( BOOST_STRING_PATH(path) );
notes_->write( path );
}
if (settings_)
{
rels_files_.add( relationship(L"rId4", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", L"settings.xml" ) );
settings_->write( BOOST_STRING_PATH(path) );
settings_->write( path );
}
if (comments_)
{
rels_files_.add( relationship(L"rId5", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", L"comments.xml" ) );
comments_->write( BOOST_STRING_PATH(path) );
comments_->write( path );
}
{
charts_files_.set_main_document(get_main_document());
charts_files_.write(BOOST_STRING_PATH(path));
charts_files_.write(path);
}
rels_files_.write(BOOST_STRING_PATH(path));
rels_files_.write(path);
}
void word_files::update_rels(docx_conversion_context & Context)
......@@ -175,8 +171,8 @@ void docx_charts_files::add_chart(chart_content_ptr chart)
}
void docx_charts_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"charts";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
FileSystem::Directory::CreateDirectory(path.c_str());
size_t count = 0;
......@@ -191,7 +187,7 @@ void docx_charts_files::write(const std::wstring & RootPath)
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes.add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......
......@@ -2,7 +2,6 @@
#include "mediaitems.h"
#include <regex.h>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
......@@ -10,14 +9,13 @@
#include "docx_rels.h"
#include "mediaitems_utils.h"
#include <cpdoccore/common/boost_filesystem_version.h>
#include "../../Common/DocxFormat/Source/Base/Base.h"
namespace cpdoccore {
namespace oox {
using boost::filesystem::wpath;
mediaitems::item::item( std::wstring const & _href,
Type _type,
std::wstring const & _outputName,
......@@ -41,8 +39,6 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
return add_or_find(href, type, isInternal, ref);
}
namespace fs = boost::filesystem;
std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool & isInternal, std::wstring & ref)
{
const bool isMediaInternal = utils::media::is_internal(href, odf_packet_);
......@@ -67,7 +63,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
inputFileName = utils::media::create_file_name(href, type, number);
std::wstring inputPath = isMediaInternal ? BOOST_STRING_PATH(wpath(odf_packet_) / href) : href;
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart)outputPath= outputPath + L".xml";
......@@ -91,8 +87,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, Type type, bool
}
else if ( type == typeImage)
{
fs::wpath file_name = fs::wpath(inputPath);
if (file_name.extension() == L".svm" || file_name.extension().empty())
if (inputPath.rfind (L".svm") >=0 )
{
outputPath = outputPath + L".png";
}
......
#include "../odf/precompiled_cpodf.h"
#include "mediaitems_utils.h"
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
namespace cpdoccore {
namespace oox {
......@@ -12,20 +13,16 @@ namespace utils {
namespace media {
using boost::filesystem::wpath;
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
{
std::wstring s = boost::regex_search(uri.begin(), uri.end(), boost::wregex(L"^/[A-Za-z]:"))
std::wstring mediaPath = boost::regex_search(uri.begin(), uri.end(), boost::wregex(L"^/[A-Za-z]:"))
? std::wstring(uri.begin() + 1, uri.end())
: uri;
wpath packetRootPath(packetRoot);
wpath mediaPath(s);
wpath resultPath = packetRoot / mediaPath;
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
return boost::filesystem::exists(resultPath);
return FileSystem::Directory::IsExist(resultPath);
}
std::wstring get_rel_type(mediaitems::Type type)
......@@ -65,11 +62,12 @@ std::wstring replace_extension(const std::wstring & ext)
std::wstring create_file_name(const std::wstring & uri, mediaitems::Type type, size_t Num)
{
#ifdef BOOST_FILESYSTEM_LEGACY
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + wpath(uri).extension();
#else
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + wpath(uri).extension().string<std::wstring>();
#endif
std::wstring sExt;
int n = uri.rfind(L".");
if (n>=0) sExt = uri.substr(n);
//todooo
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + sExt;
}
......
......@@ -2,24 +2,18 @@
#include "oox_package.h"
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <cpdoccore/utf8cpp/utf8.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include "mediaitems.h"
#include "..\..\..\ASCImageStudio3\ASCGraphics\OfficeSvmFile\SvmConverter.h"
#import "../../../Redist/ASCImageFile3.dll" named_guids rename_namespace("ImageFile") raw_interfaces_only
#include "../../../ASCImageStudio3/ASCGraphics/OfficeSvmFile/SvmConverter.h"
#include "../../DesktopEditor/common/File.h"
namespace cpdoccore {
namespace oox {
namespace package {
namespace fs = boost::filesystem;
content_types_file::content_types_file() : filename_(L"[Content_Types].xml")
{}
......@@ -42,9 +36,16 @@ simple_element::simple_element(const std::wstring & FileName, const std::wstring
void simple_element::write(const std::wstring & RootPath)
{
fs::ofstream file( fs::wpath(RootPath) / file_name_, std::ios_base::out | std::ios_base::binary );
file << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
file << content_utf8_;
std::wstring name_ = RootPath + FILE_SEPARATOR_STR + file_name_;
NSFile::CFileBinary file;
if ( file.CreateFileW(name_) == true)
{
std::string root = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
file.WriteFile((BYTE*)root.c_str(), root.length());
file.WriteFile((BYTE*)content_utf8_.c_str(), content_utf8_.length());
file.CloseFile();
}
}
rels_file::rels_file(std::wstring const & FileName) : filename_(FileName)
......@@ -66,10 +67,12 @@ void rels_file::write(const std::wstring & RootPath)
void rels_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"_rels";
fs::create_directory(path);
if (rels_file_)
rels_file_->write(BOOST_STRING_PATH(path));
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"_rels";
FileSystem::Directory::CreateDirectory(path.c_str());
if (rels_file_)
rels_file_->write(path);
}
void rels_files::add(relationship const & r)
......@@ -152,11 +155,11 @@ docProps_files::docProps_files()
void docProps_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"docProps";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"docProps";
FileSystem::Directory::CreateDirectory(path.c_str());
core_.write(BOOST_STRING_PATH(path));
app_.write(BOOST_STRING_PATH(path));
core_.write(path);
app_.write(path);
}
////////////
......@@ -168,55 +171,56 @@ media::media(mediaitems & _Mediaitems) : mediaitems_(_Mediaitems)
void media::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"media";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
FileSystem::Directory::CreateDirectory(path.c_str());
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{
if (item.mediaInternal && item.valid && item.type == mediaitems::typeImage )
{
fs::wpath file_name = fs::wpath(item.href);
fs::wpath file_name_out = fs::wpath(RootPath) / item.outputName;
if (file_name.extension() == L".svm")
std::wstring & file_name = item.href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
if (file_name.rfind(L".svm") >= 0)
{
ConvertSvmToImage(file_name, file_name_out);
}
else if(file_name.extension().empty())
{
// .. svm, emf, wmf, vclmtf ( )
//???
ImageFile::IImageFile3Ptr piImageFile = NULL;
piImageFile.CreateInstance( __uuidof(ImageFile::ImageFile3) );
if( NULL != piImageFile )
{
VARIANT_BOOL vbSuccess = VARIANT_FALSE;
IUnknown* pImage = NULL;
BSTR bstrFilename = SysAllocString(item.href.data());
try
{
piImageFile->LoadImage2(bstrFilename, &pImage, &vbSuccess);
}
catch(...)
{
}
SysFreeString( bstrFilename );
if (vbSuccess && pImage)
{
bstrFilename = SysAllocString(file_name_out.string().data());
piImageFile->SaveImage2( &pImage, 4, bstrFilename, &vbSuccess );//to png
SysFreeString( bstrFilename );
pImage->Release();
}
if (vbSuccess == FALSE)
{
boost::filesystem::copy_file(item.href, file_name_out);// png ... ? :-)
}
}
}
//else if(file_name.extension().empty())
//{
// // .. svm, emf, wmf, vclmtf ( )
// //???
// ImageFile::IImageFile3Ptr piImageFile = NULL;
// piImageFile.CreateInstance( __uuidof(ImageFile::ImageFile3) );
// if( NULL != piImageFile )
// {
// VARIANT_BOOL vbSuccess = VARIANT_FALSE;
// IUnknown* pImage = NULL;
//
// BSTR bstrFilename = SysAllocString(item.href.data());
// try
// {
// piImageFile->LoadImage2(bstrFilename, &pImage, &vbSuccess);
// }
// catch(...)
// {
// }
// SysFreeString( bstrFilename );
// if (vbSuccess && pImage)
// {
// bstrFilename = SysAllocString(file_name_out.string().data());
// piImageFile->SaveImage2( &pImage, 4, bstrFilename, &vbSuccess );//to png
// SysFreeString( bstrFilename );
// pImage->Release();
// }
// if (vbSuccess == FALSE)
// {
// FileSystem::Directory::CopyFile(item.href, file_name_out);// png ... ? :-)
// }
// }
//}
else
boost::filesystem::copy_file(item.href, file_name_out);
NSFile::CFileBinary::Copy(item.href, file_name_out);
}
}
......
......@@ -4,9 +4,13 @@
#include <vector>
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPNoncopyable.h>
#include "docx_content_type.h"
#include "docx_rels.h"
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
namespace cpdoccore {
namespace oox {
......
......@@ -2,20 +2,15 @@
#include "pptx_package.h"
#include "pptx_output_xml.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
#include <cpdoccore/utf8cpp/utf8.h>
namespace cpdoccore {
namespace oox {
namespace package {
namespace fs = boost::filesystem;
pptx_content_types_file::pptx_content_types_file()
{
......@@ -69,7 +64,7 @@ _CP_PTR(slide_content) slide_content::create()
{
return boost::make_shared<slide_content>();
}
void slide_content::add_rel(relationship const & r)
{
rels_->get_rels().add(r);
......@@ -94,8 +89,8 @@ void slides_files::add_slide(slide_content_ptr slide)
void slides_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"slides" ;
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slides" ;
FileSystem::Directory::CreateDirectory(path.c_str());
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
......@@ -123,9 +118,9 @@ void slides_files::write(const std::wstring & RootPath)
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(BOOST_STRING_PATH(path));
relFiles.write(path);
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......@@ -141,8 +136,8 @@ void slideMasters_files::add_slide(slide_content_ptr slide)
void slideMasters_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"slideMasters" ;
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideMasters" ;
FileSystem::Directory::CreateDirectory(path.c_str());
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
......@@ -169,9 +164,9 @@ void slideMasters_files::write(const std::wstring & RootPath)
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(BOOST_STRING_PATH(path));
relFiles.write(path);
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......@@ -187,8 +182,8 @@ void slideLayouts_files::add_slide(slide_content_ptr slide)
void slideLayouts_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"slideLayouts" ;
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideLayouts" ;
FileSystem::Directory::CreateDirectory(path.c_str());
size_t count = 0;
......@@ -206,9 +201,9 @@ void slideLayouts_files::write(const std::wstring & RootPath)
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(BOOST_STRING_PATH(path));
relFiles.write(path);
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......@@ -221,13 +216,12 @@ void authors_comments_element::write(const std::wstring & RootPath)
{
if (authors_comments_ == NULL) return;
fs::wpath path = fs::wpath(RootPath);
const std::wstring file_name = std::wstring(L"commentAuthors.xml");
std::wstringstream content_authors_comments;
authors_comments_->write_to(content_authors_comments);
simple_element(file_name, content_authors_comments.str()).write(BOOST_STRING_PATH(path));
simple_element(file_name, content_authors_comments.str()).write(RootPath);
if (get_main_document())
{
......@@ -243,8 +237,8 @@ void ppt_charts_files::add_chart(chart_content_ptr chart)
}
void ppt_charts_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"charts";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
FileSystem::Directory::CreateDirectory(path.c_str());
size_t count = 0;
......@@ -259,7 +253,7 @@ void ppt_charts_files::write(const std::wstring & RootPath)
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes.add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......@@ -270,8 +264,8 @@ void ppt_themes_files::add_theme(pptx_xml_theme_ptr theme)
}
void ppt_themes_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"theme" ;
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme" ;
FileSystem::Directory::CreateDirectory(path.c_str());
size_t count = 0;
......@@ -288,7 +282,7 @@ void ppt_themes_files::write(const std::wstring & RootPath)
std::wstringstream content;
item->write_to(content);
package::simple_element(fileName, content.str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, content.str()).write(path);
}
}
}
......@@ -300,10 +294,8 @@ ppt_comments_files_ptr ppt_comments_files::create(const std::vector<pptx_comment
void ppt_comments_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath);
fs::wpath comm_path = fs::wpath(RootPath) / L"comments";
fs::create_directory(comm_path);
std::wstring comm_path = RootPath + FILE_SEPARATOR_STR + L"comments";
FileSystem::Directory::CreateDirectory(comm_path.c_str());
BOOST_FOREACH(pptx_comment_elm const & e, comments_)
{
......@@ -312,7 +304,7 @@ void ppt_comments_files::write(const std::wstring & RootPath)
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
contentTypes.add_override(std::wstring(L"/ppt/comments/") + e.filename, kWSConType);
package::simple_element(e.filename, e.content).write(BOOST_STRING_PATH(comm_path));
package::simple_element(e.filename, e.content).write( comm_path);
}
}
////////////////////////////////////////////
......@@ -323,57 +315,57 @@ ppt_files::ppt_files()
void ppt_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"ppt";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"ppt";
FileSystem::Directory::CreateDirectory(path.c_str());
slides_files_.set_rels(&rels_files_);
slides_files_.set_main_document( this->get_main_document() );
slides_files_.write(BOOST_STRING_PATH(path));
slides_files_.write(path);
slideLayouts_files_.set_main_document( this->get_main_document() );
slideLayouts_files_.write(BOOST_STRING_PATH(path));
slideLayouts_files_.write(path);
slideMasters_files_.set_rels(&rels_files_);
slideMasters_files_.set_main_document( this->get_main_document() );
slideMasters_files_.write(BOOST_STRING_PATH(path));
slideMasters_files_.write(path);
//rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"ppt/presentation.xml" ) );
//if (styles_)
//{
// styles_->write(BOOST_STRING_PATH(path));
// styles_->write(path);
// rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"tableStyles.xml" ) );
//}
if (presentation_)
{
presentation_->write(BOOST_STRING_PATH(path));
presentation_->write(path);
}
if (media_)
{
media_->set_main_document(get_main_document());
media_->write(BOOST_STRING_PATH(path));
media_->write(path);
}
{
charts_files_.set_main_document(get_main_document());
charts_files_.write(BOOST_STRING_PATH(path));
charts_files_.write(path);
}
{
themes_files_.set_main_document(get_main_document());
themes_files_.write(BOOST_STRING_PATH(path));
themes_files_.write(path);
}
{
comments_->set_main_document(get_main_document());
comments_->write(BOOST_STRING_PATH(path));
comments_->write(path);
}
if (authors_comments_)
{
rels_files_.add( relationship( L"auId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors", L"commentAuthors.xml" ) );
authors_comments_->write(BOOST_STRING_PATH(path));
authors_comments_->write(path);
}
rels_files_.write(BOOST_STRING_PATH(path));
rels_files_.write(path);
}
void ppt_files::set_presentation(pptx_xml_presentation & presentation)
......
......@@ -2,7 +2,6 @@
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include <cpdoccore/odf/odf_document.h>
#include "mediaitems_utils.h"
......@@ -371,7 +370,6 @@ void pptx_slide_context::process_drawings()
void pptx_slide_context::process_images()
{
using boost::filesystem::wpath;
int pos_replaicement=0, pos_preview=0;
BOOST_FOREACH(drawing_object_description & pic, impl_->images_)
......@@ -401,7 +399,7 @@ void pptx_slide_context::process_images()
drawing.id = impl_->next_rId();
drawing.name = pic.draw_name_;
std::wstring fileName = BOOST_STRING_PATH(wpath(impl_->odfPacket_) / pic.xlink_href_);
std::wstring fileName = impl_->odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
drawing.fill.bitmap->bCrop = odf::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect);
drawing.fill.bitmap->bStretch = true;
......@@ -429,8 +427,6 @@ void pptx_slide_context::process_images()
}
void pptx_slide_context::process_charts()
{
using boost::filesystem::wpath;
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
{
_pptx_drawing drawing=_pptx_drawing();
......@@ -451,8 +447,6 @@ void pptx_slide_context::process_charts()
void pptx_slide_context::process_tables()
{
using boost::filesystem::wpath;
BOOST_FOREACH(drawing_object_description & pic, impl_->tables_)
{
_pptx_drawing drawing=_pptx_drawing();
......
#include "../odf/precompiled_cpodf.h"
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/common/boost_filesystem_version.h>
#include "../formulasconvert/include/cpdoccore/formulasconvert.h"
#include "mediaitems_utils.h"
......@@ -296,7 +295,6 @@ bool xlsx_drawing_context::empty() const
void xlsx_drawing_context::process_images(xlsx_table_metrics & table_metrics)
{
using boost::filesystem::wpath;
int pos_replaicement=0;
BOOST_FOREACH(drawing_object_description & pic, impl_->images_)
......@@ -331,7 +329,7 @@ void xlsx_drawing_context::process_images(xlsx_table_metrics & table_metrics)
bool isMediaInternal = false;
std::wstring fileName = BOOST_STRING_PATH(wpath(odf_packet_path_) / pic.xlink_href_);
std::wstring fileName = odf_packet_path_ + FILE_SEPARATOR_STR + pic.xlink_href_;
drawing.fill.bitmap->bCrop = odf::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect);
drawing.fill.bitmap->bStretch = true;
......@@ -355,8 +353,6 @@ void xlsx_drawing_context::process_images(xlsx_table_metrics & table_metrics)
void xlsx_drawing_context::process_charts(xlsx_table_metrics & table_metrics)
{
using boost::filesystem::wpath;
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
{
_xlsx_drawing drawing=_xlsx_drawing();
......
#include "../odf/precompiled_cpodf.h"
#include "xlsx_package.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
#include <cpdoccore/utf8cpp/utf8.h>
namespace cpdoccore {
namespace oox {
namespace package {
namespace fs = boost::filesystem;
xlsx_content_types_file::xlsx_content_types_file()
{
......@@ -42,10 +37,12 @@ xlsx_document::xlsx_document()
{
xl_files_.set_main_document(this);
rels_file_ptr relFile = rels_file::create(L".rels");
relFile->get_rels().add(relationship(L"rId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"xl/workbook.xml"));
relFile->get_rels().add(relationship(L"rId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"xl/workbook.xml"));
relFile->get_rels().add(relationship(L"rId2", L"http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties", L"docProps/core.xml"));
relFile->get_rels().add(relationship(L"rId3", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", L"docProps/app.xml"));
rels_files_.add_rel_file( relFile );
rels_files_.add_rel_file( relFile );
}
void xlsx_document::write(const std::wstring & RootPath)
......@@ -92,8 +89,8 @@ void sheets_files::add_sheet(sheet_content_ptr sheet)
void sheets_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"worksheets";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"worksheets";
FileSystem::Directory::CreateDirectory(path.c_str());
size_t count = 0;
......@@ -118,11 +115,11 @@ void sheets_files::write(const std::wstring & RootPath)
item->get_rel_file()->set_file_name(fileName + L".rels");
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(BOOST_STRING_PATH(path));
relFiles.write(path);
//item->get_rel_file()->write(path.string<std::wstring>());
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......@@ -136,62 +133,62 @@ xl_files::xl_files()
void xl_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"xl";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"xl";
FileSystem::Directory::CreateDirectory(path.c_str());
sheets_files_.set_rels(&rels_files_);
sheets_files_.set_main_document( this->get_main_document() );
sheets_files_.write(BOOST_STRING_PATH(path));
sheets_files_.write(path);
int index = 1;
if (true)
{
//workbook_->hyperlinks->write(BOOST_STRING_PATH(path));
//workbook_->hyperlinks->write(path);
rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"xl/workbook.xml" ) );
}
if (sharedStrings_)
{
sharedStrings_->write(BOOST_STRING_PATH(path));
sharedStrings_->write(path);
rels_files_.add( relationship( L"shId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", L"sharedStrings.xml" ) );
}
if (styles_)
{
styles_->write(BOOST_STRING_PATH(path));
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
}
if (workbook_)
{
workbook_->write(BOOST_STRING_PATH(path));
workbook_->write(path);
}
if (theme_)
{
theme_->write(BOOST_STRING_PATH(path));
theme_->write(path);
}
if (media_)
{
media_->set_main_document(get_main_document());
media_->write(BOOST_STRING_PATH(path));
media_->write(path);
}
{
charts_files_.set_main_document(get_main_document());
charts_files_.write(BOOST_STRING_PATH(path));
charts_files_.write(path);
}
if (drawings_)
{
drawings_->set_main_document(get_main_document());
drawings_->write(BOOST_STRING_PATH(path));
drawings_->write(path);
}
if (comments_)
{
comments_->set_main_document(get_main_document());
comments_->write(BOOST_STRING_PATH(path));
comments_->write(path);
}
rels_files_.write(BOOST_STRING_PATH(path));
rels_files_.write(path);
}
void xl_files::set_workbook(element_ptr Element)
......@@ -241,8 +238,8 @@ void xl_charts_files::add_chart(chart_content_ptr chart)
}
void xl_charts_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"charts";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
FileSystem::Directory::CreateDirectory(path.c_str());
size_t count = 0;
......@@ -257,7 +254,7 @@ void xl_charts_files::write(const std::wstring & RootPath)
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes.add_override(std::wstring(L"/xl/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(BOOST_STRING_PATH(path));
package::simple_element(fileName, item->str()).write(path);
}
}
}
......@@ -269,12 +266,12 @@ xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
void xl_drawings::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"drawings";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"drawings";
FileSystem::Directory::CreateDirectory(path.c_str());
BOOST_FOREACH(drawing_elm const & e, drawings_)
{
package::simple_element(e.filename, e.content).write(BOOST_STRING_PATH(path));
package::simple_element(e.filename, e.content).write(path);
rels_files relFiles;
rels_file_ptr r = rels_file::create(e.filename + L".rels");
......@@ -282,7 +279,7 @@ void xl_drawings::write(const std::wstring & RootPath)
relFiles.add_rel_file(r);
relFiles.write(BOOST_STRING_PATH(path));
relFiles.write(path);
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
......@@ -300,10 +297,8 @@ xl_comments_ptr xl_comments::create(const std::vector<comment_elm> & elms)
void xl_comments::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath);
fs::wpath vml_path = fs::wpath(RootPath) / L"drawings";
fs::create_directory(vml_path);
std::wstring vml_path = RootPath + FILE_SEPARATOR_STR + L"drawings";
FileSystem::Directory::CreateDirectory(vml_path.c_str());
BOOST_FOREACH(comment_elm const & e, comments_)
{
......@@ -312,8 +307,8 @@ void xl_comments::write(const std::wstring & RootPath)
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
contentTypes.add_override(std::wstring(L"/xl/") + e.filename, kWSConType);
package::simple_element(e.filename, e.content).write(BOOST_STRING_PATH(path));
package::simple_element(e.vml_filename, e.vml_content).write(BOOST_STRING_PATH(vml_path));
package::simple_element(e.filename, e.content).write(RootPath);
package::simple_element(e.vml_filename, e.vml_content).write(vml_path);
}
}
......
#include "../odf/precompiled_cpodf.h"
#include "xlsx_utils.h"
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
//#include <boost/date_time/gregorian/gregorian.hpp>
//#include <boost/date_time/posix_time/posix_time.hpp>
namespace cpdoccore {
......@@ -162,30 +165,34 @@ std::wstring cellType2Str(XlsxCellType::type type)
boost::int64_t convertDate(int Year, int Month, int Day)
{
using namespace boost::gregorian;
return 0;
//todooo !!!!
//using namespace boost::gregorian;
boost::int64_t daysFrom1900 = date_duration(date(Year, Month, Day) - date(1900, 1, 1)).days() + 1;
//boost::int64_t daysFrom1900 = date_duration(date(Year, Month, Day) - date(1900, 1, 1)).days() + 1;
if (Year <= 1900 &&
Month <= 2 &&
Day <= 29)
{
return daysFrom1900;
}
else
{
return daysFrom1900 + 1;
}
//if (Year <= 1900 &&
// Month <= 2 &&
// Day <= 29)
//{
// return daysFrom1900;
//}
//else
//{
// return daysFrom1900 + 1;
//}
}
double convertTime(int hours, int minutes, double sec)
{
boost::posix_time::time_duration t(hours, minutes, 0);
t += boost::posix_time::millisec(static_cast<boost::uint32_t>(sec * 1000));
boost::posix_time::time_duration day(24, 0, 0);
{
//todooo !!!!!
//boost::posix_time::time_duration t(hours, minutes, 0);
//t += boost::posix_time::millisec(static_cast<boost::uint32_t>(sec * 1000));
//boost::posix_time::time_duration day(24, 0, 0);
const boost::uint64_t m1 = t.total_milliseconds() ;
const boost::uint64_t m2 = day.total_milliseconds() ;
const boost::uint64_t m1 = 0;//t.total_milliseconds() ;
const boost::uint64_t m2 = 1;//day.total_milliseconds() ;
const double v = 1.0 * m1 / m2;
return v;
}
......
......@@ -14,7 +14,6 @@
#include "odfcontext.h"
#include "odf_document_impl.h"
#include <cpdoccore/common/boost_filesystem_version.h>
#include <cpdoccore/odf/odf_document.h>
......@@ -29,7 +28,6 @@
namespace cpdoccore {
namespace odf {
namespace fs = ::boost::filesystem;
namespace {
bool IsExistProperty(std::vector<_property> Heap,const std::wstring Name)
......@@ -1016,13 +1014,12 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
////////////////
if (properties)
{
using boost::filesystem::wpath;
if (properties->content().fo_clip_ && drawing.fill.bitmap)
{
std::wstring strRectClip = properties->content().fo_clip_.get();
strRectClip = strRectClip.substr(5,strRectClip.length()-6);
std::wstring fileName = BOOST_STRING_PATH(wpath(Context.root()->get_folder()) / href);
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR+ href;
drawing.fill.bitmap->bCrop = parse_clipping(strRectClip,fileName,drawing.fill.bitmap->cropRect);
}
......@@ -1164,18 +1161,14 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf::odf_document * odf = Context.root();
const std::wstring folder = odf->get_folder();
std::wstring folderPath = odf->get_folder();
fs::wpath folderPath(folder);
fs::wpath objectPath = folderPath / href;
std::wstring objectPath = folderPath +FILE_SEPARATOR_STR + href;
#ifdef BOOST_FILESYSTEM_LEGACY
const std::wstring dbgObjectPathStr = objectPath.normalize().string();
#else
const std::wstring dbgObjectPathStr = objectPath.normalize().wstring();
#endif
//normalize path ??? todooo
cpdoccore::odf::odf_document objectSubDoc(dbgObjectPathStr,NULL);
cpdoccore::odf::odf_document objectSubDoc(objectPath,NULL);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
const office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
......
......@@ -5,7 +5,6 @@
#include <sstream>
#include <string>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost_string.h>
#include <regex.h>
......@@ -13,7 +12,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include "serialize_elements.h"
#include <cpdoccore/odf/odf_document.h>
......@@ -35,10 +33,6 @@
namespace cpdoccore {
namespace odf {
namespace fs = ::boost::filesystem;
//
void draw_g::pptx_convert(oox::pptx_conversion_context & Context)
{
int i=0;
......@@ -239,18 +233,13 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf::odf_document::Impl * odfImpl = Context.root()->get_impl();
const std::wstring folder = odfImpl->get_folder();
const std::wstring folderPath = odfImpl->get_folder();
fs::wpath folderPath(folder);
fs::wpath objectPath = folderPath / href;
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
#ifdef BOOST_FILESYSTEM_LEGACY
const std::wstring dbgObjectPathStr = objectPath.normalize().string();
#else
const std::wstring dbgObjectPathStr = objectPath.normalize().wstring();
#endif
//normalize path ??? todooo
cpdoccore::odf::odf_document objectSubDoc(dbgObjectPathStr, NULL);
cpdoccore::odf::odf_document objectSubDoc(objectPath, NULL);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// embd , ... frame!!!
// RemanejamentoOrcamentario.ods
......
......@@ -5,7 +5,6 @@
#include <sstream>
#include <string>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost_string.h>
#include <regex.h>
......@@ -13,7 +12,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include "serialize_elements.h"
#include <cpdoccore/odf/odf_document.h>
......@@ -34,9 +32,6 @@
namespace cpdoccore {
namespace odf {
namespace fs = ::boost::filesystem;
void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context)
{
......@@ -217,18 +212,13 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf::odf_document::Impl * odfImpl = Context.root()->get_impl();
const std::wstring folder = odfImpl->get_folder();
fs::wpath folderPath(folder);
fs::wpath objectPath = folderPath / href;
std::wstring folderPath = odfImpl->get_folder();
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
#ifdef BOOST_FILESYSTEM_LEGACY
const std::wstring dbgObjectPathStr = objectPath.normalize().string();
#else
const std::wstring dbgObjectPathStr = objectPath.normalize().wstring();
#endif
// normalize path ???? todooo
cpdoccore::odf::odf_document objectSubDoc(dbgObjectPathStr,NULL);
cpdoccore::odf::odf_document objectSubDoc(objectPath,NULL);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// embd ... frame!!! RemanejamentoOrcamentario.ods
///////////////////////////////////////////////////////////////////////////
......
......@@ -7,9 +7,6 @@
namespace cpdoccore {
namespace odf {
namespace fs = ::boost::filesystem;
odf_document::odf_document(const std::wstring & Folder, const ProgressCallback* CallBack) : impl_(new Impl(Folder,CallBack))
{}
......
#include "precompiled_cpodf.h"
#include <cpdoccore/odf/odf_document.h>
#include <iostream>
#include "odf_document_impl.h"
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/CPString.h>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <cpdoccore/xml/sax.h>
#include <cpdoccore/common/readdocelement.h>
#include <boost/foreach.hpp>
#include <boost_string.h>
#include <cpdoccore/xml/sax.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include "abstract_xml.h"
#include "odfcontext.h"
......@@ -43,9 +45,6 @@
#include "draw_page.h"
#include <cpdoccore/common/readdocelement.h>
#include <iostream>
#include "documentcontext.h"
#include "..\progressCallback.h"
......@@ -54,47 +53,32 @@
namespace cpdoccore {
namespace odf {
namespace fs = ::boost::filesystem;
namespace {
content_xml_t_ptr read_file_content(const fs::wpath & Path)
content_xml_t_ptr read_file_content(const std::wstring & Path)
{
//fs::ifstream content_file;
//content_file.open(Path);
// if (content_file)
{
xml::sax_ptr Reader = xml::create_sax( /*content_file*/ Path.string().c_str());
content_xml_t_ptr result( new content_xml_t() );
const std::wstring namespacePrefix = Reader->namespacePrefix();
const std::wstring localName = Reader->nodeLocalName();
result->add_child_element(Reader.get(), namespacePrefix, localName);
xml::sax_ptr Reader = xml::create_sax( Path.c_str());
content_xml_t_ptr result( new content_xml_t() );
const std::wstring namespacePrefix = Reader->namespacePrefix();
const std::wstring localName = Reader->nodeLocalName();
//result->read_sax(sax.get());
return result;
result->add_child_element(Reader.get(), namespacePrefix, localName);
}
//else
//{
// _CP_LOG(info) << L"[warning] open file error (" << BOOST_STRING_PATH(Path) << L")\n";
//}
return content_xml_t_ptr();
}
}
odf_document::Impl::Impl(const std::wstring & Folder, const ProgressCallback* CallBack) : context_(new odf_read_context()), base_folder_(Folder), pCallBack(CallBack), bUserStopConvert (0)
odf_document::Impl::Impl(const std::wstring & folderPath, const ProgressCallback* CallBack) :
context_(new odf_read_context()), base_folder_(folderPath), pCallBack(CallBack), bUserStopConvert (0)
{
office_mime_type_ = 0;
encrypted = false;
fs::wpath folderPath(Folder);
fs::wpath content_xml = folderPath / L"content.xml";
fs::wpath styles_xml = folderPath / L"styles.xml";
fs::wpath meta_xml = folderPath / L"meta.xml";
fs::wpath settings_xml = folderPath / L"settings.xml";
fs::wpath manifest_xml = folderPath / L"META-INF" / L"manifest.xml";
std::wstring content_xml = folderPath + FILE_SEPARATOR_STR + L"content.xml";
std::wstring styles_xml = folderPath + FILE_SEPARATOR_STR + L"styles.xml";
std::wstring meta_xml = folderPath + FILE_SEPARATOR_STR + L"meta.xml";
std::wstring settings_xml = folderPath + FILE_SEPARATOR_STR + L"settings.xml";
std::wstring manifest_xml = folderPath + FILE_SEPARATOR_STR + L"META-INF" + FILE_SEPARATOR_STR + L"manifest.xml";
_CP_LOG(info) << L"[info] read manifest.xml" << std::endl;
manifest_xml_ = read_file_content(manifest_xml);
......@@ -618,13 +602,13 @@ bool odf_document::Impl::xlsx_convert(oox::xlsx_conversion_context & Context)
catch(boost::exception & ex)
{
_CP_LOG(info) << L"\n[error]:\n";
_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(boost::diagnostic_information(ex))) << std::endl;
//_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(boost::diagnostic_information(ex))) << std::endl;
throw;
}
catch(std::exception & ex)
{
_CP_LOG(info) << L"\n[error]:\n";
_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(ex.what())) << L"\n";
//_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(ex.what())) << L"\n";
throw;
}
catch(...)
......@@ -663,13 +647,13 @@ bool odf_document::Impl::pptx_convert(oox::pptx_conversion_context & Context)
catch(boost::exception & ex)
{
_CP_LOG(info) << L"\n[error]:\n";
_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(boost::diagnostic_information(ex))) << std::endl;
//_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(boost::diagnostic_information(ex))) << std::endl;
throw;
}
catch(std::exception & ex)
{
_CP_LOG(info) << L"\n[error]:\n";
_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(ex.what())) << std::endl;
//_CP_LOG(info) << utf8_to_utf16(ansi_to_utf8(ex.what())) << std::endl;
throw;
}
catch(...)
......
......@@ -3,21 +3,16 @@
#include "office_elements_create.h"
#include <iostream>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <logging.h>
#include "skipelement.h"
namespace cpdoccore {
namespace odf {
namespace {
static boost::mutex create_lock_;
}
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()
{
}
......@@ -25,9 +20,7 @@ office_element_ptr office_element_creator::create(const ::std::wstring & ns, con
{
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() )
{
office_element_ptr element = (i->second)();
......@@ -57,12 +50,8 @@ office_element_creator * office_element_creator::get()
{
if (!instance_)
{
boost::mutex::scoped_lock lock(create_lock_);
if (!instance_)
{
office_element_creator * temp = new office_element_creator();
instance_ = temp;
}
office_element_creator * temp = new office_element_creator();
instance_ = temp;
}
return instance_;
......@@ -72,8 +61,6 @@ bool office_element_creator::register_element(const std::wstring &ns, const std:
{
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 );
if ( i == map_.end() )
{
......
......@@ -3,15 +3,11 @@
#include <string>
#include <map>
#include <boost/function.hpp>
//#include <boost/function.hpp>
#include <cpdoccore/CPAssert.h>
#include <cpdoccore/CPSharedPtr.h>
#include "office_elements.h"
namespace boost {
class shared_mutex;
}
namespace xml
{
class sax;
......@@ -53,7 +49,6 @@ public:
private:
office_element_creator();
static office_element_creator * instance_;
shared_ptr<boost::shared_mutex>::Type rw_lock_;
};
/// ,
......
......@@ -13,9 +13,6 @@
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/function.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
static float getDefaultDpi(){return 96;}
......@@ -289,10 +289,6 @@
<Filter
Name="include"
>
<File
RelativePath="..\include\cpdoccore\common\boost_filesystem_version.h"
>
</File>
<File
RelativePath="..\include\cpdoccore\common\readdocelement.h"
>
......
This diff is collapsed.
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp>
#include <boost/filesystem/fstream.hpp>
#include <cpdoccore/utf8cpp/utf8.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "object_package.h"
#include "mediaitems.h"
#include "../../../DesktopEditor/common/File.h"
namespace cpdoccore
{
namespace odf
{
namespace package
{
namespace fs = boost::filesystem;
simple_element::simple_element(const std::wstring & FileName, const std::wstring & Content, bool utf8) : file_name_(FileName), utf8_(utf8)
{
if (utf8_)
......@@ -28,11 +26,19 @@ namespace odf
void simple_element::write(const std::wstring & RootPath)
{
fs::ofstream file( fs::wpath(RootPath) / file_name_, std::ios_base::out | std::ios_base::binary );
NSFile::CBinaryFile file;
if (utf8_)
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
file << content_utf8_;
if (file.CreateFileW( RootPath + FILE_SEPARATOR_STR + file_name_ ) == true)
{
if (utf8_)
{
std::string root = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
file.WriteFile((BYTE*)root.c_str(), root.length());
}
file.WriteFile((BYTE*)content_utf8_.c_str(), content_utf8_.length());
file.CloseFile();
}
}
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content, bool utf8)
......@@ -145,17 +151,16 @@ namespace odf
{
if (mediaitems_.count_media < 1)return;
fs::wpath path = fs::wpath(RootPath) / L"media";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
FileSystem::Directory::CreateDirectory(path);
BOOST_FOREACH( _mediaitems::item & item, mediaitems_.items() )
{
if (item.type == _mediaitems::typeAudio || item.type == _mediaitems::typeVideo)
{
fs::wpath file_name = fs::wpath(item.oox_ref);
fs::wpath file_name_out = fs::wpath(RootPath) / item.odf_ref;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.odf_ref;
boost::filesystem::copy_file(file_name, file_name_out);
NSFile::CFileBinary::Copy(item.oox_ref, file_name_out);
}
}
......@@ -170,19 +175,18 @@ namespace odf
{
if (mediaitems_.count_image < 1 )return;
fs::wpath path = fs::wpath(RootPath) / L"Pictures";
fs::create_directory(path);
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"Pictures";
FileSystem::Directory::CreateDirectory(path);
BOOST_FOREACH( _mediaitems::item & item, mediaitems_.items() )
{
if (item.type == _mediaitems::typeImage && item.oox_ref.length()>0)
{
fs::wpath file_name = fs::wpath(item.oox_ref);
fs::wpath file_name_out = fs::wpath(RootPath) / item.odf_ref;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.odf_ref;
try
{
boost::filesystem::copy_file(file_name, file_name_out);
boost::filesystem::copy_file(item.oox_ref, file_name_out);
}catch (...)
{
}
......
......@@ -13,10 +13,6 @@
#include <boost/weak_ptr.hpp>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/function.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
static float getDefaultDpi(){return 96;}
#include "stdAfx.h"
#include "Converter.h"
#include "../utils.h"
......
#include "stdAfx.h"
#include "Converter.h"
#include "../utils.h"
......
#include "stdAfx.h"
#include "Converter.h"
#include "../utils.h"
......
......@@ -3,7 +3,6 @@
#include <boost/lexical_cast.hpp>
#include <cpdoccore/CPOptional.h>
#include "../../../Common/boost_filesystem_version.h"
#include "../progressCallback.h"
#if defined(_WIN32) || defined (_WIN64)
......
#include "stdAfx.h"
#include "Converter.h"
#include "../utils.h"
......
#pragma once
#include "stdAfx.h"
#include "DocxConverter.h"
#include "../utils.h"
......
#pragma once
#include "stdAfx.h"
#include "XlsxConverter.h"
#include "../utils.h"
......
// stdafx.cpp : source file that includes just the standard includes
// Oox2OdfConverter.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <atlbase.h>
......@@ -48,7 +48,7 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
......@@ -112,7 +112,7 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
......@@ -173,7 +173,7 @@
AdditionalIncludeDirectories="../../../ASCOfficeOdfFile/include;../../../ASCOfficeOdfFile/src/odf/datatypes"
PreprocessorDefinitions="NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;BUILD_CONFIG_FULL_VERSION"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
......@@ -235,7 +235,7 @@
AdditionalIncludeDirectories="../../../ASCOfficeOdfFile/include;../../../ASCOfficeOdfFile/src/odf/datatypes"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;BUILD_CONFIG_FULL_VERSION"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
......@@ -333,46 +333,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\Oox2OdfConverter\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\Oox2OdfConverter\VmlShapeTypes2Oox.h"
>
</File>
<File
RelativePath="..\Oox2OdfConverter\XlsxConverter.cpp"
>
......@@ -392,7 +352,7 @@
>
</File>
<File
RelativePath="..\Oox2OdfConverter\stdafx.h"
RelativePath="..\Oox2OdfConverter\VmlShapeTypes2Oox.h"
>
</File>
<File
......
// OfficeOdfFileW.cpp : Implementation of COfficeOdfFileW
#include "stdafx.h"
#include "OfficeOdfFileW.h"
#include "../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
......
......@@ -109,7 +109,7 @@ namespace FileSystem
NSDirectory::DeleteDirectory(strDirectory.GetString(), deleteRoot);
}
CString Directory::CreateDirectoryWithUniqueName (CString strFolderPathRoot)
CString Directory::CreateDirectoryWithUniqueName (CString & strFolderPathRoot)
{
UUID uuid;
RPC_WSTR str_uuid;
......@@ -244,5 +244,36 @@ namespace FileSystem
}
return strFolderPath.substr(0,n1);
}
void Directory::DeleteDirectory(std::wstring & strDirectory, bool deleteRoot)
{
NSDirectory::DeleteDirectory(strDirectory, deleteRoot);
}
std::wstring Directory::CreateDirectoryWithUniqueName (std::wstring & strFolderPathRoot)
{
UUID uuid;
RPC_WSTR str_uuid;
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
int attemps = 10;
while (!CreateDirectory(pcTemplate.c_str()))
{
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
attemps--;
if (0 == attemps)
{
pcTemplate = _T("");
}
}
return pcTemplate;
}
#endif
}
......@@ -22,11 +22,11 @@ namespace FileSystem {
static LPCTSTR GetCurrentDirectory();
static String GetCurrentDirectoryS();
static bool CreateDirectory(LPCTSTR path);
static bool CreateDirectory(const String& path);
static bool CreateDirectory(String strFolderPathRoot, String strFolderName);
static CString CreateDirectoryWithUniqueName (CString strFolderPathRoot);
static bool CreateDirectories(LPCTSTR path);
static bool CreateDirectory(LPCTSTR path);
static bool CreateDirectory(const String& path);
static bool CreateDirectory(String strFolderPathRoot, String strFolderName);
static CString CreateDirectoryWithUniqueName (CString & strFolderPathRoot);
static bool CreateDirectories(LPCTSTR path);
static void DeleteDirectory(const CString& path, bool deleteRoot = true);
......@@ -34,13 +34,37 @@ namespace FileSystem {
static StringArray GetFilesInDirectory(const String& path, const bool& andSubdirectories = false);
static int GetFilesCount(const CString& path, const bool& recursive = false);
static CString GetFolderPath(const CString& path);
static CString GetLongPathName_(const CString& fileName);
static CString GetTempPath();
static CString CreateTempFileWithUniqueName (const CString & strFolderPathRoot,CString Prefix);
static bool PathIsDirectory(const CString& pathName);
static CString GetFolderPath(const CString& path);
static CString GetLongPathName_(const CString& fileName);
static CString GetTempPath();
static CString CreateTempFileWithUniqueName (const CString & strFolderPathRoot,CString Prefix);
static bool PathIsDirectory(const CString& pathName);
#if defined (_WIN32) || defined(_WIN64)
static std::wstring GetFolderPath(const std::wstring & strFolderPath);
static std::wstring CreateDirectoryWithUniqueName (std::wstring & strFolderPathRoot);
static void DeleteDirectory(std::wstring& path, bool deleteRoot = true);
#endif
static bool IsExist(const std::wstring& strFileName)
{
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
FILE* pFile = _wfopen(strFileName.c_str(), L"rb");
#else
BYTE* pUtf8 = NULL;
LONG lLen = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false);
FILE* pFile = fopen((char*)pUtf8, "rb");
delete [] pUtf8;
#endif
if (NULL != pFile)
{
fclose(pFile);
return true;
}
else
return false;
}
};
}
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