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

X2t добавлен Txt File Converter

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62352 954022d7-b5bf-4e40-9824-e11837661b57
parent 8bfb976f
......@@ -55,7 +55,7 @@ namespace BinXlsxRW{
sMediaPath = pathMediaDir.GetPath();
}
bool CXlsxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, CString& sXMLOptions, CString& sMediaDir)
bool CXlsxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, CString& sMediaDir)
{
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter;
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
......
......@@ -28,7 +28,7 @@ namespace BinXlsxRW {
void CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath);
bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, CString& sXMLOptions, CString& sMediaDir);
bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, CString& sMediaDir);
bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, CString& sXMLOptions);
bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
......
......@@ -18,7 +18,7 @@ LIBS += -lxml2
INCLUDEPATH += \
/usr/include/libxml2
SOURCES += RtfFormatLib.cpp \
SOURCES += \
../source/DestinationCommand.cpp \
../source/RtfBookmark.cpp \
../source/RtfChar.cpp \
......@@ -38,9 +38,10 @@ SOURCES += RtfFormatLib.cpp \
../source/Reader/OOXShapeReader.cpp \
../source/Reader/OOXTableReader.cpp \
../source/Writer/OOXDocumentWriter.cpp \
../source/Writer/OOXWriter.cpp
../source/Writer/OOXWriter.cpp \
../source/ConvertationManager.cpp
HEADERS += RtfFormatLib.h \
HEADERS += \
../source/Basic.h \
../source/ConvertationManager.h \
../source/DestinationCommand.h \
......
#include "ConvertationManager.h"
#pragma once
#include "RtfReader.h"
#include "RtfDocument.h"
#include "RtfWriter.h"
#include "Writer/OOXWriter.h"
#include "Reader/OOXReader.h"
const double g_cdMaxReadRtfPercent = 0.70;
const double g_cdMaxWriteRtfPercent = 0.30;
const double g_cdMaxReadOoxPercent = 0.70;
const double g_cdMaxWriteOoxPercent = 0.30;
//#define MEMORY_SAFE_CONVERTATION
HRESULT RtfConvertationManager::ConvertRtfToOOX( std::wstring sSrcFileName, std::wstring sDstPath )
{
m_bParseFirstItem = true;
RtfDocument oDocument;
oDocument.m_oProperty.SetDefaultRtf();
RtfReader oReader( oDocument, sSrcFileName );
OOXWriter oWriter( oDocument, sDstPath );
if (m_sTempFolder.length()< 1)
m_sTempFolder = FileSystem::Directory::GetTempPath();
oReader.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
oWriter.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
m_poRtfReader = &oReader;
m_poOOXWriter = &oWriter;
m_poRtfReader->m_convertationManager = this;
bool succes = oReader.Load( );
//сохранение будет поэлементое в обработчике OnCompleteItemRtf
//надо только завершить
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
oWriter.SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
oWriter.SaveByItemEnd( );
FileSystem::Directory::DeleteDirectory(oReader.m_sTempFolder);
FileSystem::Directory::DeleteDirectory(oWriter.m_sTempFolder);
if( true == succes )
return S_OK;
else
return S_FALSE;
}
HRESULT RtfConvertationManager::ConvertOOXToRtf( std::wstring sDstFileName, std::wstring sSrcPath )
{
m_bParseFirstItem = true;
RtfDocument oDocument;
oDocument.m_oProperty.SetDefaultOOX();
OOXReader oReader( oDocument, sSrcPath );
RtfWriter oWriter( oDocument, sDstFileName, sSrcPath );
if (m_sTempFolder.length() < 1)
m_sTempFolder = FileSystem::Directory::GetTempPath();
oReader.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
oWriter.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
m_poOOXReader = &oReader;
m_poRtfWriter = &oWriter;
m_poOOXReader->m_convertationManager = this;
bool succes = oReader.Parse( );
if( true == succes)
{
succes = oWriter.Save( );
}
FileSystem::Directory::DeleteDirectory(oReader.m_sTempFolder);
FileSystem::Directory::DeleteDirectory(oWriter.m_sTempFolder);
if( true == succes) return S_OK;
return S_FALSE;
}
void RtfConvertationManager::OnCompleteItemRtf()
{
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
m_poOOXWriter->SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
}
void RtfConvertationManager::OnCompleteItemOOX()
{
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
m_poRtfWriter->SaveByItemStart( );
}
m_poRtfWriter->SaveByItem( );
}
#pragma once
#include "RtfReader.h"
#include "RtfDocument.h"
#include "RtfWriter.h"
#include "Writer/OOXWriter.h"
#include "Reader/OOXReader.h"
#include <string>
const double g_cdMaxReadRtfPercent = 0.70;
const double g_cdMaxWriteRtfPercent = 0.30;
const double g_cdMaxReadOoxPercent = 0.70;
const double g_cdMaxWriteOoxPercent = 0.30;
class OOXWriter;
class OOXReader;
class RtfWriter;
class RtfReader;
//#define MEMORY_SAFE_CONVERTATION
class ConvertationManager
class RtfConvertationManager
{
public:
CString m_sTempFolder;
ConvertationManager( )
{
}
HRESULT ConvertRtfToOOX( std::wstring sSrcFileName, std::wstring sDstPath, CString sXMLOptions )
{
m_bParseFirstItem = true;
RtfDocument oDocument;
oDocument.m_oProperty.SetDefaultRtf();
RtfReader oReader( oDocument, sSrcFileName );
OOXWriter oWriter( oDocument, sDstPath );
if (m_sTempFolder.GetLength() < 1)
m_sTempFolder = FileSystem::Directory::GetTempPath();
oReader.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
oWriter.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
m_poRtfReader = &oReader;
m_poOOXWriter = &oWriter;
public:
std::wstring m_sTempFolder;
m_poRtfReader->m_convertationManager = this;
RtfConvertationManager( )
{
m_poOOXWriter = NULL;
m_poOOXReader = NULL;
bool succes = oReader.Load( );
m_poRtfWriter = NULL;
m_poRtfReader = NULL;
}
//сохранение будет поэлементое в обработчике OnCompleteItemRtf
//надо только завершить
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
oWriter.SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
oWriter.SaveByItemEnd( );
FileSystem::Directory::DeleteDirectory(oReader.m_sTempFolder);
FileSystem::Directory::DeleteDirectory(oWriter.m_sTempFolder);
long ConvertRtfToOOX( std::wstring sSrcFileName, std::wstring sDstPath);
if( true == succes )
return S_OK;
else
return S_FALSE;
}
HRESULT ConvertOOXToRtf( std::wstring sDstFileName, std::wstring sSrcPath, CString sXMLOptions )
{
m_bParseFirstItem = true;
long ConvertOOXToRtf( std::wstring sDstFileName, std::wstring sSrcPath);
RtfDocument oDocument;
oDocument.m_oProperty.SetDefaultOOX();
OOXReader oReader( oDocument, sSrcPath );
RtfWriter oWriter( oDocument, sDstFileName, sSrcPath );
if (m_sTempFolder.GetLength() < 1)
m_sTempFolder = FileSystem::Directory::GetTempPath();
oReader.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
oWriter.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
m_poOOXReader = &oReader;
m_poRtfWriter = &oWriter;
m_poOOXReader->m_convertationManager = this;
bool succes = oReader.Parse( );
if( true == succes)
{
succes = oWriter.Save( );
}
void OnCompleteItemRtf();
void OnCompleteItemOOX();
private:
OOXWriter* m_poOOXWriter;
OOXReader* m_poOOXReader;
FileSystem::Directory::DeleteDirectory(oReader.m_sTempFolder);
FileSystem::Directory::DeleteDirectory(oWriter.m_sTempFolder);
RtfWriter* m_poRtfWriter;
RtfReader* m_poRtfReader;
if( true == succes) return S_OK;
return S_FALSE;
}
void OnCompleteItemRtf()
{
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
m_poOOXWriter->SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
}
void OnCompleteItemOOX()
{
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
m_poRtfWriter->SaveByItemStart( );
}
m_poRtfWriter->SaveByItem( );
}
private:
OOXWriter* m_poOOXWriter;
OOXReader* m_poOOXReader;
RtfWriter* m_poRtfWriter;
RtfReader* m_poRtfReader;
bool m_bParseFirstItem;
bool m_bParseFirstItem;
};
......@@ -1216,7 +1216,7 @@ void ParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oReade
if (oReader.m_convertationManager)
{
oReader.m_convertationManager->OnCompleteItemRtf();
oReader.m_convertationManager->OnCompleteItemRtf();
}
}
//добавляем параграф
......
......@@ -3,13 +3,13 @@
#include "../RtfField.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
class ConvertationManager;
class RtfConvertationManager;
class OOXReader
{
public:
ConvertationManager * m_convertationManager;
RtfConvertationManager *m_convertationManager;
CString m_sPath;
int m_nCurItap; //для определение вложенности таблицы
......@@ -47,4 +47,4 @@ private:
void ParseColorTable( RtfDocument& oDocument );
CString GetFolder ( CString sDocPath );
RtfDocument & m_oDocument;
};
\ No newline at end of file
};
......@@ -3,7 +3,7 @@
#include "RtfProperty.h"
#include "RtfDocument.h"
class ConvertationManager;
class RtfConvertationManager;
class RtfReader
{
......@@ -11,7 +11,7 @@ public:
class ReaderState;
typedef boost::shared_ptr<ReaderState> ReaderStatePtr;
ConvertationManager *m_convertationManager;
RtfConvertationManager *m_convertationManager;
class ReaderState
{
......
......@@ -6,7 +6,6 @@
class RtfDocument;
//[ event_source(native)]
class RtfWriter
{
public:
......@@ -48,4 +47,4 @@ private:
CString CreateRtfStart();
CString CreateRtfEnd( );
};
\ No newline at end of file
};
#-------------------------------------------------
#
# Project created by QtCreator 2015-04-29T13:41:59
#
#-------------------------------------------------
QT -= core gui
TARGET = TxtXmlFormatLib
TEMPLATE = lib
CONFIG += staticlib
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wno-ignored-qualifiers
DEFINES += UNICODE \
_UNICODE \
LINUX \
_LINUX_QT \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
BUILD_CONFIG_FULL_VERSION \
DONT_WRITE_EMBEDDED_FONTS
INCLUDEPATH += \
../../../../DesktopEditor/freetype-2.5.2/include
INCLUDEPATH += /usr/include/libxml2
HEADERS += \
../Source/TxtXmlEvent.h \
../Source/TxtXmlFile.h \
../Source/Common/Encoding.h \
../Source/Common/precompiled_utility.h \
../Source/Common/StlUtils.h \
../Source/Common/ToString.h \
../Source/Common/Utility.h \
../Source/Docx2Txt/Converter.h \
../Source/Txt2Docx/Converter.h \
../Source/TxtFormat/File.h \
../Source/TxtFormat/TxtFile.h \
../Source/TxtFormat/TxtFormat.h
SOURCES += \
../Source/TxtXmlFile.cpp \
../Source/Common/Encoding.cpp \
../Source/Common/ToString.cpp \
../Source/Docx2Txt/Converter.cpp \
../Source/Txt2Docx/Converter.cpp \
../Source/TxtFormat/File.cpp \
../Source/TxtFormat/TxtFile.cpp
unix {
target.path = /usr/lib
INSTALLS += target
}
......@@ -4,11 +4,13 @@
#include "Encoding.h"
#include "Utility.h"
#ifdef _WIN32
#include <windows.h>
#if defined (_WIN32) || defined (_WIN64)
#include <windows.h>
#else
#include <iconv.h>
#endif
#include "../../../../Base/unicode_util.h"
#include "../../../Common/DocxFormat/Source/Base/unicode_util.h"
const std::wstring Encoding::ansi2unicode(const std::string& line)
......@@ -16,25 +18,53 @@ const std::wstring Encoding::ansi2unicode(const std::string& line)
return std::wstring(line.begin(), line.end());//cp2unicode(line, CP_ACP);
}
const std::wstring Encoding::cp2unicode(const std::string& sline, const unsigned int codePage)
const std::wstring Encoding::cp2unicode(const std::string& sline, const unsigned int nCodepage)
{
#ifdef _WIN32
#if defined (_WIN32) || defined (_WIN64)
const int nSize = MultiByteToWideChar(codePage, 0, sline.c_str(), sline.size(), NULL, 0);
wchar_t *sTemp = new wchar_t[nSize];
if (!sTemp)
return std::wstring();
int size = MultiByteToWideChar(codePage, 0, sline.c_str(), sline.size(), sTemp, nSize);
int size = MultiByteToWideChar(nCodepage, 0, sline.c_str(), sline.size(), sTemp, nSize);
std::wstring sResult(sTemp, size);
delete []sTemp;
return sResult;
#elif __linux__
return std::wstring();
#else
return std::wstring();
bool ansi = true;
size_t insize = sline.length();
std::wstring w_out;
w_out.reserve(insize);
char *inptr = (char*)sline.c_str();
char* outptr = (char*)w_out.c_str();
if (nCodepage > 0)
{
std::string sCodepage = "CP" + std::to_string(nCodepage);
iconv_t ic= iconv_open("WCHAR_T", sCodepage.c_str());
if (ic != (iconv_t) -1)
{
size_t nconv = 0, avail = (insize) * sizeof(wchar_t);
nconv = iconv (ic, &inptr, &insize, &outptr, &avail);
if (nconv == 0)
{
ansi = false;
}
iconv_close(ic);
}
}
if (ansi)
w_out = std::wstring(sline.begin(), sline.end());
return w_out;
#endif
}
......@@ -43,145 +73,171 @@ const std::wstring Encoding::utf82unicode(const std::string& line)
{
if (sizeof(wchar_t) == 2)//utf8 -> utf16
{
unsigned __int32 nLength = line.length();
UTF16 *pStrUtf16 = new UTF16 [nLength+1];
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) &line[0];
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF16 *pStrUtf16_Conv = pStrUtf16;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf16;
return std::wstring();
}
std::wstring utf16Str ((wchar_t *) pStrUtf16);
delete [] pStrUtf16;
unsigned int nLength = line.length();
UTF16 *pStrUtf16 = new UTF16 [nLength+1];
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) &line[0];
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF16 *pStrUtf16_Conv = pStrUtf16;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf16;
return std::wstring();
}
std::wstring utf16Str ((wchar_t *) pStrUtf16);
delete [] pStrUtf16;
return utf16Str;
}
else //utf8 -> utf32
{
unsigned __int32 nLength = line.length();
UTF32 *pStrUtf32 = new UTF32 [nLength+1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) &line[0];
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return std::wstring();
}
std::wstring utf32Str ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
unsigned int nLength = line.length();
UTF32 *pStrUtf32 = new UTF32 [nLength+1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) &line[0];
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return std::wstring();
}
std::wstring utf32Str ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
return utf32Str;
}
}
const std::string Encoding::unicode2ansi(const std::wstring& line)
{
return unicode2cp(line, CP_ACP);
return std::string(line.begin(), line.end());
}
const std::string Encoding::unicode2utf8(const std::wstring& line)
{
if (sizeof(wchar_t) == 2)
{
UTF16 *pStrUtf16 = (UTF16 *) &line[0];
unsigned __int32 nLength = line.length();
unsigned __int32 nDstLength = 4*nLength + 1;
UTF8 *pStrUtf8 = new UTF8 [nDstLength];
memset ((void *) pStrUtf8, 0, sizeof (UTF8) * (nDstLength));
// this values will be modificated
const UTF16 *pStrUtf16_Conv = pStrUtf16;
UTF8 *pStrUtf8_Conv = pStrUtf8;
ConversionResult eUnicodeConversionResult = ConvertUTF16toUTF8 (&pStrUtf16_Conv, &pStrUtf16[nLength]
, &pStrUtf8_Conv , &pStrUtf8 [nDstLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf8;
return std::string();
}
std::string utf8Str ((char *) pStrUtf8);
delete [] pStrUtf8;
UTF16 *pStrUtf16 = (UTF16 *) &line[0];
unsigned int nLength = line.length();
unsigned int nDstLength = 4*nLength + 1;
UTF8 *pStrUtf8 = new UTF8 [nDstLength];
memset ((void *) pStrUtf8, 0, sizeof (UTF8) * (nDstLength));
// this values will be modificated
const UTF16 *pStrUtf16_Conv = pStrUtf16;
UTF8 *pStrUtf8_Conv = pStrUtf8;
ConversionResult eUnicodeConversionResult = ConvertUTF16toUTF8 (&pStrUtf16_Conv, &pStrUtf16[nLength]
, &pStrUtf8_Conv , &pStrUtf8 [nDstLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf8;
return std::string();
}
std::string utf8Str ((char *) pStrUtf8);
delete [] pStrUtf8;
return utf8Str;
}
else //utf32 -> utf8
{
UTF32 *pStrUtf32 = (UTF32 *) &line[0];
unsigned __int32 nLength = line.length();
unsigned __int32 nDstLength = 4*nLength + 1;
UTF8 *pStrUtf8 = new UTF8 [nDstLength];
memset ((void *) pStrUtf8, 0, sizeof (UTF8) * (nDstLength));
// this values will be modificated
const UTF32 *pStrUtf32_Conv = pStrUtf32;
UTF8 *pStrUtf8_Conv = pStrUtf8;
ConversionResult eUnicodeConversionResult = ConvertUTF32toUTF8 (&pStrUtf32_Conv, &pStrUtf32[nLength]
, &pStrUtf8_Conv , &pStrUtf8 [nDstLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf8;
return std::string();
}
std::string utf8Str ((char *) pStrUtf8);
delete [] pStrUtf8;
UTF32 *pStrUtf32 = (UTF32 *) &line[0];
unsigned int nLength = line.length();
unsigned int nDstLength = 4*nLength + 1;
UTF8 *pStrUtf8 = new UTF8 [nDstLength];
memset ((void *) pStrUtf8, 0, sizeof (UTF8) * (nDstLength));
// this values will be modificated
const UTF32 *pStrUtf32_Conv = pStrUtf32;
UTF8 *pStrUtf8_Conv = pStrUtf8;
ConversionResult eUnicodeConversionResult = ConvertUTF32toUTF8 (&pStrUtf32_Conv, &pStrUtf32[nLength]
, &pStrUtf8_Conv , &pStrUtf8 [nDstLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf8;
return std::string();
}
std::string utf8Str ((char *) pStrUtf8);
delete [] pStrUtf8;
return utf8Str;
}
}
const std::string Encoding::unicode2cp(const std::wstring& sLine, const unsigned int codePage)
const std::string Encoding::unicode2cp(const std::wstring& sLine, const unsigned int nCodepage)
{
#ifdef _WIN32
#if defined (_WIN32) || defined (_WIN64)
const int nSize = WideCharToMultiByte(codePage, 0, sLine.c_str(), sLine.length(), NULL, 0, NULL, NULL);
char *sTemp = new char[nSize];
if (!sTemp)
return std::string();
int size = WideCharToMultiByte(codePage, 0, sLine.c_str(), sLine.length(), sTemp, nSize, NULL, NULL);
int size = WideCharToMultiByte(nCodepage, 0, sLine.c_str(), sLine.length(), sTemp, nSize, NULL, NULL);
std::string sResult(sTemp, size);
delete []sTemp;
return sResult;
#elif __linux__
return std::string();
#else
return std::string();
std::string out;
bool ansi = true;
size_t insize = sLine.length();
out.reserve(insize);
char *inptr = (char*)sLine.c_str();
char* outptr = (char*)out.c_str();
if (nCodepage > 0)
{
std::string sCodepage = "CP" + std::to_string(nCodepage);
iconv_t ic= iconv_open(sCodepage.c_str(), "WCHAR_T");
if (ic != (iconv_t) -1)
{
size_t nconv = 0, avail = insize * sizeof(wchar_t);
nconv = iconv (ic, &inptr, &insize, &outptr, &avail);
if (nconv == 0) ansi = false;
iconv_close(ic);
}
}
if (ansi)
out = std::string(sLine.begin(), sLine.end());
return out;
#endif
}
......@@ -7,33 +7,49 @@
namespace StlUtils
{
static inline std::wstring IntToWideString(int value, int radix = 10)
static inline std::wstring IntToWideString(int value)
{
wchar_t strValue[256];
#if defined(_WIN32) || defined(_WIN64)
wchar_t strValue[256];
_itow_s(value, strValue, 256, radix);
return std::wstring(strValue);
#else
return std::to_wstring(value);
#endif
}
static inline std::wstring DoubleToWideString(double value)
{
wchar_t strValue[256];
#if defined(_WIN32) || defined(_WIN64)
wchar_t strValue[256];
swprintf_s(strValue, 256, L"%f", value);
return std::wstring(strValue);
}
#else
return std::to_wstring(value);
#endif
}
static inline std::string IntToString(int value, int radix = 10)
static inline std::string IntToString(int value)
{
char strValue[256];
#if defined(_WIN32) || defined(_WIN64)
char strValue[256];
_itoa_s(value, strValue, 256, radix);
return std::string(strValue);
return std::string(strValue);
#else
return std::to_string(value);
#endif
}
static inline std::string DoubleToString(double value)
{
char strValue[256];
#if defined(_WIN32) || defined(_WIN64)
char strValue[256];
sprintf_s(strValue, 256, "%f", value);
return std::string(strValue);
}
#else
return std::to_string(value);
#endif
}
static int ToInteger(const std::string& strValue)
{
......@@ -42,8 +58,12 @@ namespace StlUtils
static int ToInteger(const std::wstring& strValue)
{
return _wtoi(strValue.c_str());
}
#if defined(_WIN32) || defined(_WIN64)
return _wtoi(strValue.c_str());
#else
return std::stoi(strValue);
#endif
}
static double ToDouble(const std::string& strValue)
{
......@@ -52,8 +72,12 @@ namespace StlUtils
static double ToDouble(const std::wstring& strValue)
{
return _wtof(strValue.c_str());
}
#if defined(_WIN32) || defined(_WIN64)
return _wtof(strValue.c_str());
#else
return std::stod(strValue);
#endif
}
}
#endif // ASC_STL_UTILS_INCLUDE_H_
\ No newline at end of file
#endif // ASC_STL_UTILS_INCLUDE_H_
#pragma once
#ifndef UTILITY_UTILITY_INCLUDE_H_
#define UTILITY_UTILITY_INCLUDE_H_
#include "../../../../Common/DocxFormat/Source/XML/stringcommon.h"
......@@ -10,7 +8,7 @@ template<typename Out, typename In>
static const std::vector<Out> _transform(const std::vector<In>& lines, const Out(*func)(const In&))
{
std::vector<Out> result;
for (std::vector<In>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
for (typename std::vector<In>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
result.push_back(func(*iter));
}
......@@ -22,7 +20,7 @@ template<typename Out, typename In>
static const std::list<Out> _transform(const std::list<In>& lines, const Out(*func)(const In&))
{
std::list<Out> result;
for (std::list<In>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
for (typename std::list<In>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
result.push_back(func(*iter));
}
......@@ -32,12 +30,11 @@ static const std::list<Out> _transform(const std::list<In>& lines, const Out(*fu
template<typename Out, typename In, typename In2>
static const std::list<Out> _transform2(const std::list<In>& lines, const int codepage, const Out(*func)(const In&, const In2 codePage))
{
std::list<Out> result;
for (std::list<In>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
std::list<Out> result;
for (typename std::list<In>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
result.push_back(func(*iter, codepage));
}
return result;
}
#endif // UTILITY_UTILITY_INCLUDE_H_
\ No newline at end of file
......@@ -32,10 +32,10 @@ namespace Docx2Txt
void convert(TxtXml::ITxtXmlEvent& Event);
void writeUtf8 (const boost::filesystem::wpath& path) const;
void writeUnicode (const boost::filesystem::wpath& path) const;
void writeBigEndian (const boost::filesystem::wpath& path) const;
void writeAnsi (const boost::filesystem::wpath& path) const;
void writeUtf8 (const std::wstring& path) const;
void writeUnicode (const std::wstring& path) const;
void writeBigEndian (const std::wstring& path) const;
void writeAnsi (const std::wstring& path) const;
Txt::File m_outputFile;
OOX::CDocx m_inputFile;
......@@ -77,33 +77,33 @@ namespace Docx2Txt
return converter_->convert(Event);
}
void Converter::read(const boost::filesystem::wpath& path)
void Converter::read(const std::wstring& path)
{
BOOL res = converter_->m_inputFile.Read(std_string2string(path.string()));
BOOL res = converter_->m_inputFile.Read(std_string2string(path));
return;
}
void Converter::write(const boost::filesystem::wpath& path)
void Converter::write(const std::wstring& path)
{
return converter_->m_outputFile.write(path);
}
void Converter::writeUtf8(const boost::filesystem::wpath& path) const
void Converter::writeUtf8(const std::wstring& path) const
{
return converter_->writeUtf8(path);
}
void Converter::writeUnicode(const boost::filesystem::wpath& path) const
void Converter::writeUnicode(const std::wstring& path) const
{
return converter_->writeUnicode(path);
}
void Converter::writeBigEndian(const boost::filesystem::wpath& path) const
void Converter::writeBigEndian(const std::wstring path) const
{
return converter_->writeBigEndian(path);
}
void Converter::writeAnsi(const boost::filesystem::wpath& path) const
void Converter::writeAnsi(const std::wstring path) const
{
return converter_->writeAnsi(path);
}
......@@ -183,25 +183,25 @@ namespace Docx2Txt
}
void Converter_Impl::writeUtf8(const boost::filesystem::wpath& path) const
void Converter_Impl::writeUtf8(const std::wstring& path) const
{
m_outputFile.writeUtf8(path);
}
void Converter_Impl::writeUnicode(const boost::filesystem::wpath& path) const
void Converter_Impl::writeUnicode(const std::wstring& path) const
{
m_outputFile.writeUnicode(path);
}
void Converter_Impl::writeBigEndian(const boost::filesystem::wpath& path) const
void Converter_Impl::writeBigEndian(const std::wstring& path) const
{
m_outputFile.writeBigEndian(path);
}
void Converter_Impl::writeAnsi(const boost::filesystem::wpath& path) const
void Converter_Impl::writeAnsi(const std::wstring& path) const
{
m_outputFile.writeAnsi(path);
}
......@@ -559,4 +559,4 @@ namespace Docx2Txt
return result;
}
} // namespace Docx2Txt
\ No newline at end of file
} // namespace Docx2Txt
......@@ -2,7 +2,6 @@
#ifndef DOCX_2_TXT_CONVERTER_INCLUDE_H_
#define DOCX_2_TXT_CONVERTER_INCLUDE_H_
#include <boost/filesystem.hpp>
#include <vector>
#include <string>
......@@ -22,13 +21,13 @@ namespace Docx2Txt
void convert(TxtXml::ITxtXmlEvent& Event);
void read (const boost::filesystem::wpath& path);
void write (const boost::filesystem::wpath& path);
void read (const std::wstring& path);
void write (const std::wstring& path);
void writeUtf8 (const boost::filesystem::wpath& path) const;
void writeUnicode (const boost::filesystem::wpath& path) const;
void writeBigEndian (const boost::filesystem::wpath& path) const;
void writeAnsi (const boost::filesystem::wpath& path) const;
void writeUtf8 (const std::wstring& path) const;
void writeUnicode (const std::wstring& path) const;
void writeBigEndian (const std::wstring& path) const;
void writeAnsi (const std::wstring& path) const;
private:
Converter_Impl * converter_;
......@@ -38,4 +37,4 @@ namespace Docx2Txt
} // namespace Docx2Txt
#endif // DOCX_2_TXT_CONVERTER_INCLUDE_H_
\ No newline at end of file
#endif // DOCX_2_TXT_CONVERTER_INCLUDE_H_
#include "Converter.h"
//#include <boost/foreach.hpp>
//#include "../Common/AbstractConverter.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../TxtFormat/TxtFormat.h"
#include "../TxtXmlEvent.h"
......@@ -34,12 +32,12 @@ namespace Txt2Docx
return converter_->convert(Event);
}
void Converter::read(const boost::filesystem::wpath& path)
void Converter::read(const std::wstring& path)
{
return converter_->m_inputFile.read(path);
}
void Converter::write(/*const boost::filesystem::wpath& path*/XmlUtils::CStringWriter & stringWriter)
void Converter::write(/*const std::wstring& path*/XmlUtils::CStringWriter & stringWriter)
{
for (long i=0;i < converter_->m_outputFile.m_arrItems.size(); i++)
{
......@@ -123,7 +121,10 @@ namespace Txt2Docx
}
if(line->length() > 0)
temp->AddText(std_string2string(*line));//, rPr);
{
CString s = std_string2string(*line);
temp->AddText(s);//, rPr);
}
pDocument->m_arrItems.push_back(temp);
......@@ -135,4 +136,4 @@ namespace Txt2Docx
}
Event.Progress(0, 900000);
}
} // namespace Txt2Docx
\ No newline at end of file
} // namespace Txt2Docx
......@@ -2,7 +2,6 @@
#ifndef TXT_2_DOCX_CONVERTER_INCLUDE_H_
#define TXT_2_DOCX_CONVERTER_INCLUDE_H_
#include <boost/filesystem.hpp>
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace TxtXml
......@@ -21,8 +20,8 @@ namespace Txt2Docx
~Converter ();
void convert(TxtXml::ITxtXmlEvent& Event);
void read (const boost::filesystem::wpath& path);
void write (XmlUtils::CStringWriter & stringWriter/*const boost::filesystem::wpath& path*/);
void read (const std::wstring& path);
void write (XmlUtils::CStringWriter & stringWriter/*const std::wstring& path*/);
private:
Converter_Impl * converter_;
......@@ -30,4 +29,4 @@ namespace Txt2Docx
} // namespace Txt2Docx
#endif // TXT_2_DOCX_CONVERTER_INCLUDE_H_
\ No newline at end of file
#endif // TXT_2_DOCX_CONVERTER_INCLUDE_H_
......@@ -2,6 +2,9 @@
#include "../Common/Utility.h"
#include "TxtFile.h"
#include "../../../DesktopEditor/common/File.h"
namespace Txt
{
......@@ -12,14 +15,14 @@ namespace Txt
{
m_listContent.clear();
}
void File::read(const boost::filesystem::wpath& filename, int code_page) //
void File::read(const std::wstring& filename, int code_page) //
{
m_listContent.clear();
if (filename.empty())
return;
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
std::list<std::string> codePageContent = file.readAnsiOrCodePage();
m_listContentSize = file.getLinesCount();
......@@ -30,14 +33,14 @@ namespace Txt
}
codePageContent.clear();
}
void File::read(const boost::filesystem::wpath& filename)
void File::read(const std::wstring& filename)
{
m_listContent.clear();
if (filename.empty())
return;
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
//
......@@ -69,15 +72,15 @@ namespace Txt
}
void File::write(const boost::filesystem::wpath& filename) const
void File::write(const std::wstring& filename) const
{
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
file.writeUtf8(_transform(m_listContent, Encoding::unicode2utf8));
}
void File::writeCodePage(const boost::filesystem::wpath& filename, int code_page) const
void File::writeCodePage(const std::wstring& filename, int code_page) const
{
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
std::list<std::string> result;
for (std::list<std::wstring>::const_iterator iter = m_listContent.begin(); iter != m_listContent.end(); ++iter)
......@@ -88,39 +91,40 @@ namespace Txt
file.writeAnsiOrCodePage(result);
}
void File::writeUtf8(const boost::filesystem::wpath& filename) const
void File::writeUtf8(const std::wstring& filename) const
{
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
file.writeUtf8(_transform(m_listContent, Encoding::unicode2utf8));
}
void File::writeUnicode(const boost::filesystem::wpath& filename) const
void File::writeUnicode(const std::wstring& filename) const
{
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
file.writeUnicode(m_listContent);
}
void File::writeBigEndian(const boost::filesystem::wpath& filename) const
void File::writeBigEndian(const std::wstring& filename) const
{
TxtFile file(std_string2string(filename.string()));
OOX::CPath path (filename);
TxtFile file(path);
file.writeBigEndian(m_listContent);
}
void File::writeAnsi(const boost::filesystem::wpath& filename) const
void File::writeAnsi(const std::wstring& filename) const
{
TxtFile file(std_string2string(filename.string()));
TxtFile file(std_string2string(filename));
file.writeAnsiOrCodePage(_transform(m_listContent, Encoding::unicode2ansi));
}
const bool File::isValid(const boost::filesystem::wpath& filename) const
const bool File::isValid(const std::wstring& filename) const
{
if (filename.empty())
return true;
return boost::filesystem::exists(filename);
return NSFile::CFileBinary::Exists(filename);
}
void File::correctUnicode(std::list<std::wstring>& input)
{
......@@ -152,4 +156,4 @@ namespace Txt
return result;
}
} // namespace Txt
\ No newline at end of file
} // namespace Txt
......@@ -2,12 +2,8 @@
#ifndef TXT_FILE_INCLUDE_H_
#define TXT_FILE_INCLUDE_H_
//#include <vector>
#include <list>
#include <string>
#include <boost/filesystem.hpp>
//#include "property.h"
namespace Txt
{
......@@ -17,18 +13,18 @@ namespace Txt
File();
~File();
void read (const boost::filesystem::wpath& filename);
void read (const boost::filesystem::wpath& filename, int code_page);
void read (const std::wstring& filename);
void read (const std::wstring& filename, int code_page);
void write (const boost::filesystem::wpath& filename) const;
void write (const std::wstring& filename) const;
void writeCodePage (const boost::filesystem::wpath& filename, int code_page) const;
void writeUtf8 (const boost::filesystem::wpath& filename) const;
void writeUnicode (const boost::filesystem::wpath& filename) const;
void writeBigEndian (const boost::filesystem::wpath& filename) const;
void writeAnsi (const boost::filesystem::wpath& filename) const;
void writeCodePage (const std::wstring& filename, int code_page) const;
void writeUtf8 (const std::wstring& filename) const;
void writeUnicode (const std::wstring& filename) const;
void writeBigEndian (const std::wstring& filename) const;
void writeAnsi (const std::wstring& filename) const;
const bool isValid (const boost::filesystem::wpath& filename) const;
const bool isValid (const std::wstring& filename) const;
std::list<std::wstring> m_listContent; //unicode ( utf8)
int m_listContentSize; //
......@@ -39,4 +35,4 @@ namespace Txt
};
} // namespace Txt
#endif // TXT_FILE_INCLUDE_H_
\ No newline at end of file
#endif // TXT_FILE_INCLUDE_H_
......@@ -10,29 +10,29 @@ static const std::string BadSymbols = "\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\
static std::wstring convertUtf16ToWString(UTF16 * Data, int nLength)
{
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
// this values will be modificated
const UTF16 *pStrUtf16_Conv = Data;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF16toUTF32 (&pStrUtf16_Conv,
&Data[nLength]
, &pStrUtf32_Conv
, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return std::wstring();
}
std::wstring wstr ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
// this values will be modificated
const UTF16 *pStrUtf16_Conv = Data;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF16toUTF32 (&pStrUtf16_Conv,
&Data[nLength]
, &pStrUtf32_Conv
, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return std::wstring();
}
std::wstring wstr ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
return wstr;
}
......@@ -231,7 +231,7 @@ const std::list<std::string> TxtFile::readUtf8()
void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // === writeUtf8withoutPref
{
CFile file;
if (file.CreateFileW(m_path.GetPath()) == S_OK)
if (file.CreateFile(m_path.GetPath()) == S_OK)
{
BYTE endLine[2] = {0x0d, 0x0a};
for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
......@@ -247,7 +247,7 @@ void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // ===
void TxtFile::writeUnicode(const std::list<std::wstring>& content)
{
CFile file;
if (file.CreateFileW(m_path.GetPath()) == S_OK)
if (file.CreateFile(m_path.GetPath()) == S_OK)
{
BYTE Header[2] = {0xff, 0xfe};
BYTE EndLine[4] = {0x0d, 0x00, 0x0a, 0x00};
......@@ -277,7 +277,7 @@ void TxtFile::writeUnicode(const std::list<std::wstring>& content)
void TxtFile::writeBigEndian(const std::list<std::wstring>& content)
{
CFile file;
if (file.CreateFileW(m_path.GetPath()) == S_OK)
if (file.CreateFile(m_path.GetPath()) == S_OK)
{
BYTE Header[2] = {0xfe, 0xff};
BYTE EndLine[4] = {0x00, 0x0d, 0x00, 0x0a};
......@@ -313,7 +313,7 @@ void TxtFile::writeBigEndian(const std::list<std::wstring>& content)
void TxtFile::writeUtf8(const std::list<std::string>& content)
{
CFile file;
if (file.CreateFileW(m_path.GetPath()) == S_OK)
if (file.CreateFile(m_path.GetPath()) == S_OK)
{
BYTE Header[3] = {0xef ,0xbb , 0xbf};
BYTE EndLine[2] = {0x0d ,0x0a};
......
#include <string>
#include <boost/filesystem.hpp>
#include "TxtXmlFile.h"
......@@ -23,7 +22,7 @@ namespace BinDocxRW
#include "../../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
#include "../../../Common/OfficeDefines.h"
#include "../../../common/docxformat/source/systemutility/file.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "../../../DesktopEditor/common/Path.h"
#include "../../../ASCOfficeDocxFile2/DocWrapper/FontProcessor.h"
......@@ -38,13 +37,13 @@ CTxtXmlFile::CTxtXmlFile()
bool CTxtXmlFile::Progress(long ID, long Percent)
{
SHORT res = 0;
m_lPercent = Percent;
//OnProgressEx(ID, Percent, &res); todooo out event
return (res != 0);
SHORT res = 0;
m_lPercent = Percent;
//OnProgressEx(ID, Percent, &res); todooo out event
return (res != 0);
}
static int ParseTxtOptions(static CString & sXmlOptions)
static int ParseTxtOptions(const std::wstring & sXmlOptions)
{
int encoding = -1;
......@@ -78,7 +77,7 @@ static int ParseTxtOptions(static CString & sXmlOptions)
}
HRESULT CTxtXmlFile::txt_LoadFromFile(CString sSrcFileName, CString sDstPath, CString sXMLOptions)
HRESULT CTxtXmlFile::txt_LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstPath, const std::wstring & sXMLOptions)
{
// xml -
//HRESULT hr = xml_LoadFromFile(sSrcFileName, sDstPath, sXMLOptions);
......@@ -87,14 +86,10 @@ HRESULT CTxtXmlFile::txt_LoadFromFile(CString sSrcFileName, CString sDstPath, CS
//As Text
const boost::filesystem::wpath txtFile = string2std_string(sSrcFileName);
const boost::filesystem::wpath docxPath = string2std_string(sDstPath);
const boost::filesystem::wpath origin = docxPath/L"Origin";
Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, _T(""), 1, false, NULL, _T(""));
Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, _T(""), 1, false, NULL, _T(""));
if (pDocxWriter == NULL) return S_FALSE;
CreateDocxEmpty(sDstPath, pDocxWriter);
CreateDocxEmpty(std_string2string(sDstPath), pDocxWriter);
try
{
......@@ -102,7 +97,7 @@ HRESULT CTxtXmlFile::txt_LoadFromFile(CString sSrcFileName, CString sDstPath, CS
Progress(0, 0);
Txt2Docx::Converter converter( encoding);
converter.read(txtFile);
converter.read(sSrcFileName);
Progress(0, 100000);
converter.convert(*this);
converter.write(pDocxWriter->m_oDocumentWriter.m_oContent);
......@@ -122,35 +117,32 @@ HRESULT CTxtXmlFile::txt_LoadFromFile(CString sSrcFileName, CString sDstPath, CS
}
HRESULT CTxtXmlFile::txt_SaveToFile(CString sDstFileName, CString sSrcPath, CString sXMLOptions)
HRESULT CTxtXmlFile::txt_SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcPath, const std::wstring & sXMLOptions)
{
const boost::filesystem::wpath txtFile = string2std_string(sDstFileName);
const boost::filesystem::wpath docxPath = string2std_string(sSrcPath);
try
{
Progress(0, 0);
Docx2Txt::Converter converter;
converter.read(docxPath);
converter.read(sSrcPath);
Progress(0, 100000);
converter.convert(*this);
int encoding = ParseTxtOptions(sXMLOptions);
if (encoding == EncodingType::Utf8)
converter.writeUtf8(txtFile);
converter.writeUtf8(sDstFileName);
else if (encoding == EncodingType::Unicode)
converter.writeUnicode(txtFile);
converter.writeUnicode(sDstFileName);
else if (encoding == EncodingType::Ansi)
converter.writeAnsi(txtFile);
converter.writeAnsi(sDstFileName);
else if (encoding == EncodingType::BigEndian)
converter.writeBigEndian(txtFile);
converter.writeBigEndian(sDstFileName);
else if (encoding > 0) //code page
{
converter.write(txtFile);
converter.write(sDstFileName);
}
else //auto define
converter.write(txtFile);
converter.write(sDstFileName);
Progress(0, 1000000);
}
......
#pragma once
#include "TxtXmlEvent.h"
#include "../../../Common/DocxFormat/Source/XML/stringcommon.h"
#include <string>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#else
#include "../../../DesktopEditor/common/ASCVariant.h"
#endif
namespace Writers
{
......@@ -13,8 +20,8 @@ class CTxtXmlFile : public TxtXml::ITxtXmlEvent
public:
virtual bool Progress(long ID, long Percent);
HRESULT txt_LoadFromFile(CString sSrcFileName, CString sDstPath, CString sXMLOptions);
HRESULT txt_SaveToFile (CString sDstFileName, CString sSrcPath, CString sXMLOptions);
HRESULT txt_LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstPath, const std::wstring & sXMLOptions);
HRESULT txt_SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcPath, const std::wstring & sXMLOptions);
//HRESULT xml_LoadFromFile(CString sSrcFileName, CString sDstPath, CString sXMLOptions);
//HRESULT xml_SaveToFile (CString sDstFileName, CString sSrcPath, CString sXMLOptions);
......@@ -24,4 +31,4 @@ public:
private:
void CreateDocxEmpty(CString path, Writers::FileWriter * DocxWriter) ;
};
\ No newline at end of file
};
......@@ -15,8 +15,7 @@ DEFINES += _LINUX LINUX UNICODE _UNICODE _USE_LIBXML2_READER_ _LINUX_QT _USE_XML
LIBS += -lxml2
INCLUDEPATH += \
/usr/include/libxml2
INCLUDEPATH += /usr/include/libxml2
SOURCES += docxformatlib.cpp \
../Source/Common/Align.cpp \
......
#include <windows.h>
#ifndef _OFFICEDEFINES_H_
#define _OFFICEDEFINES_H_
......@@ -50,4 +48,5 @@ const int c_nSaveModeNone = 0;
const int c_nSaveModeStart = 1;
const int c_nSaveModeContinue = 2;
const int c_nSaveModeCommit = 4;
#endif //_OFFICEDEFINES_H_
......@@ -5,8 +5,7 @@
#include "../../Common/DocxFormat/Source/Base/ASCString.h" // TODO: move ASCString to DecktopEditor/commmon directory
// VARIANT
#ifndef _WIN32
#if !defined(_WIN32) && !defined(_WIN64)
// 0 == FALSE, -1 == TRUE
typedef short VARIANT_BOOL;
......
......@@ -73,7 +73,7 @@ namespace SerializeCommon
return sSourcePath.Left(nIndex + 1) + sTargetExt;
return sSourcePath;
}
void ReadFileType(CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter, BYTE& cSaveFileType)
void ReadFileType(const CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter, BYTE& cSaveFileType)
{
result = BinXlsxRW::c_oFileTypes::XLSX;
nCodePage = CP_UTF8;
......
......@@ -47,7 +47,7 @@ namespace SerializeCommon
aReplies.clear();
}
};
void ReadFileType(CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter, BYTE& saveFileType);
void ReadFileType(const CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter, BYTE& saveFileType);
}
#endif //SERIALIZER_COMMON
......@@ -3023,7 +3023,7 @@ namespace BinXlsxRW {
public: BinaryFileReader()
{
}
int ReadFile(CString sSrcFileName, CString sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, CString& sXMLOptions)
int ReadFile(const CString& sSrcFileName, CString sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const CString& sXMLOptions)
{
bool bResultOk = false;
NSFile::CFileBinary oFile;
......
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