Commit 4f6e3642 authored by ElenaSubbotina's avatar ElenaSubbotina

.

parent 26c02c57
......@@ -86,7 +86,7 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
std::wstring input_path = oox_ref;
#if defined (_WIN32) || defined(_WIN64) // + mac???
#if defined (_WIN32) || defined(_WIN64)
boost::to_lower(input_path);
#endif
......@@ -100,7 +100,7 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
break;
}
}
if (output_path.length() < 1)
if (output_path.empty())
{
output_path = ( output_sub_path + output_fileName) ;
if ( type == typeImage)
......
......@@ -68,8 +68,8 @@ std::wstring create_file_name(const std::wstring & uri, _mediaitems::Type type,
{
std::wstring sExt;
if (type == _mediaitems::typeOleObject &&
type == _mediaitems::typeObjectReplacement)
//if (type == _mediaitems::typeOleObject &&
// type == _mediaitems::typeObjectReplacement)
{
int n = uri.rfind(L".");
if (n >= 0) sExt = uri.substr(n);
......
......@@ -39,7 +39,7 @@
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace cpdoccore
{
......@@ -180,8 +180,8 @@ namespace odf_writer
void media::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + (folder_.empty() ? L"" : FILE_SEPARATOR_STR) + folder_;
NSDirectory::CreateDirectory(path);
OOX::CPath path (RootPath + (folder_.empty() ? L"" : FILE_SEPARATOR_STR) + folder_);
NSDirectory::CreateDirectory(path.GetPath());
std::vector< _mediaitems::item > & items = mediaitems_.items();
......@@ -189,9 +189,10 @@ namespace odf_writer
{
if (items[i].type == type_)
{
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].odf_ref;
OOX::CPath file_name_inp ( items[i].oox_ref);
OOX::CPath file_name_out ( RootPath + FILE_SEPARATOR_STR + items[i].odf_ref); //ref содержит уже folder_
NSFile::CFileBinary::Copy(items[i].oox_ref, file_name_out);
NSFile::CFileBinary::Copy(file_name_inp.GetPath(), file_name_out.GetPath());
}
}
......@@ -206,7 +207,7 @@ namespace odf_writer
{
if (mediaitems.count_image > 0)
{
pictures_ = element_ptr( new media(mediaitems, L"Picture", 1) );
pictures_ = element_ptr( new media(mediaitems, L"Pictures", 1) );
}
if (mediaitems.count_media > 0)
{
......
......@@ -2415,8 +2415,8 @@ void DocxConverter::convert(OOX::Logic::CPicture* oox_pic)
odf_context()->drawing_context()->set_name(std::wstring (L"Custom") + std::to_wstring(sptType));
odf_context()->drawing_context()->start_shape(OOX::VmlShapeType2PrstShape(sptType));
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeType.GetPointer());
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
......
......@@ -247,11 +247,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(oox_sheet->m_oSheetPr.GetPointer());
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Предобработка
for (std::list<OOX::Spreadsheet::CHyperlink*>::iterator it = oox_sheet->m_oHyperlinks->m_arrItems.begin();
it != oox_sheet->m_oHyperlinks->m_arrItems.end(); it++)
if (oox_sheet->m_oHyperlinks.IsInit())
{
convert(*it, oox_sheet);
}
for (std::list<OOX::Spreadsheet::CHyperlink*>::iterator it = oox_sheet->m_oHyperlinks->m_arrItems.begin();
it != oox_sheet->m_oHyperlinks->m_arrItems.end(); it++)
{
convert(*it, oox_sheet);
}
}
//комментарии
std::map<std::wstring, OOX::Spreadsheet::CCommentItem*>::iterator pos = oox_sheet->m_mapComments.begin();
while ( oox_sheet->m_mapComments.end() != pos )
......@@ -262,13 +265,16 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
//todooo для оптимизации - перенести мержи в начало
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//колонки
ods_context->start_columns();
for (std::list<OOX::Spreadsheet::CCol*>::iterator it = oox_sheet->m_oCols->m_arrItems.begin();
it != oox_sheet->m_oCols->m_arrItems.end(); it++)
{
convert(*it);
}
ods_context->end_columns();
if (oox_sheet->m_oCols.IsInit())
{
ods_context->start_columns();
for (std::list<OOX::Spreadsheet::CCol*>::iterator it = oox_sheet->m_oCols->m_arrItems.begin();
it != oox_sheet->m_oCols->m_arrItems.end(); it++)
{
convert(*it);
}
ods_context->end_columns();
}
if (oox_sheet->m_oSheetData.IsInit() )
{
......@@ -287,15 +293,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
oox_sheet->m_oSheetData.reset();
}
for (std::list<OOX::Spreadsheet::CMergeCell*>::iterator it = oox_sheet->m_oMergeCells->m_arrItems.begin();
it != oox_sheet->m_oMergeCells->m_arrItems.end(); it++)
if (oox_sheet->m_oMergeCells.IsInit())
{
if ((*it) && ((*it)->m_oRef.IsInit()))
for (std::list<OOX::Spreadsheet::CMergeCell*>::iterator it = oox_sheet->m_oMergeCells->m_arrItems.begin();
it != oox_sheet->m_oMergeCells->m_arrItems.end(); it++)
{
ods_context->add_merge_cells((*it)->m_oRef.get());
if ((*it) && ((*it)->m_oRef.IsInit()))
{
ods_context->add_merge_cells((*it)->m_oRef.get());
}
}
}
if (oox_sheet->m_oDrawing.IsInit() && oox_sheet->m_oDrawing->m_oId.IsInit())
if ((oox_sheet->m_oDrawing.IsInit()) && (oox_sheet->m_oDrawing->m_oId.IsInit()))
{
smart_ptr<OOX::File> oFile = oox_sheet->Find(oox_sheet->m_oDrawing->m_oId->GetValue());
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Drawings == oFile->type())
......
......@@ -850,35 +850,37 @@ namespace NSFile
static bool Copy(const std::wstring& strSrc, const std::wstring& strDst)
{
if (strSrc == strDst)
return true;
return true;
std::ifstream src;
std::ofstream dst;
std::ifstream src;
std::ofstream dst;
int nLenBuffer = 1024 * 1024; // 10
CFileBinary oFile;
if (oFile.OpenFile(strSrc))
{
int nFileSize = (int)oFile.GetFileSize();
if (nFileSize < nLenBuffer)
nLenBuffer = nFileSize;
int nLenBuffer = 1024 * 1024; // 10
CFileBinary oFile;
if (oFile.OpenFile(strSrc))
{
int nFileSize = (int)oFile.GetFileSize();
if (nFileSize < nLenBuffer)
nLenBuffer = nFileSize;
}
oFile.CloseFile();
}
char* pBuffer_in = NULL;
char* pBuffer_out = NULL;
char* pBuffer_in = NULL;
char* pBuffer_out = NULL;
if (nLenBuffer > 0)
{
pBuffer_in = new char[nLenBuffer];
pBuffer_out = new char[nLenBuffer];
if (nLenBuffer > 0)
{
pBuffer_in = new char[nLenBuffer];
pBuffer_out = new char[nLenBuffer];
src.rdbuf()->pubsetbuf(pBuffer_in, nLenBuffer);
dst.rdbuf()->pubsetbuf(pBuffer_out, nLenBuffer);
}
src.rdbuf()->pubsetbuf(pBuffer_in, nLenBuffer);
dst.rdbuf()->pubsetbuf(pBuffer_out, nLenBuffer);
}
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
src.open(strSrc.c_str(), std::ios::binary);
dst.open(strDst.c_str(), std::ios::binary);
src.open(strSrc.c_str(), std::ios::binary);
dst.open(strDst.c_str(), std::ios::binary);
#else
BYTE* pUtf8Src = NULL;
LONG lLenSrc = 0;
......@@ -887,25 +889,26 @@ namespace NSFile
LONG lLenDst = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strDst.c_str(), strDst.length(), pUtf8Dst, lLenDst, false);
src.open((char*)pUtf8Src, std::ios::binary);
dst.open((char*)pUtf8Dst, std::ios::binary);
src.open((char*)pUtf8Src, std::ios::binary);
dst.open((char*)pUtf8Dst, std::ios::binary);
delete [] pUtf8Src;
delete [] pUtf8Dst;
#endif
bool bRet = false;
bool bRet = false;
if (src.is_open() && dst.is_open())
{
dst << src.rdbuf();
src.close();
dst.close();
bRet = true;
bRet = true;
}
RELEASEARRAYOBJECTS(pBuffer_in);
RELEASEARRAYOBJECTS(pBuffer_out);
return bRet;
RELEASEARRAYOBJECTS(pBuffer_in);
RELEASEARRAYOBJECTS(pBuffer_out);
return bRet;
}
static bool Remove(const std::wstring& strFileName)
{
......
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