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

X2tConverter linux build

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62389 954022d7-b5bf-4e40-9824-e11837661b57
parent c0a82fb4
......@@ -77,7 +77,7 @@ namespace NSHtmlRenderer
#if defined(_WIN32) || defined (_WIN64)
::_wunlink( m_wsTempFilePath.GetBuffer() );
#else
std::string sTempFilePath = U_TO_UTF8(m_wsTempFilePath);
std::string sTempFilePath = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_wsTempFilePath.c_str(), m_wsTempFilePath.length());
::unlink( sTempFilePath.c_str() );
#endif
......
......@@ -25,15 +25,16 @@ SOURCES += ../ASCSVGWriter.cpp \
../CASCSVGRenderer.cpp \
../CMetafile.cpp \
../CASCImage.cpp \
../../DesktopEditor/raster/Metafile/Common.cpp \
../../DesktopEditor/raster/Metafile/MetaFile.cpp \
../../DesktopEditor/raster/Metafile/MetaFile.cpp \
../../DesktopEditor/raster/Metafile/Emf/EmfObjects.cpp \
../../DesktopEditor/raster/Metafile/Emf/EmfPath.cpp \
../../DesktopEditor/raster/Metafile/Emf/EmfPlayer.cpp \
../../DesktopEditor/raster/Metafile/Emf/EmfClip.cpp \
../../DesktopEditor/raster/Metafile/Common/MetaFileTypes.cpp \
../../DesktopEditor/raster/Metafile/Wmf/WmfObjects.cpp \
../../DesktopEditor/raster/Metafile/Wmf/WmfPlayer.cpp
../../DesktopEditor/raster/Metafile/Wmf/WmfPlayer.cpp \
../../DesktopEditor/raster/Metafile/Common/MetaFileUtils.cpp \
../../DesktopEditor/raster/Metafile/Wmf/WmfClip.cpp
HEADERS += ../ASCSVGWriter.h \
../CASCImage.h \
......@@ -78,7 +79,9 @@ HEADERS += ../ASCSVGWriter.h \
../../DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h \
../../DesktopEditor/raster/Metafile/Common/MetaFileTypes.h \
../../DesktopEditor/raster/Metafile/Wmf/WmfObjects.h \
../../DesktopEditor/raster/Metafile/Wmf/WmfPlayer.h
../../DesktopEditor/raster/Metafile/Wmf/WmfPlayer.h \
../../DesktopEditor/raster/Metafile/Common/MetaFileUtils.h \
../../DesktopEditor/raster/Metafile/Wmf/WmfClip.h
unix {
target.path = /usr/lib
......
......@@ -35,20 +35,20 @@ HEADERS += \
../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
../Source/TxtFormat/TxtFormat.h \
../Source/ConvertDocx2Txt.h \
../Source/ConvertTxt2Docx.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
../Source/TxtFormat/TxtFile.cpp \
../Source/ConvertDocx2Txt.cpp \
../Source/ConvertTxt2Docx.cpp
unix {
target.path = /usr/lib
......
This diff is collapsed.
#pragma once
#ifndef DOCX_2_TXT_CONVERTER_INCLUDE_H_
#define DOCX_2_TXT_CONVERTER_INCLUDE_H_
#include <vector>
#include <string>
namespace TxtXml
{
class ITxtXmlEvent;
}
namespace Docx2Txt
{
class Converter_Impl;
class Converter
{
public:
Converter();
~Converter();
void convert(TxtXml::ITxtXmlEvent& Event);
void read (const std::wstring& path);
void write (const std::wstring& path);
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_;
};
} // namespace Docx2Txt
#endif // DOCX_2_TXT_CONVERTER_INCLUDE_H_
#include "ConvertTxt2Docx.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "TxtFormat/TxtFormat.h"
#include "TxtXmlEvent.h"
namespace Txt2Docx
{
class Converter_Impl
{
public:
Converter_Impl(int encoding);
void convert(TxtXml::ITxtXmlEvent& Event);
Txt::File m_inputFile;
OOX::CDocument m_outputFile;
};
Converter::Converter(int encoding) : converter_( new Converter_Impl(encoding) )
{
}
Converter::~Converter()
{
delete converter_;
}
void Converter::convert(TxtXml::ITxtXmlEvent& Event)
{
return converter_->convert(Event);
}
void Converter::read(const std::wstring& path)
{
return converter_->m_inputFile.read(path);
}
void Converter::write(/*const std::wstring& path*/XmlUtils::CStringWriter & stringWriter)
{
for (long i=0;i < converter_->m_outputFile.m_arrItems.size(); i++)
{
if (converter_->m_outputFile.m_arrItems[i] != NULL)
stringWriter.WriteString(converter_->m_outputFile.m_arrItems[i]->toXML());
}
//BOOL res = converter_->m_outputFile.Write(std_string2string(path.string()));
return;
}
Converter_Impl::Converter_Impl(int encoding)
{
m_inputFile.m_nEncoding = encoding;
}
void Converter_Impl::convert(TxtXml::ITxtXmlEvent& Event)
{
//smart_ptr<OOX::File> pFile = m_outputFile.Find(OOX::FileTypes::Document);
OOX::CDocument *pDocument = &m_outputFile;//NULL;
if (!m_inputFile.m_listContent.empty() /*&& pFile.IsInit() && OOX::FileTypes::Document == pFile->type()*/)
{
//pDocument = (OOX::CDocument*)pFile.operator->();
//pDocument->ClearItems();
int percent = 100000;
int step = 800000 / m_inputFile.m_listContentSize; // !!!!!
bool cancel = Event.Progress(0, 100000);
if(cancel)
return;
/*
OOX::Logic::ParagraphProperty pPr;
OOX::Logic::Spacing space;
space.After = 0;
space.Line = 240;
space.LineRule = "auto";
pPr.Spacing = space;
OOX::Logic::RFonts rFont;
rFont.Ascii = "Courier New";
rFont.HAnsi = "Courier New";
rFont.Cs = "Courier New";
OOX::Logic::RunProperty rPr;
rPr.RFonts = rFont;
pPr.RunProperty = rPr;
OOX::Logic::Paragraph paragraph;
paragraph.Property = pPr;
*/
for (std::list<std::wstring>::iterator line = m_inputFile.m_listContent.begin(); line != m_inputFile.m_listContent.end(); line++)
{
//OOX::Logic::ParagraphProperty pPr;
//OOX::Logic::Spacing space;
//space.After = 0;
//space.Line = 240;
//space.LineRule = "auto";
//pPr.Spacing = space;
//OOX::Logic::RFonts rFont;
//rFont.Ascii = "Courier New";
//rFont.HAnsi = "Courier New";
//rFont.Cs = "Courier New";
//OOX::Logic::RunProperty rPr;
//rPr.RFonts = rFont;
//pPr.RunProperty = rPr;
//OOX::Logic::Paragraph paragraph;
//paragraph.Property = pPr;
OOX::Logic::CParagraph *temp = new OOX::Logic::CParagraph();
while(line->find(_T("\x08")) != line->npos)
{
line->erase(line->find(_T("\x08")), 1);//, "");
}
if(line->length() > 0)
{
CString s = std_string2string(*line);
temp->AddText(s);//, rPr);
}
pDocument->m_arrItems.push_back(temp);
percent += step;
cancel = Event.Progress(0, percent);
if(cancel)
return;
}
}
Event.Progress(0, 900000);
}
} // namespace Txt2Docx
#pragma once
#ifndef TXT_2_DOCX_CONVERTER_INCLUDE_H_
#define TXT_2_DOCX_CONVERTER_INCLUDE_H_
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace TxtXml
{
class ITxtXmlEvent;
}
namespace Txt2Docx
{
class Converter_Impl;
class Converter
{
public:
Converter (int encoding);
~Converter ();
void convert(TxtXml::ITxtXmlEvent& Event);
void read (const std::wstring& path);
void write (XmlUtils::CStringWriter & stringWriter/*const std::wstring& path*/);
private:
Converter_Impl * converter_;
};
} // namespace Txt2Docx
#endif // TXT_2_DOCX_CONVERTER_INCLUDE_H_
......@@ -2,8 +2,8 @@
#include "TxtXmlFile.h"
#include "Docx2Txt/Converter.h"
#include "Txt2Docx/Converter.h"
#include "ConvertDocx2Txt.h"
#include "ConvertTxt2Docx.h"
#include "Common/StlUtils.h"
......@@ -13,11 +13,13 @@ namespace NSBinPptxRW
{
class CDrawingConverter;
}
namespace BinDocxRW
{
int g_nCurFormatVersion = 0;
}
#if defined (_WIN32) || defined (_WIN64)
namespace BinDocxRW
{
int g_nCurFormatVersion = 0; //extern from XlsxSerializer
}
#endif
#include "../../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
#include "../../../Common/OfficeDefines.h"
......
......@@ -17,6 +17,10 @@
#include <unistd.h>
#endif
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
//#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
//перенесено выше
......@@ -815,7 +819,7 @@ namespace NSFile
if (NULL == folder)
folder = "/tmp";
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(folder, strlen(folder));
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)folder, strlen(folder));
#endif
}
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix)
......
#ifndef _BUILD_STRING_CROSSPLATFORM_H_
#define _BUILD_STRING_CROSSPLATFORM_H_
#include "CPEncodings\CodePage.h"
#include "CPEncodings/CodePage.h"
namespace NSString
{
......@@ -180,4 +180,4 @@ namespace NSString
};
};
#endif // _BUILD_STRING_CROSSPLATFORM_H_
\ No newline at end of file
#endif // _BUILD_STRING_CROSSPLATFORM_H_
......@@ -235,7 +235,7 @@ namespace MetaFile
struct TEmfPointL;
struct TWmfPointS;
struct TWmfRect;
struct TWmfRect;
struct TRect
{
......@@ -246,7 +246,7 @@ namespace MetaFile
TRect();
TRect& operator=(TWmfRect& oRect);
};
};
struct TRectD
{
......@@ -269,15 +269,15 @@ namespace MetaFile
dRight = (double)oRect.nRight;
dBottom = (double)oRect.nBottom;
}
TRectD& operator=(TRect& oRect)
{
dLeft = (double)oRect.nLeft;
dTop = (double)oRect.nTop;
dRight = (double)oRect.nRight;
dBottom = (double)oRect.nBottom;
return *this;
}
TRectD& operator*=(double& dValue)
TRectD& operator=(TRect& oRect)
{
dLeft = (double)oRect.nLeft;
dTop = (double)oRect.nTop;
dRight = (double)oRect.nRight;
dBottom = (double)oRect.nBottom;
return *this;
}
TRectD& operator*=(double& dValue)
{
dLeft *= dValue;
dTop *= dValue;
......@@ -285,7 +285,7 @@ namespace MetaFile
dBottom *= dValue;
return *this;
}
};
};
struct TPointL
{
......
......@@ -7,6 +7,10 @@
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), val.length())
#ifndef DIB_RGB_COLORS
#define DIB_RGB_COLORS 0x00
#endif
namespace MetaFile
{
unsigned char GetLowestBit(unsigned int ulValue)
......
......@@ -27,7 +27,8 @@ namespace MetaFile
TRectD GetBounds()
{
TRectD oBounds = GetBoundingBox();
TRect oBoundsBox = GetBoundingBox();
TRectD oBounds = oBoundsBox;
if (IsPlaceable())
{
double dLogicalToMM = 25.4 / 72;
......@@ -334,7 +335,7 @@ namespace MetaFile
dY -= dT;
pInverse->Apply(dX, dY);
}
TRect GetBoundingBox()
TRect GetBoundingBox()
{
TRect oBB;
if (IsPlaceable())
......
......@@ -6,6 +6,9 @@
#include "WmfTypes.h"
#ifdef __linux__
#include <string.h> //memset oO
#endif
namespace MetaFile
{
typedef enum
......@@ -62,7 +65,7 @@ namespace MetaFile
CWmfFont()
{
::memset(Facename, 0x00, 32);
memset(Facename, 0x00, 32);
}
~CWmfFont()
{
......@@ -205,4 +208,4 @@ namespace MetaFile
};
}
#endif //_METAFILE_WMF_WMFOBJECTS_H
\ No newline at end of file
#endif //_METAFILE_WMF_WMFOBJECTS_H
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