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