Commit daf44553 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - small refactoring

parent 1fc824db
......@@ -41,25 +41,25 @@
#include <set>
#include <map>
#include <limits.h>
#include <math.h>
#include "utf8.h"
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#include <windows.h>
#include <tchar.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
//#include "../../DesktopEditor/common/ASCVariant.h"
//#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/XML/stringcommon.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../UnicodeConverter/UnicodeConverter.h"
#include <boost/format.hpp>
namespace DocFormatUtils
{
typedef unsigned char Bool8;
......@@ -768,10 +768,11 @@ namespace DocFormatUtils
static inline std::wstring IntToWideString(int value)
{
CString strValue;
strValue.Format(_T("%d"), value);
wchar_t sVal[32]={};
_itow(value, sVal, 10);
std::wstring strValue;
return string2std_string(strValue);
return std::wstring(sVal);
}
static inline std::wstring DoubleToWideString(double value)
{
......@@ -827,29 +828,35 @@ namespace DocFormatUtils
// wchar_t strValue[size] = _T( "\0" );
// if ( format != NULL )
// {
if ( format == NULL ) return L"";
// swprintf_s( strValue, size, format, value );
// }
CString format_str;
format_str.Format(format , value);
//// }
// CString format_str;
// format_str.Format(format , value);
return string2std_string( format_str );
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();
//return string2std_string( format_str );
}
static inline std::wstring DoubleToFormattedWideString( double value, wchar_t* format )
{
std::wstring wstr;
if ( format == NULL ) return L"";
//std::wstring wstr;
if ( format != NULL )
{
CString strValue;
strValue.Format(format, value);
//if ( format != NULL )
//{
// CString strValue;
// strValue.Format(format, value);
wstr = string2std_string( strValue );
}
// wstr = string2std_string( strValue );
//}
return wstr;
//return wstr;
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();
}
static inline void SetBytes( unsigned char *bytes, int value )
......
......@@ -34,14 +34,14 @@
#include <string>
#include <map>
#include <list>
//
//#if defined(_WIN32) || defined(_WIN64)
//#else
// #include "../../DesktopEditor/common/ASCVariant.h"
// #include "../../Common/DocxFormat/Source/Base/ASCString.h"
//#endif
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../DesktopEditor/Common/File.h"
inline static std::wstring ReplaceString(std::wstring subject, const std::wstring& search, const std::wstring& replace)
{
......@@ -118,12 +118,12 @@ namespace XMLTools
std::basic_string<T> GetXMLString()
{
std::basic_string<T> xmlString( _T( "" ) );
std::basic_string<T> xmlString( L"" );
xmlString += m_Name;
xmlString += std::basic_string<T>( _T( "=\"" ) );
xmlString += std::basic_string<T>( L"=\"" );
xmlString += m_Value;
xmlString += std::basic_string<T>( _T( "\"" ) );
xmlString += std::basic_string<T>( L"\"" );
return xmlString;
}
......@@ -165,7 +165,7 @@ namespace XMLTools
/*========================================================================================================*/
XMLElement( const T* prefix, const T* localName ) : m_Name( std::basic_string<T>( prefix ) + std::basic_string<T>( _T( ":" ) ) + std::basic_string<T>( localName ) ), m_ElementText( _T( "" ) )
XMLElement( const T* prefix, const T* localName ) : m_Name( std::basic_string<T>( prefix ) + std::basic_string<T>( L":" ) + std::basic_string<T>( localName ) ), m_ElementText( L"" )
{
}
......@@ -341,25 +341,25 @@ namespace XMLTools
std::basic_string<T> GetXMLString()
{
std::basic_string<T> xmlString( _T( "" ) );
std::basic_string<T> xmlString( L"");
bool bIsNameExists = ( m_Name != std::basic_string<T>( _T( "" ) ) );
bool bIsTextExists = ( m_ElementText != std::basic_string<T>( _T( "" ) ) );
bool bIsNameExists = ( m_Name != std::basic_string<T>( L"") );
bool bIsTextExists = ( m_ElementText != std::basic_string<T>( L"") );
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( _T( "<" ) ) + m_Name;
xmlString += std::basic_string<T>( L"<" ) + m_Name;
}
if ( ( bIsNameExists ) && ( m_AttributeMap.size() > 0 ) )
{
for ( AttMapIterator iter = m_AttributeMap.begin(); iter != m_AttributeMap.end(); iter++ )
{
xmlString += std::basic_string<T>( _T( " " ) );
xmlString += std::basic_string<T>( L" " );
xmlString += iter->first;
xmlString += std::basic_string<T>( _T( "=\"" ) );
xmlString += std::basic_string<T>( L"=\"" );
xmlString += iter->second;
xmlString += std::basic_string<T>( _T( "\"" ) );
xmlString += std::basic_string<T>( L"\"" );
}
}
......@@ -367,7 +367,7 @@ namespace XMLTools
{
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( _T( ">" ) );
xmlString += std::basic_string<T>( L">" );
}
for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ )
......@@ -382,16 +382,16 @@ namespace XMLTools
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( _T( "</" ) );
xmlString += std::basic_string<T>( L"</" );
xmlString += m_Name;
xmlString += std::basic_string<T>( _T( ">" ) );
xmlString += std::basic_string<T>( L">" );
}
}
else
{
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( _T( "/>" ) );
xmlString += std::basic_string<T>( L"/>" );
}
}
......@@ -413,4 +413,131 @@ namespace XMLTools
}
};
class CStringXmlWriter
{
std::wstring m_str;
public:
CStringXmlWriter(){}
std::wstring GetXmlString()
{
return m_str;
}
void SetXmlString(const std::wstring& strValue)
{
m_str = strValue;
}
bool SaveToFile(const std::wstring& strFilePath, bool bEncodingToUTF8 = false)
{
NSFile::CFileBinary file;
if (!file.CreateFileW(strFilePath)) return false;
if (bEncodingToUTF8)
file.WriteStringUTF8(m_str);
else
{
std::string s(m_str.begin(), m_str.end());
file.WriteFile((unsigned char*)s.c_str(), s.length());
}
file.CloseFile();
return true;
}
void WriteString(const std::wstring & strValue)
{
m_str += strValue;
}
void WriteInteger(int Value, int Base = 10)
{
wchar_t str[33]={};
_itow(Value, str, Base);
m_str += str;
}
void WriteDouble(double Value)
{
int *dec = NULL, *sign = NULL;
char *str = _fcvt( Value , 4, dec, sign);
if (str)
{
std::string sA(str);
delete []str;
m_str += std::wstring(sA.begin(), sA.end());
}
else
{
m_str += L"0";
}
}
void WriteBoolean(bool Value)
{
if (Value)
m_str += L"true";
else
m_str += L"false";
}
void WriteNodeBegin(const std::wstring& strNodeName, bool bAttributed = false)
{
m_str += L"<" + strNodeName;
if (!bAttributed)
m_str += L">";
}
void WriteNodeEnd(const std::wstring& strNodeName, bool bEmptyNode = false, bool bEndNode = true)
{
if (bEmptyNode)
{
if (bEndNode)
m_str += L"/>";
else
m_str += L">";
}
else
m_str += L"</" + strNodeName + L">";
}
void WriteNode(const std::wstring& strNodeName, const std::wstring& strNodeValue)
{
if (strNodeValue.length() == 0)
m_str += L"<" + strNodeName + L"/>";
else
m_str += L"<" + strNodeName + L">" + strNodeValue + L"</" + strNodeName + L">";
}
void WriteNode(const std::wstring& strNodeName, int nValue, int nBase = 10, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = L"")
{
WriteNodeBegin(strNodeName);
WriteString(strTextBeforeValue);
WriteInteger(nValue, nBase);
WriteString(strTextAfterValue);
WriteNodeEnd(strNodeName);
}
void WriteNode(const std::wstring& strNodeName, double dValue)
{
WriteNodeBegin(strNodeName);
WriteDouble(dValue);
WriteNodeEnd(strNodeName);
}
void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& strAttributeValue)
{
m_str += L" " + strAttributeName + L"=\"" + strAttributeValue + L"\"";
}
void WriteAttribute(const std::wstring& strAttributeName, int nValue, int nBase = 10, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = L"")
{
WriteString(L" " + strAttributeName + L"=");
WriteString(L"\"");
WriteString(strTextBeforeValue);
WriteInteger(nValue, nBase);
WriteString(strTextAfterValue);
WriteString(L"\"");
}
void WriteAttribute(const std::wstring& strAttributeName, double dValue)
{
WriteString(L" " + strAttributeName + L"=");
WriteString(L"\"");
WriteDouble(dValue);
WriteString(L"\"");
}
};
}
......@@ -31,19 +31,19 @@
*/
#pragma once
#include "../../Common/DocxFormat/Source/XML/xmlutils.h"
#include "../Common/XmlTools.h"
namespace DocFileFormat
{
class AbstractOpenXmlMapping
{
public:
AbstractOpenXmlMapping (XmlUtils::CXmlWriter* pWriter) : m_pXmlWriter(pWriter)
AbstractOpenXmlMapping (XMLTools::CStringXmlWriter* pWriter) : m_pXmlWriter(pWriter)
{
}
inline XmlUtils::CXmlWriter* GetXMLWriter()
inline XMLTools::CStringXmlWriter* GetXMLWriter()
{
return m_pXmlWriter;
}
......@@ -55,6 +55,6 @@ namespace DocFileFormat
protected:
XmlUtils::CXmlWriter* m_pXmlWriter;
XMLTools::CStringXmlWriter* m_pXmlWriter;
};
}
......@@ -34,7 +34,7 @@
namespace DocFileFormat
{
CharacterPropertiesMapping::CharacterPropertiesMapping( XmlUtils::CXmlWriter* writer, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded)
CharacterPropertiesMapping::CharacterPropertiesMapping( XMLTools::CStringXmlWriter* writer, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded)
: PropertiesMapping( writer ), _isRunStyleNeeded(isRunStyleNeeded), _isOwnRPr(true), _isRTL(false)
{
_doc = doc;
......@@ -294,11 +294,13 @@ namespace DocFileFormat
case sprmCCv:
{
CString rgbColor;
std::wstringstream sstream;
rgbColor.Format( _T( "%02x%02x%02x" ), /*R*/iter->Arguments[0], /*G*/iter->Arguments[1], /*B*/iter->Arguments[2] );
colorVal->SetValue( rgbColor.GetString() );
sstream << boost::wformat(L"%02x%02x%02x") % iter->Arguments[0] % /*G*/iter->Arguments[1] % /*B*/iter->Arguments[2];
colorVal->SetValue(sstream.str().c_str());
//CString rgbColor;
//rgbColor.Format( _T( "%02x%02x%02x" ), /*R*/iter->Arguments[0], /*G*/iter->Arguments[1], /*B*/iter->Arguments[2] );
//colorVal->SetValue( rgbColor.GetString() );
}break;
case sprmCOldHighlight:
......
......@@ -54,7 +54,7 @@ namespace DocFileFormat
class CharacterPropertiesMapping: public PropertiesMapping, public IMapping
{
public:
CharacterPropertiesMapping( XmlUtils::CXmlWriter* writer, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded = true );
CharacterPropertiesMapping( XMLTools::CStringXmlWriter* writer, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded = true );
CharacterPropertiesMapping( XMLTools::XMLElement<wchar_t>* rPr, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded = true );
virtual ~CharacterPropertiesMapping();
void Apply( IVisitable* chpx );
......@@ -74,7 +74,7 @@ namespace DocFileFormat
virtual void appendFlagElement( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique );
private:
XmlUtils::CXmlWriter pRunPr;
XMLTools::CStringXmlWriter pRunPr;
WordDocument* _doc;
XMLTools::XMLElement<wchar_t>* _rPr;
......
......@@ -32,12 +32,12 @@
#pragma once
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#include <tchar.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include <string>
namespace OpenXmlContentTypes
{
......
......@@ -42,7 +42,7 @@
namespace DocFileFormat
{
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
_fldCharCounter(0), AbstractOpenXmlMapping( new XmlUtils::CXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_fldCharCounter(0), AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_endnoteNr(0), _commentNr(0), _caller(caller)
{
m_document = NULL;
......@@ -55,7 +55,7 @@ namespace DocFileFormat
_isTextBoxContent = false;
}
DocumentMapping::DocumentMapping(ConversionContext* context, XmlUtils::CXmlWriter* writer, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
DocumentMapping::DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
_fldCharCounter(0), AbstractOpenXmlMapping(writer), _sectionNr(0), _footnoteNr(0), _endnoteNr(0),
_commentNr(0), _caller(caller)
{
......@@ -658,7 +658,7 @@ namespace DocFileFormat
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XmlUtils::CXmlWriter OleWriter;
XMLTools::CStringXmlWriter OleWriter;
VMLPictureMapping oVmlMapper (m_context, &OleWriter, true, _caller);
if (m_document->bOlderVersion)
......
......@@ -69,7 +69,7 @@ namespace DocFileFormat
public:
DocumentMapping(ConversionContext* context, IMapping* caller);
DocumentMapping(ConversionContext* context, XmlUtils::CXmlWriter* writer, IMapping* caller);
DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller);
virtual ~DocumentMapping();
virtual void Apply( IVisitable* visited ) = 0;
......
......@@ -34,7 +34,7 @@
namespace DocFileFormat
{
FontTableMapping::FontTableMapping( ConversionContext* ctx ): AbstractOpenXmlMapping( new XmlUtils::CXmlWriter() )
FontTableMapping::FontTableMapping( ConversionContext* ctx ): AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
{
_ctx = ctx;
}
......
......@@ -35,7 +35,7 @@
namespace DocFileFormat
{
LanguageIdMapping::LanguageIdMapping (XmlUtils::CXmlWriter* pWriter, LanguageType type) : PropertiesMapping (pWriter)
LanguageIdMapping::LanguageIdMapping (XMLTools::CStringXmlWriter* pWriter, LanguageType type) : PropertiesMapping (pWriter)
{
_type = type;
}
......
......@@ -48,7 +48,7 @@ namespace DocFileFormat
class LanguageIdMapping : public PropertiesMapping, public IMapping
{
public:
LanguageIdMapping( XmlUtils::CXmlWriter* writer, LanguageType type );
LanguageIdMapping( XMLTools::CStringXmlWriter* writer, LanguageType type );
LanguageIdMapping( XMLTools::XMLElement<wchar_t>* parentElement, LanguageType type );
virtual ~LanguageIdMapping();
void Apply( IVisitable* lid );
......
......@@ -150,16 +150,6 @@ public:
//------------------------------------------------------------------------------------------------------
//ATL::CAtlFile oFile;
//if (SUCCEEDED(oFile.Create(L"d:\\blop.dat",GENERIC_WRITE, FILE_SHARE_WRITE, CREATE_ALWAYS)))
//{
// DWORD nFileBuff = 0L;
// oFile.Write (pBytes, count, &nFileBuff);
// oFile.Close();
//}
//------------------------------------------------------------------------------------------------------
if ( !isResultNeeded )
{
RELEASEARRAYOBJECTS (pBytes);
......
......@@ -34,7 +34,7 @@
namespace DocFileFormat
{
NumberingMapping::NumberingMapping(ConversionContext* context) : AbstractOpenXmlMapping(new XmlUtils::CXmlWriter()), m_context(context), m_document(NULL), m_xmldocument(NULL)
NumberingMapping::NumberingMapping(ConversionContext* context) : AbstractOpenXmlMapping(new XMLTools::CStringXmlWriter()), m_context(context), m_document(NULL), m_xmldocument(NULL)
{
if (m_context)
{
......@@ -548,7 +548,7 @@ namespace DocFileFormat
{
if (!lvl) return;
XmlUtils::CXmlWriter oWriterTemp; //Временный writer,что не нарушать последовательность записи
XMLTools::CStringXmlWriter oWriterTemp; //Временный writer,что не нарушать последовательность записи
//rPr
RevisionData rev(lvl->grpprlChpx);
CharacterPropertiesMapping cpMapping(&oWriterTemp, m_document, &rev, lvl->grpprlPapx, false);
......
......@@ -157,7 +157,7 @@ class CMetaFileBuffer
{
public:
bool m_bIsValid;
CString m_sExtension;
std::wstring m_sExtension;
private:
BYTE* m_pMetaHeader;
BYTE* m_pMetaFile;
......
......@@ -33,8 +33,8 @@
#include "ProtectionBooleanProperties.h"
#include "../IVisitable.h"
#include "../../Common/XmlTools.h"
#include "../../../Common/DocxFormat/Source/XML/xmlutils.h"
#include <list>
......
......@@ -43,7 +43,7 @@ namespace DocFileFormat
class OleObjectMapping: public AbstractOpenXmlMapping, public IMapping
{
public:
OleObjectMapping(XmlUtils::CXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const std::wstring& shapeId)
OleObjectMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const std::wstring& shapeId)
:
AbstractOpenXmlMapping(writer), m_context(NULL), _pict(NULL), _caller(NULL), _shapeId(shapeId)
{
......
......@@ -36,8 +36,6 @@
#include "WordDocument.h"
#include "IMapping.h"
#include "../../Common/DocxFormat/Source/XML/xmlutils.h"
namespace DocFileFormat
{
struct Relationship
......
......@@ -35,7 +35,7 @@
namespace DocFileFormat
{
ParagraphPropertiesMapping::ParagraphPropertiesMapping(XmlUtils::CXmlWriter* writer, ConversionContext* context, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded)
ParagraphPropertiesMapping::ParagraphPropertiesMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded)
: PropertiesMapping( writer ), m_context(NULL), _pPr(NULL), _framePr(NULL), _sepx(NULL), _paraEndChpx(NULL), _sectionNr(0),
m_document(NULL), _isParagraphStyleNeeded(isParagraphStyleNeeded)
{
......@@ -50,7 +50,7 @@ namespace DocFileFormat
_isSectionPageBreak = 0;
}
ParagraphPropertiesMapping::ParagraphPropertiesMapping( XmlUtils::CXmlWriter* writer, ConversionContext* context, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded )
ParagraphPropertiesMapping::ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* context, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded )
: PropertiesMapping( writer ), m_context(NULL), _pPr(NULL), _framePr(NULL), _sepx(NULL), _paraEndChpx(NULL), _sectionNr(0),
m_document(NULL), _isParagraphStyleNeeded(isParagraphStyleNeeded)
{
......
......@@ -46,8 +46,8 @@ namespace DocFileFormat
class ParagraphPropertiesMapping: public PropertiesMapping, public IMapping
{
public:
ParagraphPropertiesMapping( XmlUtils::CXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping( XmlUtils::CXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded = true );
virtual ~ParagraphPropertiesMapping();
void Apply(IVisitable* visited);
......
......@@ -237,7 +237,7 @@ namespace DocFileFormat
}
brcTypeMapLock.Leave();
}
PropertiesMapping::PropertiesMapping (XmlUtils::CXmlWriter* pWriter) : m_pXmlWriter(pWriter)
PropertiesMapping::PropertiesMapping (XMLTools::CStringXmlWriter* pWriter) : m_pXmlWriter(pWriter)
{
init();
}
......
......@@ -32,14 +32,13 @@
#pragma once
#include "../Common/XmlTools.h"
#include "Global.h"
#include "BorderCode.h"
#include "RGBColor.h"
#include "ShadingDescriptor.h"
#include "SinglePropertyModifier.h"
#include "../../Common/DocxFormat/Source/XML/xmlutils.h"
#include "../Win32/ASCOfficeCriticalSection.h" //for linux make inside
......@@ -48,7 +47,7 @@ namespace DocFileFormat
class PropertiesMapping
{
public:
PropertiesMapping( XmlUtils::CXmlWriter* writer );
PropertiesMapping( XMLTools::CStringXmlWriter* writer );
protected:
static void init();
......@@ -72,7 +71,7 @@ namespace DocFileFormat
protected:
XmlUtils::CXmlWriter* m_pXmlWriter;
XMLTools::CStringXmlWriter* m_pXmlWriter;
static std::map<unsigned char, std::wstring> brcTypeMap;
static ASCOfficeCriticalSection brcTypeMapLock;
......
......@@ -33,15 +33,7 @@
#include "../../DesktopEditor/common/Types.h"
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../Common/DocxFormat/Source/XML/stringcommon.h"
#include <sstream>
namespace DocFileFormat
{
......@@ -69,8 +61,9 @@ namespace DocFileFormat
// wchar_t rgbColor6[7];
// wchar_t rgbColor8[9];
CString rgbColor6;
CString rgbColor8;
//CString rgbColor6;
//CString rgbColor8;
std::wstringstream rgbColor6, rgbColor8;
if( order == RedFirst )
{
......@@ -83,11 +76,16 @@ namespace DocFileFormat
//Alpha
this->Alpha = bytes[3];
rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue );
rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha );
//rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue );
//rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha );
SixDigitHexCode = string2std_string( rgbColor6 );
EightDigitHexCode = string2std_string( rgbColor8 );
//SixDigitHexCode = string2std_string( rgbColor6 );
//EightDigitHexCode = string2std_string( rgbColor8 );
rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue;
rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue % /*A*/this->Alpha;
SixDigitHexCode = rgbColor6.str();
EightDigitHexCode = rgbColor8.str();
}
else if ( order == RedLast )
{
......@@ -100,12 +98,17 @@ namespace DocFileFormat
//Alpha
this->Alpha = bytes[3];
rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue );
rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha );
//rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue );
//rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha );
SixDigitHexCode = string2std_string( rgbColor6 );
EightDigitHexCode = string2std_string( rgbColor8 );
}
//SixDigitHexCode = string2std_string( rgbColor6 );
//EightDigitHexCode = string2std_string( rgbColor8 );
rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue;
rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue % /*A*/this->Alpha;
SixDigitHexCode = rgbColor6.str();
EightDigitHexCode = rgbColor8.str();
}
RELEASEARRAYOBJECTS( bytes );
}
......
......@@ -36,7 +36,7 @@
namespace DocFileFormat
{
// Creates a new SectionPropertiesMapping which writes the properties to the given writer
SectionPropertiesMapping::SectionPropertiesMapping (XmlUtils::CXmlWriter* pWriter, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping (pWriter)
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping (pWriter)
{
m_bDeleteNode = TRUE;
m_pXmlNode = new XMLTools::XMLElement<wchar_t> (_T("w:sectPr"));
......@@ -456,9 +456,6 @@ namespace DocFileFormat
break;
default:
#ifdef _DEBUG
// //ATLTRACE (_T("SectionPropertiesMapping - UNKNOWN SPRM : 0x%x\n"), iter->OpCode);
#endif
break;
}
}
......
......@@ -156,7 +156,7 @@ namespace DocFileFormat
{
public:
// Creates a new SectionPropertiesMapping which writes the properties to the given writer
SectionPropertiesMapping (XmlUtils::CXmlWriter* writer, ConversionContext* ctx, int nSelectProperties);
SectionPropertiesMapping (XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, int nSelectProperties);
// Creates a new SectionPropertiesMapping which appends the properties to a given node.
SectionPropertiesMapping (XMLTools::XMLElement<wchar_t>* sectPr, ConversionContext* ctx, int nSelectProperties);
virtual ~SectionPropertiesMapping();
......
......@@ -58,7 +58,7 @@ namespace DocFileFormat
{
private:
ConversionContext* _ctx;
XmlUtils::CXmlWriter m_oXmlWriter;
XMLTools::CStringXmlWriter m_oXmlWriter;
public:
SettingsMapping( ConversionContext* ctx/*, OpenXmlPart targetPart*/ );
......
......@@ -123,8 +123,6 @@ namespace DocFileFormat
rgTc80.push_back(oTC80);
}
// static int m = 0; //ATLTRACE(L"PUSH: %d\n", m); ++m;
break;
}
......
......@@ -38,7 +38,7 @@ namespace DocFileFormat
std::map<std::wstring, std::wstring> StyleSheetMapping::m_mapStyleId;
ASCOfficeCriticalSection StyleSheetMapping::m_mapStyleIdLock;
StyleSheetMapping::StyleSheetMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XmlUtils::CXmlWriter() )
StyleSheetMapping::StyleSheetMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
{
_ctx = ctx;
m_document = _ctx->_doc;
......
......@@ -35,7 +35,7 @@
namespace DocFileFormat
{
TableCellPropertiesMapping::TableCellPropertiesMapping (XmlUtils::CXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex) :
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex) :
PropertiesMapping(pWriter)
{
_width = 0;
......
......@@ -58,7 +58,7 @@ namespace DocFileFormat
public:
virtual ~TableCellPropertiesMapping();
TableCellPropertiesMapping (XmlUtils::CXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex);
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex);
virtual void Apply( IVisitable* visited );
inline int GetGridSpan() const
......
......@@ -34,7 +34,7 @@
namespace DocFileFormat
{
TablePropertiesMapping::TablePropertiesMapping (XmlUtils::CXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL),
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL),
_isTableStyleNeeded(isTableStyleNeeded)
......
......@@ -71,7 +71,7 @@ namespace DocFileFormat
class TablePropertiesMapping: public PropertiesMapping, public IMapping
{
public:
TablePropertiesMapping( XmlUtils::CXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
virtual ~TablePropertiesMapping();
void Apply( IVisitable* visited );
......
......@@ -35,7 +35,7 @@
namespace DocFileFormat
{
TableRowPropertiesMapping::TableRowPropertiesMapping (XmlUtils::CXmlWriter* pWriter, CharacterPropertyExceptions* rowEndChpx) : PropertiesMapping(pWriter), _trPr(NULL), _tblPrEx(NULL), _rowEndChpx(NULL)
TableRowPropertiesMapping::TableRowPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, CharacterPropertyExceptions* rowEndChpx) : PropertiesMapping(pWriter), _trPr(NULL), _tblPrEx(NULL), _rowEndChpx(NULL)
{
_trPr = new XMLTools::XMLElement<wchar_t>(_T( "w:trPr"));
_tblPrEx = new XMLTools::XMLElement<wchar_t>(_T( "w:tblPrEx"));
......
......@@ -51,7 +51,7 @@ namespace DocFileFormat
CharacterPropertyExceptions* _rowEndChpx;
public:
TableRowPropertiesMapping( XmlUtils::CXmlWriter* writer, CharacterPropertyExceptions* rowEndChpx );
TableRowPropertiesMapping( XMLTools::CStringXmlWriter* writer, CharacterPropertyExceptions* rowEndChpx );
virtual ~TableRowPropertiesMapping();
virtual void Apply( IVisitable* visited );
};
......
......@@ -42,7 +42,7 @@ namespace DocFileFormat
{
int TextboxMapping::TextboxCount = 0;
TextboxMapping::TextboxMapping (ConversionContext* ctx, int nTBIndex, XmlUtils::CXmlWriter* writer, IMapping* caller ): DocumentMapping( ctx, writer, caller ), m_nTBIndex(0)
TextboxMapping::TextboxMapping (ConversionContext* ctx, int nTBIndex, XMLTools::CStringXmlWriter* writer, IMapping* caller ): DocumentMapping( ctx, writer, caller ), m_nTBIndex(0)
{
TextboxCount++;
m_nTBIndex = nTBIndex;
......@@ -50,7 +50,7 @@ namespace DocFileFormat
}
TextboxMapping::TextboxMapping (ConversionContext* ctx, XmlUtils::CXmlWriter* writer, IMapping* caller) : DocumentMapping( ctx, writer, caller ), m_nTBIndex(0)
TextboxMapping::TextboxMapping (ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, IMapping* caller) : DocumentMapping( ctx, writer, caller ), m_nTBIndex(0)
{
TextboxCount++;
m_nTBIndex = TextboxCount - 1;
......@@ -91,15 +91,14 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin(_T("v:textbox"), true);
if(m_dxTextLeft >= 0 && m_dyTextTop >= 0 && m_dxTextRight >= 0 && m_dyTextBottom >= 0)
{
m_pXmlWriter->WriteAttribute( _T( "inset" ), std_string2string(
FormatUtils::DoubleToWideString(m_dxTextLeft) +
m_pXmlWriter->WriteAttribute( _T( "inset" ), FormatUtils::DoubleToWideString(m_dxTextLeft) +
_T("pt,") + FormatUtils::DoubleToWideString(m_dyTextTop) +
_T("pt,") + FormatUtils::DoubleToWideString(m_dxTextRight) +
_T("pt,") + FormatUtils::DoubleToWideString(m_dyTextBottom) + _T("pt")));
_T("pt,") + FormatUtils::DoubleToWideString(m_dyTextBottom) + _T("pt"));
}
if (!m_sTextBoxStyle.empty())
{
m_pXmlWriter->WriteAttribute( _T( "style" ), std_string2string(m_sTextBoxStyle));
m_pXmlWriter->WriteAttribute( _T( "style" ), m_sTextBoxStyle);
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
......
......@@ -40,8 +40,8 @@ namespace DocFileFormat
{
public:
TextboxMapping(ConversionContext* ctx, int textboxIndex, XmlUtils::CXmlWriter* writer, IMapping* caller);
TextboxMapping(ConversionContext* ctx, XmlUtils::CXmlWriter* writer, IMapping* caller);
TextboxMapping(ConversionContext* ctx, int textboxIndex, XMLTools::CStringXmlWriter* writer, IMapping* caller);
TextboxMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, IMapping* caller);
virtual ~TextboxMapping();
virtual void Apply(IVisitable* visited);
......
......@@ -201,7 +201,7 @@ namespace DocFileFormat
}
}
VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XmlUtils::CXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture) : PropertiesMapping(writer)
VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture) : PropertiesMapping(writer)
{
m_ctx = ctx;
m_isOlePreview = olePreview;
......
......@@ -51,7 +51,7 @@ namespace DocFileFormat
class VMLPictureMapping: public PropertiesMapping, public IMapping
{
public:
VMLPictureMapping( ConversionContext* ctx, XmlUtils::CXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture = false );
VMLPictureMapping( ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture = false );
virtual ~VMLPictureMapping();
virtual void Apply( IVisitable* visited );
std::wstring GetShapeId() const;
......
......@@ -56,9 +56,11 @@
#include "../../DesktopEditor/common/String.h"
#include "../Common/FormatUtils.h"
namespace DocFileFormat
{
VMLShapeMapping::VMLShapeMapping (ConversionContext* pConv, XmlUtils::CXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, IMapping* pCaller, bool isInlineShape) : PropertiesMapping(pWriter)
VMLShapeMapping::VMLShapeMapping (ConversionContext* pConv, XMLTools::CStringXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, IMapping* pCaller, bool isInlineShape) : PropertiesMapping(pWriter)
{
m_isInlineShape = isInlineShape;
m_isBullete = false;
......@@ -281,7 +283,7 @@ namespace DocFileFormat
std::wstring adjValues[8];
ShadowStyleBooleanProperties shadowBoolean(0);
std::vector<CString> arrInscribe;
std::vector<std::wstring> arrInscribe;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
......@@ -422,8 +424,7 @@ namespace DocFileFormat
case lineWidth:
{
EmuValue eLineWidth ((int)iter->op );
CString sWidth; sWidth.Format(_T("%fpt"), eLineWidth.ToPoints());
m_pXmlWriter->WriteAttribute(_T("strokeweight"), sWidth);
m_pXmlWriter->WriteAttribute(_T("strokeweight"), FormatUtils::DoubleToWideString(eLineWidth.ToPoints()) + _T("pt"));
}break;
case lineDashing:
{
......@@ -1304,8 +1305,6 @@ namespace DocFileFormat
top = TwipsValue((pSpa->yaBottom + pSpa->yaTop) * 0.5 - (pSpa->xaRight - pSpa->xaLeft) * 0.5);
}
// //ATLTRACE (L"left : %f, top : %f\n", left.ToPoints(), top.ToPoints());
appendStyleProperty (style, _T( "margin-left" ), ( FormatUtils::DoubleToWideString(left.ToPoints()) + std::wstring( _T( "pt" ) ) ));
appendStyleProperty (style, _T( "margin-top" ), ( FormatUtils::DoubleToWideString(top.ToPoints()) + std::wstring( _T( "pt" ) ) ));
appendStyleProperty (style, _T( "width" ), ( FormatUtils::DoubleToWideString(width.ToPoints()) + std::wstring( _T( "pt" ) ) ));
......@@ -1936,7 +1935,7 @@ namespace DocFileFormat
}
//
std::vector<CString> VMLShapeMapping::GetTextRectangles(const OptionEntry& inscribe) const
std::vector<std::wstring> VMLShapeMapping::GetTextRectangles(const OptionEntry& inscribe) const
{
MemoryStream reader(inscribe.opComplex, inscribe.op + 6);
......@@ -1944,7 +1943,7 @@ namespace DocFileFormat
unsigned short allocElems = reader.ReadUInt16();
unsigned short cb = reader.ReadUInt16();
std::vector<CString> rectangles;
std::vector<std::wstring> rectangles;
if (16 != cb) return rectangles; // TODO: доделать
......@@ -1959,9 +1958,9 @@ namespace DocFileFormat
rc.right = reader.ReadInt32();
rc.bottom = reader.ReadInt32();
CString rectangle;
rectangle.Format(L"%d,%d,%d,%d", rc.top, rc.left, rc.right, rc.bottom);
rectangles.push_back(rectangle);
std::wstringstream sstream;
sstream << boost::wformat(L"%d,%d,%d,%d") % rc.top % rc.left % rc.right % rc.bottom;
rectangles.push_back(sstream.str());
}
return rectangles;
......
......@@ -59,7 +59,7 @@ namespace DocFileFormat
{
public:
VMLShapeMapping (ConversionContext* ctx ,XmlUtils::CXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, IMapping* caller, bool bullet = false);
VMLShapeMapping (ConversionContext* ctx ,XMLTools::CStringXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, IMapping* caller, bool bullet = false);
virtual ~VMLShapeMapping();
virtual void Apply(IVisitable* visited);
......@@ -120,7 +120,7 @@ namespace DocFileFormat
std::wstring GetLineFrom (const ChildAnchor* pAnchor) const;
std::wstring GetLineTo (const ChildAnchor* pAnchor) const;
std::vector<CString> GetTextRectangles(const OptionEntry& inscribe) const;
std::vector<std::wstring> GetTextRectangles(const OptionEntry& inscribe) const;
private:
bool m_isInlineShape;
......
......@@ -36,7 +36,7 @@
namespace DocFileFormat
{
VMLShapeTypeMapping::VMLShapeTypeMapping (XmlUtils::CXmlWriter* pWriter, bool isInlineShape) : PropertiesMapping(pWriter), _lock(NULL), _isInlineShape(isInlineShape)
VMLShapeTypeMapping::VMLShapeTypeMapping (XMLTools::CStringXmlWriter* pWriter, bool isInlineShape) : PropertiesMapping(pWriter), _lock(NULL), _isInlineShape(isInlineShape)
{
this->_lock = new XMLTools::XMLElement<wchar_t>( _T( "o:lock" ) );
appendValueAttribute( this->_lock, _T( "v:ext" ), _T( "edit" ) );
......
......@@ -44,7 +44,7 @@ namespace DocFileFormat
bool _isInlineShape;
public:
VMLShapeTypeMapping(XmlUtils::CXmlWriter* writer, bool isInlineShape = false );
VMLShapeTypeMapping(XMLTools::CStringXmlWriter* writer, bool isInlineShape = false );
virtual ~VMLShapeTypeMapping();
virtual void Apply( IVisitable* visited );
/// Returns the id of the referenced type
......
......@@ -36,8 +36,9 @@
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Binary/CFStream.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Directory.h"
namespace DocFileFormat
{
......@@ -450,7 +451,7 @@ namespace DocFileFormat
{
if (m_sTempFolder.empty())
{
m_sTempFolder = FileSystem::Directory::GetTempPath().GetBuffer();
m_sTempFolder = NSFile::CFileBinary::GetTempPathW();
}
m_sTempDecryptFileName = m_sTempFolder + FILE_SEPARATOR_STR + L"~tempFile.doc";
......
......@@ -32,10 +32,8 @@
#include "WordprocessingDocument.h"
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../DesktopEditor/raster/BgraFrame.h"
#include "../../DesktopEditor/Common/Directory.h"
namespace ImageHelper
{
......@@ -184,29 +182,32 @@ namespace DocFileFormat
void WordprocessingDocument::SaveDocument()
{
OOX::CPath pathWord = CString(m_strOutputPath.c_str()) + FILE_SEPARATOR_STR + _T( "word" );
FileSystem::Directory::CreateDirectory( pathWord.GetPath() );
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + _T( "word" ) ;
//OOX::CPath pathWord = CString(m_strOutputPath.c_str()) + FILE_SEPARATOR_STR + _T( "word" );
//FileSystem::Directory::CreateDirectory( pathWord.GetPath() );
NSDirectory::CreateDirectoryW( pathWord );
WritePackage();
//Write main content. (word directory)
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T("document.xml" ) ), DocumentXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "fontTable.xml" ) ), FontTableXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "styles.xml" ) ), StyleSheetXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "footnotes.xml" ) ), FootnotesXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "endnotes.xml" ) ), EndnotesXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "numbering.xml" ) ), NumberingXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "comments.xml" ) ), CommentsXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "settings.xml" ) ), SettingsXML );
SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "customizations.xml" ) ),CommandTableXML );
SaveToFile(pathWord, std::wstring( _T("document.xml" ) ), DocumentXML );
SaveToFile(pathWord, std::wstring( _T( "fontTable.xml" ) ), FontTableXML );
SaveToFile(pathWord, std::wstring( _T( "styles.xml" ) ), StyleSheetXML );
SaveToFile(pathWord, std::wstring( _T( "footnotes.xml" ) ), FootnotesXML );
SaveToFile(pathWord, std::wstring( _T( "endnotes.xml" ) ), EndnotesXML );
SaveToFile(pathWord, std::wstring( _T( "numbering.xml" ) ), NumberingXML );
SaveToFile(pathWord, std::wstring( _T( "comments.xml" ) ), CommentsXML );
SaveToFile(pathWord, std::wstring( _T( "settings.xml" ) ), SettingsXML );
SaveToFile(pathWord, std::wstring( _T( "customizations.xml" ) ),CommandTableXML );
if (!ImagesList.empty())
{
OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T( "media" );
FileSystem::Directory::CreateDirectory( pathMedia.GetPath() );
std::wstring pathMedia = pathWord + FILE_SEPARATOR_STR + _T( "media" );
//OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T( "media" );
//FileSystem::Directory::CreateDirectory( pathMedia.GetPath() );
NSDirectory::CreateDirectoryW(pathMedia);
int i = 1;
......@@ -220,12 +221,12 @@ namespace DocFileFormat
if (Global::msoblipDIB == iter->blipType)
{//user_manual_v52.doc
std::wstring file_name = string2std_string(pathMedia.GetPath()) + FILE_SEPARATOR_STR + _T("image") + FormatUtils::IntToWideString(i++);
std::wstring file_name = pathMedia + FILE_SEPARATOR_STR + _T("image") + FormatUtils::IntToWideString(i++);
iter->blipType = ImageHelper::SaveImageToFileFromDIB(bytes, iter->data.size(), file_name);
}
else
{
SaveToFile(string2std_string(pathMedia.GetPath()), std::wstring(_T("image" )) + FormatUtils::IntToWideString(i++) + iter->ext, (void*)bytes, (unsigned int)iter->data.size());
SaveToFile(pathMedia, std::wstring(_T("image" )) + FormatUtils::IntToWideString(i++) + iter->ext, (void*)bytes, (unsigned int)iter->data.size());
}
RELEASEARRAYOBJECTS(bytes);
......@@ -235,14 +236,15 @@ namespace DocFileFormat
if (!OleObjectsList.empty())
{
OOX::CPath pathObjects = pathWord + FILE_SEPARATOR_STR + _T( "embeddings" );
FileSystem::Directory::CreateDirectory( pathObjects.GetPath());
std::wstring pathObjects = pathWord + FILE_SEPARATOR_STR + _T( "embeddings") ;
//OOX::CPath pathObjects = pathWord + FILE_SEPARATOR_STR + _T( "embeddings" );
//FileSystem::Directory::CreateDirectory( pathObjects.GetPath());
NSDirectory::CreateDirectoryW( pathObjects );
int i = 1;
for (std::list<OleObjectFileStructure>::iterator iter = OleObjectsList.begin(); iter != OleObjectsList.end(); ++iter)
{
std::wstring fileName = string2std_string(pathObjects.GetPath()) + FILE_SEPARATOR_STR + _T( "oleObject" ) + FormatUtils::IntToWideString(i++) + iter->ext;
std::wstring fileName = pathObjects + FILE_SEPARATOR_STR + _T( "oleObject" ) + FormatUtils::IntToWideString(i++) + iter->ext;
if (!iter->data.empty())
{
......@@ -260,12 +262,12 @@ namespace DocFileFormat
for (std::list<std::wstring>::iterator iter = HeaderXMLList.begin(); iter != HeaderXMLList.end(); ++iter)
{
SaveToFile(string2std_string(pathWord.GetPath()), ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString(++headersCount) + std::wstring( _T( ".xml" ) ) ), *iter);
SaveToFile(pathWord, ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString(++headersCount) + std::wstring( _T( ".xml" ) ) ), *iter);
}
for (std::list<std::wstring>::iterator iter = FooterXMLList.begin(); iter != FooterXMLList.end(); ++iter)
{
SaveToFile(string2std_string(pathWord.GetPath()), ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString(++footersCount) + std::wstring( _T( ".xml" ) ) ), *iter);
SaveToFile(pathWord, ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString(++footersCount) + std::wstring( _T( ".xml" ) ) ), *iter);
}
}
}
......@@ -32,9 +32,6 @@
#include "DocFormatLib.h"
#include "../DocDocxConverter/Converter.h"
//#include "../DocxDocConverter/FileConverter.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, ProgressCallback *ffCallBack )
......
......@@ -90,23 +90,26 @@ struct SFileIdCluster
}
};
#if !defined(_WIN32) && !defined (_WIN64)
struct POINT
{
long x;
long y;
};
struct SIZE
typedef struct tagPOINT
{
long x;
long y;
} POINT;
typedef struct tagSIZE
{
long cx;
long cy;
};
struct RECT
}SIZE;
typedef struct tagRECT
{
long left;
long top;
long right;
long bottom;
};
}RECT;
#endif
namespace Gdiplus
{
......@@ -151,7 +154,6 @@ namespace Gdiplus
short Checksum; // Checksum value for previous 10 WORDs
}WmfPlaceableFileHeader;
}
#endif
class CMetaHeader
{
......
......@@ -31,12 +31,12 @@
*/
#pragma once
#if defined(_WIN32) || defined(_WIN64)
#include <atlcoll.h>
#include <gdiplus.h>
#else
//#if defined(_WIN32) || defined(_WIN64)
// #include <atlcoll.h>
// #include <gdiplus.h>
//#else
#include "../../PPTXLib/Linux/PPTXFormatLib/linux_gdiplus.h"
#endif
//#endif
#include "Metric.h"
#include "Effects.h"
......
......@@ -30,13 +30,16 @@
*
*/
#pragma once
#include <math.h>
#if !defined(_WIN32) && !defined(_WIN64)
#include "../../../DesktopEditor/common/ASCVariant.h"
#include "../../../Common/DocxFormat/Source/Base/ASCString.h"
#else
#include <atlbase.h>
#endif
#include <math.h>
namespace NSPresentationEditor
{
const double c_dMasterUnitsToInchKoef = 1.0 / 576;
......
......@@ -36,13 +36,6 @@
#include "../../../Attributes.h"
#include "Formula.h"
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
namespace NSCustomVML
{
using namespace NSPresentationEditor;
......@@ -78,7 +71,7 @@ namespace NSCustomVML
~CSegment()
{
}
int Read(WORD value)
int Read(WORD value)//from rtf segments
{
int repeate = 0;
if (value >= 0x2000 && value < 0x20FF)
......@@ -127,7 +120,7 @@ namespace NSCustomVML
}
return (std::max)(1, repeate);
}
void Read(POLE::Stream* pStream)
void Read(POLE::Stream* pStream)//from binary ms segments
{
WORD mem = StreamUtils::ReadWORD(pStream);
BYTE type = mem & 0x07;
......@@ -222,7 +215,7 @@ namespace NSCustomVML
m_nCount = (mem >> 5) & 0x00FF;
}
void Read(NSOfficeDrawing::CBinaryReader& oReader)
void Read(NSOfficeDrawing::CBinaryReader& oReader)//from binary ms segments
{
WORD mem = oReader.ReadWORD();
......@@ -231,7 +224,6 @@ namespace NSCustomVML
{
m_eRuler = (RulesType)type;
m_nCount = (mem & 0x1FFF);
//m_nCount = (WORD)GetCountPoints2(m_eRuler);
m_nCount = (WORD)GetCountPoints2(m_eRuler, m_nCount);
return;
}
......
......@@ -47,15 +47,15 @@ namespace NSBinPptxRW
{
static std::wstring g_bstr_nodeopen = L"<";
static std::wstring g_bstr_nodeclose = L">";
static std::wstring g_bstr_nodeopen_slash = L"</";
static std::wstring g_bstr_nodeclose_slash = L"/>";
static std::wstring g_bstr_nodeopen_slash = L"</";
static std::wstring g_bstr_nodeclose_slash = L"/>";
static std::wstring g_bstr_node_space = L" ";
static std::wstring g_bstr_node_equal = L"=";
static std::wstring g_bstr_node_quote = L"\"";
static std::wstring g_bstr_boolean_true = L"true";
static std::wstring g_bstr_boolean_false = L"false";
static std::wstring g_bstr_boolean_true2 = L"1";
static std::wstring g_bstr_boolean_false2 = L"0";
static std::wstring g_bstr_boolean_false = L"false";
static std::wstring g_bstr_boolean_true2 = L"1";
static std::wstring g_bstr_boolean_false2 = L"0";
AVSINLINE static double FABS(double dVal)
{
......@@ -715,21 +715,21 @@ namespace NSBinPptxRW
m_oWriter.WriteString(g_bstr_nodeclose);
}
#ifdef _WIN32
template<typename T>
AVSINLINE void WriteArray(const CString& strName, const CAtlArray<T>& arr)
{
size_t nCount = arr.GetCount();
if (0 != nCount)
{
StartNode(strName);
m_oWriter.WriteString(g_bstr_nodeclose);
for (size_t i = 0; i < nCount; ++i)
arr[i].toXmlWriter(this);
EndNode(strName);
}
}
#endif //#ifdef _WIN32
//#ifdef _WIN32
// template<typename T>
// AVSINLINE void WriteArray(const CString& strName, const CAtlArray<T>& arr)
// {
// size_t nCount = arr.GetCount();
// if (0 != nCount)
// {
// StartNode(strName);
// m_oWriter.WriteString(g_bstr_nodeclose);
// for (size_t i = 0; i < nCount; ++i)
// arr[i].toXmlWriter(this);
// EndNode(strName);
// }
// }
//#endif //#ifdef _WIN32
template<typename T>
AVSINLINE void WriteArray(const CString& strName, const std::vector<T>& arr)
{
......@@ -744,18 +744,18 @@ namespace NSBinPptxRW
}
}
#ifdef _WIN32
template<typename T>
AVSINLINE void WriteArray2(const CAtlArray<T>& arr)
{
size_t nCount = arr.GetCount();
if (0 != nCount)
{
for (size_t i = 0; i < nCount; ++i)
arr[i].toXmlWriter(this);
}
}
#endif //#ifdef _WIN32
//#ifdef _WIN32
// template<typename T>
// AVSINLINE void WriteArray2(const CAtlArray<T>& arr)
// {
// size_t nCount = arr.GetCount();
// if (0 != nCount)
// {
// for (size_t i = 0; i < nCount; ++i)
// arr[i].toXmlWriter(this);
// }
// }
//#endif //#ifdef _WIN32
template<typename T>
AVSINLINE void WriteArray2(const std::vector<T>& arr)
{
......
......@@ -58,6 +58,18 @@
#include <dirent.h>
#endif
#ifndef FILE_SEPARATOR
#if defined(_WIN32) || defined(_WIN64)
#define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '\\'
#define FILE_SEPARATOR_STR _T("\\")
#else
#define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '/'
#define FILE_SEPARATOR_STR _T("/")
#endif
#endif
namespace NSDirectory
{
#if !defined(_WIN32) && !defined (_WIN64)
......
......@@ -902,7 +902,7 @@ namespace NExtractTools
{
COfficeDocFile docFile;
docFile.m_sTempFolder = sTemp;
long hRes = docFile.LoadFromFile( sFrom, sTo, params.m_sPassword ? *params.m_sPassword : L"", NULL);
long hRes = docFile.LoadFromFile( sFrom, sTo, params.getPassword(), NULL);
if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
......
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