Compare commits

...

111 Commits

Author SHA1 Message Date
105a23d5bc DocxRenderer (not worked) 2017-01-08 19:10:35 +03:00
ef76c80014 XlsFormat - fix errors fmt & old comments 2016-12-28 19:27:34 +03:00
bb6e95ce20 DocFormatReader - refactoring + fix errors 2016-12-27 19:32:09 +03:00
69d9823847 x2t - fix users files 2016-12-27 16:37:29 +03:00
fb10c56bd3 RtfFormatWriter - fix fields, XlsFormatReader - data valdation 2016-12-27 14:02:36 +03:00
4f24ed375e XlsFormatReader - dataValidations 2016-12-26 19:32:21 +03:00
036c3b3740 XlsFormatReader - decrypter ... 2016-12-26 15:01:48 +03:00
dddaeb3eeb previous commit bug 2016-12-26 12:04:59 +03:00
f75b0704a7 ... 2016-12-26 03:23:08 +03:00
baefae258b x2t refactoring qt projects .... 2016-12-25 23:46:39 +03:00
4f46ac6e69 .. 2016-12-25 23:23:15 +03:00
f634d1cfe5 x2t refactoring qt projects ... 2016-12-25 22:25:34 +03:00
a810253b22 opne/save drawing docPr 2016-12-24 18:00:48 +03:00
05e42b1908 write images to pdf bug 2016-12-24 15:21:37 +03:00
4ea7f5f9ed for docx background 2016-12-24 13:48:57 +03:00
50a1f3f5a7 x2t - refactoring qt projects 2016-12-23 19:54:30 +03:00
2710cabdc9 XlsFormatReader - delete unuseds, fix extended crypt, .. 2016-12-23 18:07:30 +03:00
1d55b1223c . 2016-12-23 18:06:18 +03:00
ac959e32af open/save ole object in a14 format xlsx 2016-12-23 16:00:57 +03:00
1c2524f5fb FontsGen - fix build 2016-12-23 14:38:15 +03:00
c0e4b02138 Merge tag 'v4.2.3' into develop
v4.2.3 v4.2.3
2016-12-23 14:22:08 +03:00
eb29cee9ad Merge branch 'hotfix/v4.2.3' 2016-12-23 14:22:04 +03:00
5720891452 macOS 10.11 2016-12-22 18:48:28 +03:00
96f7cd9017 . 2016-12-22 17:56:34 +03:00
c7ef8e9b1d . 2016-12-22 15:34:32 +03:00
1a2f9afac7 x2t linux build, version up 2016-12-22 15:12:06 +03:00
2c945b7166 x2t - refactoring (delete double conversions string) 2016-12-21 19:29:18 +03:00
e49deaaf64 Added dependency for HtmlFileInternal 2016-12-21 12:47:22 +03:00
3edb12499c Added UnicodeConverter dependency for AllFontGen 2016-12-20 19:46:31 +03:00
52c3f9bdb1 Added UnicodeConverter 2016-12-20 19:45:06 +03:00
1e53b26704 x2t -deleting atl relations 2016-12-20 17:55:49 +03:00
8ac5180992 DocxBin background documents ... 2016-12-20 14:24:55 +03:00
8cdf491178 DocxBin - add background document 2016-12-19 11:26:24 +03:00
c5c64cb6c2 XpsFile & DjVuFile - fix build 2016-12-16 17:26:20 +03:00
86000ee48f x2t 2.0.2.422 2016-12-16 12:33:28 +03:00
652fc292af DocFormatReader - same bugs fix 2016-12-16 12:28:17 +03:00
6e3b7b1146 thumbnail error with aspect 2016-12-16 12:17:10 +03:00
2ff5bd5910 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2016-12-16 10:57:41 +03:00
01528516dd HtmlRenderer -fix build 2016-12-16 10:56:49 +03:00
95dcf3661f Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2016-12-16 10:38:00 +03:00
717d91a192 . 2016-12-16 10:31:49 +03:00
3dd4dda2e3 DocFormatReader -ole ... 2016-12-15 18:12:41 +03:00
24dc35546f arguments to builder (JSON format) 2016-12-15 17:00:56 +03:00
fc2707f0b5 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2016-12-15 15:46:40 +03:00
ea5ebe720b DocFormatReader - another ole objects(pictureId) 2016-12-15 14:55:55 +03:00
cdead54f4a ios build converter 2016-12-15 13:36:00 +03:00
29ae0bdc38 . 2016-12-15 12:11:05 +03:00
502243103b Changed the build dependency 2016-12-15 11:41:45 +03:00
c668288308 . 2016-12-14 20:03:12 +03:00
39257334e4 x2t version up 2.0.2.401 2016-12-14 19:29:29 +03:00
48f95bd9f2 fix bug #33684 2016-12-14 19:22:00 +03:00
80d95d41c5 save to pdf (only first page support) 2016-12-14 16:56:56 +03:00
42fb658349 PdfReader/Writer linux build fix 2016-12-14 16:06:44 +03:00
d500cbc615 PdfReader/Writer windows build fix 2016-12-13 18:17:14 +03:00
470d57aec2 . 2016-12-13 17:25:02 +03:00
635a5d232a DocFormatReader - background page 2016-12-13 16:03:45 +03:00
6fa18eb20d add folders to search the system fonts 2016-12-13 10:48:48 +03:00
435bb02de3 Metfiles StarView - fix coding text (charsets) 2016-12-12 13:41:02 +03:00
a84425b49f x2t 2.0.2.420 2016-12-12 11:43:10 +03:00
250a6e5a06 OdfFormatReader - sheet/workbook views 2016-12-10 17:07:31 +03:00
82dc7ab444 OdfFormatReader - global settings for documents 2016-12-09 19:37:56 +03:00
51c8ab5499 add common method (GetFormatByExtension) 2016-12-09 18:28:33 +03:00
4176176e2b Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormat - embedded office text (against text  box)
  .
  OdfFormatReader - presentation - support convert ole objects (and other embedded)
2016-12-09 18:11:24 +03:00
34d03c743e mobile-coautoring 2016-12-09 18:11:19 +03:00
4cf55208b1 OdfFormat - embedded office text (against text box) 2016-12-09 11:42:02 +03:00
fe1d48635b . 2016-12-08 19:47:49 +03:00
db20232095 OdfFormatReader - presentation - support convert ole objects (and other embedded) 2016-12-08 19:31:26 +03:00
56ecea3ffc Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatReader - spreadsheets - support convert ole objects (and other embedded)
  CONVERT_CORRUPTED
2016-12-08 18:06:13 +03:00
59599289af utils 2016-12-08 18:06:07 +03:00
d95c93abb2 OdfFormatReader - spreadsheets - support convert ole objects (and other embedded) 2016-12-08 14:51:12 +03:00
a9076bebd2 CONVERT_CORRUPTED 2016-12-07 20:04:11 +03:00
5157908b47 coach events 2016-12-07 17:20:51 +03:00
13b7306b99 . 2016-12-06 20:07:10 +03:00
b98a545d8c OdfFormatReader - ole embedded .... 2016-12-06 20:05:17 +03:00
ceb2c7863b Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2016-12-06 15:03:45 +03:00
26cedc30fa OdfFormatReader - embedded objects (ods in odt example) 2016-12-06 14:58:58 +03:00
c0f29521c4 Merge tag 'v4.2.1' into develop
v4.2.1
2016-12-06 14:52:30 +03:00
13d57361e4 Merge branch 'hotfix/v4.2.1' 2016-12-06 14:52:20 +03:00
1e04770e31 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  DocFormatReader - fix users file
  Revert "DocFormatReader - users file fix"
  DocFormatReader - users file fix OdfFormatReader - fix alphabetic text index
  DocFormatReaer - users file fix OdfFormatReader - fix alphabetic text index
  Removed version number
2016-12-05 17:38:07 +03:00
6666ba0236 insert images in collaboration mode 2016-12-05 17:37:59 +03:00
e6c334199f DocFormatReader - fix users file 2016-12-05 15:51:49 +03:00
6d75b03cc0 . 2016-12-05 15:48:23 +03:00
303b62c2a1 DocFormatReader - fix users file 2016-12-05 15:48:04 +03:00
5109acb888 Revert "DocFormatReader - users file fix"
This reverts commit cbc4a5d334.
2016-12-05 15:46:36 +03:00
cbc4a5d334 DocFormatReader - users file fix
OdfFormatReader - fix alphabetic text index
2016-12-05 15:46:05 +03:00
a639fc9eaf Revert "Merge branch 'develop' into hotfix/v4.2.1"
This reverts commit 9cc54393a0, reversing
changes made to 29b4a10435.
2016-12-05 15:37:35 +03:00
9cc54393a0 Merge branch 'develop' into hotfix/v4.2.1 2016-12-05 15:31:00 +03:00
16386f4b5c DocFormatReaer - users file fix
OdfFormatReader - fix alphabetic text index
2016-12-05 15:17:40 +03:00
149c0ae72a Merge tag 'v4.2.0' into develop
v4.2.0 v4.2.0
2016-12-05 11:39:08 +03:00
29b4a10435 Merge branch 'release/v4.2.0' 2016-12-05 11:39:06 +03:00
1cf9401e0a Removed version number 2016-12-02 18:43:51 +03:00
c6a05e493f OdfFormatReader - .. 2016-12-01 20:06:19 +03:00
82e82971d0 Changed architecture detection for linux and macos 2016-12-01 18:00:15 +03:00
4b8c2b4f6d Update Makefile 2016-12-01 16:09:25 +03:00
a7e3158c06 Merge branch 'release/v4.2.0' into develop 2016-11-30 16:18:25 +03:00
329077caaf . 2016-11-30 14:20:09 +03:00
b75495c4ba write tableStyle without tableStyleElement 2016-11-30 12:21:01 +03:00
807eace056 . 2016-11-30 12:03:55 +03:00
cfdc8c9051 x2t version up 2.0.2.417 2016-11-29 19:39:27 +03:00
da18ecd89c OdfFormatReader - fix same small bags 2016-11-29 19:35:08 +03:00
7ae68b53db OdfFormatReader - fix same small bags 2016-11-29 16:55:22 +03:00
57bd7a0d93 for bug 33110 2016-11-29 16:46:23 +03:00
daba1ad2a3 DocFormatReader - fix bug #33397 2016-11-29 14:38:57 +03:00
755ea97af8 OdfFormatReader - fix same bugs 2016-11-28 19:20:53 +03:00
0f9669aa2b x2t version up 2.0.2.415 2016-11-28 11:07:18 +03:00
71aabb5f3f OdfFormatReader - fix bugs in track changes 2016-11-28 10:19:08 +03:00
18a963231a PPTFormatReader - shape convert fix 2016-11-27 17:09:36 +03:00
e3d6d370f7 Update Makefile 2016-11-26 11:30:39 +03:00
b06681bd97 OdfFormatReader - fix mac build, ... 2016-11-25 18:37:01 +03:00
ab4412155d Switched build sequence for the all target
It done in hope to escape double building the libraries.
2016-11-25 18:13:53 +03:00
f37394db00 OdfFormatReader - fix errors content 2016-11-24 18:29:51 +03:00
1610 changed files with 22748 additions and 22186 deletions

View File

@ -125,7 +125,7 @@ namespace DocFormatUtils
if(bDeleteNoUnicode)
{
for(size_t pos = 0; pos != data.size(); ++pos)
for(size_t pos = 0; pos < data.size(); ++pos)
{
switch(data[pos])
{
@ -157,7 +157,7 @@ namespace DocFormatUtils
}
else
{
for(size_t pos = 0; pos != data.size(); ++pos)
for(size_t pos = 0; pos < data.size(); ++pos)
{
switch(data[pos])
{
@ -166,6 +166,8 @@ namespace DocFormatUtils
case '\'': buffer.append(L"&apos;"); break;
case '<': buffer.append(L"&lt;"); break;
case '>': buffer.append(L"&gt;"); break;
case '\0':
return buffer;
default: buffer.append(&data[pos], 1); break;
}
}
@ -766,18 +768,11 @@ namespace DocFormatUtils
static inline std::wstring IntToWideString(int value)
{
#if defined(_WIN32) || defined (_WIN64)
wchar_t buff[33] ={};
_itow(value, buff, 10);
return std::wstring(buff);
#else
return (std::to_wstring(value));
#endif
}
static inline std::wstring DoubleToWideString(double value)
{
std::wstringstream src;
std::wstringstream src;
src << value;
return std::wstring(src.str());
@ -785,8 +780,7 @@ namespace DocFormatUtils
static inline std::string DoubleToString(double value)
{
std::stringstream src;
std::stringstream src;
src << value;
return std::string(src.str());
@ -813,36 +807,16 @@ namespace DocFormatUtils
static inline std::wstring IntToFormattedWideString( int value, const wchar_t* format )
{
// const int size = 33;
// wchar_t strValue[size] = L"\0";
if ( format == NULL ) return L"";
// swprintf_s( strValue, size, format, value );
//// }
// CString format_str;
// format_str.Format(format , value);
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 )
{
if ( format == NULL ) return L"";
//std::wstring wstr;
//if ( format != NULL )
//{
// CString strValue;
// strValue.Format(format, value);
// wstr = string2std_string( strValue );
//}
//return wstr;
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();

View File

@ -57,11 +57,11 @@ namespace XMLTools
class XMLAttribute
========================================================================================================*/
template <class T> class XMLAttribute
class XMLAttribute
{
private:
std::basic_string<T> m_Name;
std::basic_string<T> m_Value;
std::wstring m_Name;
std::wstring m_Value;
public:
@ -69,56 +69,40 @@ namespace XMLTools
{
}
/*========================================================================================================*/
XMLAttribute( const T* name ) : m_Name(name)
XMLAttribute( const std::wstring & name ) : m_Name(name)
{
}
/*========================================================================================================*/
XMLAttribute( const T* name, const T* value ) : m_Name(name), m_Value(value)
XMLAttribute( const std::wstring & name, const std::wstring & value ) : m_Name(name), m_Value(value)
{
}
~XMLAttribute()
{
}
/*========================================================================================================*/
~XMLAttribute()
void SetValue( const std::wstring & value )
{
m_Value = std::wstring( value );
}
/*========================================================================================================*/
void SetValue( const T* value )
{
m_Value = std::basic_string<T>( value );
}
/*========================================================================================================*/
std::basic_string<T> GetName() const
std::wstring GetName() const
{
return m_Name;
}
/*========================================================================================================*/
std::basic_string<T> GetValue() const
std::wstring GetValue() const
{
return m_Value;
}
/*========================================================================================================*/
std::basic_string<T> GetXMLString()
std::wstring GetXMLString()
{
std::basic_string<T> xmlString( L"" );
std::wstring xmlString( L"" );
xmlString += m_Name;
xmlString += std::basic_string<T>( L"=\"" );
xmlString += std::wstring( L"=\"" );
xmlString += m_Value;
xmlString += std::basic_string<T>( L"\"" );
xmlString += std::wstring( L"\"" );
return xmlString;
}
@ -128,86 +112,63 @@ namespace XMLTools
class XMLElement
========================================================================================================*/
template <class T> class XMLElement
class XMLElement
{
typedef std::pair< std::basic_string<T>, std::basic_string<T> > AttributeValuePair;
typedef std::pair< std::wstring, std::wstring> AttributeValuePair;
private:
std::basic_string<T> m_Name;
std::basic_string<T> m_ElementText;
std::map<std::basic_string<T>, std::basic_string<T>> m_AttributeMap;
std::map<std::basic_string<T>, int> m_ChildMap; //for uniq
std::list<XMLElement<T>> m_Elements;
std::wstring m_Name;
std::wstring m_ElementText;
std::map<std::wstring, std::wstring> m_AttributeMap;
std::map<std::wstring, int> m_ChildMap; //for uniq
std::list<XMLElement> m_Elements;
typedef typename std::list<XMLElement<T>>::iterator ElementsIterator;
typedef typename std::list<XMLElement<T>>::const_iterator ElementsIteratorConst;
typedef std::list<XMLElement>::iterator ElementsIterator;
typedef std::list<XMLElement>::const_iterator ElementsIteratorConst;
typedef typename std::map<std::basic_string<T>, std::basic_string<T>>::iterator AttMapIterator;
typedef typename std::map<std::basic_string<T>, std::basic_string<T>>::const_iterator AttMapIteratorConst;
typedef std::map<std::wstring, std::wstring>::iterator AttMapIterator;
typedef std::map<std::wstring, std::wstring>::const_iterator AttMapIteratorConst;
public:
XMLElement()
XMLElement() {}
XMLElement( const std::wstring & name ) : m_Name(name)
{
}
/*========================================================================================================*/
XMLElement( const T* name ) : m_Name(name)
XMLElement( const std::wstring & prefix, const std::wstring & localName ) :
m_Name( std::wstring( prefix ) + std::wstring( L":" ) + std::wstring( localName ) ), m_ElementText( L"" )
{
}
~XMLElement() {}
/*========================================================================================================*/
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"" )
void AppendText( const std::wstring & text )
{
m_ElementText = std::wstring( text );
}
/*========================================================================================================*/
~XMLElement()
void AppendTextSymbol( const wchar_t symbol )
{
m_ElementText += std::wstring( &symbol );
}
/*========================================================================================================*/
void AppendText( const T* text )
{
m_ElementText = std::basic_string<T>( text );
}
/*========================================================================================================*/
void AppendTextSymbol( const T symbol )
{
m_ElementText += std::basic_string<T>( &symbol );
}
/*========================================================================================================*/
void AppendAttribute( const XMLAttribute<T>& attribute )
void AppendAttribute( const XMLAttribute& attribute )
{
AttributeValuePair p( attribute.GetName(), attribute.GetValue() );
m_AttributeMap.insert( p );
}
/*========================================================================================================*/
void AppendAttribute( const T* name, const T* value )
void AppendAttribute( const std::wstring & name, const std::wstring & value )
{
AttributeValuePair p( std::basic_string<T>( const_cast<T*>( name ) ), std::basic_string<T>( const_cast<T*>( value ) ) );
AttributeValuePair p( name , value );
m_AttributeMap.insert( p );
}
/*========================================================================================================*/
void AppendChild( const XMLElement<T>& element, bool uniq = false)
void AppendChild( const XMLElement& element, bool uniq = false)
{
if (m_ChildMap.find(element.GetName()) != m_ChildMap.end())
{
@ -215,21 +176,17 @@ namespace XMLTools
}
else
{
m_ChildMap.insert(m_ChildMap.end(), std::pair<std::basic_string<T>, int>(element.GetName(), 0));
m_ChildMap.insert(m_ChildMap.end(), std::pair<std::wstring, int>(element.GetName(), 0));
}
m_Elements.push_back( element );
}
/*========================================================================================================*/
void RemoveChild( const XMLElement<T>& element )
void RemoveChild( const XMLElement& element )
{
m_Elements.remove( element );
}
/*========================================================================================================*/
bool FindChild( const XMLElement<T>& element )
bool FindChild( const XMLElement& element )
{
bool result = false;
@ -246,15 +203,13 @@ namespace XMLTools
return result;
}
/*========================================================================================================*/
bool FindChildByName( const T* elementName ) const
bool FindChildByName( const std::wstring & elementName ) const
{
bool result = false;
for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ )
for ( ElementsIteratorConst iter = m_Elements.begin(); iter != m_Elements.end(); iter++ )
{
if ( iter->m_Name == std::basic_string<T>( elementName ) )
if ( iter->m_Name == std::wstring( elementName ) )
{
result = true;
@ -265,9 +220,7 @@ namespace XMLTools
return result;
}
/*========================================================================================================*/
bool RemoveChildByName( const std::basic_string<T>& elementName )
bool RemoveChildByName( const std::wstring& elementName )
{
bool result = false;
@ -286,9 +239,7 @@ namespace XMLTools
return result;
}
/*========================================================================================================*/
bool operator == ( const XMLElement<T>& element ) const
bool operator == ( const XMLElement& element ) const
{
bool result = false;
@ -319,7 +270,7 @@ namespace XMLTools
}
else
{
ElementsIteratorConst thisIter = m_Elements.begin();
ElementsIteratorConst thisIter = m_Elements.begin();
ElementsIteratorConst elementIter = element.m_Elements.begin();
for ( ; thisIter != m_Elements.end(); thisIter++, elementIter++ )
@ -336,34 +287,34 @@ namespace XMLTools
/*========================================================================================================*/
std::basic_string<T> GetName() const
std::wstring GetName() const
{
return m_Name;
}
/*========================================================================================================*/
std::basic_string<T> GetXMLString()
std::wstring GetXMLString()
{
std::basic_string<T> xmlString( L"");
std::wstring xmlString( L"");
bool bIsNameExists = ( m_Name != std::basic_string<T>( L"") );
bool bIsTextExists = ( m_ElementText != std::basic_string<T>( L"") );
bool bIsNameExists = ( m_Name != std::wstring( L"") );
bool bIsTextExists = ( m_ElementText != std::wstring( L"") );
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( L"<" ) + m_Name;
xmlString += std::wstring( 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>( L" " );
xmlString += std::wstring( L" " );
xmlString += iter->first;
xmlString += std::basic_string<T>( L"=\"" );
xmlString += std::wstring( L"=\"" );
xmlString += iter->second;
xmlString += std::basic_string<T>( L"\"" );
xmlString += std::wstring( L"\"" );
}
}
@ -371,7 +322,7 @@ namespace XMLTools
{
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( L">" );
xmlString += std::wstring( L">" );
}
for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ )
@ -386,16 +337,16 @@ namespace XMLTools
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( L"</" );
xmlString += std::wstring( L"</" );
xmlString += m_Name;
xmlString += std::basic_string<T>( L">" );
xmlString += std::wstring( L">" );
}
}
else
{
if ( bIsNameExists )
{
xmlString += std::basic_string<T>( L"/>" );
xmlString += std::wstring( L"/>" );
}
}

View File

@ -38,7 +38,7 @@ namespace DocFileFormat
: PropertiesMapping( writer ), _isRunStyleNeeded(isRunStyleNeeded), _isOwnRPr(true), _isRTL(false)
{
_doc = doc;
_rPr = new XMLTools::XMLElement<wchar_t>( _T( "w:rPr" ) );
_rPr = new XMLTools::XMLElement( _T( "w:rPr" ) );
_revisionData = rev;
_currentPapx = currentPapx;
_styleChpx = styleChpx;
@ -46,7 +46,7 @@ namespace DocFileFormat
_webHidden = false;
}
CharacterPropertiesMapping::CharacterPropertiesMapping( XMLTools::XMLElement<wchar_t>* rPr, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded )
CharacterPropertiesMapping::CharacterPropertiesMapping( XMLTools::XMLElement* rPr, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded )
: PropertiesMapping( NULL ), _isRunStyleNeeded(isRunStyleNeeded), _isOwnRPr(false), _isRTL(false)
{
_doc = doc;
@ -77,7 +77,7 @@ namespace DocFileFormat
// apend revision changes
if (_revisionData->Type == Changed)
{
XMLTools::XMLElement<wchar_t> rPrChange( _T( "w:rPrChange" ) );
XMLTools::XMLElement rPrChange( _T( "w:rPrChange" ) );
//todooo date - _revisionData->Dttm.Convert( new DateMapping( rPrChange ) );
@ -85,7 +85,7 @@ namespace DocFileFormat
if (author_str)
{
XMLTools::XMLAttribute<wchar_t> author( _T( "w:author" ), FormatUtils::XmlEncode(*author_str).c_str());
XMLTools::XMLAttribute author( _T( "w:author" ), FormatUtils::XmlEncode(*author_str));
rPrChange.AppendAttribute( author );
}
@ -98,7 +98,7 @@ namespace DocFileFormat
//write properties
if ( ( m_pXmlWriter != NULL ) && ( ( _rPr->GetChildCount() > 0 ) || ( _rPr->GetAttributeCount() > 0 ) ) )
{
m_pXmlWriter->WriteString( _rPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _rPr->GetXMLString());
}
}
@ -116,16 +116,16 @@ namespace DocFileFormat
/*========================================================================================================*/
void CharacterPropertiesMapping::convertSprms( std::list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent )
void CharacterPropertiesMapping::convertSprms( std::list<SinglePropertyModifier>* sprms, XMLTools::XMLElement* parent )
{
XMLTools::XMLElement<wchar_t> * rFonts = new XMLTools::XMLElement<wchar_t> ( _T( "w:rFonts" ) );
XMLTools::XMLElement<wchar_t> * color = new XMLTools::XMLElement<wchar_t> ( _T( "w:color" ) );
XMLTools::XMLAttribute<wchar_t> * colorVal = new XMLTools::XMLAttribute<wchar_t> ( _T( "w:val" ) );
XMLTools::XMLElement<wchar_t> * lang = new XMLTools::XMLElement<wchar_t> ( _T( "w:lang" ) );
XMLTools::XMLElement * rFonts = new XMLTools::XMLElement ( _T( "w:rFonts" ) );
XMLTools::XMLElement * color = new XMLTools::XMLElement ( _T( "w:color" ) );
XMLTools::XMLAttribute * colorVal = new XMLTools::XMLAttribute ( _T( "w:val" ) );
XMLTools::XMLElement * lang = new XMLTools::XMLElement ( _T( "w:lang" ) );
if (_webHidden)
{
XMLTools::XMLElement<wchar_t> * webHidden = new XMLTools::XMLElement<wchar_t> ( _T( "w:webHidden" ) );
XMLTools::XMLElement * webHidden = new XMLTools::XMLElement ( _T( "w:webHidden" ) );
parent->AppendChild( *webHidden );
RELEASEOBJECT( webHidden );
}
@ -144,7 +144,7 @@ namespace DocFileFormat
_currentIstd = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if (_currentIstd < _doc->Styles->Styles->size())
{
appendValueElement( parent, _T( "rStyle" ), StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ).c_str(), true );
appendValueElement( parent, _T( "rStyle" ), StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ), true );
}
}
}break;
@ -232,7 +232,7 @@ namespace DocFileFormat
case sprmOldCIss:
case sprmCIss:
appendValueElement( parent, _T( "vertAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ).c_str(), true );
appendValueElement( parent, _T( "vertAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ), true );
break;
case sprmCRgLid0_80:
@ -274,7 +274,7 @@ namespace DocFileFormat
case sprmCBrc80:
case sprmCBrc:
{ //borders
XMLTools::XMLElement<wchar_t> bdr( _T( "w:bdr" ) );
XMLTools::XMLElement bdr( _T( "w:bdr" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bdr );
parent->AppendChild( bdr );
@ -292,7 +292,7 @@ namespace DocFileFormat
case sprmCIco:
case sprmCIcoBi:
{//color
colorVal->SetValue( FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ).c_str() );
colorVal->SetValue( FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ));
}break;
case sprmCCv:
@ -300,25 +300,22 @@ namespace DocFileFormat
std::wstringstream sstream;
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() );
colorVal->SetValue(sstream.str());
}break;
case sprmCOldHighlight:
{
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[1], &Global::ColorIdentifier[0][0], 17, 12 ).c_str(), true );
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[1], &Global::ColorIdentifier[0][0], 17, 12 ), true );
}break;
case sprmCHighlight:
{
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ).c_str(), true );
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ), true );
}break;
case sprmOldCDxaSpace:
case sprmCDxaSpace:
{
appendValueElement( parent, _T( "spacing" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( parent, _T( "spacing" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCFtcBi :
@ -335,20 +332,20 @@ namespace DocFileFormat
case sprmCHpsBi :
{
appendValueElement( parent, _T( "szCs" ),
FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}
break;
// Font Size in points (2~3276) default 20-half-points
case sprmOldCHps :
{
appendValueElement (parent, _T( "sz" ),
FormatUtils::IntToWideString (FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize) ).c_str(),
FormatUtils::IntToWideString (FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize) ),
true );
}break;
case sprmCHps :
{
appendValueElement (parent, _T( "sz" ),
FormatUtils::IntToWideString (FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize) ).c_str(), true );
FormatUtils::IntToWideString (FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize) ), true );
}break;
case sprmCMajority :
@ -369,7 +366,7 @@ namespace DocFileFormat
case sprmOldCHpsKern:
case sprmCHpsKern:
{
appendValueElement( parent, _T( "kern" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( parent, _T( "kern" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmOldCFtc:
@ -379,10 +376,10 @@ namespace DocFileFormat
if( nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute<wchar_t>* ascii = new XMLTools::XMLAttribute<wchar_t>( _T( "w:ascii" ) );
XMLTools::XMLAttribute* ascii = new XMLTools::XMLAttribute( _T( "w:ascii" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sAsciiFont = ffn->xszFtn;
ascii->SetValue( FormatUtils::XmlEncode(m_sAsciiFont).c_str() );
ascii->SetValue( FormatUtils::XmlEncode(m_sAsciiFont, true));
rFonts->AppendAttribute( *ascii );
RELEASEOBJECT( ascii );
}
@ -393,10 +390,10 @@ namespace DocFileFormat
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex >= 0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute<wchar_t>* eastAsia = new XMLTools::XMLAttribute<wchar_t>( _T( "w:eastAsia" ) );
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( _T( "w:eastAsia" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sEastAsiaFont = ffn->xszFtn;
eastAsia->SetValue( FormatUtils::XmlEncode(m_sEastAsiaFont).c_str() );
eastAsia->SetValue( FormatUtils::XmlEncode(m_sEastAsiaFont));
rFonts->AppendAttribute( *eastAsia );
RELEASEOBJECT( eastAsia );
}
@ -408,10 +405,10 @@ namespace DocFileFormat
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute<wchar_t>* ansi = new XMLTools::XMLAttribute<wchar_t>( _T( "w:hAnsi" ) );
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( _T( "w:hAnsi" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_shAnsiFont = ffn->xszFtn;
ansi->SetValue( FormatUtils::XmlEncode(m_shAnsiFont).c_str() );
ansi->SetValue( FormatUtils::XmlEncode(m_shAnsiFont));
rFonts->AppendAttribute( *ansi );
RELEASEOBJECT( ansi );
}
@ -420,18 +417,18 @@ namespace DocFileFormat
case sprmOldCKul:
case sprmCKul:
{ //Underlining
appendValueElement( parent, _T( "u" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::UnderlineCode[0][0], 56, 16 ).c_str(), true );
appendValueElement( parent, _T( "u" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::UnderlineCode[0][0], 56, 16 ), true );
}
break;
case sprmCCharScale:
{ //char width
appendValueElement( parent, _T( "w" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( parent, _T( "w" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCSfxText:
{ //animation
appendValueElement( parent, _T( "effect" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextAnimation[0][0], 7, 16 ).c_str(), true );
appendValueElement( parent, _T( "effect" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextAnimation[0][0], 7, 16 ), true );
}break;
case sprmCIdctHint:
@ -485,8 +482,8 @@ namespace DocFileFormat
if (!m_sDefaultFont.empty() && m_sAsciiFont.empty() && m_sEastAsiaFont.empty() && m_shAnsiFont.empty())
{//????
XMLTools::XMLAttribute<wchar_t>* ascii = new XMLTools::XMLAttribute<wchar_t>( _T( "w:ascii" ) );
ascii->SetValue( FormatUtils::XmlEncode(m_sDefaultFont).c_str() );
XMLTools::XMLAttribute* ascii = new XMLTools::XMLAttribute( _T( "w:ascii" ) );
ascii->SetValue( FormatUtils::XmlEncode(m_sDefaultFont));
//rFonts->AppendAttribute( *ascii );
RELEASEOBJECT( ascii );
}
@ -520,14 +517,14 @@ namespace DocFileFormat
/// CHPX flags are special flags because the can be 0,1,128 and 129,
/// so this method overrides the appendFlagElement method.
void CharacterPropertiesMapping::appendFlagElement( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique )
void CharacterPropertiesMapping::appendFlagElement( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique )
{
unsigned char flag = sprm.Arguments[0];
if( flag != 128 )
{
XMLTools::XMLElement<wchar_t>* ele = new XMLTools::XMLElement<wchar_t>( _T( "w" ), elementName );
XMLTools::XMLAttribute<wchar_t>* val = new XMLTools::XMLAttribute<wchar_t>( _T( "w:val" ) );
XMLTools::XMLElement* ele = new XMLTools::XMLElement( _T( "w" ), elementName );
XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( _T( "w:val" ) );
if ( unique )
{

View File

@ -55,7 +55,7 @@ namespace DocFileFormat
{
public:
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 );
CharacterPropertiesMapping( XMLTools::XMLElement* rPr, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded = true );
virtual ~CharacterPropertiesMapping();
void Apply( IVisitable* chpx );
bool CheckIsSymbolFont();
@ -63,7 +63,7 @@ namespace DocFileFormat
bool _webHidden;
bool _isRTL;
private:
void convertSprms( std::list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent );
void convertSprms( std::list<SinglePropertyModifier>* sprms, XMLTools::XMLElement* parent );
std::list<CharacterPropertyExceptions*> buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart );
bool applyToggleHierachy( const SinglePropertyModifier& sprm );
bool toogleValue( bool currentValue, unsigned char toggle );
@ -71,13 +71,13 @@ namespace DocFileFormat
protected:
/// CHPX flags are special flags because the can be 0,1,128 and 129,
/// so this method overrides the appendFlagElement method.
virtual void appendFlagElement( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique );
virtual void appendFlagElement( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique );
private:
XMLTools::CStringXmlWriter pRunPr;
WordDocument* _doc;
XMLTools::XMLElement<wchar_t>* _rPr;
XMLTools::XMLElement* _rPr;
unsigned short _currentIstd;
RevisionData* _revisionData;
bool _styleChpx;

View File

@ -73,10 +73,10 @@ namespace DocFileFormat
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
m_pXmlWriter->WriteNodeBegin( _T( "w:comment" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( index ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( index ));
m_pXmlWriter->WriteAttribute( _T( "w:author" ),
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:initials" ), atrdPre10->GetUserInitials().c_str() );
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ));
m_pXmlWriter->WriteAttribute( _T( "w:initials" ), atrdPre10->GetUserInitials());
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files

View File

@ -33,11 +33,9 @@
#if defined(_WIN32) || defined(_WIN64)
#include <tchar.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include <string>
#include "../../DesktopEditor/common/ASCVariant.h"
namespace OpenXmlContentTypes
{

View File

@ -41,7 +41,7 @@
namespace DocFileFormat
{
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller) : _skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL),
_fldCharCounter(0), AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_endnoteNr(0), _commentNr(0), _caller(caller)
{
@ -53,6 +53,10 @@ namespace DocFileFormat
_writeInstrText = false;
_isSectionPageBreak = 0;
_isTextBoxContent = false;
//--------------------------------------------
_embeddedObject = false;
_writeInstrText = false;
}
DocumentMapping::DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
@ -67,6 +71,9 @@ namespace DocFileFormat
_writeInstrText = false;
_isSectionPageBreak = 0;
_isTextBoxContent = false;
_embeddedObject = false;
_cacheListNum = -1;
}
DocumentMapping::~DocumentMapping()
@ -76,12 +83,8 @@ namespace DocFileFormat
RELEASEOBJECT(m_pXmlWriter);
}
}
}
namespace DocFileFormat
{
// Looks into the section table to find out if this CP is the end & current of a sections
int DocumentMapping::getCurrentSection(int cp)
{
//if cp is the last char of a section, the next section will start at cp +1
@ -100,6 +103,22 @@ namespace DocFileFormat
return m_document->SectionPlex->CharacterPositions[current + 1];
}
int DocumentMapping::getListNumCache(int fc, int fc_end)
{
if ( !m_document->ListPlex ) return -1;
for (int i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
{
if ((fc >= m_document->ListPlex->CharacterPositions[i-1]) && (fc_end <= m_document->ListPlex->CharacterPositions[i]))
{
ListNumCache* listNum = dynamic_cast<ListNumCache*> (m_document->ListPlex->Elements[i-1]);
return listNum->value;
}
}
return -1;
}
bool DocumentMapping::isSectionEnd(int cp)
{
bool result = false;
@ -175,8 +194,8 @@ namespace DocFileFormat
// get all CHPX between these boundaries to determine the count of runs
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd);
std::vector<int>* chpxFcs = m_document->GetFileCharacterPositions(fc, fcEnd);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd);
std::vector<int>* chpxFcs = m_document->GetFileCharacterPositions(fc, fcEnd);
CharacterPropertyExceptions* paraEndChpx = NULL;
@ -193,7 +212,7 @@ namespace DocFileFormat
// start paragraph
m_pXmlWriter->WriteNodeBegin(_T("w:p"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:p"), true);
writeParagraphRsid(papx);
// ----------- check for section properties
@ -203,8 +222,8 @@ namespace DocFileFormat
{
isBidi = currentSection->isBidi;
}
//-----------------------------------------------------------
//_cacheListNum = getListNumCache(fc, fcEnd);
_isSectionPageBreak = 0;
if (sectionEnd)
{
@ -327,14 +346,14 @@ namespace DocFileFormat
{
std::wstring id = FormatUtils::IntToFormattedWideString(FormatUtils::BytesToInt32(iter->Arguments, 0, iter->argumentsSize), _T("%08x"));
m_context->AddRsid(id);
m_pXmlWriter->WriteAttribute(_T("w:rsidP"), id.c_str());
m_pXmlWriter->WriteAttribute(_T("w:rsidP"), id);
break;
}
}
}
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
}
// Writes a run with the given characters and CHPX
@ -351,47 +370,47 @@ namespace DocFileFormat
if (Deleted == rev.Type)
{
//If it's a deleted run
m_pXmlWriter->WriteNodeBegin(_T("w:del"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:del"), true);
m_pXmlWriter->WriteAttribute(_T("w:author"), _T("[b2x: could not retrieve author]"));
m_pXmlWriter->WriteAttribute(_T("w:date"), _T("[b2x: could not retrieve date]"));
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
}
else if ( rev.Type == Inserted )
{
WideString* author = dynamic_cast<WideString*>(m_document->RevisionAuthorTable->operator[](rev.Isbt));
//if it's a inserted run
m_pXmlWriter->WriteNodeBegin(_T("w:ins"), TRUE);
m_pXmlWriter->WriteAttribute(_T("w:author"), FormatUtils::XmlEncode(*author).c_str());
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeBegin(_T("w:ins"), true);
m_pXmlWriter->WriteAttribute(_T("w:author"), FormatUtils::XmlEncode(*author));
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
//rev.Dttm.Convert(new DateMapping(m_pXmlWriter));
}
//start run
m_pXmlWriter->WriteNodeBegin(_T("w:r"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:r"), true);
//append rsids
if (0 != rev.Rsid)
{
std::wstring rsid = FormatUtils::IntToFormattedWideString(rev.Rsid, _T("%08x"));
m_pXmlWriter->WriteAttribute(_T("w:rsidR"), rsid.c_str());
m_pXmlWriter->WriteAttribute(_T("w:rsidR"), rsid);
m_context->AddRsid(rsid);
}
if (0 != rev.RsidDel)
{
std::wstring rsidDel = FormatUtils::IntToFormattedWideString(rev.RsidDel, _T("%08x"));
m_pXmlWriter->WriteAttribute(_T("w:rsidDel"), rsidDel.c_str());
m_pXmlWriter->WriteAttribute(_T("w:rsidDel"), rsidDel);
m_context->AddRsid(rsidDel);
}
if (0 != rev.RsidProp)
{
std::wstring rsidProp = FormatUtils::IntToFormattedWideString(rev.RsidProp, _T("%08x"));
m_pXmlWriter->WriteAttribute(_T("w:rsidRPr"), rsidProp.c_str());
m_pXmlWriter->WriteAttribute(_T("w:rsidRPr"), rsidProp);
m_context->AddRsid(rsidProp);
}
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
/// <w:rPr>
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &rev, _lastValidPapx, false);
@ -428,7 +447,7 @@ namespace DocFileFormat
if (!_writeAfterRun.empty())
{
m_pXmlWriter->WriteString(_writeAfterRun.c_str());
m_pXmlWriter->WriteString(_writeAfterRun);
_writeAfterRun.clear();
}
}
@ -472,9 +491,9 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement<wchar_t> elem(_T("w:tab"));
XMLTools::XMLElement elem(_T("w:tab"));
m_pXmlWriter->WriteString(elem.GetXMLString().c_str());
m_pXmlWriter->WriteString(elem.GetXMLString());
}
else if (TextMark::HardLineBreak == code)
{
@ -482,11 +501,11 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement<wchar_t> elem(_T("w:br"));
XMLTools::XMLElement elem(_T("w:br"));
elem.AppendAttribute(_T("w:type"), _T("textWrapping"));
elem.AppendAttribute(_T("w:clear"), _T("all"));
m_pXmlWriter->WriteString(elem.GetXMLString().c_str());
m_pXmlWriter->WriteString(elem.GetXMLString());
}
else if (TextMark::ParagraphEnd == code)
{
@ -501,10 +520,10 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement<wchar_t> elem(_T("w:br"));
XMLTools::XMLElement elem(_T("w:br"));
elem.AppendAttribute(_T("w:type"), _T("page"));
m_pXmlWriter->WriteString(elem.GetXMLString().c_str());
m_pXmlWriter->WriteString(elem.GetXMLString());
}
}
else if (TextMark::ColumnBreak == code)
@ -513,10 +532,10 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement<wchar_t> elem(_T("w:br"));
XMLTools::XMLElement elem(_T("w:br"));
elem.AppendAttribute(_T("w:type"), _T("column"));
m_pXmlWriter->WriteString(elem.GetXMLString().c_str());
m_pXmlWriter->WriteString(elem.GetXMLString());
}
else if (TextMark::FieldBeginMark == code)
{
@ -559,9 +578,9 @@ namespace DocFileFormat
if ( bFORM )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
@ -584,9 +603,9 @@ namespace DocFileFormat
&&
( ( bEMBED || bLINK ) && bChart) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
@ -603,9 +622,9 @@ namespace DocFileFormat
if ((search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end()) || bPAGE)
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
_writeInstrText = true;
_fldCharCounter++;
@ -633,9 +652,9 @@ namespace DocFileFormat
//if (_writeInstrText == true)
//{
// m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
// m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
// m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "separate" ) );
// m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
//}
_writeInstrText = false;
@ -643,13 +662,13 @@ namespace DocFileFormat
}
cpFieldSep1 = cpFieldSep2;
}
_skipRuns = 5;
_skipRuns = 5; //with separator
}
}
else if ( bEMBED || bLINK || bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
@ -666,31 +685,38 @@ namespace DocFileFormat
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XMLTools::CStringXmlWriter OleWriter;
VMLPictureMapping oVmlMapper (m_context, &OleWriter, true, _caller);
XMLTools::CStringXmlWriter oleWriter;
XMLTools::CStringXmlWriter oleObjectWriter;
VMLPictureMapping oVmlMapper (m_context, &oleWriter, true, _caller);
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->bOlderVersion)
{
OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion);
OleWriter.WriteNodeBegin (_T( "w:object" ), TRUE);
OleWriter.WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ).c_str() );
OleWriter.WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ).c_str() );
OleWriter.WriteNodeEnd( _T( "" ), TRUE, FALSE );
oleWriter.WriteNodeBegin (_T( "w:object" ), true);
oleWriter.WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
oleWriter.WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ));
oleWriter.WriteNodeEnd( _T( "" ), true, false );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &OleWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.GetShapeId() );
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.m_shapeId);
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
OleWriter.WriteNodeBegin (_T( "w:object" ), TRUE);
OleWriter.WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ).c_str() );
OleWriter.WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ).c_str() );
OleWriter.WriteNodeEnd( _T( "" ), TRUE, FALSE );
oleWriter.WriteNodeBegin (_T( "w:object" ), true);
oleWriter.WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
oleWriter.WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ) );
oleWriter.WriteNodeEnd( _T( "" ), true, false );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
@ -704,7 +730,7 @@ namespace DocFileFormat
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &OleWriter, m_context, &pic, _caller, oVmlMapper.GetShapeId() );
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
{
@ -713,38 +739,35 @@ namespace DocFileFormat
ole.emeddedData = oVmlMapper.m_embeddedData;
}
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
RELEASEOBJECT( chpxs );
}
}
OleWriter.WriteNodeEnd( _T( "w:object" ) );
oleWriter.WriteString( _lastOLEObject );
oleWriter.WriteNodeEnd( _T( "w:object" ) );
if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml.c_str());
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
}
else
{
m_pXmlWriter->WriteString(OleWriter.GetXmlString());
m_pXmlWriter->WriteString(oleWriter.GetXmlString());
}
}
if (bEMBED)
{
//Приложения_011015.doc(9 стр) ellipt_eq.doc конфликтные
cp = cpFieldEnd;
_skipRuns = 3;
}
else
_skipRuns = 5;
_skipRuns = 3;
_embeddedObject = true;
}
else
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
_writeInstrText = true;
_fldCharCounter++;
@ -754,20 +777,21 @@ namespace DocFileFormat
{
if (_fldCharCounter > 0)
{
XMLTools::XMLElement<wchar_t> elem( _T( "w:fldChar" ) );
XMLTools::XMLElement elem( _T( "w:fldChar" ) );
elem.AppendAttribute( _T( "w:fldCharType" ), _T( "separate" ) );
m_pXmlWriter->WriteString( elem.GetXMLString().c_str() );
m_pXmlWriter->WriteString( elem.GetXMLString() );
}
if (_embeddedObject) _skipRuns += 2;
}
else if (TextMark::FieldEndMark == code)
{
if (_fldCharCounter > 0)
{
XMLTools::XMLElement<wchar_t> elem( _T( "w:fldChar" ) );
XMLTools::XMLElement elem( _T( "w:fldChar" ) );
elem.AppendAttribute( _T( "w:fldCharType" ), _T( "end" ) );
m_pXmlWriter->WriteString( elem.GetXMLString().c_str() );
m_pXmlWriter->WriteString( elem.GetXMLString());
_fldCharCounter--;
}
@ -781,15 +805,16 @@ namespace DocFileFormat
{
_writeInstrText = false;
}
_embeddedObject = false;
}
else if ((TextMark::Symbol == code) && fSpec)
{
Symbol s = getSymbol( chpx );
m_pXmlWriter->WriteNodeBegin(_T("w:sym"), TRUE);
m_pXmlWriter->WriteAttribute(_T("w:font"), FormatUtils::XmlEncode(s.FontName).c_str());
m_pXmlWriter->WriteAttribute(_T("w:char"), FormatUtils::XmlEncode(s.HexValue).c_str());
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:sym"), true);
m_pXmlWriter->WriteAttribute(_T("w:font"), FormatUtils::XmlEncode(s.FontName));
m_pXmlWriter->WriteAttribute(_T("w:char"), FormatUtils::XmlEncode(s.HexValue));
m_pXmlWriter->WriteNodeEnd(_T(""), true);
}
else if ((TextMark::DrawnObject == code) && fSpec)
{
@ -806,20 +831,23 @@ namespace DocFileFormat
if (pSpa)
{
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if (pShape)
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
m_pXmlWriter->WriteNodeBegin (L"w:pict");
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
m_pXmlWriter->WriteNodeEnd (L"w:pict");
}
if (!pSpa->primitives.empty())
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
pSpa->primitives.Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
@ -864,7 +892,7 @@ namespace DocFileFormat
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.GetShapeId() );
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
@ -875,7 +903,7 @@ namespace DocFileFormat
else if (oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml.c_str());
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
bFormula = true;
}
@ -896,40 +924,40 @@ namespace DocFileFormat
{
if ((m_document->FootnoteReferenceCharactersPlex != NULL) && (m_document->FootnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteReference" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString(_footnoteNr++ ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteReference" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString(_footnoteNr++ ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else if ((m_document->IndividualFootnotesPlex != NULL) && (m_document->IndividualFootnotesPlex->IsCpExists(cp - m_document->FIB->m_RgLw97.ccpText)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteRef" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteRef" ), true );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else if ((m_document->EndnoteReferenceCharactersPlex != NULL) && (m_document->EndnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteReference" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString(_endnoteNr++ ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteReference" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString(_endnoteNr++ ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else if ((m_document->IndividualEndnotesPlex != NULL) &&
(m_document->IndividualEndnotesPlex->IsCpExists(cp - m_document->FIB->m_RgLw97.ccpAtn - m_document->FIB->m_RgLw97.ccpHdr - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpText)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteRef" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteRef" ), true );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
}
else if (TextMark::AnnotationReference == code)
{
if (typeid(*this) != typeid(CommentsMapping))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:commentReference" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( _commentNr ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:commentReference" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( _commentNr ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else
{
m_pXmlWriter->WriteNodeBegin( _T( "w:annotationRef" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:annotationRef" ), true );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
_commentNr++;
@ -948,7 +976,7 @@ namespace DocFileFormat
writeTextStart(textType, true/*preserve_space*/);
m_pXmlWriter->WriteString(text.c_str());
m_pXmlWriter->WriteString(text);
writeTextEnd(textType);
}
@ -965,7 +993,7 @@ namespace DocFileFormat
writeTextStart( textType, preserve_space );
m_pXmlWriter->WriteString( text.c_str() );
m_pXmlWriter->WriteString( text);
writeTextEnd( textType );
}
@ -975,19 +1003,19 @@ namespace DocFileFormat
{
std::wstring str = ( std::wstring( _T( "w:" ) ) + textType );
m_pXmlWriter->WriteNodeBegin( str.c_str(), TRUE );
m_pXmlWriter->WriteNodeBegin( str, true );
if (preserve_space)
{
m_pXmlWriter->WriteAttribute( _T( "xml:space" ), _T( "preserve" ) );
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
}
void DocumentMapping::writeTextEnd(const std::wstring& textType)
{
std::wstring str = ( std::wstring( _T( "w:" ) ) + textType );
m_pXmlWriter->WriteNodeEnd( str.c_str() );
m_pXmlWriter->WriteNodeEnd( str );
}
// Searches for bookmarks in the list of characters.
@ -1542,12 +1570,12 @@ namespace DocFileFormat
if ((bookmarkName != NULL) && (*bookmarkName != _T("_PictureBullets")))
{
XMLTools::XMLElement<wchar_t> bookmarkElem(_T("w:bookmarkStart"));
XMLTools::XMLElement bookmarkElem(_T("w:bookmarkStart"));
bookmarkElem.AppendAttribute(_T("w:id"), FormatUtils::IntToWideString(id).c_str());
bookmarkElem.AppendAttribute(_T("w:name"), bookmarkName->c_str());
bookmarkElem.AppendAttribute(_T("w:id"), FormatUtils::IntToWideString(id));
bookmarkElem.AppendAttribute(_T("w:name"), *bookmarkName);
m_pXmlWriter->WriteString(bookmarkElem.GetXMLString().c_str());
m_pXmlWriter->WriteString(bookmarkElem.GetXMLString());
return true;
}
@ -1563,11 +1591,11 @@ namespace DocFileFormat
if ( ( bookmarkName != NULL ) && ( *bookmarkName != _T( "_PictureBullets" ) ) )
{
XMLTools::XMLElement<wchar_t> bookmarkElem( _T( "w:bookmarkEnd" ) );
XMLTools::XMLElement bookmarkElem( _T( "w:bookmarkEnd" ) );
bookmarkElem.AppendAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ).c_str() );
bookmarkElem.AppendAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ));
m_pXmlWriter->WriteString( bookmarkElem.GetXMLString().c_str() );
m_pXmlWriter->WriteString( bookmarkElem.GetXMLString());
return true;
}

View File

@ -70,73 +70,76 @@ namespace DocFileFormat
public:
DocumentMapping(ConversionContext* context, IMapping* caller);
DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller);
virtual ~DocumentMapping();
virtual void Apply( IVisitable* visited ) = 0;
//--------------------------------- 4571833.doc
std::wstring m_shapeIdOwner;
std::wstring getOLEObject() { return _lastOLEObject; }
protected:
/// Looks into the section table to find out if this CP is the current of a section
int getCurrentSection(int cp);
/// Looks into the section table to find out if this CP is the end of a section
bool isSectionEnd( int cp );
/// Writes a Paragraph that starts at the given cp and
/// ends at the next paragraph end mark or section end mark
int getListNumCache (int fc, int fc_end);
int getCurrentSection (int cp);
//---------------------------------
bool isSectionEnd ( int cp );
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int writeParagraph( int cp );
/// Writes a Paragraph that starts at the given cpStart and
/// ends at the given cpEnd
// Writes a Paragraph that starts at the given cpStart and
// ends at the given cpEnd
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false );
/// Writes a Paragraph RSID
// Writes a Paragraph RSID
void writeParagraphRsid( const ParagraphPropertyExceptions* papx );
/// Writes a run with the given characters and CHPX
// Writes a run with the given characters and CHPX
int writeRun( std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
/// Writes the given text to the document
// Writes the given text to the document
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeTextElement ( const std::wstring& text, const std::wstring& textType );
void writeTextStart ( const std::wstring& textType, bool preserve_space);
void writeTextEnd ( const std::wstring& textType );
int writeText( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeTextElement( const std::wstring& text, const std::wstring& textType );
void writeTextStart( const std::wstring& textType, bool preserve_space);
void writeTextEnd( const std::wstring& textType );
/// Searches for bookmarks in the list of characters.
// Searches for bookmarks in the list of characters.
std::vector<int> searchBookmarks( std::vector<wchar_t>* chars, int initialCp );
ParagraphPropertyExceptions* findValidPapx( int fc );
/// Splits a list of characters into several lists
// Splits a list of characters into several lists
std::list<std::vector<wchar_t> >* splitCharList( std::vector<wchar_t>* chars, std::vector<int>* splitIndices );
/// Writes the table starts at the given cp value
int writeTable( int initialCp, unsigned int nestingLevel );
/// Builds a list that contains the width of the several columns of the table.
// Writes the table starts at the given cp value
int writeTable ( int initialCp, unsigned int nestingLevel );
// Builds a list that contains the width of the several columns of the table.
std::vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
/// Finds the FC of the next row end mark.
int findRowEndFc( int initialCp, int& rowEndCp, unsigned int nestingLevel );
/// Finds the FC of the next row end mark.
int findRowEndFc( int initialCp, unsigned int nestingLevel );
/// Writes the table row that starts at the given cp value and ends at the next row end mark
int writeTableRow( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp( int initialCp, unsigned int nestingLevel );
bool writeBookmarks( int cp );
bool writeBookmarkStart( short id );
bool writeBookmarkEnd( short id );
/// Checks if the CHPX is special
// Finds the FC of the next row end mark.
int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel );
// Finds the FC of the next row end mark.
int findRowEndFc ( int initialCp, unsigned int nestingLevel );
// Writes the table row that starts at the given cp value and ends at the next row end mark
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
bool writeBookmarks ( int cp );
bool writeBookmarkStart ( short id );
bool writeBookmarkEnd ( short id );
// Checks if the CHPX is special
bool isSpecial( CharacterPropertyExceptions* chpx );
/// Finds the SEPX that is valid for the given CP.
// Finds the SEPX that is valid for the given CP.
SectionPropertyExceptions* findValidSepx( int cp );
/// Searches the given vector for the next FieldEnd character.
// Searches the given vector for the next FieldEnd character.
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
private:
Symbol getSymbol( const CharacterPropertyExceptions* chpx );
Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
//----------------------------------------------------------------------------------------------------------------------
bool m_bInternalXmlWriter;
protected:
WordDocument* m_document;
ConversionContext* m_context;
IMapping* _caller;
ParagraphPropertyExceptions* _lastValidPapx;
SectionPropertyExceptions* _lastValidSepx;
bool _embeddedObject;
int _skipRuns;
int _sectionNr;
int _footnoteNr;
@ -148,5 +151,7 @@ namespace DocFileFormat
bool _writeWebHidden;
unsigned int _fldCharCounter;
std::wstring _writeAfterRun;
std::wstring _lastOLEObject;
int _cacheListNum;
};
}

View File

@ -43,7 +43,8 @@ namespace DocFileFormat
/*========================================================================================================*/
WordDocumentProperties::WordDocumentProperties(FileInformationBlock* fib, POLE::Stream* tableStream) : doptypography(NULL), dogrid(NULL), asumyi(NULL)
WordDocumentProperties::WordDocumentProperties(FileInformationBlock* fib, POLE::Stream* tableStream) :
doptypography(NULL), dogrid(NULL), asumyi(NULL), bDisplayBackgroundShape(false)
{
Initialize();
@ -226,7 +227,7 @@ namespace DocFileFormat
dywDispPag = FormatUtils::BytesToInt16( bytes, 498, size );
//WORD 2000, 2002, 2003 PART
if ( size > 500 )
if ( size > 500/* && fib->m_FibNew.nFibNew > Fib1997*/)
{
ilvlLastBulletMain = bytes[500];
ilvlLastNumberMain = bytes[501];
@ -266,138 +267,158 @@ namespace DocFileFormat
fDntULTrlSpc = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 14 );
fDntBlnSbDbWid = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 15 );
fSuppressTopSpacingMac5 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 16 );
fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 17 );
fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 18 );
fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 19 );
fMakeSpaceForUL = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 20 );
fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 21 );
f2ptExtLeadingOnly = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 22 );
fTruncFontHeight = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 23 );
fSubOnSize = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 24 );
fLineWrapLikeWord6 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 25 );
fWW6BorderRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 26 );
fExactOnTop = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 27 );
fExtraAfter = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 28 );
fWPSpace = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 29 );
fWPJust = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 30 );
fPrintMet = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 31 );
fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 17 );
fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 18 );
fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 19 );
fMakeSpaceForUL = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 20 );
fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 21 );
f2ptExtLeadingOnly = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 22 );
fTruncFontHeight = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 23 );
fSubOnSize = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 24 );
fLineWrapLikeWord6 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 25 );
fWW6BorderRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 26 );
fExactOnTop = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 27 );
fExtraAfter = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 28 );
fWPSpace = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 29 );
fWPJust = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 30 );
fPrintMet = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 31 );
//split bytes 512,513,514,515 into bits
fSpLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 0 );
fFtnLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 1 );
fDontUseHTMLParagraphAutoSpacing = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 2 );
fDontAdjustLineHeightInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 3 );
fForgetLastTabAlign = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 4 );
fUseAutoSpaceForFullWidthAlpha = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 5 );
fAlignTablesRowByRow = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 6 );
fLayoutRawTableWidth = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 7 );
fLayoutTableRowsApart = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 8 );
fUserWord97LineBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 9 );
fDontBreakWrappedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 10 );
fDontSnapToGridInCell = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 11 );
fDontAllowFieldEndSelect = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 12 );
fApplyBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 13 );
fDontWrapTextWithPunct = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 14 );
fDontUseAsianBreakRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 15 );
fUseWord2002TableStyleRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 16 );
fGrowAutofit = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 17 );
fUseNormalStyleForList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 18 );
fDontUseIndentAsNumberingTabStop = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 19 );
fFELineBreak11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 20 );
fAllowSpaceOfSameStyleInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 21 );
fWW11IndentRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 22 );
fDontAutofitConstrainedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 23 );
fAutofitLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 24 );
fUnderlineTabInNumList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 25 );
fHangulWidthLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 26 );
fSplitPgBreakAndParaMark = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 27 );
fDontVertAlignCellWithSp = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 28 );
fDontBreakConstrainedForcedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 29 );
fDontVertAlignInTxbx = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 30 );
fWord11KerningPairs = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 31 );
fCachedColBalance = FormatUtils::GetBitFromBytes( ( bytes + 516 ), 4, 0 );
//split bytes 512,513,514,515 into bits
fSpLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 0 );
fFtnLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 1 );
fDontUseHTMLParagraphAutoSpacing = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 2 );
fDontAdjustLineHeightInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 3 );
fForgetLastTabAlign = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 4 );
fUseAutoSpaceForFullWidthAlpha = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 5 );
fAlignTablesRowByRow = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 6 );
fLayoutRawTableWidth = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 7 );
fLayoutTableRowsApart = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 8 );
fUserWord97LineBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 9 );
fDontBreakWrappedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 10 );
fDontSnapToGridInCell = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 11 );
fDontAllowFieldEndSelect = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 12 );
fApplyBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 13 );
fDontWrapTextWithPunct = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 14 );
fDontUseAsianBreakRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 15 );
fUseWord2002TableStyleRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 16 );
fGrowAutofit = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 17 );
fUseNormalStyleForList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 18 );
fDontUseIndentAsNumberingTabStop = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 19 );
fFELineBreak11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 20 );
fAllowSpaceOfSameStyleInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 21 );
fWW11IndentRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 22 );
fDontAutofitConstrainedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 23 );
fAutofitLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 24 );
fUnderlineTabInNumList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 25 );
fHangulWidthLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 26 );
fSplitPgBreakAndParaMark = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 27 );
fDontVertAlignCellWithSp = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 28 );
fDontBreakConstrainedForcedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 29 );
fDontVertAlignInTxbx = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 30 );
fWord11KerningPairs = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 31 );
fCachedColBalance = FormatUtils::GetBitFromBytes( ( bytes + 516 ), 4, 0 );
//bytes 517-539 are unused
//bytes 517-539 are unused
verCompatPreW10 = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 540 ), 4, 0, 16 );
fNoMargPgvwSaved = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 16 );
fNoMargPgvWPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 17 );
fWebViewPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 18 );
fSeeDrawingsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 19 );
fBulletProofed = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 20 );
fCorrupted = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 21 );
fSaveUim = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 22 );
fFilterPrivacy = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 23 );
fInFReplaceNoRM = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 24 );
fSeenRepairs = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 25 );
fHasXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 26 );
fSeeScriptAnchorsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 27 );
fValidateXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 28 );
fSaveIfInvalidXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 29 );
fShowXMLErrors = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 30 );
fAlwaysMergeEmptyNamespace = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 31 );
verCompatPreW10 = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 540 ), 4, 0, 16 );
fNoMargPgvwSaved = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 16 );
fNoMargPgvWPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 17 );
fWebViewPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 18 );
fSeeDrawingsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 19 );
fBulletProofed = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 20 );
fCorrupted = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 21 );
fSaveUim = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 22 );
fFilterPrivacy = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 23 );
fInFReplaceNoRM = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 24 );
fSeenRepairs = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 25 );
fHasXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 26 );
fSeeScriptAnchorsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 27 );
fValidateXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 28 );
fSaveIfInvalidXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 29 );
fShowXMLErrors = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 30 );
fAlwaysMergeEmptyNamespace = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 31 );
if ( size > 544/* && fib->m_FibNew.nFibNew > Fib2000*/)
{
cpMaxListCacheMainDoc = FormatUtils::BytesToInt32( bytes, 544, size ); //unused
cpMaxListCacheMainDoc = FormatUtils::BytesToInt32( bytes, 544, size );
//split bytes 548,549 into bits
fDoNotEmbedSystemFont = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 0 );
fWordCompact = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 1 );
fLiveRecover = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 2 );
fEmbedFactoids = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 3 );
fFactoidXML = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 4 );
fFactoidAllDone = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 5 );
fFolioPrint = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 6 );
fReverseFolio = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 7 );
iTextLineEnding = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 548 ), 2, 8, 3 );
fHideFcc = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 11 );
fAcetateShowMarkup = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 12 );
fAcetateShowAtn = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 13 );
fAcetateShowInsDel = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 14 );
fAcetateShowProps = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 15 );
//split bytes 548,549 into bits
fDoNotEmbedSystemFont = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 0 );
fWordCompact = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 1 );
fLiveRecover = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 2 );
fEmbedFactoids = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 3 );
fFactoidXML = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 4 );
fFactoidAllDone = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 5 );
fFolioPrint = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 6 );
fReverseFolio = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 7 );
iTextLineEnding = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 548 ), 2, 8, 3 );
fHideFcc = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 11 );
fAcetateShowMarkup = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 12 );
fAcetateShowAtn = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 13 );
fAcetateShowInsDel = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 14 );
fAcetateShowProps = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 15 );
istdTableDflt = FormatUtils::BytesToUInt16( bytes, 550, size );
verCompat = FormatUtils::BytesToUInt16( bytes, 552, size );
grfFmtFilter = FormatUtils::BytesToUInt16( bytes, 554, size );
iFolioPages = FormatUtils::BytesToInt16 ( bytes, 556, size );
cpgText = FormatUtils::BytesToUInt16( bytes, 558, size );
cpMinRMText = FormatUtils::BytesToInt32 ( bytes, 560, size );
cpMinRMFtn = FormatUtils::BytesToInt32 ( bytes, 564, size );
cpMinRMHdd = FormatUtils::BytesToInt32 ( bytes, 568, size );
cpMinRMAtn = FormatUtils::BytesToInt32 ( bytes, 572, size );
cpMinRMEdn = FormatUtils::BytesToInt32 ( bytes, 576, size );
cpMinRMTxbx = FormatUtils::BytesToInt32 ( bytes, 580, size );
cpMinRMHdrTxbx = FormatUtils::BytesToInt32 ( bytes, 584, size );
rsidRoot = FormatUtils::BytesToInt32 ( bytes, 588, size );
//unused 2
istdTableDflt = FormatUtils::BytesToUInt16( bytes, 550, size );
verCompat = FormatUtils::BytesToUInt16( bytes, 552, size );
grfFmtFilter = FormatUtils::BytesToUInt16( bytes, 554, size );
iFolioPages = FormatUtils::BytesToInt16( bytes, 556, size );
cpgText = FormatUtils::BytesToUInt16( bytes, 558, size );
cpMinRMText = FormatUtils::BytesToInt32( bytes, 560, size );
cpMinRMFtn = FormatUtils::BytesToInt32( bytes, 564, size );
cpMinRMHdd = FormatUtils::BytesToInt32( bytes, 568, size );
cpMinRMAtn = FormatUtils::BytesToInt32( bytes, 572, size );
cpMinRMEdn = FormatUtils::BytesToInt32( bytes, 576, size );
cpMinRMTxbx = FormatUtils::BytesToInt32( bytes, 580, size );
cpMinRMHdrTxbx = FormatUtils::BytesToInt32( bytes, 584, size );
rsidRoot = FormatUtils::BytesToInt32( bytes, 588, size );
if ( size > 594/* && fib->m_FibNew.nFibNew > Fib2002*/)
{
//split bytes 592,593,594,595 into bits
fTreatLockAtnAsReadOnly = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 0 );
fStyleLock = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 1 );
fAutoFmtOverride = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 2 );
fRemoveWordML = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 3 );
fApplyCustomXForm = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 4 );
fStyeLockEnforced = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 5 );
fFakeLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 6 );
fIgnoreMixedContent = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 7 );
fShowPlaceholderText = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 8 );
grf = FormatUtils::GetUIntFromBytesBits( ( bytes + 592 ), 4, 9, 23 );
if ( size == 610 )
{
//split bytes 592,593,594,595 into bits
fTreatLockAtnAsReadOnly = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 0 );
fStyleLock = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 1 );
fAutoFmtOverride = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 2 );
fRemoveWordML = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 3 );
fApplyCustomXForm = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 4 );
fStyeLockEnforced = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 5 );
fFakeLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 6 );
fIgnoreMixedContent = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 7 );
fShowPlaceholderText = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 8 );
grf = FormatUtils::GetUIntFromBytesBits( ( bytes + 592 ), 4, 9, 23 );
//split bytes 596 and 597 into bits
fReadingModeInkLockDown = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 0 );
fAcetateShowInkAtn = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 1 );
fFilterDttm = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 2 );
fEnforceDocProt = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 3 );
iDocProtCur = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 596 ), 2, 4, 3 );
fDispBkSpSaved = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 7 );
//split bytes 596 and 597 into bits
fReadingModeInkLockDown = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 0 );
fAcetateShowInkAtn = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 1 );
fFilterDttm = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 2 );
fEnforceDocProt = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 3 );
iDocProtCur = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 596 ), 2, 4, 3 );
fDispBkSpSaved = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 7 );
dxaPageLock = FormatUtils::BytesToInt16( bytes, 598, size );
dyaPageLock = FormatUtils::BytesToInt16( bytes, 600, size );
pctFontLock = FormatUtils::BytesToInt32( bytes, 602, size );
grfitbid = bytes[606];
//unsigned char 607 is unused
ilfoMacAtCleanup = FormatUtils::BytesToUInt16( bytes, 608, size );
}
dxaPageLock = FormatUtils::BytesToInt16( bytes, 598, size );
dyaPageLock = FormatUtils::BytesToInt16( bytes, 600, size );
pctFontLock = FormatUtils::BytesToInt32( bytes, 602, size );
grfitbid = bytes[606];
//unsigned char 607 is unused
ilfoMacAtCleanup = FormatUtils::BytesToUInt16( bytes, 608, size );
if ( size > 616/* && fib->m_FibNew.nFibNew > Fib2003*/)
{
//4 bytes reserved
bool fRMTrackFormatting = FormatUtils::GetBitFromBytes( ( bytes + 620 ), 2, 0 );
bool fRMTrackMoves = FormatUtils::GetBitFromBytes( ( bytes + 620 ), 2, 1 );
//dopMth = 34 bytes from 624 = 658
if ( size > 674/* && fib->m_FibNew.nFibNew > Fib2007*/)
{
if ( size > 690/* && fib->m_FibNew.nFibNew > Fib2010*/)
{
}
}
}
}
}
}
}
}

View File

@ -54,6 +54,7 @@ namespace DocFileFormat
friend class SettingsMapping;
bool bDisplayBackgroundShape;
private:
// True when facing pages should be printed
bool fFacingPages;

View File

@ -70,7 +70,7 @@ namespace DocFileFormat
while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr + m_document->FIB->m_RgLw97.ccpAtn + m_document->FIB->m_RgLw97.ccpEdn - 2 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnote" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
while ( ( cp - m_document->FIB->m_RgLw97.ccpText - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpHdr - m_document->FIB->m_RgLw97.ccpAtn ) < (*m_document->IndividualEndnotesPlex)[id + 1] )

View File

@ -49,39 +49,46 @@ namespace DocFileFormat
unsigned char fNested:1;
unsigned char fHasSep:1;
};
public:
static const int STRUCTURE_SIZE = 2;
FieldCharacter():
fldch(0), grffld(0)
{
}
virtual ~FieldCharacter()
{
}
FieldCharacter() : fldch(0), grffld(0) {}
virtual ~FieldCharacter() {}
virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length)
{
FieldCharacter* pFldChar = new FieldCharacter();
FieldCharacter* pFldChar = new FieldCharacter();
if (pFldChar)
{
pFldChar->fldch = pReader->ReadByte();
pFldChar->grffld = pReader->ReadByte();
#ifdef _DEBUG
grffldEnd* __grffldEnd = (grffldEnd*)(&pFldChar->grffld);
int dbg = 0;
#endif
pFldChar->fldch = pReader->ReadByte();
pFldChar->grffld = pReader->ReadByte();
}
return static_cast<ByteStructure*>(pFldChar);
}
private:
unsigned char fldch;
unsigned char grffld;
};
class ListNumCache: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 4;
ListNumCache() : value(-1) {}
virtual ~ListNumCache() {}
virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length)
{
ListNumCache* pList = new ListNumCache();
if (pList)
{
pList->value = pReader->ReadInt32();
}
return static_cast<ByteStructure*>(pList);
}
int value;
};
}

View File

@ -1162,6 +1162,8 @@ namespace DocFileFormat
{
//Read the FibRgCswNew
m_FibNew.nFibNew = (FibVersion)reader.ReadUInt16();
if (m_FibNew.nFibNew == 0) m_FibNew.nFibNew = Fib1997;
m_FibNew.cQuickSavesNew = reader.ReadUInt16();
}
}

View File

@ -59,34 +59,39 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "xmlns:w" ), OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
int sz_fonts = table->Data.size();
int sz_fonts = table->Data.size();
int users_fonts = 0;
for ( std::vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
m_pXmlWriter->WriteNodeBegin( _T( "w:font" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:name" ), FormatUtils::XmlEncode(font->xszFtn, true).c_str());
std::wstring name_ = FormatUtils::XmlEncode(font->xszFtn, true);
if (name_.empty())
name_ = L"UserFont_" + std::to_wstring(++users_fonts);
m_pXmlWriter->WriteAttribute( _T( "w:name" ), name_);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
//alternative name
if ( ( font->xszAlt != std::wstring( _T( "" ) ) ) && ( font->xszAlt.length() > 0 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:altName" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt, true).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt, true));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:altName" ) );
}
//charset
m_pXmlWriter->WriteNodeBegin( _T("w:charset" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( font->chs, _T( "%02x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( font->chs, _T( "%02x" ) ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:charset" ) );
//font family
m_pXmlWriter->WriteNodeBegin( _T("w:family"), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->ff, &FontFamily[0][0], 6, 11 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->ff, &FontFamily[0][0], 6, 11 ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:family" ) );
@ -100,13 +105,13 @@ namespace DocFileFormat
wstr += FormatUtils::IntToFormattedWideString( font->panose[i], _T( "%02x" ) );
}
m_pXmlWriter->WriteAttribute( _T( "w:val" ), wstr.c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), wstr);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:panose1" ) );
//pitch
m_pXmlWriter->WriteNodeBegin( _T("w:pitch"), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->prq, &FontPitch[0][0], 3, 9 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->prq, &FontPitch[0][0], 3, 9 ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:pitch" ) );
@ -121,12 +126,12 @@ namespace DocFileFormat
//font signature
m_pXmlWriter->WriteNodeBegin( _T("w:sig"), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:usb0" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield0, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb1" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield1, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb2" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield2, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb3" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield3, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:csb0" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield0, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:csb1" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield1, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb0" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield0, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:usb1" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield1, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:usb2" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield2, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:usb3" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield3, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:csb0" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield0, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:csb1" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield1, _T( "%08x" ) ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:sig" ) );

View File

@ -77,9 +77,14 @@ namespace DocFileFormat
{
//this PAPX is for a table
//cp = writeTable( cp, tai.iTap );
int start_table_cp = cp;
Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) );
table.Convert( this );
cp = table.GetCPEnd();
if (cp == start_table_cp)
cp++;
}
else
{

View File

@ -70,7 +70,7 @@ namespace DocFileFormat
while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn - 2 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:footnote" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
while ( ( cp - m_document->FIB->m_RgLw97.ccpText ) < (*m_document->IndividualFootnotesPlex)[id + 1] )

View File

@ -40,7 +40,7 @@ namespace DocFileFormat
_type = type;
}
LanguageIdMapping::LanguageIdMapping (XMLTools::XMLElement<wchar_t>* parentElement, LanguageType type) : PropertiesMapping(NULL)
LanguageIdMapping::LanguageIdMapping (XMLTools::XMLElement* parentElement, LanguageType type) : PropertiesMapping(NULL)
{
_parent = parentElement;
_type = type;
@ -59,31 +59,31 @@ namespace DocFileFormat
{
std::wstring langcode = getLanguageCode( dynamic_cast<LanguageId*>( lid ) );
XMLTools::XMLAttribute<wchar_t>* att = NULL;
XMLTools::XMLAttribute* att = NULL;
switch ( _type )
{
case Default:
{
att = new XMLTools::XMLAttribute<wchar_t>( L"w:val", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:val", langcode);
}
break;
case EastAsian:
{
att = new XMLTools::XMLAttribute<wchar_t>( L"w:eastAsia", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:eastAsia", langcode);
}
break;
case Complex:
{
att = new XMLTools::XMLAttribute<wchar_t>( L"w:bidi", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:bidi", langcode);
}
break;
default:
{
att = new XMLTools::XMLAttribute<wchar_t>( L"w:val", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:val", langcode);
}
break;
}
@ -91,7 +91,7 @@ namespace DocFileFormat
if (m_pXmlWriter)
{
// !!!TODO!!!
m_pXmlWriter->WriteString( att->GetXMLString().c_str() );
m_pXmlWriter->WriteString( att->GetXMLString());
}
else if ( _parent != NULL )
{

View File

@ -49,14 +49,14 @@ namespace DocFileFormat
{
public:
LanguageIdMapping( XMLTools::CStringXmlWriter* writer, LanguageType type );
LanguageIdMapping( XMLTools::XMLElement<wchar_t>* parentElement, LanguageType type );
LanguageIdMapping( XMLTools::XMLElement* parentElement, LanguageType type );
virtual ~LanguageIdMapping();
void Apply( IVisitable* lid );
static std::wstring getLanguageCode( LanguageId* lid );
private:
LanguageType _type;
XMLTools::XMLElement<wchar_t>* _parent;
LanguageType _type;
XMLTools::XMLElement* _parent;
};
}

View File

@ -53,33 +53,47 @@ namespace DocFileFormat
m_context->_docx->RegisterDocument();
// Header
m_pXmlWriter->WriteNodeBegin(_T("?xml version=\"1.0\" encoding=\"UTF-8\"?"));
m_pXmlWriter->WriteNodeBegin(_T("w:document"), TRUE );
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );
// Namespaces
m_pXmlWriter->WriteAttribute(_T("xmlns:w"), OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(_T("xmlns:v"), OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(_T("xmlns:o"), OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(_T("xmlns:w10"), OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(_T("xmlns:r"), OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(_T("xmlns:m"), _T("http://schemas.openxmlformats.org/officeDocument/2006/math"));
m_pXmlWriter->WriteAttribute(L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(L"xmlns:v", OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math");
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpc"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:mc"), _T("http://schemas.openxmlformats.org/markup-compatibility/2006"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wp14"),_T("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wp"), _T("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:w14"), _T("http://schemas.microsoft.com/office/word/2010/wordml"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpg"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpi"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingInk"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wne"), _T("http://schemas.microsoft.com/office/word/2006/wordml"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wps"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingShape"));
//m_pXmlWriter->WriteAttribute(_T("mc:Ignorable"), _T("w14 wp14"));
//m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
//m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
//m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
//m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 wp14");
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( _T("w:body"), FALSE );
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
m_document->DocProperties->bDisplayBackgroundShape = true;
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeBackgound();
// Convert the document
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
}
m_pXmlWriter->WriteNodeBegin( L"w:body", FALSE );
// Convert the document
_lastValidPapx = NULL;
if (m_document->AllPapxFkps->empty() == false)
{
@ -175,8 +189,8 @@ namespace DocFileFormat
}
}
m_pXmlWriter->WriteNodeEnd( _T( "w:body" ) );
m_pXmlWriter->WriteNodeEnd( _T( "w:document" ) );
m_pXmlWriter->WriteNodeEnd( L"w:body" );
m_pXmlWriter->WriteNodeEnd( L"w:document" );
m_context->_docx->DocumentXML = std::wstring(m_pXmlWriter->GetXmlString());
}

View File

@ -83,12 +83,12 @@ namespace DocFileFormat
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( _T( "w:abstractNum" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:abstractNumId" ), FormatUtils::IntToWideString( i ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:abstractNumId" ), FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
//nsid
m_pXmlWriter->WriteNodeBegin( _T( "w:nsid" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( (*iter)->lsid, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( (*iter)->lsid, _T( "%08x" ) ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
//multiLevelType
@ -111,7 +111,7 @@ namespace DocFileFormat
//template
m_pXmlWriter->WriteNodeBegin( _T( "w:tmpl" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( (*iter)->tplc, _T( "%08x" ) ).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( (*iter)->tplc, _T( "%08x" ) ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// writes the levels
@ -131,12 +131,12 @@ namespace DocFileFormat
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( _T( "w:abstractNum" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:abstractNumId" ), FormatUtils::IntToWideString( i ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:abstractNumId" ), FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
////nsid
//m_pXmlWriter->WriteNodeBegin( _T( "w:nsid" ), TRUE );
//m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( (*iter)->lsid, _T( "%08x" ) ).c_str() );
//m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( (*iter)->lsid, _T( "%08x" ) ));
//m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
//multiLevelType
@ -160,26 +160,26 @@ namespace DocFileFormat
//start num
m_pXmlWriter->WriteNodeBegin( _T( "w:num" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:numId" ), FormatUtils::IntToWideString(i + 1).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:numId" ), FormatUtils::IntToWideString(i + 1));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
int index = FindIndexbyId( rglst->listData, lfo->lsid );
m_pXmlWriter->WriteNodeBegin( _T( "w:abstractNumId" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( index ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( index ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
for (std::vector<ListFormatOverrideLevel*>::const_iterator iter = lfo->rgLfoLvl.begin(); iter != lfo->rgLfoLvl.end(); ++iter)
{
m_pXmlWriter->WriteNodeBegin( _T( "w:lvlOverride" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:ilvl" ), FormatUtils::IntToWideString( (*iter)->ilvl ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:ilvl" ), FormatUtils::IntToWideString( (*iter)->ilvl ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
if ( ( (*iter)->fStartAt ) && ( !(*iter)->fFormatting ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:startOverride" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( (*iter)->iStartAt ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( (*iter)->iStartAt ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
@ -197,12 +197,12 @@ namespace DocFileFormat
for (std::list<NumberingDescriptor>::iterator iter = rglst->listNumbering.begin(); iter != rglst->listNumbering.end(); ++iter, ++i)
{
m_pXmlWriter->WriteNodeBegin( _T( "w:num" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:numId" ), FormatUtils::IntToWideString(i+1).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:numId" ), FormatUtils::IntToWideString(i+1));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( _T( "w:abstractNumId" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( i ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd(_T( "w:num"));
@ -255,8 +255,10 @@ namespace DocFileFormat
if (!FormatUtils::IsControlSymbol(xchBullet))
{
ret.push_back(lvl->xst[0]);
ret.push_back(L'\0');
ret.push_back(lvl->xst[0]);//??? xchBullet
}
else
{
}
}
}
@ -487,20 +489,20 @@ namespace DocFileFormat
//--------------------------------------------------------------------------------
m_pXmlWriter->WriteNodeBegin( _T( "w:lvl" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:ilvl" ), FormatUtils::IntToWideString(level).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:ilvl" ), FormatUtils::IntToWideString(level));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( _T( "w:start" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString(lvl.iStartAt).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString(lvl.iStartAt));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:numFmt" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), GetNumberFormatWideString(lvl.nfc, true).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), GetNumberFormatWideString(lvl.nfc, true));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
//// suffix
// m_pXmlWriter->WriteNodeBegin( _T( "w:suff" ), TRUE );
// m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl.ixchFollow, &FollowingCharMap[0][0], 3, 8).c_str());
// m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl.ixchFollow, &FollowingCharMap[0][0], 3, 8));
// m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// Number level text
@ -516,13 +518,13 @@ namespace DocFileFormat
if (!lvlText.empty())
{
m_pXmlWriter->WriteNodeBegin(_T("w:lvlText"), TRUE);
m_pXmlWriter->WriteAttribute(_T("w:val"), lvlText.c_str());
m_pXmlWriter->WriteAttribute(_T("w:val"), lvlText);
m_pXmlWriter->WriteNodeEnd(_T( ""), TRUE);
}
// jc
m_pXmlWriter->WriteNodeBegin( _T( "w:lvlJc" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl.jc, &LevelJustificationMap[0][0], 3, 7).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl.jc, &LevelJustificationMap[0][0], 3, 7));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// pPr
m_pXmlWriter->WriteNodeBegin( _T( "w:pPr" ), FALSE );
@ -535,8 +537,8 @@ namespace DocFileFormat
{
m_pXmlWriter->WriteNodeBegin( _T( "w:rFonts" ), TRUE );
// w:hint="default"
m_pXmlWriter->WriteAttribute(_T("w:hAnsi"), fontFamily.c_str());
m_pXmlWriter->WriteAttribute(_T("w:ascii"), fontFamily.c_str());
m_pXmlWriter->WriteAttribute(_T("w:hAnsi"), fontFamily);
m_pXmlWriter->WriteAttribute(_T("w:ascii"), fontFamily);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
m_pXmlWriter->WriteNodeEnd(_T("w:rPr"));
@ -557,25 +559,25 @@ namespace DocFileFormat
// Проверяем шрифт
m_pXmlWriter->WriteNodeBegin( _T( "w:lvl" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:ilvl" ), FormatUtils::IntToWideString(level).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:ilvl" ), FormatUtils::IntToWideString(level));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
// starts at
m_pXmlWriter->WriteNodeBegin( _T( "w:start" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString(lvl->iStartAt).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString(lvl->iStartAt));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// number format
m_pXmlWriter->WriteNodeBegin( _T( "w:numFmt" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), GetNumberFormatWideString(lvl->nfc).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), GetNumberFormatWideString(lvl->nfc));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// suffix
m_pXmlWriter->WriteNodeBegin( _T( "w:suff" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl->ixchFollow, &FollowingCharMap[0][0], 3, 8).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl->ixchFollow, &FollowingCharMap[0][0], 3, 8));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// style
@ -585,14 +587,14 @@ namespace DocFileFormat
if (styleIndex != ListData::ISTD_NIL)
{
m_pXmlWriter->WriteNodeBegin( _T( "w:pStyle" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId(m_document->Styles->Styles->at(styleIndex))).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId(m_document->Styles->Styles->at(styleIndex))));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
// Number level text
m_pXmlWriter->WriteNodeBegin(_T("w:lvlText"), TRUE);
m_pXmlWriter->WriteAttribute(_T("w:val"), GetLvlText(lvl, cpMapping.CheckIsSymbolFont()).c_str());
m_pXmlWriter->WriteAttribute(_T("w:val"), GetLvlText(lvl, cpMapping.CheckIsSymbolFont()));
m_pXmlWriter->WriteNodeEnd(_T( ""), TRUE);
WriteLevelPictureBullet(lvl->grpprlChpx);
@ -606,7 +608,7 @@ namespace DocFileFormat
}
// jc
m_pXmlWriter->WriteNodeBegin( _T( "w:lvlJc" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl->jc, &LevelJustificationMap[0][0], 3, 7).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString(lvl->jc, &LevelJustificationMap[0][0], 3, 7));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// pPr
bool isBidi = false;
@ -638,7 +640,7 @@ namespace DocFileFormat
if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:numPicBullet" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:numPicBulletId" ), FormatUtils::IntToWideString( iter->first ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:numPicBulletId" ), FormatUtils::IntToWideString( iter->first ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( _T( "w:pict" ) );
@ -670,7 +672,7 @@ namespace DocFileFormat
{
if (grpprlChpx)
{
unsigned int cp = 0;
unsigned int index = 0;
bool isPictureBullet = false;
for (std::list<SinglePropertyModifier>::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter)
@ -679,7 +681,7 @@ namespace DocFileFormat
{
case sprmCPbiIBullet:
{
cp = FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize);
index = FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize);
}break;
case sprmCPbiGrf:
@ -692,7 +694,7 @@ namespace DocFileFormat
if (isPictureBullet)
{
m_pXmlWriter->WriteNodeBegin(_T("w:lvlPicBulletId"), TRUE);
m_pXmlWriter->WriteAttribute(_T("w:val"), FormatUtils::IntToWideString(cp).c_str());
m_pXmlWriter->WriteAttribute(_T("w:val"), FormatUtils::IntToWideString(index));
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE);
}
}

View File

@ -34,6 +34,7 @@
#include "OfficeDrawing/RecordFactory.h"
#include "OfficeDrawing/DrawingContainer.h"
#include "OfficeDrawing/DrawingRecord.h"
#include "OfficeDrawing/DrawingGroup.h"
#include "OfficeDrawing/GroupContainer.h"
#include "OfficeDrawing/Shape.h"
@ -57,7 +58,7 @@ namespace DocFileFormat
public:
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL)
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL)
{
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion);
@ -87,15 +88,23 @@ namespace DocFileFormat
{
// the child is a subgroup
GroupContainer* group = static_cast<GroupContainer*>(groupChild);
group->Index = i;
drawing.container->Children[i] = group;
if (group)
{
group->Index = i;
}
}
else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode)
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
shape->Index = i;
drawing.container->Children[i] = shape;
if (shape)
{
shape->Index = i;
if (shape->isBackground())
{
m_pBackgroud = shape;
}
}
}
}
}
@ -112,7 +121,10 @@ namespace DocFileFormat
for ( std::list<OfficeArtWordDrawing>::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter)
RELEASEOBJECT(iter->container);
}
inline ShapeContainer* GetShapeBackgound()
{
return m_pBackgroud;
}
inline ShapeContainer* GetShapeContainer (int spid)
{
ShapeContainer* ret = NULL;
@ -138,7 +150,6 @@ namespace DocFileFormat
if (shape->GetShapeID() == spid)
{
ret = container;
break;
}
}
@ -150,7 +161,7 @@ namespace DocFileFormat
if (shape->GetShapeID() == spid)
{
ret = container;
ret = container;
break;
}
}
@ -174,7 +185,7 @@ namespace DocFileFormat
}
private:
ShapeContainer* m_pBackgroud;
DrawingGroup* m_pDrawingGroupData;
std::list<OfficeArtWordDrawing> m_arrDrawings;
};

View File

@ -39,11 +39,9 @@ namespace DocFileFormat
{
public:
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
/// The number of shapes in this drawing
unsigned int csp;
/// The last MSOSPID given to an SP in this DG
int spidCur;
unsigned int csp; // The number of shapes in this drawing
int spidCur; // The last MSOSPID given to an SP in this DG
DrawingRecord():
Record(), csp(0), spidCur(0)
@ -53,8 +51,8 @@ namespace DocFileFormat
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
this->csp = this->Reader->ReadUInt32();
this->spidCur = this->Reader->ReadInt32();
csp = Reader->ReadUInt32();
spidCur = Reader->ReadInt32();
}
virtual ~DrawingRecord()

View File

@ -93,29 +93,23 @@ namespace DocFileFormat
{
case ShapeContainer::TYPE_CODE_0xF004:
return new ShapeContainer();
break;
case Shape::TYPE_CODE_0xF00A:
return new Shape();
break;
case ShapeOptions::TYPE_CODE_0xF00B:
case ShapeOptions::TYPE_CODE_0xF121:
case ShapeOptions::TYPE_CODE_0xF122:
return new ShapeOptions();
break;
case ClientAnchor::TYPE_CODE_0xF010:
return new ClientAnchor();
break;
case ChildAnchor::TYPE_CODE_0xF00F:
return new ChildAnchor();
break;
case BlipStoreEntry::TYPE_CODE_0xF007:
return new BlipStoreEntry();
break;
case BitmapBlip::TYPE_CODE_0xF01D: //OfficeArtBlipJPEG
case BitmapBlip::TYPE_CODE_0xF01E: //OfficeArtBlipPNG
@ -125,25 +119,25 @@ namespace DocFileFormat
case BitmapBlip::TYPE_CODE_0xF029: //OfficeArtBlipTIFF
case BitmapBlip::TYPE_CODE_0xF02A: //OfficeArtBlipJPEG
return new BitmapBlip();
break;
case MetafilePictBlip::TYPE_CODE_0xF01A: //OfficeArtBlipEMF
case MetafilePictBlip::TYPE_CODE_0xF01B: //OfficeArtBlipWMF
case MetafilePictBlip::TYPE_CODE_0xF01C : //OfficeArtBlipPICT
return new MetafilePictBlip(); break;
return new MetafilePictBlip();
case DrawingGroup::TYPE_CODE_0xF000 : return new DrawingGroup(); break;
case DrawingGroupRecord::TYPE_CODE_0xF006 : return new DrawingGroupRecord(); break;
case BlipStoreContainer::TYPE_CODE_0xF001 : return new BlipStoreContainer(); break;
case SplitMenuColorContainer::TYPE_CODE_0xF11E : return new SplitMenuColorContainer(); break;
case ClientData::TYPE_CODE_0xF011 : return new ClientData(); break;
case DrawingContainer::TYPE_CODE_0xF002 : return new DrawingContainer(); break;
case DrawingRecord::TYPE_CODE_0xF008 : return new DrawingRecord(); break;
case GroupContainer::TYPE_CODE_0xF003 : return new GroupContainer(); break;
case GroupShapeRecord::TYPE_CODE_0xF009 : return new GroupShapeRecord (); break;
case OfficeArtClientTextbox::TYPE_CODE_0xF00D : return new OfficeArtClientTextbox (); break;
case DrawingGroup::TYPE_CODE_0xF000 : return new DrawingGroup();
case DrawingGroupRecord::TYPE_CODE_0xF006 : return new DrawingGroupRecord();
case BlipStoreContainer::TYPE_CODE_0xF001 : return new BlipStoreContainer();
case SplitMenuColorContainer::TYPE_CODE_0xF11E : return new SplitMenuColorContainer();
case ClientData::TYPE_CODE_0xF011 : return new ClientData();
case DrawingContainer::TYPE_CODE_0xF002 : return new DrawingContainer();
case DrawingRecord::TYPE_CODE_0xF008 : return new DrawingRecord();
case GroupContainer::TYPE_CODE_0xF003 : return new GroupContainer();
case GroupShapeRecord::TYPE_CODE_0xF009 : return new GroupShapeRecord ();
case OfficeArtClientTextbox::TYPE_CODE_0xF00D : return new OfficeArtClientTextbox ();
default: return new UnknownRecord(); break;
default:
return new UnknownRecord();
}
}
}

View File

@ -39,33 +39,20 @@ namespace DocFileFormat
class Shape: public Record
{
public:
int spid;
/// This shape is a group shape
bool fGroup;
/// Not a top-level shape
bool fChild;
/// This is the topmost group shape.
/// Exactly one of these per drawing.
bool fPatriarch;
/// The shape has been deleted
bool fDeleted;
/// The shape is an OLE object
bool fOleShape;
/// Shape has a hspMaster property
bool fHaveMaster;
/// Shape is flipped horizontally
bool fFlipH;
/// Shape is flipped vertically
bool fFlipV;
/// Connector type of shape
bool fConnector;
/// Shape has an anchor of some kind
bool fHaveAnchor;
/// Background shape
bool fBackground;
/// Shape has a shape type property
bool fHaveSpt;
/// The shape type of the shape
int spid;
bool fGroup;
bool fChild;
bool fPatriarch; // This is the topmost group shape. Exactly one of these per drawing.
bool fDeleted; // The shape has been deleted
bool fOleShape; // The shape is an OLE object
bool fHaveMaster;
bool fFlipH;
bool fFlipV;
bool fConnector;
bool fHaveAnchor;
bool fBackground;
bool fHaveSpt;
ShapeType* shapeType;
public:
@ -80,7 +67,7 @@ namespace DocFileFormat
virtual ~Shape()
{
RELEASEOBJECT( this->shapeType );
RELEASEOBJECT( shapeType );
}
Shape( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
@ -120,12 +107,12 @@ namespace DocFileFormat
inline int GetShapeID() const
{
return this->spid;
return spid;
}
inline ShapeType* GetShapeType() const
{
return this->shapeType;
return shapeType;
}
template<class T> bool is() const

View File

@ -69,7 +69,34 @@ namespace DocFileFormat
}
return 0;
}
bool isBackground()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fBackground;
}
}
return false;
}
bool isOLE()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fOleShape;
}
}
return false;
}
virtual ~ShapeContainer()
{
}
@ -79,7 +106,6 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
/// Searches all OptionEntry in the ShapeContainer and puts them into a list.
std::list<OptionEntry> ExtractOptions() const
{
std::list<OptionEntry> ret;

View File

@ -0,0 +1,303 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "OleObject.h"
namespace DocFileFormat
{
OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ )
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_), isEquation(false), isEmbedded (false)
{
if (!docStorage) return;
if (!chpx) return;
oleStorage = docStorage->GetStorage();
if (!oleStorage) return;
HRESULT res = S_OK;
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, "ObjectPool");
if (ObjectPoolStorage)
{
ObjectId = getOleEntryName( chpx );
std::string sObjectId( ObjectId.begin(), ObjectId.end() );
{
std::string name = "ObjectPool/" + sObjectId + "/";
processOleStream( name + "Ole" );
if ( bLinked )
{
processLinkInfoStream( name + "LinkInfo" );
}
else
{
processCompObjStream( name + "CompObj" );
}
processPICStream( name + "PIC" );
processEquationNativeStream( name + "Equation Native" );
}
delete ObjectPoolStorage;
}
}
void OleObject::processLinkInfoStream( const std::string& linkStream )
{
try
{
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
pLinkStream = //oleStorage->stream(linkStream);
new POLE::Stream(oleStorage, linkStream);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
//there are two versions of the Link string, one contains ANSI characters, the other contains
//unicode characters.
//Both strings seem not to be standardized:
//The length prefix is a character count EXCLUDING the terminating zero
//Read the ANSI version
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string
//even if the characters are ANSI chars, the terminating zero has 2 bytes
reader.ReadBytes( 2, false );
//skip the next 4 bytes (flags?)
reader.ReadBytes( 4, false );
//Read the Unicode version
this->Link.clear();
cch = reader.ReadInt16();
str = reader.ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the Unicode string
reader.ReadBytes( 2, false );
delete pLinkStream;
}
}
catch (...)
{
}
}
void OleObject::processEquationNativeStream( const std::string& eqStream )
{
try
{
POLE::Stream* pCompStream = NULL;
HRESULT res = S_OK;
pCompStream = new POLE::Stream(oleStorage, eqStream);
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
int sz = reader.GetSize();
unsigned char *Buffer = reader.ReadBytes( sz, true );
if (Buffer && sz > 0)
{
isEquation = true;
delete []Buffer;
}
delete pCompStream;
}
}
catch (...)
{
}
}
void OleObject::processPICStream( const std::string& picStream )
{
try
{
HRESULT res = S_OK;
POLE::Stream* pPICStream = new POLE::Stream(oleStorage, picStream);
if ( pPICStream )
{
VirtualStreamReader reader( pPICStream, 0, false);
int sz = reader.GetSize();
int cbHeader = reader.ReadUInt32();
reader.ReadBytes(4, false);
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
reader.ReadBytes(20, false);
pictureDesciptor.mx = reader.ReadUInt32();
pictureDesciptor.my = reader.ReadUInt32();
}
}
catch (...)
{
}
}
void OleObject::processCompObjStream( const std::string& compStream )
{
try
{
HRESULT res = S_OK;
POLE::Stream* pCompStream = new POLE::Stream(oleStorage, compStream);
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
//skip the CompObjHeader
reader.ReadBytes( 28, false );
int sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
{
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
}
delete pCompStream;
}
}
catch (...)
{
}
}
void OleObject::processOleStream( const std::string& oleStreamName )
{
try
{
POLE::Stream* pOleStream;
HRESULT res = S_OK;
pOleStream = new POLE::Stream(oleStorage, oleStreamName);
if ( pOleStream )
{
VirtualStreamReader reader( pOleStream, 0, false );
//skip version
reader.ReadBytes( 4, false );
//read the embedded/linked flag
int flag = reader.ReadInt32();
bLinked = FormatUtils::BitmaskToBool( flag, 0x1 );
//Link update option
this->updateMode = (LinkUpdateOption)reader.ReadInt32();
switch ( this->updateMode )
{
case NoLink:
{
this->UpdateMode = L"NoLink";
}
break;
case Always:
{
this->UpdateMode = L"Always";
}
break;
case OnCall:
{
this->UpdateMode = L"OnCall";
}
break;
}
delete pOleStream;
}
}
catch (...)
{
}
}
std::wstring OleObject::getOleEntryName( const CharacterPropertyExceptions* chpx )
{
std::wstring ret;
if ( chpx != NULL )
{
for ( std::list<SinglePropertyModifier>::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{
if ( iter->OpCode == sprmCPicLocation || iter->OpCode == sprmOldCPicLocation)
{
ret = ( L"_" + FormatUtils::IntToWideString( FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
}
}
}
return ret;
}
}

View File

@ -68,276 +68,18 @@ namespace DocFileFormat
PictureDescriptor pictureDesciptor;
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ )
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_)
{
isEquation = isEmbedded = false;
oleStorage = docStorage->GetStorage();
if ( ( chpx != NULL ) && ( docStorage != NULL ) )
{
HRESULT res = S_OK;
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, "ObjectPool");
if (ObjectPoolStorage)
{
ObjectId = getOleEntryName( chpx );
std::string sObjectId( ObjectId.begin(), ObjectId.end() );
{
std::string name = "ObjectPool/" + sObjectId + "/";
processOleStream( name + "Ole" );
if ( bLinked )
{
processLinkInfoStream( name + "LinkInfo" );
}
else
{
processCompObjStream( name + "CompObj" );
}
processPICStream( name + "PIC" );
processEquationNativeStream( name + "Equation Native" );
}
delete ObjectPoolStorage;
}
}
}
virtual ~OleObject()
{
}
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ );
virtual ~OleObject() {}
private:
POLE::Storage *oleStorage;
void processLinkInfoStream( const std::string& linkStream )
{
try
{
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
void processLinkInfoStream ( const std::string& linkStream );
void processEquationNativeStream( const std::string& eqStream );
void processPICStream ( const std::string& picStream );
void processCompObjStream ( const std::string& compStream );
void processOleStream ( const std::string& oleStreamName );
pLinkStream = //oleStorage->stream(linkStream);
new POLE::Stream(oleStorage, linkStream);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
//there are two versions of the Link string, one contains ANSI characters, the other contains
//unicode characters.
//Both strings seem not to be standardized:
//The length prefix is a character count EXCLUDING the terminating zero
//Read the ANSI version
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string
//even if the characters are ANSI chars, the terminating zero has 2 bytes
reader.ReadBytes( 2, false );
//skip the next 4 bytes (flags?)
reader.ReadBytes( 4, false );
//Read the Unicode version
this->Link.clear();
cch = reader.ReadInt16();
str = reader.ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the Unicode string
reader.ReadBytes( 2, false );
delete pLinkStream;
}
}
catch (...)
{
}
}
void processEquationNativeStream( const std::string& eqStream )
{
try
{
POLE::Stream* pCompStream = NULL;
HRESULT res = S_OK;
pCompStream = new POLE::Stream(oleStorage, eqStream);
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
int sz = reader.GetSize();
unsigned char *Buffer = reader.ReadBytes( sz, true );
if (Buffer && sz > 0)
{
isEquation = true;
delete []Buffer;
}
delete pCompStream;
}
}
catch (...)
{
}
}
void processPICStream( const std::string& picStream )
{
try
{
HRESULT res = S_OK;
POLE::Stream* pPICStream = new POLE::Stream(oleStorage, picStream);
if ( pPICStream )
{
VirtualStreamReader reader( pPICStream, 0, false);
int sz = reader.GetSize();
int cbHeader = reader.ReadUInt32();
reader.ReadBytes(4, false);
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
reader.ReadBytes(20, false);
pictureDesciptor.mx = reader.ReadUInt32();
pictureDesciptor.my = reader.ReadUInt32();
}
}
catch (...)
{
}
}
void processCompObjStream( const std::string& compStream )
{
try
{
HRESULT res = S_OK;
POLE::Stream* pCompStream = new POLE::Stream(oleStorage, compStream);
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
//skip the CompObjHeader
reader.ReadBytes( 28, false );
int sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
{
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
}
delete pCompStream;
}
}
catch (...)
{
}
}
void processOleStream( const std::string& oleStreamName )
{
try
{
POLE::Stream* pOleStream;
HRESULT res = S_OK;
pOleStream = new POLE::Stream(oleStorage, oleStreamName);
if ( pOleStream )
{
VirtualStreamReader reader( pOleStream, 0, false );
//skip version
reader.ReadBytes( 4, false );
//read the embedded/linked flag
int flag = reader.ReadInt32();
bLinked = FormatUtils::BitmaskToBool( flag, 0x1 );
//Link update option
this->updateMode = (LinkUpdateOption)reader.ReadInt32();
switch ( this->updateMode )
{
case NoLink:
{
this->UpdateMode = _T( "NoLink" );
}
break;
case Always:
{
this->UpdateMode = _T( "Always" );
}
break;
case OnCall:
{
this->UpdateMode = _T( "OnCall" );
}
break;
}
delete pOleStream;
}
}
catch (...)
{
}
}
std::wstring getOleEntryName( const CharacterPropertyExceptions* chpx )
{
std::wstring ret;
if ( chpx != NULL )
{
for ( std::list<SinglePropertyModifier>::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{
if ( iter->OpCode == sprmCPicLocation || iter->OpCode == sprmOldCPicLocation)
{
ret = ( _T( "_" ) + FormatUtils::IntToWideString( FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
}
}
}
return ret;
}
};
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
};
}

View File

@ -67,14 +67,13 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeBegin( _T( "o:OLEObject" ), TRUE );
//type
if ( ole->bLinked )
{
int relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ));
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Link" ) );
m_pXmlWriter->WriteAttribute( _T( "UpdateMode" ), ole->UpdateMode.c_str() );
m_pXmlWriter->WriteAttribute( _T( "UpdateMode" ), ole->UpdateMode);
}
else
{
@ -85,25 +84,16 @@ namespace DocFileFormat
else
relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat);
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ));
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) );
//copy the object
copyEmbeddedObject( ole );
}
//ProgID
m_pXmlWriter->WriteAttribute( _T( "ProgID" ), ole->Program.c_str() );
//ShapeId
m_pXmlWriter->WriteAttribute( _T( "ShapeID" ), _shapeId.c_str() );
//DrawAspect
m_pXmlWriter->WriteAttribute( _T( "ProgID" ), ole->Program);
m_pXmlWriter->WriteAttribute( _T( "ShapeID" ), _shapeId);
m_pXmlWriter->WriteAttribute( _T( "DrawAspect" ), _T( "Content" ) );
//ObjectID
m_pXmlWriter->WriteAttribute( _T( "ObjectID" ), ole->ObjectId.c_str() );
m_pXmlWriter->WriteAttribute( _T( "ObjectID" ), ole->ObjectId);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "o:OLEObject" ) );
@ -165,20 +155,15 @@ namespace DocFileFormat
}
private:
// Writes the embedded OLE object from the ObjectPool of the binary file to the OpenXml Package.
inline void copyEmbeddedObject( const OleObject* ole )
{
if ( ole != NULL )
{
//!!!TODO: There is issue with some Office OLE Objects. Word can't open *.xls object (Excel.Chart) with set CLSID and
//some Power Point Presentations, and Word Documents. Open Office CAN start this objects!!!
std::wstring clsid;
std::wstring exelChart = _T( "Excel.Chart" );
if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() )
{//??
{
clsid = ole->ClassId;
}
OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid);

View File

@ -224,7 +224,7 @@ namespace DocFileFormat
{
HeaderRelationshipsFiles.push_back( RelationshipsFile( ( std::wstring( _T( "word/_rels/header" ) ) + FormatUtils::IntToWideString( ++_headerCounter ) + std::wstring( _T( ".xml.rels" ) ) ) ) );
return AddPart( _T( "word" ), ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString( _headerCounter ) + std::wstring( _T( ".xml" ) ) ).c_str(), WordprocessingMLContentTypes::Header, OpenXmlRelationshipTypes::Header );
return AddPart( _T( "word" ), ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString( _headerCounter ) + std::wstring( _T( ".xml" ) ) ), WordprocessingMLContentTypes::Header, OpenXmlRelationshipTypes::Header );
}
int OpenXmlPackage::AddHeaderPart( const std::wstring& fileName, const std::wstring& relationshipType, const std::wstring& targetMode )
@ -245,7 +245,7 @@ namespace DocFileFormat
{
FooterRelationshipsFiles.push_back( RelationshipsFile( ( std::wstring( _T( "word/_rels/footer" ) ) + FormatUtils::IntToWideString( ++_footerCounter ) + std::wstring( _T( ".xml.rels" ) ) ) ) );
return AddPart( _T( "word" ), ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString( _footerCounter ) + std::wstring( _T( ".xml" ) ) ).c_str(), WordprocessingMLContentTypes::Footer, OpenXmlRelationshipTypes::Footer );
return AddPart( _T( "word" ), ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString( _footerCounter ) + std::wstring( _T( ".xml" ) ) ), WordprocessingMLContentTypes::Footer, OpenXmlRelationshipTypes::Footer );
}
int OpenXmlPackage::AddFooterPart( const std::wstring& fileName, const std::wstring& relationshipType, const std::wstring& targetMode )
@ -322,13 +322,13 @@ namespace DocFileFormat
for ( std::list<Relationship>::const_iterator iter = relationshipsFile.Relationships.begin(); iter != relationshipsFile.Relationships.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Relationship" ), TRUE );
writer.WriteAttribute( _T( "Id" ), iter->Id.c_str() );
writer.WriteAttribute( _T( "Type" ), iter->Type.c_str() );
writer.WriteAttribute( _T( "Target" ), iter->Target.c_str() );
writer.WriteAttribute( _T( "Id" ), iter->Id );
writer.WriteAttribute( _T( "Type" ), iter->Type );
writer.WriteAttribute( _T( "Target" ), iter->Target );
if ( !iter->TargetMode.empty() )
{
writer.WriteAttribute( _T( "TargetMode" ), iter->TargetMode.c_str() );
writer.WriteAttribute( _T( "TargetMode" ), iter->TargetMode );
}
writer.WriteNodeEnd( _T( "" ), TRUE );
@ -358,16 +358,16 @@ namespace DocFileFormat
for ( std::map<std::wstring, std::wstring>::iterator iter = DocumentContentTypesFile._defaultTypes.begin(); iter != DocumentContentTypesFile._defaultTypes.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Default" ), TRUE );
writer.WriteAttribute( _T( "Extension" ), iter->first.c_str() );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._defaultTypes[iter->first].c_str() );
writer.WriteAttribute( _T( "Extension" ), iter->first );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._defaultTypes[iter->first] );
writer.WriteNodeEnd( _T( "" ), TRUE );
}
for ( std::map<std::wstring, std::wstring>::iterator iter = DocumentContentTypesFile._partOverrides.begin(); iter != DocumentContentTypesFile._partOverrides.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Override" ), TRUE );
writer.WriteAttribute( _T( "PartName" ), iter->first.c_str() );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._partOverrides[iter->first].c_str() );
writer.WriteAttribute( _T( "PartName" ), iter->first );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._partOverrides[iter->first] );
writer.WriteNodeEnd( _T( "" ), TRUE );
}

View File

@ -42,8 +42,8 @@ namespace DocFileFormat
m_document = document;
m_context = context;
_pPr = new XMLTools::XMLElement<wchar_t>( _T( "w:pPr" ) );
_framePr = new XMLTools::XMLElement<wchar_t>( _T( "w:framePr" ) );
_pPr = new XMLTools::XMLElement( _T( "w:pPr" ) );
_framePr = new XMLTools::XMLElement( _T( "w:framePr" ) );
_paraEndChpx = paraEndChpx;
_isBidi = isBidi;
@ -57,8 +57,8 @@ namespace DocFileFormat
m_document = document;
m_context = context;
_pPr = new XMLTools::XMLElement<wchar_t>( _T( "w:pPr" ) );
_framePr = new XMLTools::XMLElement<wchar_t>( _T( "w:framePr" ) );
_pPr = new XMLTools::XMLElement( _T( "w:pPr" ) );
_framePr = new XMLTools::XMLElement( _T( "w:framePr" ) );
_paraEndChpx = paraEndChpx;
_isBidi = isBidi;
@ -73,10 +73,7 @@ namespace DocFileFormat
RELEASEOBJECT(_pPr);
RELEASEOBJECT(_framePr);
}
}
namespace DocFileFormat
{
int ParagraphPropertiesMapping::get_section_page_break()
{
return _isSectionPageBreak;
@ -85,21 +82,21 @@ namespace DocFileFormat
{
ParagraphPropertyExceptions* papx = static_cast<ParagraphPropertyExceptions*>( visited );
XMLTools::XMLElement<wchar_t> ind ( _T( "w:ind" ) );
XMLTools::XMLElement<wchar_t> numPr ( _T( "w:numPr" ) );
XMLTools::XMLElement<wchar_t> pBdr ( _T( "w:pBdr" ) );
XMLTools::XMLElement<wchar_t> spacing ( _T( "w:spacing" ) );
XMLTools::XMLElement<wchar_t>* jc = NULL;
XMLTools::XMLElement ind ( _T( "w:ind" ) );
XMLTools::XMLElement numPr ( _T( "w:numPr" ) );
XMLTools::XMLElement pBdr ( _T( "w:pBdr" ) );
XMLTools::XMLElement spacing ( _T( "w:spacing" ) );
XMLTools::XMLElement* jc = NULL;
if ( _isParagraphStyleNeeded )
{
//append style id , do not append "Normal" style (istd 0)
XMLTools::XMLElement<wchar_t> pStyle( _T( "w:pStyle" ) );
XMLTools::XMLAttribute<wchar_t> styleId( _T( "w:val" ), StyleIdentifierMap[0] );
XMLTools::XMLElement pStyle( _T( "w:pStyle" ) );
XMLTools::XMLAttribute styleId( _T( "w:val" ), StyleIdentifierMap[0] );
if ( papx->istd < m_document->Styles->Styles->size() )
{
styleId.SetValue( FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId( m_document->Styles->Styles->at( papx->istd ) )).c_str() );
styleId.SetValue( FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId( m_document->Styles->Styles->at( papx->istd ) )) );
}
pStyle.AppendAttribute( styleId );
@ -109,7 +106,7 @@ namespace DocFileFormat
//append formatting of paragraph end mark
if ( _paraEndChpx != NULL )
{
XMLTools::XMLElement<wchar_t>* rPr = new XMLTools::XMLElement<wchar_t>( _T( "w:rPr" ) );
XMLTools::XMLElement* rPr = new XMLTools::XMLElement( _T( "w:rPr" ) );
//append properties
RevisionData* rev = new RevisionData( _paraEndChpx );
@ -119,7 +116,7 @@ namespace DocFileFormat
//append delete infos
if ( rev->Type == Deleted )
{
XMLTools::XMLElement<wchar_t> del( _T( "w:del" ) );
XMLTools::XMLElement del( _T( "w:del" ) );
rPr->AppendChild( del );
}
@ -142,20 +139,18 @@ namespace DocFileFormat
{
case sprmPIpgp:
{
appendValueElement(_pPr, _T( "divId" ), FormatUtils::IntToWideString( FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize)).c_str(), true);
appendValueElement(_pPr, _T( "divId" ), FormatUtils::IntToWideString( FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize)), true);
}break;
case sprmPFAutoSpaceDE:
{
appendFlagElement(_pPr, *iter, _T( "autoSpaceDE" ), true);
}
break;
}break;
case sprmPFAutoSpaceDN:
{
appendFlagElement( _pPr, *iter, _T( "autoSpaceDN" ), true );
}
break;
}break;
case sprmPFBiDi:
{
@ -247,9 +242,8 @@ namespace DocFileFormat
flValue *= -1;
}
appendValueAttribute( &ind, flName.c_str(), flValue );
}
break;
appendValueAttribute( &ind, flName, flValue );
}break;
case sprmPDxcLeft1:
appendValueAttribute( &ind, _T( "w:firstLineChars" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
@ -289,10 +283,10 @@ namespace DocFileFormat
{
LineSpacingDescriptor lspd( iter->Arguments, iter->argumentsSize );
XMLTools::XMLAttribute<wchar_t> line( _T( "w:line" ), FormatUtils::IntToWideString( abs( lspd.dyaLine ) ).c_str() );
XMLTools::XMLAttribute line( _T( "w:line" ), FormatUtils::IntToWideString( abs( lspd.dyaLine ) ));
spacing.AppendAttribute( line );
XMLTools::XMLAttribute<wchar_t> lineRule( _T( "w:lineRule" ), _T( "auto" ) );
XMLTools::XMLAttribute lineRule( _T( "w:lineRule" ), _T( "auto" ) );
if( ( !lspd.fMultLinespace ) && ( lspd.dyaLine < 0 ) )
{
@ -305,10 +299,9 @@ namespace DocFileFormat
//no line rule means auto
spacing.AppendAttribute( lineRule );
}
break;
}break;
//justification code
//justification code
case sprmOldPJc:
case sprmPJc:
case sprmPJc80:
@ -318,28 +311,28 @@ namespace DocFileFormat
iter->Arguments[0] = (iter->Arguments[0] == 0 ? 2 : 0);
}
RELEASEOBJECT( jc );
jc = new XMLTools::XMLElement<wchar_t>( _T( "w:jc" ) );
XMLTools::XMLAttribute<wchar_t> jcVal( _T( "w:val" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str() );
jc->AppendAttribute( jcVal );
}
break;
//borders
jc = new XMLTools::XMLElement( L"w:jc" );
if ( jc )
{
XMLTools::XMLAttribute jcVal( L"w:val", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ));
jc->AppendAttribute( jcVal );
}
}break;
//borders
//case 0x461C:
case sprmOldPBrcTop:
case sprmPBrcTop:
//case 0x4424:
case sprmPBrcTop80:
{
XMLTools::XMLElement<wchar_t> topBorder( _T( "w:top" ) );
XMLTools::XMLElement topBorder( _T( "w:top" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &topBorder );
addOrSetBorder( &pBdr, &topBorder );
}
break;
}break;
//case 0x461D:
case sprmOldPBrcLeft:
@ -347,15 +340,14 @@ namespace DocFileFormat
//case 0x4425:
case sprmPBrcLeft80:
{
XMLTools::XMLElement<wchar_t> leftBorder( _T( "w:left" ) );
XMLTools::XMLElement leftBorder( _T( "w:left" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &leftBorder );
addOrSetBorder( &pBdr, &leftBorder );
}
break;
}break;
//case 0x461E:
case sprmOldPBrcBottom:
@ -363,31 +355,29 @@ namespace DocFileFormat
//case 0x4426:
case sprmPBrcBottom80:
{
XMLTools::XMLElement<wchar_t> bottomBorder( _T( "w:bottom" ) );
XMLTools::XMLElement bottomBorder( _T( "w:bottom" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bottomBorder );
addOrSetBorder( &pBdr, &bottomBorder );
}
break;
}break;
//case 0x461F:
case sprmOldPBrcRight:
case sprmPBrcRight:
//case 0x4427:
case sprmPBrcRight80:
{
XMLTools::XMLElement<wchar_t> rightBorder( _T( "w:right" ) );
XMLTools::XMLElement rightBorder( _T( "w:right" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &rightBorder );
addOrSetBorder( &pBdr, &rightBorder );
}
break;
}break;
//case 0x4620:
case sprmOldPBrcBetween:
@ -395,15 +385,14 @@ namespace DocFileFormat
//case 0x4428:
case sprmPBrcBetween80:
{
XMLTools::XMLElement<wchar_t> betweenBorder( _T( "w:between" ) );
XMLTools::XMLElement betweenBorder( _T( "w:between" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &betweenBorder );
addOrSetBorder( &pBdr, &betweenBorder );
}
break;
}break;
//case 0x4621:
case sprmOldPBrcBar:
@ -411,25 +400,24 @@ namespace DocFileFormat
//case 0x4629:
case sprmPBrcBar80:
{
XMLTools::XMLElement<wchar_t> barBorder( _T( "w:bar" ) );
XMLTools::XMLElement barBorder( _T( "w:bar" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &barBorder );
addOrSetBorder( &pBdr, &barBorder );
}
break;
}break;
//shading
//shading
case sprmPShd80:
case sprmPShd:
{
ShadingDescriptor desc( iter->Arguments, iter->argumentsSize );
appendShading( _pPr, desc );
}
break;
}break;
//numbering
case sprmOldPAnld:
@ -450,10 +438,13 @@ namespace DocFileFormat
}break;
case sprmOldPNLvlAnm:
{
{
short level = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize) - 1;
if (level > 0 && level < 10)
appendValueElement( _pPr, _T( "outlineLvl" ), level, false );
appendValueElement( _pPr, _T( "outlineLvl" ), level, false );
}break;
case sprmOldPFNoLineNumb:
{
}break;
@ -467,8 +458,10 @@ namespace DocFileFormat
{
//Если numbering.xml пустой, то не пищем свойство
//Todo разобраться с закоментированным кодом
{
if (NULL != m_document->listTable && false == m_document->listTable->listData.empty())
{
appendValueElement( &numPr, _T( "numId" ), FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), true );
}
//check if there is a ilvl reference, if not, check the count of LVLs.
//if only one LVL exists in the referenced list, create a hard reference to that LVL
@ -485,12 +478,12 @@ namespace DocFileFormat
}
break;
}
break;
case sprmOldPChgTabs: //tabs
case sprmPChgTabsPapx:
case sprmPChgTabs:
{
case sprmPChgTabsPapx:
XMLTools::XMLElement tabs( _T( "w:tabs" ) );
int pos = 0;
@ -501,14 +494,14 @@ namespace DocFileFormat
for( int i=0; i < itbdDelMax; i++ )
{
XMLTools::XMLElement tab( _T( "w:tab" ) );
//clear
XMLTools::XMLElement<wchar_t> tab( _T( "w:tab" ) );
XMLTools::XMLAttribute tabsVal( _T( "w:val" ), _T( "clear" ) );
tab.AppendAttribute( tabsVal );
//position
tab.AppendAttribute( tabsVal );
XMLTools::XMLAttribute tabsPos( _T( "w:pos" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, pos, iter->argumentsSize ) ) );
tab.AppendAttribute( tabsPos );
tabs.AppendChild( tab );
@ -525,26 +518,26 @@ namespace DocFileFormat
}
//read the added tabs
}
unsigned char itbdAddMax = pos < iter->argumentsSize ? iter->Arguments[pos] : 0;
//read the added tabs
if (itbdAddMax > 0) pos++;
for ( int i = 0; i < itbdAddMax; i++ )
{
TabDescriptor tbd( iter->Arguments[pos + ( itbdAddMax * 2 ) + i] );
{
XMLTools::XMLElement tab( _T( "w:tab" ) );
//justification
XMLTools::XMLElement<wchar_t> tab( _T( "w:tab" ) );
XMLTools::XMLAttribute tabsVal( _T( "w:val" ), FormatUtils::MapValueToWideString( tbd.jc, &Global::TabStop[0][0], 7, 8 ) );
tab.AppendAttribute( tabsVal );
//tab leader type
tab.AppendAttribute( tabsVal );
XMLTools::XMLAttribute leader( _T( "w:leader" ), FormatUtils::MapValueToWideString( tbd.tlc, &Global::TabLeader[0][0], 8, 11 ) );
tab.AppendAttribute( leader );
//position
tab.AppendAttribute( leader );
XMLTools::XMLAttribute tabsPos( _T( "w:pos" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, ( pos + (i * 2) ), iter->argumentsSize ) ) );
tab.AppendAttribute( tabsPos );
tabs.AppendChild( tab );
@ -561,14 +554,14 @@ namespace DocFileFormat
//position code
unsigned char flag = iter->Arguments[0];
//position code
unsigned char flag = iter->Arguments[0];
appendValueAttribute (_framePr, _T( "w:hAnchor" ), FormatUtils::MapValueToWideString( ( ( flag & 0xC0 ) >> 6 ), &Global::HorizontalPositionCode[0][0], 4, 7 ) );
appendValueAttribute (_framePr, _T( "w:vAnchor" ), FormatUtils::MapValueToWideString( ( ( flag & 0x30 ) >> 4 ), &Global::VerticalPositionCode[0][0], 4, 7 ) );
}
break;
case sprmOldPWr:
case sprmPWr:
appendValueAttribute( _framePr, _T( "w:wrap" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextFrameWrapping[0][0], 6, 10 ) );
break;
case sprmOldPDxaAbs:
@ -605,7 +598,7 @@ namespace DocFileFormat
{
short pDcs = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
{
appendValueAttribute( _framePr, _T( "w:dropCap" ), FormatUtils::MapValueToWideString( ( pDcs & 0x07 ), &Global::TextFrameDropCapLocation[0][0], 3, 7 ) );
appendValueAttribute( _framePr, _T( "w:lines" ), (unsigned char)( ( pDcs & 0xF8 ) >> 3 ) );
}
@ -642,7 +635,7 @@ namespace DocFileFormat
//append section properties
if ( _sepx != NULL )
{
//append section properties
XMLTools::XMLElement sectPr( _T( "w:sectPr" ) );
SectionPropertiesMapping* sectionPropertiesMapping = new SectionPropertiesMapping( &sectPr, m_context, _sectionNr );
_sepx->Convert( sectionPropertiesMapping );
@ -663,28 +656,24 @@ namespace DocFileFormat
{
_pPr->AppendChild( ind );
}
{
_pPr->AppendChild( ind );
}
if ( spacing.GetAttributeCount() > 0 )//append spacing
{
_pPr->AppendChild( spacing );
}
{
_pPr->AppendChild( spacing );
}
if ( jc ) //append justification
{
_pPr->AppendChild( *jc );
RELEASEOBJECT( jc );
}
_pPr->AppendChild( *jc );
RELEASEOBJECT( jc );
}
if ( numPr.GetChildCount() > 0 )//append numPr
{
_pPr->AppendChild( numPr );
}
{
_pPr->AppendChild( numPr );
}
if ( pBdr.GetChildCount() > 0 ) //append borders
{
_pPr->AppendChild( pBdr );
}
@ -692,7 +681,7 @@ namespace DocFileFormat
//write Properties
if ( ( _pPr->GetChildCount() > 0 ) || ( _pPr->GetAttributeCount() > 0 ) )
{
//write Properties
m_pXmlWriter->WriteString( _pPr->GetXMLString() );
}
}
m_pXmlWriter->WriteString( _pPr->GetXMLString().c_str() );
}

View File

@ -46,26 +46,25 @@ namespace DocFileFormat
class ParagraphPropertiesMapping: public PropertiesMapping, public IMapping
{
public:
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 );
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);
int get_section_page_break();
private:
WordDocument* m_document;
ConversionContext* m_context;
WordDocument* m_document;
ConversionContext* m_context;
XMLTools::XMLElement<wchar_t>* _pPr;
XMLTools::XMLElement<wchar_t>* _framePr;
SectionPropertyExceptions* _sepx;
CharacterPropertyExceptions* _paraEndChpx;
int _sectionNr;
XMLTools::XMLElement* _pPr;
XMLTools::XMLElement* _framePr;
SectionPropertyExceptions* _sepx;
CharacterPropertyExceptions* _paraEndChpx;
int _sectionNr;
bool _isParagraphStyleNeeded;
bool _isBidi;
int _isSectionPageBreak;
bool _isParagraphStyleNeeded;
bool _isBidi;
int _isSectionPageBreak;
};
}

View File

@ -244,22 +244,22 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendFlagAttribute( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* attributeName )
void PropertiesMapping::appendFlagAttribute( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const std::wstring & attributeName )
{
XMLTools::XMLAttribute<wchar_t> att( attributeName, FormatUtils::IntToWideString( sprm.Arguments[0] ).c_str());
XMLTools::XMLAttribute att( attributeName, FormatUtils::IntToWideString( sprm.Arguments[0] ));
node->AppendAttribute( att );
}
/*========================================================================================================*/
void PropertiesMapping::appendFlagElement( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique )
void PropertiesMapping::appendFlagElement( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const std::wstring & elementName, bool unique )
{
XMLTools::XMLElement<wchar_t> ele( L"w", elementName );
XMLTools::XMLElement ele( L"w", elementName );
if ( sprm.Arguments[0] == 0 )
{
XMLTools::XMLAttribute<wchar_t> val( L"w:val" , L"off" );
XMLTools::XMLAttribute val( L"w:val" , L"off" );
ele.AppendAttribute( val );
}
@ -274,58 +274,58 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, const wchar_t* attributeValue )
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement* node, const std::wstring & attributeName, const std::wstring & attributeValue )
{
XMLTools::XMLAttribute<wchar_t> att( attributeName, attributeValue );
XMLTools::XMLAttribute att( attributeName, attributeValue );
node->AppendAttribute( att );
}
/*========================================================================================================*/
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, int attributeValue )
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement* node, const std::wstring & attributeName, int attributeValue )
{
XMLTools::XMLAttribute<wchar_t> att( attributeName, FormatUtils::IntToWideString( attributeValue ).c_str());
XMLTools::XMLAttribute att( attributeName, FormatUtils::IntToWideString( attributeValue ));
node->AppendAttribute( att );
}
/*========================================================================================================*/
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, short attributeValue )
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement* node, const std::wstring & attributeName, short attributeValue )
{
XMLTools::XMLAttribute<wchar_t> att( attributeName, FormatUtils::IntToWideString( attributeValue ).c_str());
XMLTools::XMLAttribute att( attributeName, FormatUtils::IntToWideString( attributeValue ));
node->AppendAttribute( att );
}
/*========================================================================================================*/
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, unsigned short attributeValue )
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement* node, const std::wstring & attributeName, unsigned short attributeValue )
{
XMLTools::XMLAttribute<wchar_t> att( attributeName, FormatUtils::IntToWideString( attributeValue ).c_str());
XMLTools::XMLAttribute att( attributeName, FormatUtils::IntToWideString( attributeValue ));
node->AppendAttribute( att );
}
/*========================================================================================================*/
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, unsigned char attributeValue )
void PropertiesMapping::appendValueAttribute( XMLTools::XMLElement* node, const std::wstring & attributeName, unsigned char attributeValue )
{
XMLTools::XMLAttribute<wchar_t> att( attributeName, FormatUtils::IntToWideString( attributeValue ).c_str());
XMLTools::XMLAttribute att( attributeName, FormatUtils::IntToWideString( attributeValue ));
node->AppendAttribute( att );
}
/*========================================================================================================*/
void PropertiesMapping::appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique )
void PropertiesMapping::appendValueElement( XMLTools::XMLElement* node, const std::wstring & elementName, const std::wstring & elementValue, bool unique )
{
XMLTools::XMLElement<wchar_t>* ele = new XMLTools::XMLElement<wchar_t>( L"w" , elementName );
XMLTools::XMLElement* ele = new XMLTools::XMLElement( L"w" , elementName );
if( ( elementValue != NULL ) && ( wcscmp( elementValue, L"" ) != 0 ))
if(!elementValue.empty())
{
XMLTools::XMLAttribute<wchar_t>* val = new XMLTools::XMLAttribute<wchar_t>( L"w:val" );
XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( L"w:val" );
val->SetValue( elementValue );
@ -347,15 +347,15 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, short elementValue, bool unique )
void PropertiesMapping::appendValueElement( XMLTools::XMLElement* node, const std::wstring & elementName, short elementValue, bool unique )
{
XMLTools::XMLElement<wchar_t>* ele = new XMLTools::XMLElement<wchar_t>( L"w" , elementName );
XMLTools::XMLElement* ele = new XMLTools::XMLElement( L"w" , elementName );
std::wstring strValue = FormatUtils::IntToWideString( elementValue );
if ( strValue != std::wstring( L""))
{
XMLTools::XMLAttribute<wchar_t>* val = new XMLTools::XMLAttribute<wchar_t>( L"w:val", strValue.c_str());
XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( L"w:val", strValue);
ele->AppendAttribute( *val );
RELEASEOBJECT( val );
}
@ -373,15 +373,15 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, unsigned short elementValue, bool unique )
void PropertiesMapping::appendValueElement( XMLTools::XMLElement* node, const std::wstring & elementName, unsigned short elementValue, bool unique )
{
XMLTools::XMLElement<wchar_t>* ele = new XMLTools::XMLElement<wchar_t>( L"w" , elementName );
XMLTools::XMLElement* ele = new XMLTools::XMLElement( L"w" , elementName );
std::wstring strValue = FormatUtils::IntToWideString( elementValue );
if ( strValue != std::wstring( L"" ))
{
XMLTools::XMLAttribute<wchar_t>* val = new XMLTools::XMLAttribute<wchar_t>( L"w:val", strValue.c_str());
XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( L"w:val", strValue);
ele->AppendAttribute( *val );
RELEASEOBJECT( val );
}
@ -399,15 +399,15 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, unsigned char elementValue, bool unique )
void PropertiesMapping::appendValueElement( XMLTools::XMLElement* node, const std::wstring & elementName, unsigned char elementValue, bool unique )
{
XMLTools::XMLElement<wchar_t>* ele = new XMLTools::XMLElement<wchar_t>( L"w", elementName );
XMLTools::XMLElement* ele = new XMLTools::XMLElement( L"w", elementName );
std::wstring strValue = FormatUtils::IntToWideString( elementValue );
if ( strValue != std::wstring( L"" ))
{
XMLTools::XMLAttribute<wchar_t>* val = new XMLTools::XMLAttribute<wchar_t>( L"w:val", strValue.c_str());
XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( L"w:val", strValue);
ele->AppendAttribute( *val );
RELEASEOBJECT( val );
}
@ -425,9 +425,9 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendBorderAttributes( BorderCode* brc, XMLTools::XMLElement<wchar_t>* border )
void PropertiesMapping::appendBorderAttributes( BorderCode* brc, XMLTools::XMLElement* border )
{
XMLTools::XMLAttribute<wchar_t> val( L"w:val" );
XMLTools::XMLAttribute val( L"w:val" );
if ( brc->fNil )
{
@ -436,22 +436,22 @@ namespace DocFileFormat
}
else
{
val.SetValue( getBorderType( brc->brcType ).c_str());
val.SetValue( getBorderType( brc->brcType ));
border->AppendAttribute( val );
XMLTools::XMLAttribute<wchar_t> color( L"w:color" );
color.SetValue( RGBColor( brc->cv, RedFirst ).SixDigitHexCode.c_str());
XMLTools::XMLAttribute color( L"w:color" );
color.SetValue( RGBColor( brc->cv, RedFirst ).SixDigitHexCode);
border->AppendAttribute( color );
XMLTools::XMLAttribute<wchar_t> space( L"w:space" , FormatUtils::IntToWideString( brc->dptSpace ).c_str());
XMLTools::XMLAttribute space( L"w:space" , FormatUtils::IntToWideString( brc->dptSpace ));
border->AppendAttribute( space );
XMLTools::XMLAttribute<wchar_t> sz( L"w:sz", FormatUtils::IntToWideString( brc->dptLineWidth ).c_str());
XMLTools::XMLAttribute sz( L"w:sz", FormatUtils::IntToWideString( brc->dptLineWidth ));
border->AppendAttribute( sz );
if ( brc->fShadow )
{
XMLTools::XMLAttribute<wchar_t> shadow( L"w:shadow" );
XMLTools::XMLAttribute shadow( L"w:shadow" );
shadow.SetValue( L"1" );
border->AppendAttribute( shadow );
}
@ -460,14 +460,14 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendShading( XMLTools::XMLElement<wchar_t>* parent, const ShadingDescriptor& desc )
void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc )
{
if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal ))
{
XMLTools::XMLElement<wchar_t> shd( L"w:shd" );
XMLTools::XMLElement shd( L"w:shd" );
//fill color
XMLTools::XMLAttribute<wchar_t> fill( L"w:fill" );
XMLTools::XMLAttribute fill( L"w:fill" );
if ( desc.shadingType == shadingTypeShd )
{
@ -477,18 +477,18 @@ namespace DocFileFormat
}
else
{
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode.c_str());
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
}
}
else
{
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ).c_str());
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( fill );
//foreground color
XMLTools::XMLAttribute<wchar_t> color( L"w:color" );
XMLTools::XMLAttribute color( L"w:color" );
if ( desc.shadingType == shadingTypeShd )
{
@ -498,19 +498,19 @@ namespace DocFileFormat
}
else
{
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode.c_str());
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
}
}
else
{
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ).c_str());
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( color );
//pattern
XMLTools::XMLAttribute<wchar_t> val( L"w:val" );
val.SetValue( getShadingPattern( desc ).c_str());
XMLTools::XMLAttribute val( L"w:val" );
val.SetValue( getShadingPattern( desc ));
shd.AppendAttribute( val );
parent->RemoveChildByName( L"w:shd" );
@ -759,12 +759,12 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::appendDxaElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique )
void PropertiesMapping::appendDxaElement( XMLTools::XMLElement* node, const std::wstring & elementName, const std::wstring & elementValue, bool unique )
{
XMLTools::XMLElement<wchar_t> ele( L"w", elementName );
XMLTools::XMLAttribute<wchar_t> val( L"w:w", elementValue );
XMLTools::XMLElement ele( L"w", elementName );
XMLTools::XMLAttribute val( L"w:w", elementValue );
ele.AppendAttribute( val );
XMLTools::XMLAttribute<wchar_t> type( L"w:type", L"dxa" );
XMLTools::XMLAttribute type( L"w:type", L"dxa" );
ele.AppendAttribute( type );
if ( unique )
@ -777,7 +777,7 @@ namespace DocFileFormat
/*========================================================================================================*/
void PropertiesMapping::addOrSetBorder( XMLTools::XMLElement<wchar_t>* pBdr, const XMLTools::XMLElement<wchar_t>* border )
void PropertiesMapping::addOrSetBorder( XMLTools::XMLElement* pBdr, const XMLTools::XMLElement* border )
{
if ( ( pBdr != NULL ) && ( border != NULL ))
{

View File

@ -51,24 +51,26 @@ namespace DocFileFormat
protected:
static void init();
void appendFlagAttribute( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* attributeName );
virtual void appendFlagElement( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique );
void appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, const wchar_t* attributeValue );
void appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, int attributeValue );
void appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, short attributeValue );
void appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, unsigned short attributeValue );
void appendValueAttribute( XMLTools::XMLElement<wchar_t>* node, const wchar_t* attributeName, unsigned char attributeValue );
void appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique );
void appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, short elementValue, bool unique );
void appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, unsigned short elementValue, bool unique );
void appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, unsigned char elementValue, bool unique );
void appendBorderAttributes( BorderCode* brc, XMLTools::XMLElement<wchar_t>* border );
void appendShading( XMLTools::XMLElement<wchar_t>* parent, const ShadingDescriptor& desc );
std::wstring getBorderType( unsigned char type );
std::wstring getShadingPattern( const ShadingDescriptor& shd );
void appendDxaElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique );
void addOrSetBorder( XMLTools::XMLElement<wchar_t>* pBdr, const XMLTools::XMLElement<wchar_t>* border );
virtual void appendFlagElement( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const std::wstring & elementName, bool unique );
void appendFlagAttribute ( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const std::wstring & attributeName );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, const std::wstring & attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, int attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & ttributeName, short attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, unsigned short attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, unsigned char attributeValue );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, const std::wstring & elementValue, bool unique );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, short elementValue, bool unique );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, unsigned short elementValue, bool unique );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, unsigned char elementValue, bool unique );
void appendShading ( XMLTools::XMLElement* parent, const ShadingDescriptor& desc );
void appendDxaElement ( XMLTools::XMLElement* node, const std::wstring & elementName, const std::wstring & elementValue, bool unique );
void addOrSetBorder ( XMLTools::XMLElement* pBdr, const XMLTools::XMLElement* border );
void appendBorderAttributes ( BorderCode* brc, XMLTools::XMLElement* border );
std::wstring getBorderType ( unsigned char type );
std::wstring getShadingPattern ( const ShadingDescriptor& shd );
protected:
XMLTools::CStringXmlWriter* m_pXmlWriter;

View File

@ -59,28 +59,15 @@ namespace DocFileFormat
{
unsigned char* bytes = FormatUtils::GetBytes( cv );
// wchar_t rgbColor6[7];
// wchar_t rgbColor8[9];
//CString rgbColor6;
//CString rgbColor8;
std::wstringstream rgbColor6, rgbColor8;
if( order == RedFirst )
{
//R
this->Red = bytes[0];
//G
this->Green = bytes[1];
//B
this->Green = bytes[1];
this->Blue = bytes[2];
//Alpha
this->Alpha = bytes[3];
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 );
//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;
@ -89,20 +76,11 @@ namespace DocFileFormat
}
else if ( order == RedLast )
{
//R
this->Red = bytes[2];
//G
this->Green = bytes[1];
//B
this->Blue = bytes[0];
//Alpha
this->Alpha = bytes[3];
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 );
//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;

View File

@ -35,11 +35,10 @@
namespace DocFileFormat
{
// Creates a new SectionPropertiesMapping which writes the properties to the given writer
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping (pWriter)
{
m_bDeleteNode = TRUE;
m_pXmlNode = new XMLTools::XMLElement<wchar_t> (_T("w:sectPr"));
m_pXmlNode = new XMLTools::XMLElement (_T("w:sectPr"));
m_nColumns = 0;
m_arrWidth = NULL;
@ -54,8 +53,7 @@ namespace DocFileFormat
_type = std::wstring (_T("nextPage"));
}
// Creates a new SectionPropertiesMapping which appends the properties to a given node.
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::XMLElement<wchar_t>* pBaseNode, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping(NULL)
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::XMLElement* pBaseNode, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping(NULL)
{
m_bDeleteNode = FALSE;
m_pXmlNode = pBaseNode;
@ -85,21 +83,20 @@ namespace DocFileFormat
namespace DocFileFormat
{
// Converts the given SectionPropertyExceptions
void SectionPropertiesMapping::Apply (IVisitable* visited)
{
SectionPropertyExceptions* sepx = static_cast<SectionPropertyExceptions*>(visited);
XMLTools::XMLElement<wchar_t> pgSz (_T("w:pgSz"));
XMLTools::XMLElement<wchar_t> pgMar (_T("w:pgMar"));
XMLTools::XMLElement<wchar_t> lnNumType (_T("w:lnNumType"));
XMLTools::XMLElement<wchar_t> cols (_T("w:cols"));
XMLTools::XMLElement<wchar_t> docGrid (_T("w:docGrid"));
XMLTools::XMLElement<wchar_t> pgBorders (_T("w:pgBorders"));
XMLTools::XMLElement<wchar_t> paperSrc (_T("w:paperSrc"));
XMLTools::XMLElement<wchar_t> footnotePr(_T("w:footnotePr"));
XMLTools::XMLElement<wchar_t> endnotePr (_T("w:endnotePr"));
XMLTools::XMLElement<wchar_t> pgNumType (_T("w:pgNumType"));
XMLTools::XMLElement pgSz (_T("w:pgSz"));
XMLTools::XMLElement pgMar (_T("w:pgMar"));
XMLTools::XMLElement lnNumType (_T("w:lnNumType"));
XMLTools::XMLElement cols (_T("w:cols"));
XMLTools::XMLElement docGrid (_T("w:docGrid"));
XMLTools::XMLElement pgBorders (_T("w:pgBorders"));
XMLTools::XMLElement paperSrc (_T("w:paperSrc"));
XMLTools::XMLElement footnotePr(_T("w:footnotePr"));
XMLTools::XMLElement endnotePr (_T("w:endnotePr"));
XMLTools::XMLElement pgNumType (_T("w:pgNumType"));
HeaderAndFooterTable* pTable = _ctx->_doc->headerAndFooterTable;
@ -156,280 +153,262 @@ namespace DocFileFormat
{
switch (iter->OpCode)
{
//page margins
case sprmOldSDxaLeft:
case sprmSDxaLeft:
{
//left margin
_marLeft = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:left" ), FormatUtils::IntToWideString( _marLeft ).c_str() );
}
break;
{
_marLeft = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:left" ), FormatUtils::IntToWideString( _marLeft ) );
}
break;
case sprmOldSDxaRight:
case sprmSDxaRight:
{
//right margin
_marRight = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:right" ), FormatUtils::IntToWideString( _marRight ).c_str() );
}
break;
{
_marRight = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:right" ), FormatUtils::IntToWideString( _marRight ) );
}
break;
case sprmOldSDyaTop:
case sprmSDyaTop:
//top margin
appendValueAttribute( &pgMar, _T( "w:top" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
//top margin
appendValueAttribute( &pgMar, _T( "w:top" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSDyaBottom:
case sprmSDyaBottom:
//bottom margin
appendValueAttribute( &pgMar, _T( "w:bottom" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
//bottom margin
appendValueAttribute( &pgMar, _T( "w:bottom" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSDzaGutter:
case sprmSDzaGutter:
//gutter margin
appendValueAttribute( &pgMar, _T( "w:gutter" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
//gutter margin
appendValueAttribute( &pgMar, _T( "w:gutter" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSDyaHdrTop:
case sprmSDyaHdrTop:
//header margin
appendValueAttribute( &pgMar, _T( "w:header"), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
//header margin
appendValueAttribute( &pgMar, _T( "w:header"), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSDyaHdrBottom:
case sprmSDyaHdrBottom:
//footer margin
appendValueAttribute( &pgMar, _T( "w:footer" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
//footer margin
appendValueAttribute( &pgMar, _T( "w:footer" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
//page size and orientation
//page size and orientation
case sprmOldSXaPage:
case sprmSXaPage:
{
//width
_pgWidth = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgSz, _T( "w:w" ), FormatUtils::IntToWideString( _pgWidth ).c_str() );
appendValueAttribute( &pgSz, _T( "w:w" ), FormatUtils::IntToWideString( _pgWidth ) );
}
break;
case sprmOldSYaPage:
case sprmSYaPage:
//height
appendValueAttribute( &pgSz, _T( "w:h" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
appendValueAttribute( &pgSz, _T( "w:h" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSBOrientation:
case sprmSBOrientation:
//orientation
appendValueAttribute( &pgSz, _T( "w:orient" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ).c_str() );
appendValueAttribute( &pgSz, _T( "w:orient" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ) );
break;
//paper source
//paper source
case sprmOldSDmBinFirst:
case sprmSDmBinFirst:
appendValueAttribute( &paperSrc, _T( "w:first" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
appendValueAttribute( &paperSrc, _T( "w:first" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSDmBinOther:
case sprmSDmBinOther:
appendValueAttribute( &paperSrc, _T( "w:other" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
appendValueAttribute( &paperSrc, _T( "w:other" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
//page borders
//page borders
case sprmSBrcTop80:
case sprmSBrcTop:
{
//top
XMLTools::XMLElement<wchar_t> topBorder( _T( "w:top" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &topBorder );
addOrSetBorder( &pgBorders, &topBorder);
}
break;
{
//top
XMLTools::XMLElement topBorder( _T( "w:top" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &topBorder );
addOrSetBorder( &pgBorders, &topBorder);
}
break;
case sprmSBrcLeft80:
case sprmSBrcLeft:
{
//left
XMLTools::XMLElement<wchar_t> leftBorder( _T( "w:left" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &leftBorder);
addOrSetBorder( &pgBorders, &leftBorder);
}
break;
{
XMLTools::XMLElement leftBorder( _T( "w:left" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &leftBorder);
addOrSetBorder( &pgBorders, &leftBorder);
}
break;
case sprmSBrcBottom80:
case sprmSBrcBottom:
{
//left
XMLTools::XMLElement<wchar_t> bottomBorder( _T( "w:bottom" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bottomBorder );
addOrSetBorder( &pgBorders, &bottomBorder);
}
break;
{
//left
XMLTools::XMLElement bottomBorder( _T( "w:bottom" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bottomBorder );
addOrSetBorder( &pgBorders, &bottomBorder);
}
break;
case sprmSBrcRight80:
case sprmSBrcRight:
{
//left
XMLTools::XMLElement<wchar_t> rightBorder( _T( "w:right" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &rightBorder);
addOrSetBorder( &pgBorders, &rightBorder);
}
break;
{
//left
XMLTools::XMLElement rightBorder( _T( "w:right" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &rightBorder);
addOrSetBorder( &pgBorders, &rightBorder);
}
break;
//footnote properties
case sprmSRncFtn:
//restart code
appendValueElement( &footnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &FootnoteRestartCodeMap[0][0], 3, 11 ).c_str(), true );
appendValueElement( &footnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &FootnoteRestartCodeMap[0][0], 3, 11 ), true );
break;
//endnote properties
case sprmSRncEdn:
//restart code
appendValueElement( &endnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &EndnoteRestartCodeMap[0][0], 3, 11 ).c_str(), true );
appendValueElement( &endnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &EndnoteRestartCodeMap[0][0], 3, 11 ), true );
break;
case sprmSFpc:
{
//position code
short fpc = 0;
if ( iter->argumentsSize == 2 )
{
//position code
short fpc = 0;
if ( iter->argumentsSize == 2 )
{
fpc = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
}
else
{
fpc = (short)iter->Arguments[0];
}
if ( fpc == 2 )
{
appendValueElement( &footnotePr, _T( "pos" ), _T( "beneathText" ), true );
}
fpc = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
}
break;
else
{
fpc = (short)iter->Arguments[0];
}
if ( fpc == 2 )
{
appendValueElement( &footnotePr, _T( "pos" ), _T( "beneathText" ), true );
}
}break;
case sprmSNfcFtnRef:
//number format
appendValueElement( &footnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( &footnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
break;
case sprmSNfcEdnRef:
//number format
appendValueElement( &endnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( &endnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
break;
case sprmSNFtn:
appendValueElement( &footnotePr, _T( "numStart" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( &footnotePr, _T( "numStart" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
break;
case sprmSNEdn:
appendValueElement( &endnotePr, _T( "numStart" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( &endnotePr, _T( "numStart" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
break;
//doc grid
case sprmSDyaLinePitch:
appendValueAttribute( &docGrid, _T( "w:linePitch" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
appendValueAttribute( &docGrid, _T( "w:linePitch" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmSDxtCharSpace:
appendValueAttribute( &docGrid, _T( "w:charSpace" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
appendValueAttribute( &docGrid, _T( "w:charSpace" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmSClm:
appendValueAttribute( &docGrid, _T( "w:type" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), &DocGridTypeMap[0][0], 4, 14 ).c_str() );
appendValueAttribute( &docGrid, _T( "w:type" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), &DocGridTypeMap[0][0], 4, 14 ) );
break;
// Columns
case sprmOldSCcolumns:
case sprmSCcolumns:
{
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
{
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
RELEASEARRAYOBJECTS (m_arrSpace);
m_arrSpace = new short [m_nColumns];
RELEASEARRAYOBJECTS (m_arrSpace);
m_arrSpace = new short [m_nColumns];
appendValueAttribute (&cols, _T( "w:num" ), FormatUtils::IntToWideString (m_nColumns).c_str());
}
break;
appendValueAttribute (&cols, _T( "w:num" ), FormatUtils::IntToWideString (m_nColumns));
}
break;
case sprmOldSDxaColumns:
case sprmSDxaColumns:
//evenly spaced columns
appendValueAttribute (&cols, _T( "w:space" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
appendValueAttribute (&cols, _T( "w:space" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
case sprmOldSDxaColWidth:
case sprmSDxaColWidth:
{
if (m_nColumns) // there is at least one width set, so create the array
{
// there is at least one width set, so create the array
if (m_nColumns)
{
if (NULL == m_arrWidth)
m_arrWidth = new short [m_nColumns];
if (NULL == m_arrWidth)
m_arrWidth = new short [m_nColumns];
unsigned char nInd = iter->Arguments[0];
m_arrWidth[nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
unsigned char nInd = iter->Arguments[0];
m_arrWidth[nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
break;
}
break;
case sprmOldSDxaColSpacing:
case sprmSDxaColSpacing:
{
// there is at least one space set, so create the array
if (m_nColumns)
{
// there is at least one space set, so create the array
if (m_nColumns)
{
if (NULL == m_arrSpace)
m_arrSpace = new short[m_nColumns];
if (NULL == m_arrSpace)
m_arrSpace = new short[m_nColumns];
unsigned char nInd = iter->Arguments[0];
m_arrSpace [nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
unsigned char nInd = iter->Arguments[0];
m_arrSpace [nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
break;
}break;
//bidi
case sprmSFBiDi:
appendFlagElement (m_pXmlNode, *iter, _T( "bidi" ), true );
break;
{
appendFlagElement (m_pXmlNode, *iter, _T( "bidi" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
//title page
case sprmOldSFTitlePage:
case sprmSFTitlePage:
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), true );
break;
{
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
//RTL gutter
case sprmSFRTLGutter:
appendFlagElement (m_pXmlNode, *iter, _T( "rtlGutter" ), true );
break;
//type
{
appendFlagElement (m_pXmlNode, *iter, _T( "rtlGutter" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
case sprmOldSBkc:
case sprmSBkc:
{
_type = FormatUtils::MapValueToWideString( iter->Arguments[0], &SectionTypeMap[0][0], 5, 11 );
}
break;
{
_type = FormatUtils::MapValueToWideString( iter->Arguments[0], &SectionTypeMap[0][0], 5, 11 );
}
break;
//align
case sprmOldSVjc:
case sprmSVjc:
appendValueElement (m_pXmlNode, _T( "vAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &TextVerticalAlignment[0][0], 4, 7 ).c_str(), true );
appendValueElement (m_pXmlNode, _T( "vAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &TextVerticalAlignment[0][0], 4, 7 ), true );
break;
//pgNumType
case sprmOldSNfcPgn:
case sprmSNfcPgn:
appendValueAttribute( &pgNumType, _T( "w:fmt" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageNumberFormatCodeMap[0][0], 42, 29 ).c_str() );
appendValueAttribute( &pgNumType, _T( "w:fmt" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageNumberFormatCodeMap[0][0], 42, 29 ) );
break;
case sprmOldSPgnStart:
@ -442,7 +421,7 @@ namespace DocFileFormat
bWasSprmSFPgnRestart = true;
break;
// <w:lnNumType> - Line Numbering Settings
// <w:lnNumType> - Line Numbering Settings
case sprmOldSLnnMin :
case sprmSLnnMin :
@ -460,7 +439,7 @@ namespace DocFileFormat
SLncOperand mode = (SLncOperand)FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize);
mode = (SLncOperand)(std::min)((std::max)(mode,lncPerPage),lncContinue);
appendValueAttribute (&lnNumType, _T("w:restart"), LineNumberRestart[mode].c_str() );
appendValueAttribute (&lnNumType, _T("w:restart"), LineNumberRestart[mode] );
}
break;
@ -476,18 +455,18 @@ namespace DocFileFormat
default:
{
int sz = iter->argumentsSize;
}break;
}
}
if (bWasSprmSFPgnRestart && false == wsSprmSPgnStart.empty() )
appendValueAttribute( &pgNumType, _T( "w:start" ), wsSprmSPgnStart.c_str() );
appendValueAttribute( &pgNumType, _T( "w:start" ), wsSprmSPgnStart );
// build the columns
if (m_arrWidth)
{
//set to unequal width
XMLTools::XMLAttribute<wchar_t> equalWidth( _T( "w:equalWidth" ), _T( "0" ) );
XMLTools::XMLAttribute equalWidth( _T( "w:equalWidth" ), _T( "0" ) );
cols.AppendAttribute( equalWidth );
//calculate the width of the last column:
@ -505,12 +484,11 @@ namespace DocFileFormat
m_arrWidth [m_nColumns - 1] = lastColWidth;
}
// append the xml elements
for (int i = 0; i < m_nColumns; ++i)
{
XMLTools::XMLElement<wchar_t> col (_T( "w:col" ));
XMLTools::XMLAttribute<wchar_t> w (_T( "w:w" ), FormatUtils::IntToWideString (m_arrWidth[i]).c_str());
XMLTools::XMLAttribute<wchar_t> space (_T( "w:space" ), FormatUtils::IntToWideString (m_arrSpace[i]).c_str());
XMLTools::XMLElement col (_T( "w:col" ));
XMLTools::XMLAttribute w (_T( "w:w" ), FormatUtils::IntToWideString (m_arrWidth[i]));
XMLTools::XMLAttribute space (_T( "w:space" ), FormatUtils::IntToWideString (m_arrSpace[i]));
col.AppendAttribute (w);
col.AppendAttribute (space);
@ -518,56 +496,45 @@ namespace DocFileFormat
}
}
//append the section type
appendValueElement (m_pXmlNode, _T( "type" ), _type.c_str(), true );
appendValueElement (m_pXmlNode, _T( "type" ), _type, true );
// Document-Wide Footnote Properties
if (footnotePr.GetChildCount())
m_pXmlNode->AppendChild (footnotePr);
// Document-Wide Endnote Properties
if (endnotePr.GetChildCount())
m_pXmlNode->AppendChild (endnotePr);
// Page Size
if (pgSz.GetAttributeCount())
m_pXmlNode->AppendChild (pgSz);
// Page Borders
if (pgBorders.GetChildCount())
m_pXmlNode->AppendChild (pgBorders);
// Page Margins
if (pgMar.GetAttributeCount())
m_pXmlNode->AppendChild (pgMar);
// Line Numbering Settings
if (lnNumType.GetAttributeCount())
m_pXmlNode->AppendChild (lnNumType);
// Paper Source Information
if (paperSrc.GetAttributeCount())
m_pXmlNode->AppendChild (paperSrc);
// Single Column Definition)
if (cols.GetAttributeCount() || cols.GetChildCount())
m_pXmlNode->AppendChild (cols);
// Document Grid
if (docGrid.GetAttributeCount())
m_pXmlNode->AppendChild (docGrid);
// Page Numbering Settings
if (pgNumType.GetAttributeCount())
m_pXmlNode->AppendChild (pgNumType);
if (m_pXmlWriter)
m_pXmlWriter->WriteString (m_pXmlNode->GetXMLString().c_str() );
m_pXmlWriter->WriteString (m_pXmlNode->GetXMLString() );
}
void SectionPropertiesMapping::AppendRef (XMLTools::XMLElement<wchar_t> *parent, const wchar_t* element, const wchar_t* refType, const wchar_t* refId)
void SectionPropertiesMapping::AppendRef (XMLTools::XMLElement *parent, const std::wstring& element, const std::wstring& refType, const std::wstring& refId)
{
XMLTools::XMLElement<wchar_t> headerRef (_T("w"), element);
XMLTools::XMLElement headerRef (_T("w"), element);
headerRef.AppendAttribute (_T("w:type"), refType);
headerRef.AppendAttribute (_T("r:id"), refId);
@ -609,7 +576,7 @@ namespace DocFileFormat
}
}
AppendRef (m_pXmlNode, StoryType.c_str(), Story.c_str(), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(nRelID) ).c_str() );
AppendRef (m_pXmlNode, StoryType, Story, ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(nRelID) ) );
return TRUE;
}

View File

@ -158,7 +158,7 @@ namespace DocFileFormat
// Creates a new SectionPropertiesMapping which writes the properties to the given writer
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);
SectionPropertiesMapping (XMLTools::XMLElement* sectPr, ConversionContext* ctx, int nSelectProperties);
virtual ~SectionPropertiesMapping();
// Converts the given SectionPropertyExceptions
@ -167,11 +167,11 @@ namespace DocFileFormat
const std::wstring & get_section_type();
private:
void AppendRef (XMLTools::XMLElement<wchar_t>* pBaseNode, const wchar_t* element, const wchar_t* refType, const wchar_t* refId);
void AppendRef (XMLTools::XMLElement* pBaseNode, const std::wstring& element, const std::wstring& refType, const std::wstring& refId);
bool WriteSectionStory (CharacterRange* pRange, const std::wstring& StoryType, const std::wstring& Story);
XMLTools::XMLElement<wchar_t>* m_pXmlNode;
XMLTools::XMLElement* m_pXmlNode;
bool m_bDeleteNode;
int m_nColumns;

View File

@ -42,11 +42,11 @@ namespace DocFileFormat
SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ):
PropertyExceptions( bytes, size, oldVersion ), isBidi(false)
{
for ( std::list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ )
for ( std::list<SinglePropertyModifier>::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ )
{
SinglePropertyModifier sprm( *iter );
if( sprm.OpCode == sprmSFBiDi )
if( sprm.OpCode == sprmSFBiDi && sprm.Arguments[0] != 0)
{
isBidi = true;
}

View File

@ -44,27 +44,31 @@ namespace DocFileFormat
{
WordDocumentProperties* dop = static_cast<WordDocumentProperties*>( visited );
this->_ctx->_docx->RegisterSettings();
_ctx->_docx->RegisterSettings();
//start w:settings
m_oXmlWriter.WriteNodeBegin( _T( "?xml version=\"1.0\" encoding=\"UTF-8\"?" ) );
m_oXmlWriter.WriteNodeBegin( _T( "w:settings" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
//write namespaces
m_oXmlWriter.WriteAttribute( _T( "xmlns:w" ), OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( L"", TRUE, FALSE );
//zoom
m_oXmlWriter.WriteNodeBegin( _T( "w:zoom" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:percent" ), FormatUtils::IntToWideString( dop->wScaleSaved ).c_str() );
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved ) );
if ( dop->zkSaved != 0 )
{
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( dop->zkSaved, &ZoomTypeMap[0][0], 3, 9 ).c_str() );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::MapValueToWideString( dop->zkSaved, &ZoomTypeMap[0][0], 3, 9 ) );
}
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
if (dop->bDisplayBackgroundShape)
{
m_oXmlWriter.WriteNodeBegin ( L"w:displayBackgroundShape", TRUE );
m_oXmlWriter.WriteNodeEnd ( L"", TRUE );
}
//doc protection
//<w:documentProtection w:edit="forms" w:enforcement="1"/>
@ -72,65 +76,65 @@ namespace DocFileFormat
//embed system fonts
if( !dop->fDoNotEmbedSystemFont )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:embedSystemFonts" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:embedSystemFonts", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
//mirror margins
if ( dop->fMirrorMargins )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:mirrorMargins" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:mirrorMargins", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
//evenAndOddHeaders
if ( dop->fFacingPages )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:evenAndOddHeaders" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:evenAndOddHeaders", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
//proof state
XMLTools::XMLElement<wchar_t> proofState( _T( "w:proofState" ) );
XMLTools::XMLElement proofState( L"w:proofState" );
if ( dop->fGramAllClean )
{
appendValueAttribute( &proofState, _T( "w:grammar" ), _T( "clean" ) );
appendValueAttribute( &proofState, L"w:grammar", L"clean" );
}
if ( proofState.GetAttributeCount() > 0 )
{
m_oXmlWriter.WriteString( proofState.GetXMLString().c_str() );
m_oXmlWriter.WriteString( proofState.GetXMLString() );
}
//stylePaneFormatFilter
if ( dop->grfFmtFilter != 0 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:stylePaneFormatFilter" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( dop->grfFmtFilter, _T( "%04x" ) ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:stylePaneFormatFilter", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( dop->grfFmtFilter, L"%04x" ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
//default tab stop
m_oXmlWriter.WriteNodeBegin( _T( "w:defaultTabStop" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( dop->dxaTab ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:defaultTabStop", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dxaTab ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
//drawing grid
if( dop->dogrid != NULL )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:displayHorizontalDrawingGridEvery" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( dop->dogrid->dxGridDisplay ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:displayHorizontalDrawingGridEvery", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dxGridDisplay ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:displayVerticalDrawingGridEvery" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( dop->dogrid->dyGridDisplay ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:displayVerticalDrawingGridEvery", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dyGridDisplay ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
if ( dop->dogrid->fFollowMargins == false )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseMarginsForDrawingGridOrigin" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseMarginsForDrawingGridOrigin", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
}
@ -139,32 +143,32 @@ namespace DocFileFormat
{
if ( dop->doptypography->fKerningPunct == false )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:noPunctuationKerning" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:noPunctuationKerning", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
}
//footnote properties
XMLTools::XMLElement<wchar_t> footnotePr( _T( "w:footnotePr" ) );
XMLTools::XMLElement footnotePr( L"w:footnotePr" );
if ( dop->nFtn != 0 )
{
appendValueAttribute( &footnotePr, _T( "w:numStart" ), FormatUtils::IntToWideString( dop->nFtn ).c_str() );
appendValueAttribute( &footnotePr, L"w:numStart", FormatUtils::IntToWideString( dop->nFtn ) );
}
if ( dop->rncFtn != 0 )
{
appendValueAttribute( &footnotePr, _T( "w:numRestart" ), FormatUtils::IntToWideString( dop->rncFtn ).c_str() );
appendValueAttribute( &footnotePr, L"w:numRestart", FormatUtils::IntToWideString( dop->rncFtn ) );
}
if ( dop->Fpc != 0 )
{
appendValueAttribute( &footnotePr, _T( "w:pos" ), FormatUtils::MapValueToWideString( dop->Fpc, &FootnotePositionMap[0][0], 4, 12 ).c_str() );
appendValueAttribute( &footnotePr, L"w:pos", FormatUtils::MapValueToWideString( dop->Fpc, &FootnotePositionMap[0][0], 4, 12 ) );
}
if ( footnotePr.GetAttributeCount() > 0 )
{
m_oXmlWriter.WriteString( footnotePr.GetXMLString().c_str() );
m_oXmlWriter.WriteString( footnotePr.GetXMLString() );
}
@ -173,7 +177,7 @@ namespace DocFileFormat
writeRsidList();
//close w:settings
m_oXmlWriter.WriteNodeEnd( _T( "w:settings" ) );
m_oXmlWriter.WriteNodeEnd( L"w:settings" );
this->_ctx->_docx->SettingsXML = std::wstring( m_oXmlWriter.GetXmlString() );
}
@ -181,368 +185,368 @@ namespace DocFileFormat
void SettingsMapping::writeRsidList()
{
//convert the rsid list
m_oXmlWriter.WriteNodeBegin( _T( "w:rsids" ) );
m_oXmlWriter.WriteNodeBegin( L"w:rsids" );
for ( std::set<std::wstring>::iterator iter = this->_ctx->AllRsids.begin(); iter != this->_ctx->AllRsids.end(); iter++ )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:rsid" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), iter->c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:rsid", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", iter->c_str() );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
m_oXmlWriter.WriteNodeEnd( _T( "w:rsids" ) );
m_oXmlWriter.WriteNodeEnd( L"w:rsids" );
}
void SettingsMapping::writeCompatibilitySettings(const WordDocumentProperties* dop)
{
//compatibility settings
m_oXmlWriter.WriteNodeBegin( _T( "w:compat" ) );
m_oXmlWriter.WriteNodeBegin( L"w:compat" );
//some settings must always be written
if ( dop->fUseNormalStyleForList )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:useNormalStyleForList" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:useNormalStyleForList", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontUseIndentAsNumberingTabStop )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseIndentAsNumberingTabStop" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseIndentAsNumberingTabStop", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fFELineBreak11 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:useAltKinsokuLineBreakRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:useAltKinsokuLineBreakRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fAllowSpaceOfSameStyleInTable )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:allowSpaceOfSameStyleInTable" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:allowSpaceOfSameStyleInTable", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fWW11IndentRules )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotSuppressIndentation" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotSuppressIndentation", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontAutofitConstrainedTables )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotAutofitConstrainedTables" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotAutofitConstrainedTables", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fAutofitLikeWW11 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:autofitToFirstFixedWidthCell" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:autofitToFirstFixedWidthCell", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fUnderlineTabInNumList )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:underlineTabInNumList" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:underlineTabInNumList", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fHangulWidthLikeWW11 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:displayHangulFixedWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:displayHangulFixedWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fSplitPgBreakAndParaMark )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:splitPgBreakAndParaMark" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:splitPgBreakAndParaMark", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontVertAlignCellWithSp )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotVertAlignCellWithSp" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotVertAlignCellWithSp", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontBreakConstrainedForcedTables )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotBreakConstrainedForcedTable" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotBreakConstrainedForcedTable", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontVertAlignInTxbx )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotVertAlignInTxbx" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotVertAlignInTxbx", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fWord11KerningPairs )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:useAnsiKerningPairs" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:useAnsiKerningPairs", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fCachedColBalance )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:cachedColBalance" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:cachedColBalance", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
//others are saved in the file
if ( !dop->fDontAdjustLineHeightInTable )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:adjustLineHeightInTable" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:adjustLineHeightInTable", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fAlignTablesRowByRow )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:alignTablesRowByRow" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:alignTablesRowByRow", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fApplyBreakingRules )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:applyBreakingRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:applyBreakingRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fUseAutoSpaceForFullWidthAlpha )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:autoSpaceLikeWord95" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:autoSpaceLikeWord95", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( !dop->fDntBlnSbDbWid )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:balanceSingleByteDoubleByteWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:balanceSingleByteDoubleByteWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fConvMailMergeEsc )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:convMailMergeEsc" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:convMailMergeEsc", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontBreakWrappedTables )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotBreakWrappedTables" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotBreakWrappedTables", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( !dop->fExpShRtn )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotExpandShiftReturn" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotExpandShiftReturn", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( !dop->fLeaveBackslashAlone )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotLeaveBackslashAlone" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotLeaveBackslashAlone", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontSnapToGridInCell )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotSnapToGridInCell" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotSnapToGridInCell", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontUseAsianBreakRules )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseEastAsianBreakRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseEastAsianBreakRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontUseHTMLParagraphAutoSpacing )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseHTMLParagraphAutoSpacing" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseHTMLParagraphAutoSpacing", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontWrapTextWithPunct )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotWrapTextWithPunct" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:doNotWrapTextWithPunct", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fFtnLayoutLikeWW8 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:footnoteLayoutLikeWW8" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:footnoteLayoutLikeWW8", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fForgetLastTabAlign )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:forgetLastTabAlignment" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:forgetLastTabAlignment", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fGrowAutofit )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:growAutofit" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:growAutofit", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fLayoutRawTableWidth )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:layoutRawTableWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:layoutRawTableWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fLayoutTableRowsApart )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:layoutTableRowsApart" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:layoutTableRowsApart", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fLineWrapLikeWord6 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:lineWrapLikeWord6" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:lineWrapLikeWord6", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fMWSmallCaps )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:mwSmallCaps" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:mwSmallCaps", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fNoColumnBalance )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:noColumnBalance" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:noColumnBalance", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fNoLeading )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:noLeading" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:noLeading", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fNoSpaceRaiseLower )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:noSpaceRaiseLower" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:noSpaceRaiseLower", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fNoTabForInd )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:noTabHangInd" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:noTabHangInd", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fPrintBodyBeforeHdr )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:printBodyTextBeforeHeader" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:printBodyTextBeforeHeader", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fMapPrintTextColor )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:printColBlack" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:printColBlack", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fDontAllowFieldEndSelect )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:selectFldWithFirstOrLastChar" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:selectFldWithFirstOrLastChar", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fSpLayoutLikeWW8 )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:shapeLayoutLikeWW8" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:shapeLayoutLikeWW8", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fShowBreaksInFrames )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:showBreaksInFrames" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:showBreaksInFrames", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fMakeSpaceForUL )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:spaceForUL" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:spaceForUL", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fTruncDxaExpand )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:spacingInWholePoints" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:spacingInWholePoints", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fSubOnSize )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:subFontBySize" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:subFontBySize", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fSuppressSpbfAfterPageBreak )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:suppressSpBfAfterPgBrk" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:suppressSpBfAfterPgBrk", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fSuppressTopSpacing )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:suppressTopSpacing" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:suppressTopSpacing", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fSwapBordersFacingPgs )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:swapBordersFacingPages" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:swapBordersFacingPages", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( !dop->fDntULTrlSpc )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:ulTrailSpace" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:ulTrailSpace", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fPrintMet )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:usePrinterMetrics" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:usePrinterMetrics", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fUseWord2002TableStyleRules )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:useWord2002TableStyleRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:useWord2002TableStyleRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fUserWord97LineBreakingRules )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:useWord97LineBreakRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:useWord97LineBreakRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fWPJust )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:wpJustification" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:wpJustification", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fWPSpace )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:wpSpaceWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:wpSpaceWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if ( dop->fWrapTrailSpaces )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:wrapTrailSpaces" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:wrapTrailSpaces", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
m_oXmlWriter.WriteNodeEnd( _T( "w:compat" ) );
m_oXmlWriter.WriteNodeEnd( L"w:compat" );
}
}
}

View File

@ -112,23 +112,14 @@ namespace DocFileFormat
friend class PropertiesMapping;
private:
/// 24-bit foreground color
unsigned int cvFore;
bool cvForeAuto;
/// Foreground color.
/// Only used if cvFore is not set
int icoFore;
/// 24-bit background color
unsigned int cvBack;
bool cvBackAuto;
/// Background color.
/// Only used if cvBack is not set.
int icoBack;
/// Shading pattern
ShadingPattern ipat;
/// Shading type
ShadingType shadingType;
/// Shading special vale
unsigned int cvFore; // 24-bit foreground color
bool cvForeAuto;
int icoFore; // Foreground color.
unsigned int cvBack;
bool cvBackAuto;
int icoBack;
ShadingPattern ipat;
ShadingType shadingType;
ShadingSpecialValue shadingSpecialValue;
public:
@ -236,7 +227,7 @@ namespace DocFileFormat
else if (0x0F == icoBack) { cvBack = RGB2 (0x80, 0x80, 0x80); }
else if (0x10 == icoBack) { cvBack = RGB2 (0xC0, 0xC0, 0xC0); }
// TODO : если будут документы с такими цветовыми палитрами
// .... если будут документы с такими цветовыми палитрами
//if ((cvFore == 0) && (icoFore == 0x0) && (cvBack == 0) && (icoBack == 0x0) && (ipat == Automatic))
//{
@ -250,7 +241,6 @@ namespace DocFileFormat
}
else
{
//throw new ByteParseException("Cannot parse the struct SHD, the length of the struct doesn't match");
}
}
}

View File

@ -86,7 +86,7 @@ namespace DocFileFormat
{
m_pXmlWriter->WriteNodeBegin( _T( "w:style" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:type" ), FormatUtils::MapValueToWideString( (*iter)->stk, &StyleKindMap[0][0], 5, 10 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:type" ), FormatUtils::MapValueToWideString( (*iter)->stk, &StyleKindMap[0][0], 5, 10 ));
//!!!TODO: There is NO default styles in DOC file. So, we can't choose one of them!!!
/*if ( ( (*iter)->sti != Null ) && ( (*iter)->sti != User ) )
@ -95,19 +95,19 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "w:default" ), _T( "1" ) );
}*/
m_pXmlWriter->WriteAttribute( _T( "w:styleId" ), FormatUtils::XmlEncode(MakeStyleId( *iter )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:styleId" ), FormatUtils::XmlEncode(MakeStyleId( *iter )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
// <w:name val="" />
m_pXmlWriter->WriteNodeBegin( _T( "w:name" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(getStyleName( *iter ), true ).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(getStyleName( *iter ), true ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// <w:basedOn val="" />
if ( ( (*iter)->istdBase != 4095 ) && ( (*iter)->istdBase < sheet->Styles->size() ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:basedOn" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdBase ) )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdBase ) )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
@ -115,7 +115,7 @@ namespace DocFileFormat
if ( (*iter)->istdNext < sheet->Styles->size() )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:next" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdNext ) )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdNext ) )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
@ -123,7 +123,7 @@ namespace DocFileFormat
if ( (*iter)->istdLink < sheet->Styles->size() )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:link" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdLink ) )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdLink ) )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
@ -242,19 +242,19 @@ namespace DocFileFormat
FontFamilyName* ffnAscii = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) );
if (ffnAscii)
m_pXmlWriter->WriteAttribute( _T( "w:ascii" ), FormatUtils::XmlEncode(ffnAscii->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:ascii" ), FormatUtils::XmlEncode(ffnAscii->xszFtn, true));
FontFamilyName* ffnAsia = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) );
if (ffnAsia)
m_pXmlWriter->WriteAttribute( _T( "w:eastAsia" ), FormatUtils::XmlEncode(ffnAsia->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:eastAsia" ), FormatUtils::XmlEncode(ffnAsia->xszFtn, true));
FontFamilyName* ffnAnsi = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) );
if (ffnAnsi)
m_pXmlWriter->WriteAttribute( _T( "w:hAnsi" ), FormatUtils::XmlEncode(ffnAnsi->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:hAnsi" ), FormatUtils::XmlEncode(ffnAnsi->xszFtn, true));
FontFamilyName* ffnComplex = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) );
if (ffnComplex)
m_pXmlWriter->WriteAttribute( _T( "w:cs" ), FormatUtils::XmlEncode(ffnComplex->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:cs" ), FormatUtils::XmlEncode(ffnComplex->xszFtn, true));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:rFonts" ) );
@ -263,7 +263,7 @@ namespace DocFileFormat
std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid );
m_pXmlWriter->WriteNodeBegin( _T( "w:lang" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), langcode.c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), langcode);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:lang" ) );

View File

@ -49,9 +49,9 @@ namespace DocFileFormat
_brcRight = NULL;
_brcBottom = NULL;
_tcPr = new XMLTools::XMLElement<wchar_t>(L"w:tcPr");
_tcMar = new XMLTools::XMLElement<wchar_t>(L"w:tcMar");
_tcBorders = new XMLTools::XMLElement<wchar_t>(L"w:tcBorders");
_tcPr = new XMLTools::XMLElement(L"w:tcPr");
_tcMar = new XMLTools::XMLElement(L"w:tcMar");
_tcBorders = new XMLTools::XMLElement(L"w:tcBorders");
_ftsWidth = Global::nil;
}
@ -89,7 +89,7 @@ namespace DocFileFormat
_tGrid = tdef.rgdxaCenter;
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)]; // NOTE: fix for crash
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ).c_str(), false );
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ), false );
if ( _tcDef.vertMerge == Global::fvmMerge )
{
@ -100,7 +100,7 @@ namespace DocFileFormat
appendValueElement( _tcPr, L"vMerge", L"restart", false );
}
appendValueElement( _tcPr, L"vAlign", FormatUtils::MapValueToWideString( _tcDef.vertAlign, &Global::VerticalAlignMap[0][0], 3, 7 ).c_str(), false );
appendValueElement( _tcPr, L"vAlign", FormatUtils::MapValueToWideString( _tcDef.vertAlign, &Global::VerticalAlignMap[0][0], 3, 7 ), false );
if ( _tcDef.fFitText )
{
@ -145,22 +145,22 @@ namespace DocFileFormat
{
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 0 ) == true )
{
appendDxaElement( _tcMar, L"top", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"top", FormatUtils::IntToWideString( wMargin ), true );
}
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 1 ) == true )
{
appendDxaElement( _tcMar, L"left", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"left", FormatUtils::IntToWideString( wMargin ), true );
}
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 2 ) == true )
{
appendDxaElement( _tcMar, L"bottom", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"bottom", FormatUtils::IntToWideString( wMargin ), true );
}
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 3 ) == true )
{
appendDxaElement( _tcMar, L"right", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"right", FormatUtils::IntToWideString( wMargin ), true );
}
}
}
@ -210,7 +210,7 @@ namespace DocFileFormat
if ((_cellIndex >= first) && (_cellIndex < lim))
{
appendValueElement(_tcPr, L"vAlign", FormatUtils::MapValueToWideString( (VerticalCellAlignment)iter->Arguments[2], &VerticalCellAlignmentMap[0][0], 3, 7 ).c_str(), true );
appendValueElement(_tcPr, L"vAlign", FormatUtils::MapValueToWideString( (VerticalCellAlignment)iter->Arguments[2], &VerticalCellAlignmentMap[0][0], 3, 7 ), true );
}
}
break;
@ -222,7 +222,7 @@ namespace DocFileFormat
if ( ( _cellIndex >= first ) && ( _cellIndex < lim ) )
{
appendValueElement( _tcPr, L"tcFitText", FormatUtils::IntToWideString( iter->Arguments[2] ).c_str(), true );
appendValueElement( _tcPr, L"tcFitText", FormatUtils::IntToWideString( iter->Arguments[2] ), true );
}
}
break;
@ -271,10 +271,11 @@ namespace DocFileFormat
}
//width
XMLTools::XMLElement<wchar_t> tcW( L"w:tcW" );
XMLTools::XMLAttribute<wchar_t> tcWType( L"w:type", FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ).c_str() );
XMLTools::XMLAttribute<wchar_t> tcWVal( L"w:w", FormatUtils::IntToWideString( _width ).c_str() );
tcW.AppendAttribute( tcWType );
XMLTools::XMLElement tcW ( L"w:tcW" );
XMLTools::XMLAttribute tcWType ( L"w:type", FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) );
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width ) );
tcW.AppendAttribute( tcWType );
tcW.AppendAttribute( tcWVal );
_tcPr->AppendChild( tcW );
@ -298,7 +299,7 @@ namespace DocFileFormat
}
}
appendValueElement( _tcPr, L"gridSpan", FormatUtils::IntToWideString( _gridSpan ).c_str(), true );
appendValueElement( _tcPr, L"gridSpan", FormatUtils::IntToWideString( _gridSpan ), true );
}
//append margins
@ -310,28 +311,28 @@ namespace DocFileFormat
//append borders
if (_brcTop)
{
XMLTools::XMLElement<wchar_t> topBorder( L"w:top" );
XMLTools::XMLElement topBorder( L"w:top" );
appendBorderAttributes(_brcTop, &topBorder);
addOrSetBorder(_tcBorders, &topBorder );
}
if (_brcLeft )
{
XMLTools::XMLElement<wchar_t> leftBorder( L"w:left" );
XMLTools::XMLElement leftBorder( L"w:left" );
appendBorderAttributes(_brcLeft, &leftBorder);
addOrSetBorder(_tcBorders, &leftBorder);
}
if (_brcBottom)
{
XMLTools::XMLElement<wchar_t> bottomBorder( L"w:bottom" );
XMLTools::XMLElement bottomBorder( L"w:bottom" );
appendBorderAttributes(_brcBottom, &bottomBorder);
addOrSetBorder(_tcBorders, &bottomBorder);
}
if (_brcRight)
{
XMLTools::XMLElement<wchar_t> rightBorder( L"w:right" );
XMLTools::XMLElement rightBorder( L"w:right" );
appendBorderAttributes( _brcRight, &rightBorder );
addOrSetBorder( _tcBorders, &rightBorder );
}
@ -343,7 +344,7 @@ namespace DocFileFormat
//write Properties
if ((_tcPr->GetChildCount() > 0) || (_tcPr->GetAttributeCount() > 0))
m_pXmlWriter->WriteString(_tcPr->GetXMLString().c_str());
m_pXmlWriter->WriteString(_tcPr->GetXMLString());
}
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)

View File

@ -77,9 +77,9 @@ namespace DocFileFormat
int _gridIndex;
int _cellIndex;
XMLTools::XMLElement<wchar_t>* _tcPr;
XMLTools::XMLElement<wchar_t>* _tcMar;
XMLTools::XMLElement<wchar_t>* _tcBorders;
XMLTools::XMLElement* _tcPr;
XMLTools::XMLElement* _tcMar;
XMLTools::XMLElement* _tcBorders;
const std::vector<short>* _grid;
std::vector<short> _tGrid;

View File

@ -40,8 +40,8 @@ namespace DocFileFormat
_isTableStyleNeeded(isTableStyleNeeded)
{
_styles = styles;
_tblPr = new XMLTools::XMLElement<wchar_t>( _T( "w:tblPr" ) );
_tblBorders = new XMLTools::XMLElement<wchar_t>( _T( "w:tblBorders" ) );
_tblPr = new XMLTools::XMLElement( _T( "w:tblPr" ) );
_tblBorders = new XMLTools::XMLElement( _T( "w:tblBorders" ) );
_grid = grid;
}
TablePropertiesMapping::~TablePropertiesMapping()
@ -63,10 +63,10 @@ namespace DocFileFormat
{
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>( visited );
XMLTools::XMLElement<wchar_t> tblCellMar ( _T( "w:tblCellMar" ) );
XMLTools::XMLElement<wchar_t> tblLayout ( _T( "w:tblLayout" ) );
XMLTools::XMLElement<wchar_t> tblpPr ( _T( "w:tblpPr" ) );
XMLTools::XMLAttribute<wchar_t> layoutType ( _T( "w:type" ), _T( "fixed" ) );
XMLTools::XMLElement tblCellMar ( _T( "w:tblCellMar" ) );
XMLTools::XMLElement tblLayout ( _T( "w:tblLayout" ) );
XMLTools::XMLElement tblpPr ( _T( "w:tblpPr" ) );
XMLTools::XMLAttribute layoutType ( _T( "w:type" ), _T( "fixed" ) );
bool bLayoutFixed = true;
short tblIndent = 0;
@ -87,19 +87,19 @@ namespace DocFileFormat
case sprmOldTDefTable:
case sprmTDefTable:
{ //table definition
{
//table definition
SprmTDefTable tDef( iter->Arguments, iter->argumentsSize );
//Workaround for retrieving the indent of the table:
//In some files there is a indent but no sprmTWidthIndent is set.
//For this cases we can calculate the indent of the table by getting the
//first boundary of the TDef and adding the padding of the cells
tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
//add the gabHalf
tblIndent += gabHalf;
//If there follows a real sprmTWidthIndent, this value will be overwritten
tblIndent = (std::max)((int)tblIndent,0);
//tblIndent = (std::max)((int)tblIndent,0); //cerere.doc
}
break;
@ -109,10 +109,10 @@ namespace DocFileFormat
unsigned char fts = iter->Arguments[0];
short width = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
XMLTools::XMLElement<wchar_t> tblW( _T( "w:tblW" ) );
XMLTools::XMLElement tblW( _T( "w:tblW" ) );
XMLTools::XMLAttribute<wchar_t> w( _T( "w:w" ), FormatUtils::IntToWideString( width ).c_str() );
XMLTools::XMLAttribute<wchar_t> type( _T( "w:type" ), FormatUtils::MapValueToWideString( fts, &WidthType[0][0], 4, 5 ).c_str() );
XMLTools::XMLAttribute w( _T( "w:w" ), FormatUtils::IntToWideString( width ) );
XMLTools::XMLAttribute type( _T( "w:type" ), FormatUtils::MapValueToWideString( fts, &WidthType[0][0], 4, 5 ) );
tblW.AppendAttribute( type );
tblW.AppendAttribute( w );
@ -126,7 +126,7 @@ namespace DocFileFormat
case sprmTJcRow:
{ //justification
appendValueElement( _tblPr, _T( "jc" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str(), true );
appendValueElement( _tblPr, _T( "jc" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ), true );
}
break;
@ -150,7 +150,7 @@ namespace DocFileFormat
if( id != std::wstring( _T( "TableNormal" )) && !id.empty() )
{
appendValueElement( _tblPr, _T( "tblStyle" ), id.c_str(), true );
appendValueElement( _tblPr, _T( "tblStyle" ), id, true );
}
}
}
@ -168,7 +168,7 @@ namespace DocFileFormat
case sprmTTlp:
{ //table look
appendValueElement( _tblPr, _T( "tblLook" ), FormatUtils::IntToFormattedWideString( FormatUtils::BytesToInt16( iter->Arguments, 2, iter->argumentsSize ), _T( "%04x" ) ).c_str(), true );
appendValueElement( _tblPr, _T( "tblLook" ), FormatUtils::IntToFormattedWideString( FormatUtils::BytesToInt16( iter->Arguments, 2, iter->argumentsSize ), _T( "%04x" ) ), true );
}
break;
@ -194,7 +194,7 @@ namespace DocFileFormat
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x01 ) )
{
appendDxaElement( &tblCellMar, _T( "top" ), strValue.c_str(), true );
appendDxaElement( &tblCellMar, _T( "top" ), strValue, true );
}
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x02 ) )
@ -204,7 +204,7 @@ namespace DocFileFormat
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x04 ) )
{
appendDxaElement( &tblCellMar, _T( "bottom" ), strValue.c_str(), true );
appendDxaElement( &tblCellMar, _T( "bottom" ), strValue, true );
}
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x08 ) )
@ -238,7 +238,7 @@ namespace DocFileFormat
tblOverlapVal = std::wstring( _T( "never" ) );
}
appendValueElement( _tblPr, _T( "tblOverlap" ), tblOverlapVal.c_str(), true );
appendValueElement( _tblPr, _T( "tblOverlap" ), tblOverlapVal, true );
}
break;
@ -332,11 +332,11 @@ namespace DocFileFormat
{
unsigned char flag = ( iter->Arguments[0] & 0x30 ) >> 4;
appendValueAttribute( &tblpPr, _T( "w:vertAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::VerticalPositionCode[0][0], 4, 7 ).c_str() );
appendValueAttribute( &tblpPr, _T( "w:vertAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::VerticalPositionCode[0][0], 4, 7 ) );
flag = ( iter->Arguments[0] & 0xC0 ) >> 6;
appendValueAttribute( &tblpPr, _T( "w:horzAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::HorizontalPositionCode[0][0], 4, 7 ).c_str() );
appendValueAttribute( &tblpPr, _T( "w:horzAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::HorizontalPositionCode[0][0], 4, 7 ) );
}
break;
@ -381,12 +381,12 @@ namespace DocFileFormat
//indent
if ( tblIndent != 0 )
{
XMLTools::XMLElement<wchar_t> tblInd( _T( "w:tblInd" ) );
XMLTools::XMLElement tblInd( _T( "w:tblInd" ) );
XMLTools::XMLAttribute<wchar_t> tblIndW( _T( "w:w" ),FormatUtils::IntToWideString( tblIndent ).c_str() );
XMLTools::XMLAttribute tblIndW( _T( "w:w" ),FormatUtils::IntToWideString( tblIndent ) );
tblInd.AppendAttribute( tblIndW );
XMLTools::XMLAttribute<wchar_t> tblIndType( _T( "w:type" ), _T( "dxa" ) );
XMLTools::XMLAttribute tblIndType( _T( "w:type" ), _T( "dxa" ) );
tblInd.AppendAttribute( tblIndType );
_tblPr->AppendChild( tblInd );
@ -401,42 +401,42 @@ namespace DocFileFormat
//set borders
if ( brcTop != NULL )
{
XMLTools::XMLElement<wchar_t> topBorder( _T( "w:top" ) );
XMLTools::XMLElement topBorder( _T( "w:top" ) );
appendBorderAttributes( brcTop, &topBorder );
addOrSetBorder( _tblBorders, &topBorder );
}
if ( brcLeft != NULL )
{
XMLTools::XMLElement<wchar_t> leftBorder( _T( "w:left" ) );
XMLTools::XMLElement leftBorder( _T( "w:left" ) );
appendBorderAttributes( brcLeft, &leftBorder );
addOrSetBorder( _tblBorders, &leftBorder );
}
if ( brcBottom != NULL )
{
XMLTools::XMLElement<wchar_t> bottomBorder( _T( "w:bottom" ) );
XMLTools::XMLElement bottomBorder( _T( "w:bottom" ) );
appendBorderAttributes( brcBottom, &bottomBorder );
addOrSetBorder( _tblBorders, &bottomBorder );
}
if ( brcRight != NULL )
{
XMLTools::XMLElement<wchar_t> rightBorder( _T( "w:right" ) );
XMLTools::XMLElement rightBorder( _T( "w:right" ) );
appendBorderAttributes( brcRight, &rightBorder );
addOrSetBorder( _tblBorders, &rightBorder );
}
if ( brcHorz != NULL )
{
XMLTools::XMLElement<wchar_t> insideHBorder( _T( "w:insideH" ) );
XMLTools::XMLElement insideHBorder( _T( "w:insideH" ) );
appendBorderAttributes( brcHorz, &insideHBorder );
addOrSetBorder( _tblBorders, &insideHBorder );
}
if ( brcVert != NULL )
{
XMLTools::XMLElement<wchar_t> insideVBorder( _T( "w:insideV" ) );
XMLTools::XMLElement insideVBorder( _T( "w:insideV" ) );
appendBorderAttributes( brcVert, &insideVBorder );
addOrSetBorder( _tblBorders, &insideVBorder );
}
@ -453,20 +453,20 @@ namespace DocFileFormat
//append margins
if ( ( marginLeft == 0 ) && ( gabHalf != 0 ) )
{
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( gabHalf ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( gabHalf ), true );
}
else
{
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( marginLeft ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( marginLeft ), true );
}
if ( ( marginRight == 0 ) && ( gabHalf != 0 ) )
{
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( gabHalf ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( gabHalf ), true );
}
else
{
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( marginRight ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( marginRight ), true );
}
_tblPr->AppendChild( tblCellMar );
@ -474,11 +474,11 @@ namespace DocFileFormat
//write Properties
if ( ( _tblPr->GetChildCount() > 0 ) || ( _tblPr->GetAttributeCount() > 0 ) )
{
m_pXmlWriter->WriteString( _tblPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _tblPr->GetXMLString() );
}
//append the grid
_tblGrid = new XMLTools::XMLElement<wchar_t>( _T( "w:tblGrid" ) );
_tblGrid = new XMLTools::XMLElement( _T( "w:tblGrid" ) );
//Если _grid состоит из одних DocFormatUtils::gc_nZeroWidth и layout != "fixed", значит это doc полученный нами при конвертации из html. Таблицу размеров писать не нужно
bool bWriteGridCol = false;
@ -499,13 +499,13 @@ namespace DocFileFormat
{
for ( unsigned int i = 0; i < _grid->size(); i++ )
{
XMLTools::XMLElement<wchar_t> gridCol( _T( "w:gridCol" ) );
XMLTools::XMLAttribute<wchar_t> gridColW( _T( "w:w" ), FormatUtils::IntToWideString( _grid->at( i ) ).c_str() );
XMLTools::XMLElement gridCol( _T( "w:gridCol" ) );
XMLTools::XMLAttribute gridColW( _T( "w:w" ), FormatUtils::IntToWideString( _grid->at( i ) ) );
gridCol.AppendAttribute( gridColW );
_tblGrid->AppendChild( gridCol );
}
}
m_pXmlWriter->WriteString( _tblGrid->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _tblGrid->GetXMLString() );
}
}

View File

@ -77,9 +77,9 @@ namespace DocFileFormat
private:
XMLTools::XMLElement<wchar_t>* _tblPr;
XMLTools::XMLElement<wchar_t>* _tblGrid;
XMLTools::XMLElement<wchar_t>* _tblBorders;
XMLTools::XMLElement* _tblPr;
XMLTools::XMLElement* _tblGrid;
XMLTools::XMLElement* _tblBorders;
StyleSheet* _styles;
std::vector<short>* _grid;

View File

@ -37,9 +37,9 @@ namespace DocFileFormat
{
TableRowPropertiesMapping::TableRowPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, CharacterPropertyExceptions* rowEndChpx) : PropertiesMapping(pWriter), _trPr(NULL), _tblPrEx(NULL), _rowEndChpx(NULL)
{
_trPr = new XMLTools::XMLElement<wchar_t>(L"w:trPr");
_tblPrEx = new XMLTools::XMLElement<wchar_t>(L"w:tblPrEx");
//_tblBorders = new XMLTools::XMLElement<wchar_t>(L"w:tblBorders");
_trPr = new XMLTools::XMLElement(L"w:trPr");
_tblPrEx = new XMLTools::XMLElement(L"w:tblPrEx");
//_tblBorders = new XMLTools::XMLElement(L"w:tblBorders");
_rowEndChpx = rowEndChpx;
}
@ -58,7 +58,7 @@ namespace DocFileFormat
if ( ( _rowEndChpx != NULL ) && ( rev.Type == Deleted ) )
{
XMLTools::XMLElement<wchar_t> del( L"w:del" );
XMLTools::XMLElement del( L"w:del" );
_trPr->AppendChild( del );
}
@ -81,7 +81,7 @@ namespace DocFileFormat
if ( fHeader )
{
XMLTools::XMLElement<wchar_t> header( L"w:tblHeader" );
XMLTools::XMLElement header( L"w:tblHeader" );
_trPr->AppendChild( header );
}
}
@ -89,11 +89,11 @@ namespace DocFileFormat
case sprmTWidthAfter:
{ //width after
XMLTools::XMLElement<wchar_t> wAfter( L"w:wAfter" );
XMLTools::XMLAttribute<wchar_t> wAfterValue( L"w:w", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ) ).c_str() );
XMLTools::XMLElement wAfter( L"w:wAfter" );
XMLTools::XMLAttribute wAfterValue( L"w:w", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ) ) );
wAfter.AppendAttribute( wAfterValue );
XMLTools::XMLAttribute<wchar_t> wAfterType( L"w:type", L"dxa" );
XMLTools::XMLAttribute wAfterType( L"w:type", L"dxa" );
wAfter.AppendAttribute( wAfterType );
_trPr->AppendChild( wAfter, true );
}
@ -105,11 +105,11 @@ namespace DocFileFormat
if ( before != 0 )
{
XMLTools::XMLElement<wchar_t> wBefore( L"w:wBefore" );
XMLTools::XMLAttribute<wchar_t> wBeforeValue( L"w:w", FormatUtils::IntToWideString( before ).c_str() );
XMLTools::XMLElement wBefore( L"w:wBefore" );
XMLTools::XMLAttribute wBeforeValue( L"w:w", FormatUtils::IntToWideString( before ) );
wBefore.AppendAttribute( wBeforeValue );
XMLTools::XMLAttribute<wchar_t> wBeforeType( L"w:type", L"dxa" );
XMLTools::XMLAttribute wBeforeType( L"w:type", L"dxa" );
wBefore.AppendAttribute( wBeforeType );
_trPr->AppendChild( wBefore, true );
}
@ -119,16 +119,16 @@ namespace DocFileFormat
case sprmOldTDyaRowHeight:
case sprmTDyaRowHeight:
{ //row height
XMLTools::XMLElement<wchar_t> rowHeight( L"w:trHeight" );
XMLTools::XMLAttribute<wchar_t> rowHeightVal( L"w:val" );
XMLTools::XMLAttribute<wchar_t> rowHeightRule( L"w:hRule" );
XMLTools::XMLElement rowHeight( L"w:trHeight" );
XMLTools::XMLAttribute rowHeightVal( L"w:val" );
XMLTools::XMLAttribute rowHeightRule( L"w:hRule" );
short rH = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
if ( rH > 0 )
{
rowHeightRule.SetValue( L"atLeast" );
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ).c_str() );
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ) );
rowHeight.AppendAttribute( rowHeightVal );
}
else if( rH == 0 )
@ -139,7 +139,7 @@ namespace DocFileFormat
{
rowHeightRule.SetValue( L"exact" );
rH *= -1;
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ).c_str() );
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ) );
rowHeight.AppendAttribute( rowHeightVal );
}
@ -158,7 +158,7 @@ namespace DocFileFormat
//div id
case sprmTIpgp:
{
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
//borders 80 exceptions
@ -260,7 +260,7 @@ namespace DocFileFormat
//write Properties
if ( ( _trPr->GetChildCount() > 0 ) || ( _trPr->GetAttributeCount() > 0 ) )
{
m_pXmlWriter->WriteString( _trPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _trPr->GetXMLString() );
}
}
}

View File

@ -44,9 +44,9 @@ namespace DocFileFormat
class TableRowPropertiesMapping: public PropertiesMapping, public IMapping
{
private:
XMLTools::XMLElement<wchar_t>* _trPr;
XMLTools::XMLElement<wchar_t>* _tblPrEx;
//XMLTools::XMLElement<wchar_t>* _tblBorders;
XMLTools::XMLElement* _trPr;
XMLTools::XMLElement* _tblPrEx;
//XMLTools::XMLElement* _tblBorders;
//BorderCode brcLeft, brcTop, brcBottom, brcRight, brcHorz, brcVert;
CharacterPropertyExceptions* _rowEndChpx;
@ -55,4 +55,4 @@ namespace DocFileFormat
virtual ~TableRowPropertiesMapping();
virtual void Apply( IVisitable* visited );
};
}
}

View File

@ -96,6 +96,8 @@ namespace DocFileFormat
{
friend class TextboxMapping;
public:
static const int STRUCTURE_SIZE = 22;
struct FTXBXSReusable
{
int iNextReuse;
@ -108,8 +110,6 @@ namespace DocFileFormat
int cTxbxEdit; // This value MUST be zero and MUST be ignored.
};
static const int STRUCTURE_SIZE = 22;
FTXBXS ()
{

View File

@ -50,9 +50,8 @@ namespace DocFileFormat
void SetTextboxStyle(const std::wstring & style);
private:
static int TextboxCount;
static int TextboxCount;
int m_nTBIndex;
double m_dxTextLeft;

View File

@ -149,7 +149,7 @@ namespace DocFileFormat
file.WriteFile((BYTE*)xmlString.c_str(), xmlString.size());
file.CloseFile();
OOX::CPath path(sTempXmlFile.c_str());
OOX::CPath path(sTempXmlFile);
OOX::CDocument docEmbedded(path, path);
bool res = false;
@ -189,15 +189,14 @@ namespace DocFileFormat
return res;
}
//---------------------------------------------------------------
static int count_vml_objects = 0;
void VMLPictureMapping::appendStyleProperty(std::wstring* b, const std::wstring& propName, const std::wstring& propValue) const
{
if ( b != NULL )
{
b->operator += ( propName );
b->operator += ( _T( ":" ) );
b->operator += ( L":" );
b->operator += ( propValue );
b->operator +=( _T( ";" ) );
b->operator +=( L";" );
}
}
@ -214,9 +213,7 @@ namespace DocFileFormat
m_isEquation = false;
m_isEmbedded = false;
m_imageData = new XMLTools::XMLElement<wchar_t>( _T( "v:imagedata" ) );
m_ShapeId = std::wstring(L"_x0000_i") + FormatUtils::IntToWideString(1024 + (count_vml_objects++));
m_imageData = new XMLTools::XMLElement( L"v:imagedata" );
}
VMLPictureMapping::~VMLPictureMapping()
@ -259,19 +256,24 @@ namespace DocFileFormat
{
type.SetType(msosptPictureFrame);
}
m_pXmlWriter->WriteNodeBegin( _T( "v:shape" ), true );
m_pXmlWriter->WriteNodeBegin( L"v:shape", true );
m_pXmlWriter->WriteAttribute( _T( "type" ), std::wstring( _T( "#" ) + VMLShapeTypeMapping::GenerateTypeId(&type)).c_str());
m_pXmlWriter->WriteAttribute( L"type", std::wstring( L"#" + VMLShapeTypeMapping::GenerateTypeId(&type)));
m_pXmlWriter->WriteAttribute( _T( "id" ), m_ShapeId.c_str() );
count_vml_objects++;
if (m_shapeId.empty())
m_shapeId = L"_x0000_s" + FormatUtils::IntToWideString(1024 + count_vml_objects);
m_pXmlWriter->WriteAttribute( L"id", m_shapeId);
if (m_isOlePreview)
{
m_pXmlWriter->WriteAttribute( _T( "o:ole" ), _T( "" ) );
m_pXmlWriter->WriteAttribute( L"o:ole", L"" );
}
else if (m_isBullete)
{
m_pXmlWriter->WriteAttribute( _T( "o:bullet" ), _T( "1" ) );
m_pXmlWriter->WriteAttribute( L"o:bullet", L"1" );
}
//todooo oбъединить с shape_mapping
@ -302,25 +304,25 @@ namespace DocFileFormat
case borderBottomColor:
{
RGBColor bottomColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderbottomcolor" ), ( std::wstring( _T( "#" ) ) + bottomColor.SixDigitHexCode ).c_str() );
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor", L"#" + bottomColor.SixDigitHexCode);
}
break;
case borderLeftColor:
{
RGBColor leftColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderleftcolor" ), ( std::wstring( _T( "#" ) ) + leftColor.SixDigitHexCode ).c_str() );
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor", L"#" + leftColor.SixDigitHexCode);
}
break;
case borderRightColor:
{
RGBColor rightColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderrightcolor" ), ( std::wstring( _T( "#" ) ) + rightColor.SixDigitHexCode ).c_str() );
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor", L"#" + rightColor.SixDigitHexCode);
}
break;
case borderTopColor:
{
RGBColor topColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:bordertopcolor" ), ( std::wstring( _T( "#" ) ) + topColor.SixDigitHexCode ).c_str() );
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor", L"#" + topColor.SixDigitHexCode);
}
break;
//CROPPING
@ -328,28 +330,28 @@ namespace DocFileFormat
{
//cast to signed integer
int cropBottom = (int)iter->op;
appendValueAttribute(m_imageData, _T( "cropbottom" ), ( FormatUtils::IntToWideString( cropBottom ) + std::wstring( _T( "f" ) ) ).c_str() );
appendValueAttribute(m_imageData, L"cropbottom", FormatUtils::IntToWideString( cropBottom ) + L"f" );
}
break;
case cropFromLeft:
{
//cast to signed integer
int cropLeft = (int)iter->op;
appendValueAttribute(m_imageData, _T( "cropleft" ), ( FormatUtils::IntToWideString( cropLeft ) + std::wstring( _T( "f" ) ) ).c_str());
appendValueAttribute(m_imageData, L"cropleft", FormatUtils::IntToWideString( cropLeft ) + L"f" );
}
break;
case cropFromRight:
{
//cast to signed integer
int cropRight = (int)iter->op;
appendValueAttribute(m_imageData, _T( "cropright" ), ( FormatUtils::IntToWideString( cropRight ) + std::wstring( _T( "f" ) ) ).c_str());
appendValueAttribute(m_imageData, L"cropright", FormatUtils::IntToWideString( cropRight ) + L"f" );
}
break;
case cropFromTop:
{
//cast to signed integer
int cropTop = (int)iter->op;
appendValueAttribute(m_imageData, _T( "croptop" ), ( FormatUtils::IntToWideString( cropTop ) + std::wstring( _T( "f" ) ) ).c_str());
appendValueAttribute(m_imageData, L"croptop", FormatUtils::IntToWideString( cropTop ) + L"f" );
}
break;
//------------------------------------------------------------
@ -363,23 +365,23 @@ namespace DocFileFormat
std::wstring v = strHeight;
strHeight = strWidth; strWidth = v;
appendStyleProperty(&strStyle, _T( "rotation" ), FormatUtils::DoubleToWideString(dAngle));
appendStyleProperty(&strStyle, L"rotation", FormatUtils::DoubleToWideString(dAngle));
}break;
case posh:
{
appendStyleProperty(&strStyle, _T("mso-position-horizontal"), VMLShapeMapping::mapHorizontalPosition((PositionHorizontal)iter->op));
appendStyleProperty(&strStyle, L"mso-position-horizontal", VMLShapeMapping::mapHorizontalPosition((PositionHorizontal)iter->op));
}break;
case posrelh:
{
appendStyleProperty(&strStyle, _T("mso-position-horizontal-relative"), VMLShapeMapping::mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op));
appendStyleProperty(&strStyle, L"mso-position-horizontal-relative", VMLShapeMapping::mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op));
}break;
case posv:
{
appendStyleProperty(&strStyle, _T("mso-position-vertical"), VMLShapeMapping::mapVerticalPosition((PositionVertical)iter->op));
appendStyleProperty(&strStyle, L"mso-position-vertical", VMLShapeMapping::mapVerticalPosition((PositionVertical)iter->op));
}break;
case posrelv:
{
appendStyleProperty(&strStyle, _T("mso-position-vertical-relative"), VMLShapeMapping::mapVerticalPositionRelative((PositionVerticalRelative)iter->op));
appendStyleProperty(&strStyle, L"mso-position-vertical-relative", VMLShapeMapping::mapVerticalPositionRelative((PositionVerticalRelative)iter->op));
}break;
case groupShapeBooleans:
{
@ -388,57 +390,53 @@ namespace DocFileFormat
if (groupShapeBooleans.fUsefBehindDocument && groupShapeBooleans.fBehindDocument)
{
//The shape is behind the text, so the z-index must be negative.
appendStyleProperty(&strStyle, _T( "z-index" ), _T( "-1" ) );
appendStyleProperty(&strStyle, L"z-index", L"-1" );
}
//else if (!m_isInlinePicture)
//{
// appendStyleProperty( &strStyle, _T( "z-index" ), FormatUtils::IntToWideString(zIndex + 0x7ffff));
// appendStyleProperty( &strStyle, L"z-index", FormatUtils::IntToWideString(zIndex + 0x7ffff));
//}
if (groupShapeBooleans.fHidden && groupShapeBooleans.fUsefHidden)
{
appendStyleProperty(&strStyle, _T( "visibility" ), _T( "hidden" ));
appendStyleProperty(&strStyle, L"visibility", L"hidden");
}
}
break;
}
}
strStyle += _T( "width:" ) + strWidth + _T( "pt;" ) + _T( "height:" ) + strHeight + _T( "pt;" );
m_pXmlWriter->WriteAttribute( _T( "style" ), strStyle.c_str() );
strStyle += L"width:" + strWidth + L"pt;" + L"height:" + strHeight + L"pt;";
m_pXmlWriter->WriteAttribute( L"style", strStyle);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
if (CopyPicture(pict))
{
//v:imageData
appendValueAttribute(m_imageData, _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" ));
m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str());
appendValueAttribute(m_imageData, L"r:id", L"rId" + FormatUtils::IntToWideString(m_nImageId));
appendValueAttribute(m_imageData, L"o:title", L"" );
m_pXmlWriter->WriteString(m_imageData->GetXMLString());
}
//borders
writePictureBorder( _T( "bordertop" ), pict->brcTop );
writePictureBorder( _T( "borderleft" ), pict->brcLeft );
writePictureBorder( _T( "borderbottom" ), pict->brcBottom );
writePictureBorder( _T( "borderright" ), pict->brcRight );
{//borders
writePictureBorder( L"bordertop", pict->brcTop );
writePictureBorder( L"borderleft", pict->brcLeft );
writePictureBorder( L"borderbottom", pict->brcBottom );
writePictureBorder( L"borderright", pict->brcRight );
}
m_pXmlWriter->WriteNodeEnd( _T( "v:shape" ) );
}
std::wstring VMLPictureMapping::GetShapeId () const
{
return m_ShapeId;
m_pXmlWriter->WriteNodeEnd( L"v:shape" );
}
void VMLPictureMapping::writePictureBorder( const std::wstring & name, const BorderCode* brc )
{
if (!brc || name.empty()) return;
m_pXmlWriter->WriteNodeBegin( ( std::wstring( _T( "w10:" ) ) + name).c_str(), true );
m_pXmlWriter->WriteAttribute( _T( "type" ), getBorderType( brc->brcType ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "width" ), FormatUtils::IntToWideString( brc->dptLineWidth ).c_str() );
m_pXmlWriter->WriteNodeEnd ( _T( "" ), true );
m_pXmlWriter->WriteNodeBegin( L"w10:" + name, true );
m_pXmlWriter->WriteAttribute( L"type", getBorderType( brc->brcType ));
m_pXmlWriter->WriteAttribute( L"width", FormatUtils::IntToWideString( brc->dptLineWidth ));
m_pXmlWriter->WriteNodeEnd ( L"", true );
}
bool VMLPictureMapping::CopyPicture (PictureDescriptor* pict)
@ -537,26 +535,26 @@ namespace DocFileFormat
switch (nType)
{
case Global::msoblipDIB:
return std::wstring(_T(".bmp"));
return std::wstring(L".bmp");
case Global::msoblipEMF:
return std::wstring(_T(".emf"));
return std::wstring(L".emf");
case Global::msoblipJPEG:
case Global::msoblipCMYKJPEG:
return std::wstring(_T(".jpg"));
return std::wstring(L".jpg");
case Global::msoblipPNG:
return std::wstring(_T(".png"));
return std::wstring(L".png");
case Global::msoblipTIFF:
return std::wstring(_T(".tif"));
return std::wstring(L".tif");
case Global::msoblipWMF:
return std::wstring(_T(".wmf"));
return std::wstring(L".wmf");
default:
return std::wstring(_T(".png"));
return std::wstring(L".png");
}
}
@ -568,17 +566,17 @@ namespace DocFileFormat
return std::wstring(OpenXmlContentTypes::Emf);
//case msoblipGIF:
// return wstring( _T( "image/gif" ) );
// return wstring( L"image/gif" );
//case msoblipICON:
// return wstring( _T( "image/x-icon" ) );
// return wstring( L"image/x-icon" );
case Global::msoblipJPEG:
case Global::msoblipCMYKJPEG:
return std::wstring(OpenXmlContentTypes::Jpeg);
//case msoblipPCX:
// return wstring( _T( "image/pcx" ) );
// return wstring( L"image/pcx" );
case Global::msoblipPNG:
return std::wstring(OpenXmlContentTypes::Png);

View File

@ -54,8 +54,6 @@ namespace DocFileFormat
VMLPictureMapping( ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture = false );
virtual ~VMLPictureMapping();
virtual void Apply( IVisitable* visited );
std::wstring GetShapeId() const;
private:
/// Writes a border element
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
@ -75,17 +73,18 @@ namespace DocFileFormat
bool m_isEmbedded;
std::string m_embeddedData;
std::wstring m_equationXml;
std::wstring m_shapeId;
private:
ConversionContext* m_ctx;
IMapping* m_caller;
int m_nImageId;
std::wstring m_ShapeId;
bool m_isOlePreview;
bool m_isInlinePicture;
XMLTools::XMLElement<wchar_t>* m_imageData;
XMLTools::XMLElement* m_imageData;
};
}

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,8 @@ namespace DocFileFormat
static std::wstring mapHorizontalPosition (PositionHorizontal hPos );
static std::wstring mapHorizontalPositionRelative(int hRel );
bool m_isBullete;
bool m_isBullete;
std::wstring m_shapeId;
private:
void ApplyPrimitives (DrawingPrimitives * primitives );
@ -129,14 +130,14 @@ namespace DocFileFormat
BlipStoreContainer* m_pBlipStore;
int m_nImageId;
std::wstring m_textPathStyle;
ConversionContext* m_ctx;
ConversionContext* m_context;
PictureDescriptor* m_pict;
XMLTools::XMLElement<wchar_t> m_fill;
XMLTools::XMLElement<wchar_t> m_stroke;
XMLTools::XMLElement<wchar_t> m_shadow;
XMLTools::XMLElement<wchar_t> m_imagedata;
XMLTools::XMLElement<wchar_t> m_3dstyle;
XMLTools::XMLElement<wchar_t> m_textpath;
XMLTools::XMLElement m_fill;
XMLTools::XMLElement m_stroke;
XMLTools::XMLElement m_shadow;
XMLTools::XMLElement m_imagedata;
XMLTools::XMLElement m_3dstyle;
XMLTools::XMLElement m_textpath;
};
}

View File

@ -38,7 +38,7 @@ namespace DocFileFormat
{
VMLShapeTypeMapping::VMLShapeTypeMapping (XMLTools::CStringXmlWriter* pWriter, bool isInlineShape) : PropertiesMapping(pWriter), _lock(NULL), _isInlineShape(isInlineShape)
{
this->_lock = new XMLTools::XMLElement<wchar_t>( L"o:lock");
this->_lock = new XMLTools::XMLElement( L"o:lock");
appendValueAttribute( this->_lock, L"v:ext", L"edit");
}
@ -58,21 +58,21 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"v:shapetype", true );
// ID
m_pXmlWriter->WriteAttribute( L"id", GenerateTypeId( pShape ).c_str() );
m_pXmlWriter->WriteAttribute( L"id", GenerateTypeId( pShape ));
// Coordinate System
m_pXmlWriter->WriteAttribute( L"coordsize", L"21600,21600");
// Shape Code
m_pXmlWriter->WriteAttribute( L"o:spt", FormatUtils::IntToWideString( pShape->GetTypeCode() ).c_str() );
m_pXmlWriter->WriteAttribute( L"o:spt", FormatUtils::IntToWideString( pShape->GetTypeCode() ));
// Adj
if (pShape->AdjustmentValues.length())
m_pXmlWriter->WriteAttribute( L"adj", pShape->AdjustmentValues.c_str() );
m_pXmlWriter->WriteAttribute( L"adj", pShape->AdjustmentValues);
// Path
if (!pShape->Path.empty())
m_pXmlWriter->WriteAttribute( L"path", pShape->Path.c_str() );
m_pXmlWriter->WriteAttribute( L"path", pShape->Path);
else if (_isInlineShape)
m_pXmlWriter->WriteAttribute( L"path", L"m@4@5l@4@11@9@11@9@5xe");
@ -99,12 +99,12 @@ namespace DocFileFormat
if (!pShape->Textpath.empty())
{
m_pXmlWriter->WriteNodeBegin( L"v:textpath", true );
m_pXmlWriter->WriteString( pShape->Textpath.c_str() );
m_pXmlWriter->WriteString( pShape->Textpath );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
// Stroke
m_pXmlWriter->WriteNodeBegin( L"v:stroke", true );
m_pXmlWriter->WriteAttribute( L"joinstyle", FormatUtils::MapValueToWideString( pShape->Joins, &JoinStyleMap[0][0], 3, 6 ).c_str() );
m_pXmlWriter->WriteAttribute( L"joinstyle", FormatUtils::MapValueToWideString( pShape->Joins, &JoinStyleMap[0][0], 3, 6 ));
m_pXmlWriter->WriteNodeEnd( L"", true );
// Formulas
@ -115,7 +115,7 @@ namespace DocFileFormat
for ( std::list<std::wstring>::iterator iter = pShape->Formulas.begin(); iter != pShape->Formulas.end(); iter++ )
{
m_pXmlWriter->WriteNodeBegin( L"v:f", true );
m_pXmlWriter->WriteAttribute( L"eqn", iter->c_str() );
m_pXmlWriter->WriteAttribute( L"eqn", *iter );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -147,19 +147,19 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"gradientshapeok", L"t" );
if (pShape->Limo.length())
m_pXmlWriter->WriteAttribute( L"limo", pShape->Limo.c_str() );
m_pXmlWriter->WriteAttribute( L"limo", pShape->Limo );
if (pShape->ConnectorLocations.length())
{
m_pXmlWriter->WriteAttribute( L"o:connecttype", L"custom");
m_pXmlWriter->WriteAttribute( L"o:connectlocs", pShape->ConnectorLocations.c_str() );
m_pXmlWriter->WriteAttribute( L"o:connectlocs", pShape->ConnectorLocations);
}
if (pShape->TextBoxRectangle.length())
m_pXmlWriter->WriteAttribute( L"textboxrect", pShape->TextBoxRectangle.c_str() );
m_pXmlWriter->WriteAttribute( L"textboxrect", pShape->TextBoxRectangle);
if (pShape->ConnectorAngles.length())
m_pXmlWriter->WriteAttribute( L"o:connectangles", pShape->ConnectorAngles.c_str() );
m_pXmlWriter->WriteAttribute( L"o:connectangles", pShape->ConnectorAngles);
}
WordArtTextType* wordArt = dynamic_cast<WordArtTextType*>(pShape);
if (wordArt)
@ -177,7 +177,7 @@ namespace DocFileFormat
if ( _lock->GetAttributeCount() > 1 )
{
m_pXmlWriter->WriteString( _lock->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _lock->GetXMLString() );
}
// Handles
@ -190,22 +190,22 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"v:h", true );
if (iter->position.length())
m_pXmlWriter->WriteAttribute( L"position", iter->position.c_str() );
m_pXmlWriter->WriteAttribute( L"position", iter->position);
if (iter->switchHandle.length())
m_pXmlWriter->WriteAttribute( L"switch", iter->switchHandle.c_str() );
m_pXmlWriter->WriteAttribute( L"switch", iter->switchHandle);
if (iter->xrange.length())
m_pXmlWriter->WriteAttribute( L"xrange", iter->xrange.c_str() );
m_pXmlWriter->WriteAttribute( L"xrange", iter->xrange);
if (iter->yrange.length())
m_pXmlWriter->WriteAttribute( L"yrange", iter->yrange.c_str() );
m_pXmlWriter->WriteAttribute( L"yrange", iter->yrange);
if (iter->polar.length())
m_pXmlWriter->WriteAttribute( L"polar", iter->polar.c_str() );
m_pXmlWriter->WriteAttribute( L"polar", iter->polar);
if (iter->radiusrange.length())
m_pXmlWriter->WriteAttribute( L"radiusrange", iter->radiusrange.c_str() );
m_pXmlWriter->WriteAttribute( L"radiusrange", iter->radiusrange );
m_pXmlWriter->WriteNodeEnd( L"", true );
}

View File

@ -37,11 +37,13 @@
namespace DocFileFormat
{
static int count_vml_objects = 0;
class VMLShapeTypeMapping: public PropertiesMapping, public IMapping
{
private:
XMLTools::XMLElement<wchar_t> *_lock;
bool _isInlineShape;
XMLTools::XMLElement * _lock;
bool _isInlineShape;
public:
VMLShapeTypeMapping(XMLTools::CStringXmlWriter* writer, bool isInlineShape = false );

View File

@ -49,7 +49,7 @@ namespace DocFileFormat
EndnoteReferenceCharactersPlex(NULL), FieldsPlex(NULL), FootnoteDocumentFieldsPlex(NULL),
EndnoteDocumentFieldsPlex(NULL), HeadersAndFootersDocumentFieldsPlex(NULL), HeaderStoriesPlex(NULL),
AnnotationsReferencePlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
TextboxIndividualPlex(NULL),
TextboxIndividualPlex(NULL),AssocNames(NULL), BookmarkAnnotNames(NULL), Captions(NULL), AutoCaptions(NULL), ListPlex(NULL),
OfficeDrawingPlex(NULL), OfficeDrawingPlexHeader(NULL), SectionPlex(NULL), BookmarkStartPlex(NULL), BookmarkEndPlex(NULL),
AutoTextPlex(NULL), AllPapxFkps(NULL), AllChpxFkps(NULL), AllPapx(NULL), AllPapxVector(NULL), AllSepx(NULL), Styles(NULL), listTable(NULL),
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL), encryptionHeader(NULL)
@ -218,10 +218,14 @@ namespace DocFileFormat
m_pStorage->GetStream ("WordDocument", &TableStream);
}
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
FontTable = new StringTable<FontFamilyName> (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, bOlderVersion);
BookmarkNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, bOlderVersion);
AutoTextNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, bOlderVersion);
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
FontTable = new StringTable<FontFamilyName> (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, bOlderVersion);
BookmarkNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, bOlderVersion);
AutoTextNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, bOlderVersion);
AssocNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAssoc, FIB->m_FibWord97.lcbSttbfAssoc, bOlderVersion);
BookmarkAnnotNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, bOlderVersion);
Captions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfCaption, FIB->m_FibWord97.lcbSttbfCaption, bOlderVersion);
AutoCaptions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAutoCaption, FIB->m_FibWord97.lcbSttbfAutoCaption, bOlderVersion);
if (m_pCallFunc)
{
@ -268,7 +272,7 @@ namespace DocFileFormat
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, bOlderVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, bOlderVersion);
TextboxIndividualPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, bOlderVersion);
BookmarkStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, bOlderVersion);
@ -286,12 +290,13 @@ namespace DocFileFormat
}
}
AutoTextPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion);
FieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion);
EndnoteDocumentFieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, bOlderVersion);
HeadersAndFootersDocumentFieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, bOlderVersion);
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion);
EndnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, bOlderVersion);
HeadersAndFootersDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, bOlderVersion);
ListPlex = new Plex<ListNumCache> (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, bOlderVersion);
if (m_pCallFunc)
{
m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000 );
@ -366,9 +371,9 @@ namespace DocFileFormat
if ( ( bookmarkName != NULL ) && ( *bookmarkName == L"_PictureBullets" ) )
{
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < this->Text->size(); ++j, ++k )
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
{
if ( this->Text->at( j ) == 1 )
if ( Text->at( j ) == 1 )
{
PictureBulletsCPsMap.insert (std::make_pair( k, j ));
}
@ -419,7 +424,7 @@ namespace DocFileFormat
int cp = SectionPlex->CharacterPositions[i + 1];
//Get the SEPX
VirtualStreamReader wordReader( this->WordDocumentStream, sed->fcSepx, bOlderVersion);
VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, bOlderVersion);
//!!!TODO: cbSepx is the size in bytes of the rest properties part!!!
short cbSepx = wordReader.ReadInt16();
@ -592,6 +597,11 @@ namespace DocFileFormat
RELEASEOBJECT(FontTable);
RELEASEOBJECT(BookmarkNames);
RELEASEOBJECT(AutoTextNames);
RELEASEOBJECT(AutoCaptions);
RELEASEOBJECT(Captions);
RELEASEOBJECT(BookmarkAnnotNames);
RELEASEOBJECT(AssocNames);
RELEASEOBJECT(IndividualFootnotesPlex);
RELEASEOBJECT(FootnoteReferenceCharactersPlex);
RELEASEOBJECT(IndividualEndnotesPlex);
@ -613,6 +623,7 @@ namespace DocFileFormat
RELEASEOBJECT(BookmarkStartPlex);
RELEASEOBJECT(BookmarkEndPlex);
RELEASEOBJECT(AutoTextPlex);
RELEASEOBJECT(ListPlex);
RELEASEOBJECT(Styles);
RELEASEOBJECT(listTable);
RELEASEOBJECT(AllPapx);
@ -661,7 +672,7 @@ namespace DocFileFormat
//last fkp?
//use full table
if ( i++ == ( this->AllChpxFkps->size() - 1 ) )
if ( i++ == ( AllChpxFkps->size() - 1 ) )
{
max = fkp->rgfcSize;
}
@ -699,8 +710,7 @@ namespace DocFileFormat
{
FormattedDiskPageCHPX *fkp = (*iter);
// get the CHPX
// get the CHPX
for (unsigned int j = 0; j < fkp->grpchpxSize; ++j)
{
if ( ( fkp->rgfc[j] < fcMin ) && ( fkp->rgfc[j + 1] > fcMin ) )

View File

@ -177,6 +177,10 @@ namespace DocFileFormat
StringTable<FontFamilyName> *FontTable; // A list of all font names, used in the doucument
StringTable<WideString> *BookmarkNames;
StringTable<WideString> *AutoTextNames;
StringTable<WideString> *AssocNames;
StringTable<WideString> *BookmarkAnnotNames;
StringTable<WideString> *Captions;
StringTable<WideString> *AutoCaptions;
Plex<EmptyStructure> *IndividualFootnotesPlex; //A plex of locations of individual footnotes
Plex<FootnoteDescriptor> *FootnoteReferenceCharactersPlex; //A plex of footnote reference characters
@ -187,7 +191,7 @@ namespace DocFileFormat
Plex<EmptyStructure> *HeaderStoriesPlex; //A plex of the header document
Plex<EmptyStructure> *IndividualCommentsPlex; // A plex with all ATRDPre10 structs
Plex<EmptyStructure> *TextboxIndividualPlex;
Plex<FTXBXS> *TextboxIndividualPlex;
Plex<Tbkd> *TextboxBreakPlex; // Describes the breaks inside the textbox subdocument
Plex<Tbkd> *TextboxBreakPlexHeader; // Describes the breaks inside the header textbox subdocument
@ -200,13 +204,14 @@ namespace DocFileFormat
Plex<BookmarkFirst> *BookmarkStartPlex;
Plex<EmptyStructure> *BookmarkEndPlex;
Plex<ListNumCache> *ListPlex;
Plex<FieldCharacter> *FieldsPlex;
Plex<FieldCharacter> *FootnoteDocumentFieldsPlex;
Plex<FieldCharacter> *EndnoteDocumentFieldsPlex;
Plex<FieldCharacter> *HeadersAndFootersDocumentFieldsPlex;
Plex<AnnotationReferenceDescriptor> *AnnotationsReferencePlex;
Plex<EmptyStructure> *AutoTextPlex; // Each character position specifies the beginning of\
a range of text that constitutes the contents of an AutoText item
Plex<EmptyStructure> *AutoTextPlex;
// Each character position specifies the beginning of a range of text that constitutes the contents of an AutoText item
};
}

View File

@ -183,7 +183,7 @@ namespace DocFileFormat
void WordprocessingDocument::SaveDocument()
{
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + _T( "word" ) ;
//OOX::CPath pathWord = CString(m_strOutputPath.c_str()) + FILE_SEPARATOR_STR + _T( "word" );
//OOX::CPath pathWord = CString(m_strOutputPath) + FILE_SEPARATOR_STR + _T( "word" );
//FileSystem::Directory::CreateDirectory( pathWord.GetPath() );
NSDirectory::CreateDirectory( pathWord );

View File

@ -32,14 +32,12 @@
#ifndef DOC_FORMAT_LIB
#define DOC_FORMAT_LIB
#include <string>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#endif
#include "../../DesktopEditor/common/ASCVariant.h"
struct ProgressCallback;
class COfficeDocFile

View File

@ -32,7 +32,7 @@ INCLUDEPATH += \
../../../DesktopEditor/xml/libxml2/include
core_mac {
QMAKE_MAC_SDK = macosx10.11
#QMAKE_MAC_SDK = macosx10.11
}
SOURCES += \
@ -40,12 +40,15 @@ SOURCES += \
../../../Common/3dParty/pole/pole.cpp \
../../DocDocxConverter/EncryptionHeader.cpp \
../../DocDocxConverter/DrawingPrimitives.cpp \
../../DocDocxConverter/Spa.cpp
../../DocDocxConverter/Spa.cpp \
../../DocDocxConverter/OleObject.cpp
build_fast {
core_release {
SOURCES += \
docformatlib_converter.cpp
} else {
}
core_debug {
SOURCES += \
../../DocDocxConverter/AnnotationReferenceDescriptor.cpp \
../../DocDocxConverter/CharacterPropertiesMapping.cpp \

View File

@ -29,6 +29,7 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../../DocDocxConverter/AnnotationReferenceDescriptor.cpp"
#include "../../DocDocxConverter/CharacterPropertiesMapping.cpp"
#include "../../DocDocxConverter/Converter.cpp"

View File

@ -555,6 +555,10 @@
RelativePath="..\..\DocDocxConverter\OfficeArtContent.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.cpp"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.h"
>

View File

@ -50,8 +50,10 @@
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
std::wstring sSrcDoc = argv[1];
std::wstring sDstDocx = argv[2];
std::wstring sDstDocx = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx";
std::wstring outputDir = FileSystem::Directory::GetFolderPath(sDstDocx);
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);

View File

@ -42,16 +42,16 @@ namespace Writers
{
public:
std::wstring content;
CString filename;
std::wstring filename;
int index;
};
std::vector<ChartElem*> m_aCharts;
ContentTypesWriter& m_oContentTypesWriter;
ContentTypesWriter& m_oContentTypesWriter;
int nChartCount;
public:
CString m_sDir;
std::wstring m_sDir;
public:
ChartWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
ChartWriter(std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
nChartCount = 0;
}
@ -71,7 +71,7 @@ namespace Writers
if(false == IsEmpty())
{
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
FileSystem::Directory::CreateDirectory(string2std_string(pathChartDir.GetPath()));
FileSystem::Directory::CreateDirectory(pathChartDir.GetPath());
for(int i = 0, length = m_aCharts.size(); i < length; ++i)
{
@ -80,25 +80,26 @@ namespace Writers
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename;
NSFile::CFileBinary oFile;
oFile.CreateFileW(string2std_string(filePath.GetPath()));
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
//Content_Types
CString sRelPath = _T("/word/charts/") + elem->filename;
m_oContentTypesWriter.AddOverride(sRelPath, CString(_T("application/vnd.openxmlformats-officedocument.drawingml.chart+xml")));
std::wstring sRelPath = L"/word/charts/" + elem->filename;
m_oContentTypesWriter.AddOverride(sRelPath, L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
}
}
}
void AddChart(std::wstring& content, CString& sRelsName, CString& sFileName, int& index)
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index)
{
ChartElem* pChartElem = new ChartElem();
pChartElem->content = content;
pChartElem->index = nChartCount + 1;
nChartCount++;
pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index);
sRelsName = _T("charts/") + pChartElem->filename;
pChartElem->filename = L"chart" + std::to_wstring(pChartElem->index) + L".xml";
sRelsName = L"charts/" + pChartElem->filename;
sFileName = pChartElem->filename;
index = pChartElem->index;

View File

@ -36,18 +36,18 @@
namespace Writers
{
static CString g_string_ct_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
static CString g_string_ct_Ext = _T("<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\"/><Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>");
static CString g_string_ct_Override = _T("<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>");
static CString g_string_ct_End = _T("</Types>");
static std::wstring g_string_ct_Start = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">";
static std::wstring g_string_ct_Ext = L"<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\"/><Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>";
static std::wstring g_string_ct_Override = L"<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>";
static std::wstring g_string_ct_End = L"</Types>";
class ContentTypesWriter
{
XmlUtils::CStringWriter m_oWriter;
CString m_sDir;
std::wstring m_sDir;
XmlUtils::CStringWriter m_oAdditional;
public:
ContentTypesWriter(CString sDir):m_sDir(sDir)
ContentTypesWriter(std::wstring sDir) : m_sDir(sDir)
{
}
void Write()
@ -58,7 +58,7 @@ namespace Writers
m_oWriter.Write(m_oAdditional);
m_oWriter.WriteString(g_string_ct_End);
OOX::CPath filePath = m_sDir + _T("/[Content_Types].xml");
OOX::CPath filePath = m_sDir + L"/[Content_Types].xml";
CFile oFile;
oFile.CreateFile(filePath.GetPath());
@ -66,12 +66,12 @@ namespace Writers
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
void AddOverride(const CString& PartName, const CString& ContentType)
void AddOverride(const std::wstring& PartName, const std::wstring& ContentType)
{
CString sOverride;sOverride.Format(_T("<Override PartName=\"%ls\" ContentType=\"%ls\"/>"),PartName , ContentType);
std::wstring sOverride = L"<Override PartName=\"" + PartName+ L"\ ContentType=\"" + ContentType + L"\"/>";
m_oAdditional.WriteString(sOverride);
}
void AddOverrideRaw(const CString& sXml)
void AddOverrideRaw(const std::wstring& sXml)
{
m_oAdditional.WriteString(sXml);
}

View File

@ -53,13 +53,22 @@ namespace Writers
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
oFile.WriteStringUTF8(CString(_T("<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">")));
oFile.WriteStringUTF8(m_oBackground.GetData());
oFile.WriteStringUTF8(CString(_T("<w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body>")));
oFile.WriteStringUTF8(CString(_T("</w:document>")));
oFile.CloseFile();
}
CString WriteSectPrHdrFtr()

View File

@ -39,7 +39,8 @@ namespace Writers
class ContentWriter
{
public:
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oBackground;
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oSecPr;
};
class HdrFtrItem

View File

@ -39,26 +39,26 @@ namespace Writers
class MediaWriter
{
XmlUtils::CStringWriter m_oWriter;
CString m_sDir;
CString m_sMediaDir;
std::wstring m_sDir;
std::wstring m_sMediaDir;
public:
std::vector<CString> m_aImageNames;
std::vector<std::wstring> m_aImageNames;
long nImageCount;
public:
MediaWriter(CString sDir):m_sDir(sDir)
MediaWriter(std::wstring sDir):m_sDir(sDir)
{
nImageCount = 0;
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("media");
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"media";
m_sMediaDir = filePath.GetPath();
}
CString AddImageGetNewPath()
std::wstring AddImageGetNewPath()
{
OOX::CSystemUtility::CreateDirectories(m_sMediaDir);
CString sNewImgName;sNewImgName.Format(_T("image%d.jpg"), (nImageCount + 1));
CString sNewImg = m_sMediaDir + FILE_SEPARATOR_STR + sNewImgName;
std::wstring sNewImgName = L"image" + std::to_wstring(nImageCount + 1) + L".jpg";
std::wstring sNewImg = m_sMediaDir + FILE_SEPARATOR_STR + sNewImgName;
nImageCount++;
return sNewImg;
}
@ -72,23 +72,23 @@ namespace Writers
DWORD dwSizeRead = (DWORD)fread((void*)pData, 1, size, pFile);
if(dwSizeRead > 0)
{
CString sNewImagePath = AddImageGetNewPath();
std::wstring sNewImagePath = AddImageGetNewPath();
NSFile::CFileBinary oFile;
oFile.CreateFileW(string2std_string(sNewImagePath));
oFile.CreateFileW(sNewImagePath);
oFile.WriteFile(pData, dwSizeRead);
oFile.CloseFile();
CString sFilename = NSSystemPath::GetFileName(string2std_string(sNewImagePath)).c_str();
std::wstring sFilename = NSSystemPath::GetFileName(sNewImagePath);
m_aImageNames.push_back(sFilename);
}
RELEASEARRAYOBJECTS(pData);
}
}
void AddImage(const CString& sImg)
void AddImage(const std::wstring& sImg)
{
OOX::CPath pathNewImg = AddImageGetNewPath();
NSFile::CFileBinary::Copy(string2std_string(sImg), string2std_string(pathNewImg.GetPath()));
CString sFilename = NSSystemPath::GetFileName(string2std_string(pathNewImg.GetPath())).c_str();
NSFile::CFileBinary::Copy(sImg, pathNewImg.GetPath());
std::wstring sFilename = NSSystemPath::GetFileName(pathNewImg.GetPath()).c_str();
m_aImageNames.push_back(sFilename);
}
};

File diff suppressed because it is too large Load Diff

View File

@ -33,13 +33,14 @@
#define READERS
#include "FileWriter.h"
#include "../BinWriter/BinReaderWriterDefines.h"
#include "ReaderClasses.h"
#include "../BinWriter/BinReaderWriterDefines.h"
#include "../../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../DocWrapper/XlsxSerializer.h"
#include "../../DesktopEditor/common/ASCVariant.h"
namespace BinDocxRW {
@ -613,9 +614,8 @@ public:
if(0 != contextualSpacing)
pCStringWriter->WriteString(CString(_T("<w:contextualSpacing w:val=\"true\"/>")));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:contextualSpacing w:val=\"false\"/>")));
break;
}
pCStringWriter->WriteString(CString(_T("<w:contextualSpacing w:val=\"false\"/>")));
}break;
case c_oSerProp_pPrType::Ind:
{
XmlUtils::CStringWriter oTempWriter;
@ -637,27 +637,24 @@ public:
case align_Left: pCStringWriter->WriteString(CString(_T("<w:jc w:val=\"left\" />")));break;
case align_Center: pCStringWriter->WriteString(CString(_T("<w:jc w:val=\"center\" />")));break;
case align_Justify: pCStringWriter->WriteString(CString(_T("<w:jc w:val=\"both\" />")));break;
}
break;
}
}
}break;
case c_oSerProp_pPrType::KeepLines:
{
BYTE KeepLines = m_oBufferedStream.GetUChar();
if(0 != KeepLines)
pCStringWriter->WriteString(CString(_T("<w:keepLines/>")));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:keepLines w:val=\"false\"/>")));
break;
}
pCStringWriter->WriteString(CString(_T("<w:keepLines w:val=\"false\"/>")));
}break;
case c_oSerProp_pPrType::KeepNext:
{
BYTE KeepNext = m_oBufferedStream.GetUChar();
if(0 != KeepNext)
pCStringWriter->WriteString(CString(_T("<w:keepNext/>")));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:keepNext w:val=\"false\"/>")));
break;
}
pCStringWriter->WriteString(CString(_T("<w:keepNext w:val=\"false\"/>")));
}break;
case c_oSerProp_pPrType::PageBreakBefore:
{
BYTE pageBreakBefore = m_oBufferedStream.GetUChar();
@ -788,34 +785,33 @@ public:
pCStringWriter->WriteString(sTab);
}
pCStringWriter->WriteString(CString(_T("</w:tabs>")));
}
break;
}
}
}break;
case c_oSerProp_pPrType::ParaStyle:
{
CString sStyleName(m_oBufferedStream.GetString3(length));
sStyleName = XmlUtils::EncodeXmlString(sStyleName);
CString sStyle;
sStyle.Append(_T("<w:pStyle w:val=\""));
sStyle.Append(sStyleName);
sStyle.Append(_T("\" />"));
pCStringWriter->WriteString(sStyle);
break;
}
sStyle += L"<w:pStyle w:val=\"";
sStyle += sStyleName;
sStyle += L"\" />";
pCStringWriter->WriteString(sStyle);
}break;
case c_oSerProp_pPrType::numPr:
pCStringWriter->WriteString(CString(_T("<w:numPr>")));
res = Read2(length, &Binary_pPrReader::ReadNumPr, this, poResult);
pCStringWriter->WriteString(CString(_T("</w:numPr>")));
break;
{
pCStringWriter->WriteString(CString(_T("<w:numPr>")));
res = Read2(length, &Binary_pPrReader::ReadNumPr, this, poResult);
pCStringWriter->WriteString(CString(_T("</w:numPr>")));
}break;
case c_oSerProp_pPrType::pPr_rPr:
{
rPr orPr(m_oFontTableWriter.m_mapFonts);
res = oBinary_rPrReader.Read(length, &orPr);
//Read2(length, &Binary_pPrReader::ReadNumPr, this, &orPr);
if(orPr.IsNoEmpty())
orPr.Write(pCStringWriter);
break;
}
orPr.Write(pCStringWriter);
}break;
case c_oSerProp_pPrType::pBdr:
{
docBorders odocBorders;
@ -825,33 +821,29 @@ public:
pCStringWriter->WriteString(CString(_T("<w:pBdr>")));
odocBorders.Write(pCStringWriter, false);
pCStringWriter->WriteString(CString(_T("</w:pBdr>")));
}
break;
}
}
}break;
case c_oSerProp_pPrType::FramePr:
{
CFramePr oFramePr;
res = Read2(length, &Binary_pPrReader::ReadFramePr, this, &oFramePr);
if(false == oFramePr.IsEmpty())
oFramePr.Write(*pCStringWriter);
break;
}
oFramePr.Write(*pCStringWriter);
}break;
case c_oSerProp_pPrType::pPrChange:
{
TrackRevision oPPrChange;
res = Read1(length, &Binary_pPrReader::ReadPPrChange, this, &oPPrChange);
oPPrChange.Write(pCStringWriter, _T("w:pPrChange"));
break;
}
case c_oSerProp_pPrType::SectPr:
oPPrChange.Write(pCStringWriter, _T("w:pPrChange"));
}break;
case c_oSerProp_pPrType::SectPr:
{
SectPr oSectPr;
res = Read1(length, &Binary_pPrReader::Read_SecPr, this, &oSectPr);
pCStringWriter->WriteString(CString(_T("<w:sectPr>")));
pCStringWriter->WriteString(oSectPr.Write());
pCStringWriter->WriteString(CString(_T("</w:sectPr>")));
break;
}
pCStringWriter->WriteString(CString(_T("</w:sectPr>")));
}break;
default:
res = c_oSerConstants::ReadUnknown;
break;
@ -871,7 +863,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadInd(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -913,7 +905,7 @@ public:
break;
}
return res;
};
}
int ReadSpacing(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -949,7 +941,7 @@ public:
break;
}
return res;
};
}
int ReadTabs(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -975,7 +967,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadNumPr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1050,7 +1042,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadBorder(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1083,7 +1075,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadFramePr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1161,9 +1153,9 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int Read_SecPr(BYTE type, long length, void* poResult)
{
}
int Read_SecPr(BYTE type, long length, void* poResult)
{
SectPr* pSectPr = static_cast<SectPr*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerProp_secPrType::pgSz == type )
@ -1686,9 +1678,9 @@ public:
res = Read1(length, &Binary_tblPrReader::ReadCellMargins, this, &oTempWriter);
if(oTempWriter.GetCurSize() > 0)
{
pWiterTblPr->TableCellMar.Append(CString(_T("<w:tblCellMar>")));
pWiterTblPr->TableCellMar.Append(oTempWriter.GetData());
pWiterTblPr->TableCellMar.Append(CString(_T("</w:tblCellMar>")));
pWiterTblPr->TableCellMar += L"<w:tblCellMar>";
pWiterTblPr->TableCellMar += oTempWriter.GetData();
pWiterTblPr->TableCellMar += L"</w:tblCellMar>";
}
}
else if( c_oSerProp_tblPrType::TableBorders == type )
@ -1699,9 +1691,9 @@ public:
{
XmlUtils::CStringWriter oTempWriter;
odocBorders.Write(&oTempWriter, false);
pWiterTblPr->TableBorders.Append(CString(_T("<w:tblBorders>")));
pWiterTblPr->TableBorders.Append(oTempWriter.GetData());
pWiterTblPr->TableBorders.Append(CString(_T("</w:tblBorders>")));
pWiterTblPr->TableBorders += L"<w:tblBorders>";
pWiterTblPr->TableBorders += oTempWriter.GetData();
pWiterTblPr->TableBorders += L"</w:tblBorders>";
}
}
else if( c_oSerProp_tblPrType::Shd == type )
@ -1718,17 +1710,17 @@ public:
{
XmlUtils::CStringWriter oTempWriter;
res = Read2(length, &Binary_tblPrReader::Read_tblpPr, this, &oTempWriter);
pWiterTblPr->tblpPr.Append(CString(_T("<w:tblpPr w:vertAnchor=\"page\" w:horzAnchor=\"page\"")));
pWiterTblPr->tblpPr.Append(oTempWriter.GetData());
pWiterTblPr->tblpPr.Append(CString(_T("/>")));
pWiterTblPr->tblpPr += L"<w:tblpPr w:vertAnchor=\"page\" w:horzAnchor=\"page\"";
pWiterTblPr->tblpPr += oTempWriter.GetData();
pWiterTblPr->tblpPr += L"/>";
}
else if( c_oSerProp_tblPrType::tblpPr2 == type )
{
XmlUtils::CStringWriter oTempWriter;
res = Read2(length, &Binary_tblPrReader::Read_tblpPr2, this, &oTempWriter);
pWiterTblPr->tblpPr.Append(CString(_T("<w:tblpPr")));
pWiterTblPr->tblpPr.Append(oTempWriter.GetData());
pWiterTblPr->tblpPr.Append(CString(_T("/>")));
pWiterTblPr->tblpPr += L"<w:tblpPr";
pWiterTblPr->tblpPr += oTempWriter.GetData();
pWiterTblPr->tblpPr += L"/>";
}
else if( c_oSerProp_tblPrType::Style == type )
{
@ -1896,10 +1888,10 @@ public:
CString sXml;
switch(m_oBufferedStream.GetUChar())
{
case 0:sXml.Append(_T(" w:horzAnchor=\"margin\""));break;
case 1:sXml.Append(_T(" w:horzAnchor=\"page\""));break;
case 2:sXml.Append(_T(" w:horzAnchor=\"text\""));break;
default:sXml.Append(_T(" w:horzAnchor=\"text\""));break;
case 0:sXml += (_T(" w:horzAnchor=\"margin\""));break;
case 1:sXml += (_T(" w:horzAnchor=\"page\""));break;
case 2:sXml += (_T(" w:horzAnchor=\"text\""));break;
default:sXml += (_T(" w:horzAnchor=\"text\""));break;
}
pCStringWriter->WriteString(sXml);
}
@ -1915,12 +1907,12 @@ public:
CString sXml;
switch(m_oBufferedStream.GetUChar())
{
case 0:sXml.Append(_T(" w:tblpXSpec=\"center\""));break;
case 1:sXml.Append(_T(" w:tblpXSpec=\"inside\""));break;
case 2:sXml.Append(_T(" w:tblpXSpec=\"left\""));break;
case 3:sXml.Append(_T(" w:tblpXSpec=\"outside\""));break;
case 4:sXml.Append(_T(" w:tblpXSpec=\"right\""));break;
default:sXml.Append(_T(" w:tblpXSpec=\"left\""));break;
case 0:sXml += (_T(" w:tblpXSpec=\"center\""));break;
case 1:sXml += (_T(" w:tblpXSpec=\"inside\""));break;
case 2:sXml += (_T(" w:tblpXSpec=\"left\""));break;
case 3:sXml += (_T(" w:tblpXSpec=\"outside\""));break;
case 4:sXml += (_T(" w:tblpXSpec=\"right\""));break;
default:sXml += (_T(" w:tblpXSpec=\"left\""));break;
}
pCStringWriter->WriteString(sXml);
}
@ -1929,10 +1921,10 @@ public:
CString sXml;
switch(m_oBufferedStream.GetUChar())
{
case 0:sXml.Append(_T(" w:vertAnchor=\"margin\""));break;
case 1:sXml.Append(_T(" w:vertAnchor=\"page\""));break;
case 2:sXml.Append(_T(" w:vertAnchor=\"text\""));break;
default:sXml.Append(_T(" w:vertAnchor=\"text\""));break;
case 0:sXml += (_T(" w:vertAnchor=\"margin\""));break;
case 1:sXml += (_T(" w:vertAnchor=\"page\""));break;
case 2:sXml += (_T(" w:vertAnchor=\"text\""));break;
default:sXml += (_T(" w:vertAnchor=\"text\""));break;
}
pCStringWriter->WriteString(sXml);
}
@ -1948,13 +1940,13 @@ public:
CString sXml;
switch(m_oBufferedStream.GetUChar())
{
case 0:sXml.Append(_T(" w:tblpYSpec=\"bottom\""));break;
case 1:sXml.Append(_T(" w:tblpYSpec=\"center\""));break;
case 2:sXml.Append(_T(" w:tblpYSpec=\"inline\""));break;
case 3:sXml.Append(_T(" w:tblpYSpec=\"inside\""));break;
case 4:sXml.Append(_T(" w:tblpYSpec=\"outside\""));break;
case 5:sXml.Append(_T(" w:tblpYSpec=\"top\""));break;
default:sXml.Append(_T(" w:tblpYSpec=\"top\""));break;
case 0:sXml += (_T(" w:tblpYSpec=\"bottom\""));break;
case 1:sXml += (_T(" w:tblpYSpec=\"center\""));break;
case 2:sXml += (_T(" w:tblpYSpec=\"inline\""));break;
case 3:sXml += (_T(" w:tblpYSpec=\"inside\""));break;
case 4:sXml += (_T(" w:tblpYSpec=\"outside\""));break;
case 5:sXml += (_T(" w:tblpYSpec=\"top\""));break;
default:sXml += (_T(" w:tblpYSpec=\"top\""));break;
}
pCStringWriter->WriteString(sXml);
}
@ -2945,11 +2937,11 @@ public:
{
m_oFileWriter.m_oMediaWriter.AddImage2(pFileNative);
}
else if(NSFile::CFileBinary::Exists(string2std_string(sFilePath)))
else if(NSFile::CFileBinary::Exists(sFilePath))
{
m_oFileWriter.m_oMediaWriter.AddImage(sFilePath);
if(bDeleteFile)
NSFile::CFileBinary::Remove(string2std_string(sFilePath));
NSFile::CFileBinary::Remove(sFilePath);
}
}
else
@ -3066,36 +3058,36 @@ public:
{
switch(i)
{
case 0: sSchemeMapping.Append(_T(" w:accent1"));break;
case 1: sSchemeMapping.Append(_T(" w:accent2"));break;
case 2: sSchemeMapping.Append(_T(" w:accent3"));break;
case 3: sSchemeMapping.Append(_T(" w:accent4"));break;
case 4: sSchemeMapping.Append(_T(" w:accent5"));break;
case 5: sSchemeMapping.Append(_T(" w:accent6"));break;
case 6: sSchemeMapping.Append(_T(" w:bg1"));break;
case 7: sSchemeMapping.Append(_T(" w:bg2"));break;
case 8: sSchemeMapping.Append(_T(" w:followedHyperlink"));break;
case 9: sSchemeMapping.Append(_T(" w:hyperlink"));break;
case 10: sSchemeMapping.Append(_T(" w:t1"));break;
case 11: sSchemeMapping.Append(_T(" w:t2"));break;
case 0: sSchemeMapping += (_T(" w:accent1"));break;
case 1: sSchemeMapping += (_T(" w:accent2"));break;
case 2: sSchemeMapping += (_T(" w:accent3"));break;
case 3: sSchemeMapping += (_T(" w:accent4"));break;
case 4: sSchemeMapping += (_T(" w:accent5"));break;
case 5: sSchemeMapping += (_T(" w:accent6"));break;
case 6: sSchemeMapping += (_T(" w:bg1"));break;
case 7: sSchemeMapping += (_T(" w:bg2"));break;
case 8: sSchemeMapping += (_T(" w:followedHyperlink"));break;
case 9: sSchemeMapping += (_T(" w:hyperlink"));break;
case 10: sSchemeMapping += (_T(" w:t1"));break;
case 11: sSchemeMapping += (_T(" w:t2"));break;
}
switch(aSchemeMapping[i])
{
case 0: sSchemeMapping.Append(_T("=\"accent1\""));break;
case 1: sSchemeMapping.Append(_T("=\"accent2\""));break;
case 2: sSchemeMapping.Append(_T("=\"accent3\""));break;
case 3: sSchemeMapping.Append(_T("=\"accent4\""));break;
case 4: sSchemeMapping.Append(_T("=\"accent5\""));break;
case 5: sSchemeMapping.Append(_T("=\"accent6\""));break;
case 6: sSchemeMapping.Append(_T("=\"dark1\""));break;
case 7: sSchemeMapping.Append(_T("=\"dark2\""));break;
case 8: sSchemeMapping.Append(_T("=\"followedHyperlink\""));break;
case 9: sSchemeMapping.Append(_T("=\"hyperlink\""));break;
case 10: sSchemeMapping.Append(_T("=\"light1\""));break;
case 11: sSchemeMapping.Append(_T("=\"light2\""));break;
case 0: sSchemeMapping += (_T("=\"accent1\""));break;
case 1: sSchemeMapping += (_T("=\"accent2\""));break;
case 2: sSchemeMapping += (_T("=\"accent3\""));break;
case 3: sSchemeMapping += (_T("=\"accent4\""));break;
case 4: sSchemeMapping += (_T("=\"accent5\""));break;
case 5: sSchemeMapping += (_T("=\"accent6\""));break;
case 6: sSchemeMapping += (_T("=\"dark1\""));break;
case 7: sSchemeMapping += (_T("=\"dark2\""));break;
case 8: sSchemeMapping += (_T("=\"followedHyperlink\""));break;
case 9: sSchemeMapping += (_T("=\"hyperlink\""));break;
case 10: sSchemeMapping += (_T("=\"light1\""));break;
case 11: sSchemeMapping += (_T("=\"light2\""));break;
}
}
sSchemeMapping.Append(_T("/>"));
sSchemeMapping += (_T("/>"));
m_oSettingWriter.AddSetting(sSchemeMapping);
m_oFileWriter.m_pDrawingConverter->LoadClrMap(sSchemeMapping);
}
@ -3444,9 +3436,9 @@ public:
sFontName = XmlUtils::EncodeXmlString(sFontName);
CString sVal;
sVal.Append(_T("<m:mathFont m:val=\""));
sVal.Append(sFontName);
sVal.Append(_T("\" />"));
sVal += (_T("<m:mathFont m:val=\""));
sVal += (sFontName);
sVal += (_T("\" />"));
m_oFileWriter.m_oSettingWriter.AddSetting(sVal);
}
else
@ -3579,22 +3571,37 @@ public:
};
class Binary_DocumentTableReader : public Binary_CommonReader<Binary_DocumentTableReader>
{
Writers::FileWriter& m_oFileWriter;
Writers::FontTableWriter& m_oFontTableWriter;
Binary_pPrReader oBinary_pPrReader;
Binary_rPrReader oBinary_rPrReader;
Binary_tblPrReader oBinary_tblPrReader;
XmlUtils::CStringWriter* m_pCurWriter;
rPr m_oCur_rPr;
rPr m_oMath_rPr;
XmlUtils::CStringWriter m_oCur_pPr;
BYTE m_byteLastElemType;
CComments* m_pComments;
private:
Binary_CommonReader2 oBinary_CommonReader2;
Writers::FileWriter& m_oFileWriter;
Writers::FontTableWriter& m_oFontTableWriter;
Binary_pPrReader oBinary_pPrReader;
Binary_rPrReader oBinary_rPrReader;
Binary_tblPrReader oBinary_tblPrReader;
XmlUtils::CStringWriter* m_pCurWriter;
rPr m_oCur_rPr;
rPr m_oMath_rPr;
XmlUtils::CStringWriter m_oCur_pPr;
BYTE m_byteLastElemType;
CComments* m_pComments;
public:
Writers::ContentWriter& m_oDocumentWriter;
Writers::MediaWriter& m_oMediaWriter;
public:
Binary_DocumentTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, Writers::ContentWriter& oDocumentWriter, CComments* pComments) :Binary_CommonReader(poBufferedStream), m_oDocumentWriter(oDocumentWriter), m_oFileWriter(oFileWriter), m_oMediaWriter(oFileWriter.m_oMediaWriter), m_oFontTableWriter(oFileWriter.m_oFontTableWriter), oBinary_pPrReader(poBufferedStream, oFileWriter), oBinary_rPrReader(poBufferedStream, oFileWriter), oBinary_tblPrReader(poBufferedStream, oFileWriter), m_oCur_rPr(m_oFontTableWriter.m_mapFonts), m_oMath_rPr(m_oFontTableWriter.m_mapFonts), m_pComments(pComments)
Writers::ContentWriter& m_oDocumentWriter;
Writers::MediaWriter& m_oMediaWriter;
Binary_DocumentTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, Writers::ContentWriter& oDocumentWriter, CComments* pComments)
: Binary_CommonReader(poBufferedStream)
, m_oDocumentWriter(oDocumentWriter)
, m_oFileWriter(oFileWriter)
, m_oMediaWriter(oFileWriter.m_oMediaWriter)
, m_oFontTableWriter(oFileWriter.m_oFontTableWriter)
, oBinary_CommonReader2(poBufferedStream)
, oBinary_pPrReader(poBufferedStream, oFileWriter)
, oBinary_rPrReader(poBufferedStream, oFileWriter)
, oBinary_tblPrReader(poBufferedStream, oFileWriter)
, m_oCur_rPr(m_oFontTableWriter.m_mapFonts)
, m_oMath_rPr(m_oFontTableWriter.m_mapFonts)
, m_pComments(pComments)
{
m_byteLastElemType = c_oSerParType::Content;
m_pCurWriter = NULL;
@ -3605,7 +3612,7 @@ public:
int Read()
{
return ReadTable(&Binary_DocumentTableReader::ReadDocumentContent, this);
};
}
XmlUtils::CStringWriter& GetRunStringWriter()
{
if(NULL != m_pCurWriter)
@ -3628,12 +3635,12 @@ public:
else if(c_oSerParType::Table == type)
{
m_byteLastElemType = c_oSerParType::Table;
//сбрасываем Shd
//сбрасываем Shd
oBinary_tblPrReader.m_sCurTableShd.Empty();
m_oDocumentWriter.m_oContent.WriteString(CString(_T("<w:tbl>")));
res = Read1(length, &Binary_DocumentTableReader::ReadDocTable, this, &m_oDocumentWriter.m_oContent);
m_oDocumentWriter.m_oContent.WriteString(CString(_T("</w:tbl>")));
//сбрасываем Shd
//сбрасываем Shd
oBinary_tblPrReader.m_sCurTableShd.Empty();
}
else if ( c_oSerParType::sectPr == type )
@ -3644,10 +3651,16 @@ public:
if(oSectPr.bEvenAndOddHeaders && oSectPr.EvenAndOddHeaders)
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<w:evenAndOddHeaders/>"));
}
else if ( c_oSerParType::Background == type )
{
Background oBackground;
res = Read2(length, &Binary_DocumentTableReader::Read_Background, this, &oBackground);
m_oDocumentWriter.m_oBackground.WriteString(oBackground.Write());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadParagraph(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3668,7 +3681,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadParagraphContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -4068,9 +4081,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -4144,9 +4157,9 @@ public:
{
CString sChr = GetMathText (length);
CString sVal;
sVal.Append(_T("<m:begChr m:val=\""));
sVal.Append(sChr);
sVal.Append(_T("\" />"));
sVal += (_T("<m:begChr m:val=\""));
sVal += (sChr);
sVal += (_T("\" />"));
GetRunStringWriter().WriteString(sVal);
}
@ -4281,9 +4294,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:alnAt=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else if ( c_oSer_OMathBottomNodesValType::Val == type )
@ -4307,9 +4320,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -4328,9 +4341,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -4345,9 +4358,9 @@ public:
{
CString sChr = GetMathText (length);
CString sVal;
sVal.Append(_T("<m:chr m:val=\""));
sVal.Append(sChr);
sVal.Append(_T("\" />"));
sVal += (_T("<m:chr m:val=\""));
sVal += (sChr);
sVal += (_T("\" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -4365,9 +4378,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -4385,9 +4398,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -4533,9 +4546,9 @@ public:
{
CString sChr = GetMathText (length);
CString sVal;
sVal.Append(_T("<m:endChr m:val=\""));
sVal.Append(sChr);
sVal.Append(_T("\" />"));
sVal += (_T("<m:endChr m:val=\""));
sVal += (sChr);
sVal += (_T("\" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -5553,9 +5566,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -5573,9 +5586,9 @@ public:
if (lVal)
{
CString sXml; sXml.Format(_T(" m:val=\"%d\""), lVal);
sVal.Append(sXml);
sVal += (sXml);
}
sVal.Append(_T(" />"));
sVal += (_T(" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -5613,9 +5626,9 @@ public:
{
CString sChr = GetMathText (length);
CString sVal;
sVal.Append(_T("<m:sepChr m:val=\""));
sVal.Append(sChr);
sVal.Append(_T("\" />"));
sVal += (_T("<m:sepChr m:val=\""));
sVal += (sChr);
sVal += (_T("\" />"));
GetRunStringWriter().WriteString(sVal);
}
else
@ -6262,7 +6275,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadFootnoteRef(BYTE type, long length, void* poResult)
{
OOX::Logic::CFootnoteReference* pFootnoteRef = static_cast<OOX::Logic::CFootnoteReference*>(poResult);
@ -6304,20 +6317,14 @@ public:
CString sDrawingProperty = oCDrawingProperty.Write();
if(false == sDrawingProperty.IsEmpty())
{
VARIANT var;
var.vt = VT_I4;
var.lVal = m_oFileWriter.m_oChartWriter.getChartCount();
m_oFileWriter.m_pDrawingConverter->SetAdditionalParam(CString(_T("DocumentChartsCount")), var);
m_oFileWriter.m_pDrawingConverter->SetDocumentChartsCount(m_oFileWriter.m_oChartWriter.getChartCount());
long nCurPos = m_oBufferedStream.GetPos();
CString* bstrDrawingXml = NULL;
m_oFileWriter.m_pDrawingConverter->SaveObjectEx(oCDrawingProperty.DataPos, oCDrawingProperty.DataLength, sDrawingProperty, XMLWRITER_DOC_TYPE_DOCX, &bstrDrawingXml);
m_oBufferedStream.Seek(nCurPos);
VARIANT vt;
m_oFileWriter.m_pDrawingConverter->GetAdditionalParam(CString(_T("DocumentChartsCount")), &vt);
if(VT_I4 == vt.vt)
m_oFileWriter.m_oChartWriter.setChartCount(vt.lVal);
m_oFileWriter.m_oChartWriter.setChartCount(m_oFileWriter.m_pDrawingConverter->GetDocumentChartsCount());
if(NULL != bstrDrawingXml && false == bstrDrawingXml->IsEmpty())
{
@ -6339,8 +6346,11 @@ public:
{
CDrawingProperty oCDrawingProperty(m_oFileWriter.getNextDocPr());
res = Read2(length, &Binary_DocumentTableReader::ReadPptxDrawing, this, &oCDrawingProperty);
if(oCDrawingProperty.bDataPos && oCDrawingProperty.bDataLength)
if(oCDrawingProperty.bDataPos && oCDrawingProperty.bDataLength)
{
ReadDrawing(oCDrawingProperty);
}
}
else
res = c_oSerConstants::ReadUnknown;
@ -6380,7 +6390,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
};
int Read_tblGrid(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -6545,6 +6555,38 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int Read_Background(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
Background* pBackground = static_cast<Background*>(poResult);
if( c_oSerBackgroundType::Color == type )
{
pBackground->bColor = true;
pBackground->Color = oBinary_CommonReader2.ReadColor();
}
else if( c_oSerBackgroundType::ColorTheme == type )
{
pBackground->bThemeColor = true;
oBinary_CommonReader2.ReadThemeColor(length, pBackground->ThemeColor);
}
else if( c_oSerBackgroundType::pptxDrawing == type )
{
CDrawingProperty oCDrawingProperty(m_oFileWriter.getNextDocPr());
res = Read2(length, &Binary_DocumentTableReader::ReadPptxDrawing, this, &oCDrawingProperty);
if (oCDrawingProperty.bDataPos && oCDrawingProperty.bDataLength)
{
long nCurPos = m_oBufferedStream.GetPos();
pBackground->sObject = m_oFileWriter.m_pDrawingConverter->SaveObjectBackground(oCDrawingProperty.DataPos, oCDrawingProperty.DataLength);
m_oBufferedStream.Seek(nCurPos);
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadPptxDrawing(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -6591,14 +6633,14 @@ public:
//save xlsx
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(m_oFileWriter.m_oChartWriter.getChartCount() + 1) + L".xlsx";
std::wstring sXlsxPath = string2std_string(pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR) + sXlsxFilename;
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
CString bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, std_string2string(sChartsWorksheetRelsName), CString(), &rIdXlsx);
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, CString(), &rIdXlsx);
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
@ -6611,14 +6653,15 @@ public:
NSStringUtils::CStringBuilder sw;
pChartSpace->toXML(sw);
CString sFilename;
CString sRelsName;
std::wstring sFilename;
std::wstring sRelsName;
int nChartIndex;
std::wstring sContent = sw.GetData();
m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex);
m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex);
m_oFileWriter.m_oContentTypesWriter.AddOverrideRaw(oSaveParams.sAdditionalContentTypes);
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + _T(".rels");
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
long rIdChart;
@ -6756,6 +6799,13 @@ public:
oGraphicFramePr.m_oGraphicFrameLocks.reset(pLocking);
pDrawingProperty->sGraphicFramePr = oGraphicFramePr.toXML();
}
else if ( c_oSerImageType2::DocPr == type )
{
OOX::Drawing::CNonVisualDrawingProps pNonVisualDrawingProps;
pNonVisualDrawingProps.m_eType = OOX::et_wp_docPr;
res = Read1(length, &Binary_DocumentTableReader::ReadDocPr, this, &pNonVisualDrawingProps);
pDrawingProperty->sDocPr = pNonVisualDrawingProps.toXML();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -6798,6 +6848,39 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadDocPr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Drawing::CNonVisualDrawingProps* pNonVisualDrawingProps = static_cast<OOX::Drawing::CNonVisualDrawingProps*>(poResult);
if ( c_oSerDocPr::Id == type )
{
pNonVisualDrawingProps->m_oId.Init();
pNonVisualDrawingProps->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerDocPr::Name == type )
{
pNonVisualDrawingProps->m_sName.Init();
pNonVisualDrawingProps->m_sName->Append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerDocPr::Hidden == type )
{
pNonVisualDrawingProps->m_oHidden.Init();
pNonVisualDrawingProps->m_oHidden->FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerDocPr::Title == type )
{
pNonVisualDrawingProps->m_sTitle.Init();
pNonVisualDrawingProps->m_sTitle->Append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerDocPr::Descr == type )
{
pNonVisualDrawingProps->m_sDescr.Init();
pNonVisualDrawingProps->m_sDescr->Append(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadEffectExtent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -7035,7 +7118,7 @@ Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReade
int Binary_HdrFtrTableReader::Read()
{
return ReadTable(&Binary_HdrFtrTableReader::ReadHdrFtrContent, this);
};
}
int Binary_HdrFtrTableReader::ReadHdrFtrContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;

View File

@ -57,7 +57,7 @@ namespace Writers
if(sFontDir.IsEmpty())
m_oApplicationFonts.Initialize();
else
m_oApplicationFonts.InitializeFromFolder(string2std_string(sFontDir));
m_oApplicationFonts.InitializeFromFolder(sFontDir);
CFontList* pFontList = m_oApplicationFonts.GetList();
if(NULL != pFontList)
{

View File

@ -198,7 +198,7 @@ namespace MathEquation
// nCurPos = WriteItemStart(BinDocxRW::c_oSerRunType::rPr);
CString sFontName;
//sFontName.Format(_T("%lS"), pFont->sName.c_str());
sFontName.Insert(0, _T("Cambria Math"));
if (sFontName)
{

View File

@ -152,7 +152,8 @@ extern int g_nCurFormatVersion;
Comments = 8,
Settings = 9,
Footnotes = 10,
Endnotes = 11
Endnotes = 11,
Background
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
@ -446,20 +447,21 @@ extern int g_nCurFormatVersion;
};}
namespace c_oSerParType{enum c_oSerParType
{
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9,
Hyperlink = 10,
FldSimple = 11,
Del = 12,
Ins = 13
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9,
Hyperlink = 10,
FldSimple = 11,
Del = 12,
Ins = 13,
Background = 14
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -506,6 +508,12 @@ extern int g_nCurFormatVersion;
endnoteReference = 27,
arPr = 28
};}
namespace c_oSerBackgroundType{enum c_oSerBackgroundType
{
Color = 0,
ColorTheme = 1,
pptxDrawing = 2
};}
namespace c_oSerImageType{enum c_oSerImageType
{
MediaId = 0,
@ -549,7 +557,8 @@ extern int g_nCurFormatVersion;
SizeRelH = 27,
SizeRelV = 28,
Embedded = 29,
GraphicFramePr = 30
GraphicFramePr = 30,
DocPr = 31
};}
namespace c_oSerEffectExtent{enum c_oSerEffectExtent
{
@ -978,6 +987,14 @@ extern int g_nCurFormatVersion;
PrEndPos = 10,
PrRef = 11
};}
namespace c_oSerDocPr{enum c_oSerDocPr
{
Id = 0,
Name = 1,
Hidden = 2,
Title = 3,
Descr = 4
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

File diff suppressed because it is too large Load Diff

View File

@ -248,7 +248,7 @@ namespace BinXlsxRW{
pTable->m_oTable->m_oDisplayName.Init();
pTable->m_oTable->m_oDisplayName->append(L"Table1");
pTable->m_oTable->m_oRef.Init();
pTable->m_oTable->m_oRef->SetValue(std_string2string(OOX::Spreadsheet::CCell::combineRef(m_nRow1 - 1, m_nCol1 - 1) + L":" + OOX::Spreadsheet::CCell::combineRef(m_nRow2 - 1, m_nCol2 - 1)));
pTable->m_oTable->m_oRef->SetValue(OOX::Spreadsheet::CCell::combineRef(m_nRow1 - 1, m_nCol1 - 1) + L":" + OOX::Spreadsheet::CCell::combineRef(m_nRow2 - 1, m_nCol2 - 1));
pTable->m_oTable->m_oTotalsRowCount.Init();
pTable->m_oTable->m_oTotalsRowCount->SetValue(0);
pTable->m_oTable->m_oTableBorderDxfId.Init();

View File

@ -32,12 +32,7 @@
#ifndef CHART_WRITER
#define CHART_WRITER
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#include <string>
#include <map>

View File

@ -50,48 +50,45 @@ BinDocxRW::CDocxSerializer::CDocxSerializer()
}
bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(string2std_string(sTmpDir), _T("from"));
std::wstring strDirDst = NSSystemPath::Combine(string2std_string(sTmpDir), _T("to"));
std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, _T("Editor.bin"));
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, L"Editor.bin");
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
CString sDirSrc = std_string2string(strDirSrc);
CString sEditorBin = std_string2string(strEditorBin);
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(string2std_string(sSrcFileName), strDirSrc, NULL, 0))
if(saveToFile(sEditorBin, sDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1))
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(saveToFile(strEditorBin, strDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1))
return true;
return false;
}
bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(string2std_string(sTmpDir), _T("from"));
std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, _T("Editor.bin"));
std::wstring strDirDst = NSSystemPath::Combine(string2std_string(sTmpDir), _T("to"));
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, L"Editor.bin");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
CString sEditorBin = std_string2string(strEditorBin);
CString sEditorBin = strEditorBin;
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(string2std_string(sSrcFileName), strDirSrc, NULL, 0))
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
{
CString sMediaPath;
CString sThemePath;
CString sEmbedPath;
CreateDocxFolders(std_string2string(strDirDst), sThemePath, sMediaPath, sEmbedPath);
CreateDocxFolders(strDirDst, sThemePath, sMediaPath, sEmbedPath);
if(loadFromFile(sEditorBin, std_string2string(strDirDst), sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1))
return true;
}
}
@ -102,7 +99,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
OOX::CPath pathMain(sSrcFileName);
OOX::CPath pathMedia = pathMain.GetDirectory() + FILE_SEPARATOR_STR + _T("media");
NSDirectory::CreateDirectory(string2std_string(pathMedia.GetPath()));
NSDirectory::CreateDirectory(pathMedia.GetPath());
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -116,7 +113,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL;
if(false == m_sEmbeddedFontsDir.IsEmpty())
{
NSDirectory::CreateDirectory(string2std_string(m_sEmbeddedFontsDir));
NSDirectory::CreateDirectory(m_sEmbeddedFontsDir);
pFontPicker->SetEmbeddedFontsDirectory(m_sEmbeddedFontsDir);
@ -146,7 +143,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
if (m_bIsNoBase64Save)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(string2std_string(sSrcFileName));
oFile.CreateFileW(sSrcFileName);
oFile.WriteFile(pbBinBuffer, nBinBufferLen);
oFile.CloseFile();
}
@ -158,8 +155,8 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
if(true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen))
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(string2std_string(sSrcFileName));
oFile.WriteStringUTF8(string2std_string(oBinaryFileWriter.WriteFileHeader(nBinBufferLen)));
oFile.CreateFileW(sSrcFileName);
oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
@ -175,32 +172,32 @@ bool BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString
bool res = true;
// rels
OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels");
if (!NSDirectory::CreateDirectory(pathRels.GetPath().GetBuffer())) res = false;
if (!NSDirectory::CreateDirectory(pathRels.GetPath())) res = false;
// word
OOX::CPath pathWord = strDirectory + FILE_SEPARATOR_STR + _T("word");
if (!NSDirectory::CreateDirectory(pathWord.GetPath().GetBuffer())) res = false;
if (!NSDirectory::CreateDirectory(pathWord.GetPath())) res = false;
// documentRels
OOX::CPath pathWordRels = pathWord + FILE_SEPARATOR_STR + _T("_rels");
if (!NSDirectory::CreateDirectory(pathWordRels.GetPath().GetBuffer()))res = false;
if (!NSDirectory::CreateDirectory(pathWordRels.GetPath()))res = false;
//media
OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T("media");
if (!NSDirectory::CreateDirectory(pathMedia.GetPath().GetBuffer())) res = false;
if (!NSDirectory::CreateDirectory(pathMedia.GetPath())) res = false;
sMediaPath = pathMedia.GetPath();
//embeddings
OOX::CPath pathEmbeddings = pathWord + FILE_SEPARATOR_STR + _T("embeddings");
if (!NSDirectory::CreateDirectory(pathEmbeddings.GetPath().GetBuffer()))res = false;
if (!NSDirectory::CreateDirectory(pathEmbeddings.GetPath()))res = false;
sEmbedPath = pathEmbeddings.GetPath();
// theme
OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme");
if (!NSDirectory::CreateDirectory(pathTheme.GetPath().GetBuffer())) res = false;
if (!NSDirectory::CreateDirectory(pathTheme.GetPath())) res = false;
OOX::CPath pathThemeRels = pathTheme + FILE_SEPARATOR_STR + _T("_rels");
if (!NSDirectory::CreateDirectory(pathThemeRels.GetPath().GetBuffer())) res = false;
if (!NSDirectory::CreateDirectory(pathThemeRels.GetPath())) res = false;
pathTheme = pathTheme + FILE_SEPARATOR_STR + _T("theme1.xml");
sThemePath = pathTheme.GetPath();
@ -212,7 +209,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
bool bResultOk = false;
NSFile::CFileBinary oFile;
if(oFile.OpenFile(string2std_string(sSrcFileName)))
if(oFile.OpenFile(sSrcFileName))
{
DWORD nBase64DataSize = 0;
BYTE* pBase64Data = new BYTE[oFile.GetFileSize()];
@ -286,19 +283,10 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//папка с картинками
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName));
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
CString sFileInDir = strFileInDir.c_str();
VARIANT var;
var.vt = VT_BSTR;
#if defined(_WIN32) || defined (_WIN64)
var.bstrVal = sFileInDir.AllocSysString();
oDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir"), var);
RELEASESYSSTRING(var.bstrVal);
#else
var.bstrVal = sFileInDir.GetString();
oDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir"), var);
#endif
oDrawingConverter.SetSourceFileDir(sFileInDir);
//default theme
m_pCurFileWriter->m_oDefaultTheme.Write(sThemePath);
@ -335,10 +323,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
delete pCore;
}
/////////////////////////////////////////////////////////////////////////////////////
VARIANT vt;
oDrawingConverter.GetAdditionalParam(CString(_T("ContentTypes")), &vt);
if(VT_BSTR == vt.vt)
m_pCurFileWriter->m_oContentTypesWriter.AddOverrideRaw(CString(vt.bstrVal));
m_pCurFileWriter->m_oContentTypesWriter.AddOverrideRaw(oDrawingConverter.GetContentTypes());
m_pCurFileWriter->m_oCommentsWriter.Write();
m_pCurFileWriter->m_oChartWriter.Write();

View File

@ -32,12 +32,7 @@
#ifndef DOCX_SERIALIZER
#define DOCX_SERIALIZER
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#include "../../Common/DocxFormat/Source/DocxFormat/WritingElement.h"
namespace Writers

View File

@ -95,13 +95,14 @@ namespace DocWrapper {
sFontName = pTheme->GetMinorFont();
}
if(sFontName.IsEmpty() && oRFont.IsInit() && oRFont->m_sVal.IsInit())
sFontName = std_string2string(oRFont->ToString2());
sFontName = oRFont->ToString2();
if(sFontName.IsEmpty())
sFontName = CString(gc_sNoNameFont);
//подбор перенесен в js
return sFontName;
oFontSelectFormat.wsName = new std::wstring;
*oFontSelectFormat.wsName = string2std_string(sFontName);
oFontSelectFormat.wsName = new std::wstring(sFontName);
if(oCharset.IsInit() && oCharset->m_oCharset.IsInit())
{
SimpleTypes::Spreadsheet::EFontCharset eCharset = oCharset->m_oCharset->GetValue();
@ -121,7 +122,7 @@ namespace DocWrapper {
CString sRes;
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
sRes = std_string2string(pFontInfo->m_wsFontName);
sRes = pFontInfo->m_wsFontName;
else
sRes = gc_sDefaultFontName;
fontMap[sFontName] = sRes;
@ -135,12 +136,12 @@ namespace DocWrapper {
sFontName = CString(gc_sNoNameFont);
else
sFontName = font.m_sName;
oFontSelectFormat.wsName = new std::wstring;
*oFontSelectFormat.wsName = string2std_string(sFontName);
oFontSelectFormat.wsName = new std::wstring(sFontName);
if (font.m_oAltName.IsInit() && font.m_oAltName->GetLength() > 0)
{
oFontSelectFormat.wsAltName = new std::wstring;
*oFontSelectFormat.wsAltName = string2std_string(*font.m_oAltName);
oFontSelectFormat.wsAltName = new std::wstring(*font.m_oAltName);
}
if(font.m_oCharset.IsInit())
{
@ -216,7 +217,7 @@ namespace DocWrapper {
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
fontMap[sFontName] = std_string2string(pFontInfo->m_wsFontName);
fontMap[sFontName] = pFontInfo->m_wsFontName;
else
fontMap[sFontName] = gc_sDefaultFontName;
}

View File

@ -34,14 +34,9 @@
#include <map>
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;

View File

@ -54,7 +54,7 @@ namespace BinXlsxRW{
{
}
void CXlsxSerializer::CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath, CString& sEmbedPath)
void CXlsxSerializer::CreateXlsxFolders(const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath)
{
OOX::CPath pathMediaDir = sDstPath + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("media");
OOX::CPath pathEmbedDir = sDstPath + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("embeddings");
@ -68,11 +68,11 @@ namespace BinXlsxRW{
OOX::CPath pathThemeThemeRelsDir = pathThemeDir + FILE_SEPARATOR_STR + _T("_rels");
NSDirectory::CreateDirectory(string2std_string(pathXlDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathThemeDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathThemeThemeRelsDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathMediaDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathEmbedDir.GetPath()));
NSDirectory::CreateDirectory(pathXlDir.GetPath());
NSDirectory::CreateDirectory(pathThemeDir.GetPath());
NSDirectory::CreateDirectory(pathThemeThemeRelsDir.GetPath());
NSDirectory::CreateDirectory(pathMediaDir.GetPath());
NSDirectory::CreateDirectory(pathEmbedDir.GetPath());
//Create Default Theme
{
@ -83,32 +83,22 @@ namespace BinXlsxRW{
sMediaPath = pathMediaDir.GetPath();
sEmbedPath = pathEmbedDir.GetPath();
}
bool CXlsxSerializer::loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sMediaDir, const CString& sEmbedDir)
bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter;
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir);
//папка с бинарников
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName));
CString sFileInDir = strFileInDir.c_str();
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
VARIANT var;
var.vt = VT_BSTR;
#if defined(_WIN32) || defined (_WIN64)
var.bstrVal = sFileInDir.AllocSysString();
oOfficeDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir2"), var);
RELEASESYSSTRING(var.bstrVal);
#else
var.bstrVal = sFileInDir.GetString();
oOfficeDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir2"), var);
#endif
oOfficeDrawingConverter.SetSourceFileDir(strFileInDir, 2);
BinXlsxRW::BinaryFileReader oBinaryFileReader;
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oOfficeDrawingConverter, sXMLOptions);
return true;
}
bool CXlsxSerializer::saveToFile(const CString& sDstFileName, const CString& sSrcPath, const CString& sXMLOptions)
bool CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
{
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -119,7 +109,7 @@ namespace BinXlsxRW{
NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL;
if(false == m_sEmbeddedFontsDir.IsEmpty())
{
NSDirectory::CreateDirectory(string2std_string(m_sEmbeddedFontsDir));
NSDirectory::CreateDirectory(m_sEmbeddedFontsDir);
pFontPicker->SetEmbeddedFontsDirectory(m_sEmbeddedFontsDir);
pEmbeddedFontsManager = pFontPicker->GetNativeCutter();
@ -149,7 +139,7 @@ namespace BinXlsxRW{
RELEASEOBJECT(pFontPicker);
return true;
}
bool CXlsxSerializer::loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize)
bool CXlsxSerializer::loadChart(const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize)
{
bool bRes = false;
//todo передать нормальный oRootPath
@ -174,7 +164,7 @@ namespace BinXlsxRW{
}
return bRes;
}
bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sFilepath, CString& sContentTypePath, CString** sContentTypeElement, const long& lChartNumber)
bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilepath, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber)
{
bool bRes = false;
*sContentTypeElement = NULL;
@ -182,40 +172,42 @@ namespace BinXlsxRW{
{
m_pExternalDrawingConverter->SetDstContentRels();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
CString sThemePath;
CString sEmbedingPath;
CString sFilenameReverse = sFilepath;sFilenameReverse.MakeReverse();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
std::wstring sThemePath;
std::wstring sEmbedingPath;
CString sFilenameReverse = sFilepath; sFilenameReverse.MakeReverse();
int nIndex = sFilenameReverse.Find(FILE_SEPARATOR_CHAR);
nIndex = sFilenameReverse.Find(FILE_SEPARATOR_CHAR, nIndex + 1);
if(-1 != nIndex)
{
CString sFilepathLeft = sFilepath.Left(sFilepath.GetLength() - nIndex);
sThemePath = sFilepathLeft + _T("theme");
sEmbedingPath = sFilepathLeft + _T("embeddings");
CString sFilepathLeft = sFilepath.substr(0, sFilepath.length() - nIndex);
sThemePath = sFilepathLeft + L"theme";
sEmbedingPath = sFilepathLeft + L"embeddings";
}
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath);
OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter);
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath);
OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
if(oChartSpace.isValid())
{
//todo не делать embeddings, если пишем xlsx
//save xlsx
if(!sEmbedingPath.IsEmpty())
if(!sEmbedingPath.empty())
{
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = string2std_string(sEmbedingPath + FILE_SEPARATOR_STR) + sXlsxFilename;
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
CString bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, std_string2string(sChartsWorksheetRelsName), CString(), &rId);
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, CString(), &rId);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
@ -225,9 +217,9 @@ namespace BinXlsxRW{
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
std::wstring strFilepath = string2std_string(sFilepath);
CString strDir = std_string2string(NSSystemPath::GetDirectoryName(strFilepath));
CString strFilename = std_string2string(NSSystemPath::GetFileName(strFilepath));
std::wstring strFilepath = sFilepath;
CString strDir = NSSystemPath::GetDirectoryName(strFilepath);
CString strFilename = NSSystemPath::GetFileName(strFilepath);
OOX::CPath pathRelsDir = strDir + FILE_SEPARATOR_STR + _T("_rels");
@ -239,22 +231,23 @@ namespace BinXlsxRW{
m_pExternalDrawingConverter->SaveDstContentRels(pathRelsFile.GetPath());
CString sContentType(sContentTypePath);
sContentType.Append(strFilename);
sContentType += strFilename;
(*sContentTypeElement) = new CString();
(*sContentTypeElement)->Format(_T("<Override PartName=\"%ls\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>"), sContentType);
(*sContentTypeElement)->Append(oSaveParams.sAdditionalContentTypes);
std::wstring sContent = L"<Override PartName=\"" + sContentType + L"\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>";
sContent += oSaveParams.sAdditionalContentTypes;
(*sContentTypeElement) = new std::wstring(sContent);
bRes = true;
}
}
return bRes;
}
void CXlsxSerializer::setFontDir(CString& sFontDir)
void CXlsxSerializer::setFontDir(const std::wstring& sFontDir)
{
m_sFontDir = sFontDir;
}
void CXlsxSerializer::setEmbeddedFontsDir(CString& sEmbeddedFontsDir)
void CXlsxSerializer::setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir)
{
m_sEmbeddedFontsDir = sEmbeddedFontsDir;
}
@ -275,7 +268,7 @@ namespace BinXlsxRW{
CString sXmlOptions = _T("");
CString sMediaPath;// will be filled by 'CreateXlsxFolders' method
CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method
CreateXlsxFolders (sXmlOptions, std_string2string(sTempDir), sMediaPath, sEmbedPath);
CreateXlsxFolders (sXmlOptions, sTempDir, sMediaPath, sEmbedPath);
//заполняем Xlsx
OOX::Spreadsheet::CXlsx oXlsx;
helper.toXlsx(oXlsx);

View File

@ -32,13 +32,7 @@
#ifndef XLSX_SERIALIZER
#define XLSX_SERIALIZER
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#include <string>
namespace OOX
@ -66,19 +60,19 @@ namespace BinXlsxRW {
CXlsxSerializer();
~CXlsxSerializer();
void CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath, CString& sEmbedPath);
void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sMediaDir, const CString& sEmbedPath);
bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions);
bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
bool saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sFilename, CString& sContentTypePath, CString** sContentTypeElement, const long& lChartNumber);
bool loadChart (const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
bool saveChart (NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilename, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber);
void setFontDir(CString& sFontDir);
void setEmbeddedFontsDir(CString& sEmbeddedFontsDir);
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
void writeChartXlsx(const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
void writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
};
}
#endif // #ifndef XLSX_SERIALIZER

View File

@ -31,16 +31,17 @@ INCLUDEPATH += \
../../DesktopEditor/xml/libxml2/include \
SOURCES += ../DocWrapper/DocxSerializer.cpp \
SOURCES += \
../DocWrapper/DocxSerializer.cpp \
../DocWrapper/FontProcessor.cpp \
../DocWrapper/XlsxSerializer.cpp \
../BinWriter/BinWriters.cpp \
../DocWrapper/ChartWriter.cpp \
../BinWriter/BinWriters.cpp \
../../XlsxSerializerCom/Common/Common.cpp \
../../XlsxSerializerCom/Reader/ChartFromToBinary.cpp \
../../XlsxSerializerCom/Reader/CommonWriter.cpp \
../../XlsxSerializerCom/Reader/CSVReader.cpp \
../../XlsxSerializerCom/Writer/CSVWriter.cpp \
../DocWrapper/ChartWriter.cpp \
../../OfficeCryptReader/source/ECMACryptReader.cpp \
../../OfficeCryptReader/source/CryptTransform.cpp

View File

@ -37,12 +37,21 @@
#include "../../src/ConvertOO2OOX.h"
#if defined(_WIN64)
#pragma comment(lib, "../../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#pragma comment(lib, "../../../build/bin/icu/win_32/icuuc.lib")
#endif
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argv[2];
std::wstring dstPath = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx"; //xlsx pptx
std::wstring outputDir = FileSystem::Directory::GetFolderPath(dstPath);
std::wstring srcTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);

View File

@ -345,6 +345,30 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\Common\3dParty\pole\pole.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\UnicodeConverter\UnicodeConverter.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>

View File

@ -34,21 +34,15 @@ CONFIG(debug, debug|release){
DEFINES += _DEBUG
}
build_fast {
core_release {
SOURCES += \
odffilereaderlib_odf_datatypes.cpp \
odffilereaderlib_odf.cpp \
odffilereaderlib_docx.cpp \
odffilereaderlib_pptx.cpp \
odffilereaderlib_xlsx.cpp \
odffilereaderlib_converter.cpp
} else {
odffilereaderlib_oox.cpp
}
core_debug {
SOURCES += \
../src/conversionelement.cpp \
../src/xml/attributes.cpp \
../src/xml/sax.cpp \
../src/xml/sax_xmllite.cpp \
../src/xml/utils.cpp \
../src/xml/xmlchar.cpp \
../src/odf/abstract_xml.cpp \
../src/odf/anim_elements.cpp \
../src/odf/calcs_styles.cpp \
@ -114,6 +108,15 @@ SOURCES += \
../src/odf/templates.cpp \
../src/odf/text_content.cpp \
../src/odf/text_elements.cpp \
../src/odf/math_elementaries.cpp \
../src/odf/math_layout_elements.cpp \
../src/odf/math_limit_elements.cpp \
../src/odf/math_table_elements.cpp \
../src/odf/math_token_elements.cpp \
../src/odf/datatypes/mathvariant.cpp \
../src/odf/calcext_elements.cpp \
../src/odf/table_database_ranges.cpp \
../src/odf/math_elements.cpp \
../src/odf/datatypes/anchortype.cpp \
../src/odf/datatypes/backgroundcolor.cpp \
../src/odf/datatypes/bool.cpp \
@ -204,6 +207,8 @@ SOURCES += \
../src/odf/datatypes/wrapoption.cpp \
../src/odf/datatypes/writingmode.cpp \
../src/odf/datatypes/xlink.cpp \
../src/docx/xlsx_conditionalFormatting.cpp \
../src/docx/xlsx_dxfs.cpp \
../src/docx/docx_content_type.cpp \
../src/docx/docx_conversion_context.cpp \
../src/docx/docx_drawing.cpp \
@ -213,7 +218,6 @@ SOURCES += \
../src/docx/hyperlinks.cpp \
../src/docx/measuredigits.cpp \
../src/docx/mediaitems.cpp \
../src/docx/mediaitems_utils.cpp \
../src/docx/namespaces.cpp \
../src/docx/oox_chart_axis.cpp \
../src/docx/oox_chart_context.cpp \
@ -273,27 +277,22 @@ SOURCES += \
../src/docx/xlsx_table_state.cpp \
../src/docx/xlsx_textcontext.cpp \
../src/docx/xlsx_utils.cpp \
../src/docx/xlsx_xf.cpp \
../src/common/CPColorUtils.cpp \
../src/common/CPString.cpp \
../src/common/readdocelement.cpp \
../src/ConvertOO2OOX.cpp \
../src/odf/math_elements.cpp
../src/docx/xlsx_xf.cpp
}
SOURCES += \
../formulasconvert/formulasconvert_oox.cpp \
../src/odf/math_elementaries.cpp \
../src/odf/math_layout_elements.cpp \
../src/odf/math_limit_elements.cpp \
../src/odf/math_table_elements.cpp \
../src/odf/math_token_elements.cpp \
../src/odf/datatypes/mathvariant.cpp \
../formulasconvert/formulasconvert_odf.cpp \
../src/odf/calcext_elements.cpp \
../src/odf/table_database_ranges.cpp \
../src/docx/xlsx_conditionalFormatting.cpp \
../src/docx/xlsx_dxfs.cpp
../src/conversionelement.cpp \
../src/xml/attributes.cpp \
../src/xml/sax.cpp \
../src/xml/sax_xmllite.cpp \
../src/xml/utils.cpp \
../src/xml/xmlchar.cpp \
../src/common/CPColorUtils.cpp \
../src/common/CPString.cpp \
../src/common/readdocelement.cpp \
../src/ConvertOO2OOX.cpp
HEADERS += \
../formulasconvert/formulasconvert.h \
@ -358,6 +357,16 @@ HEADERS += \
../src/odf/text_content.h \
../src/odf/text_elements.h \
../src/odf/visitor.h \
../src/ConvertOO2OOX.h \
../src/odf/math_elements.h \
../src/odf/math_elementaries.h \
../src/odf/math_layout_elements.h \
../src/odf/math_limit_elements.h \
../src/odf/math_table_elements.h \
../src/odf/math_token_elements.h \
../src/odf/datatypes/mathvariant.h \
../src/odf/calcext_elements.h \
../src/odf/table_database_ranges.h \
../src/odf/datatypes/anchortype.h \
../src/odf/datatypes/backgroundcolor.h \
../src/odf/datatypes/bool.h \
@ -457,12 +466,13 @@ HEADERS += \
../src/docx/docx_drawing.h \
../src/docx/docx_package.h \
../src/docx/docx_table_context.h \
../src/docx/xlsx_conditionalFormatting.h \
../src/docx/xlsx_dxfs.h \
../src/docx/drawing_object_description.h \
../src/docx/headers_footers.h \
../src/docx/hyperlinks.h \
../src/docx/measuredigits.h \
../src/docx/mediaitems.h \
../src/docx/mediaitems_utils.h \
../src/docx/namespaces.h \
../src/docx/oox_chart_axis.h \
../src/docx/oox_chart_context.h \
@ -553,16 +563,5 @@ HEADERS += \
../include/cpdoccore/xml/simple_xml_writer.h \
../include/cpdoccore/xml/utils.h \
../include/cpdoccore/xml/xmlchar.h \
../include/cpdoccore/xml/xmlelement.h \
../src/ConvertOO2OOX.h \
../src/odf/math_elements.h \
../src/odf/math_elementaries.h \
../src/odf/math_layout_elements.h \
../src/odf/math_limit_elements.h \
../src/odf/math_table_elements.h \
../src/odf/math_token_elements.h \
../src/odf/datatypes/mathvariant.h \
../src/odf/calcext_elements.h \
../src/odf/table_database_ranges.h \
../src/docx/xlsx_conditionalFormatting.h \
../src/docx/xlsx_dxfs.h
../include/cpdoccore/xml/xmlelement.h

View File

@ -1,41 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../src/conversionelement.cpp"
#include "../src/xml/attributes.cpp"
#include "../src/xml/sax.cpp"
#include "../src/xml/sax_xmllite.cpp"
#include "../src/xml/utils.cpp"
#include "../src/xml/xmlchar.cpp"
#include "../src/common/CPColorUtils.cpp"
#include "../src/common/CPString.cpp"
#include "../src/common/readdocelement.cpp"
#include "../src/ConvertOO2OOX.cpp"

View File

@ -1,61 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../src/docx/docx_content_type.cpp"
#include "../src/docx/docx_conversion_context.cpp"
#include "../src/docx/docx_drawing.cpp"
#include "../src/docx/docx_package.cpp"
#include "../src/docx/docx_rels.cpp"
#include "../src/docx/docx_table_context.cpp"
#include "../src/docx/headers_footers.cpp"
#include "../src/docx/hyperlinks.cpp"
#include "../src/docx/measuredigits.cpp"
#include "../src/docx/mediaitems.cpp"
#include "../src/docx/mediaitems_utils.cpp"
#include "../src/docx/namespaces.cpp"
#include "../src/docx/oox_chart_axis.cpp"
#include "../src/docx/oox_chart_context.cpp"
#include "../src/docx/oox_chart_legend.cpp"
#include "../src/docx/oox_chart_series.cpp"
#include "../src/docx/oox_chart_shape.cpp"
#include "../src/docx/oox_conversion_context.cpp"
#include "../src/docx/oox_data_labels.cpp"
#include "../src/docx/oox_drawing.cpp"
#include "../src/docx/oox_drawing_fills.cpp"
#include "../src/docx/oox_layout.cpp"
#include "../src/docx/oox_package.cpp"
#include "../src/docx/oox_plot_area.cpp"
#include "../src/docx/oox_title.cpp"
#include "../src/docx/oox_types_chart.cpp"
#include "../src/odf/draw_frame_docx.cpp"
#include "../src/odf/draw_shapes_docx.cpp"
#include "../src/odf/style_paragraph_properties_docx.cpp"
#include "../src/odf/table_docx.cpp"

View File

@ -37,8 +37,14 @@
#include "../src/odf/documentcontext.cpp"
#include "../src/odf/draw_common.cpp"
#include "../src/odf/draw_frame.cpp"
#include "../src/odf/draw_frame_docx.cpp"
#include "../src/odf/draw_frame_pptx.cpp"
#include "../src/odf/draw_frame_xlsx.cpp"
#include "../src/odf/draw_page.cpp"
#include "../src/odf/draw_shapes.cpp"
#include "../src/odf/draw_shapes_docx.cpp"
#include "../src/odf/draw_shapes_pptx.cpp"
#include "../src/odf/draw_shapes_xlsx.cpp"
#include "../src/odf/font_face.cpp"
#include "../src/odf/header_footer.cpp"
#include "../src/odf/list.cpp"
@ -48,7 +54,6 @@
#include "../src/odf/odf_content_xml.cpp"
#include "../src/odf/odfcontext.cpp"
#include "../src/odf/odf_document.cpp"
#include "../src/odf/odf_document_impl.cpp"
#include "../src/odf/office_annotation.cpp"
#include "../src/odf/office_binary_data.cpp"
#include "../src/odf/office_body.cpp"
@ -69,6 +74,8 @@
#include "../src/odf/style_graphic_properties.cpp"
#include "../src/odf/style_map.cpp"
#include "../src/odf/style_paragraph_properties.cpp"
#include "../src/odf/style_paragraph_properties_docx.cpp"
#include "../src/odf/style_paragraph_properties_pptx.cpp"
#include "../src/odf/style_presentation.cpp"
#include "../src/odf/style_regions.cpp"
#include "../src/odf/styles.cpp"
@ -79,98 +86,20 @@
#include "../src/odf/svg_parser.cpp"
#include "../src/odf/table.cpp"
#include "../src/odf/table_calculation_settings.cpp"
#include "../src/odf/table_docx.cpp"
#include "../src/odf/table_named_expressions.cpp"
#include "../src/odf/table_pptx.cpp"
#include "../src/odf/table_xlsx.cpp"
#include "../src/odf/templates.cpp"
#include "../src/odf/text_content.cpp"
#include "../src/odf/text_elements.cpp"
#include "../src/odf/datatypes/anchortype.cpp"
#include "../src/odf/datatypes/backgroundcolor.cpp"
#include "../src/odf/datatypes/bool.cpp"
#include "../src/odf/datatypes/bordermodel.cpp"
#include "../src/odf/datatypes/borderstyle.cpp"
#include "../src/odf/datatypes/borderwidths.cpp"
#include "../src/odf/datatypes/calcext_type.cpp"
#include "../src/odf/datatypes/chartdatalabelnumber.cpp"
#include "../src/odf/datatypes/charterrorcategory.cpp"
#include "../src/odf/datatypes/chartinterpolation.cpp"
#include "../src/odf/datatypes/chartlabelarrangement.cpp"
#include "../src/odf/datatypes/chartregressiontype.cpp"
#include "../src/odf/datatypes/chartseriessource.cpp"
#include "../src/odf/datatypes/chartsolidtype.cpp"
#include "../src/odf/datatypes/chartsymbol.cpp"
#include "../src/odf/datatypes/clockvalue.cpp"
#include "../src/odf/datatypes/color.cpp"
#include "../src/odf/datatypes/common_attlists.cpp"
#include "../src/odf/datatypes/direction.cpp"
#include "../src/odf/datatypes/drawfill.cpp"
#include "../src/odf/datatypes/dropcaplength.cpp"
#include "../src/odf/datatypes/fillimagerefpoint.cpp"
#include "../src/odf/datatypes/fobreak.cpp"
#include "../src/odf/datatypes/fontfamilygeneric.cpp"
#include "../src/odf/datatypes/fontpitch.cpp"
#include "../src/odf/datatypes/fontrelief.cpp"
#include "../src/odf/datatypes/fontsize.cpp"
#include "../src/odf/datatypes/fontstretch.cpp"
#include "../src/odf/datatypes/fontstyle.cpp"
#include "../src/odf/datatypes/fontvariant.cpp"
#include "../src/odf/datatypes/fontweight.cpp"
#include "../src/odf/datatypes/gradientstyle.cpp"
#include "../src/odf/datatypes/hatchstyle.cpp"
#include "../src/odf/datatypes/hyphenationkeep.cpp"
#include "../src/odf/datatypes/hyphenationladdercount.cpp"
#include "../src/odf/datatypes/iconset_type.cpp"
#include "../src/odf/datatypes/keeptogether.cpp"
#include "../src/odf/datatypes/layoutgridmode.cpp"
#include "../src/odf/datatypes/length.cpp"
#include "../src/odf/datatypes/lengthorpercent.cpp"
#include "../src/odf/datatypes/letterspacing.cpp"
#include "../src/odf/datatypes/linebreak.cpp"
#include "../src/odf/datatypes/linemode.cpp"
#include "../src/odf/datatypes/linestyle.cpp"
#include "../src/odf/datatypes/linetype.cpp"
#include "../src/odf/datatypes/linewidth.cpp"
#include "../src/odf/datatypes/markerstyle.cpp"
#include "../src/odf/datatypes/noteclass.cpp"
#include "../src/odf/datatypes/officevaluetype.cpp"
#include "../src/odf/datatypes/pageusage.cpp"
#include "../src/odf/datatypes/percent.cpp"
#include "../src/odf/datatypes/percentorscale.cpp"
#include "../src/odf/datatypes/presentationclass.cpp"
#include "../src/odf/datatypes/punctuationwrap.cpp"
#include "../src/odf/datatypes/rotationalign.cpp"
#include "../src/odf/datatypes/runthrough.cpp"
#include "../src/odf/datatypes/scripttype.cpp"
#include "../src/odf/datatypes/shadowtype.cpp"
#include "../src/odf/datatypes/smil_transitiontype.cpp"
#include "../src/odf/datatypes/stylefamily.cpp"
#include "../src/odf/datatypes/stylehorizontalpos.cpp"
#include "../src/odf/datatypes/stylehorizontalrel.cpp"
#include "../src/odf/datatypes/styleleadercolor.cpp"
#include "../src/odf/datatypes/styleposition.cpp"
#include "../src/odf/datatypes/style_ref.cpp"
#include "../src/odf/datatypes/stylerepeat.cpp"
#include "../src/odf/datatypes/styletype.cpp"
#include "../src/odf/datatypes/styleverticalpos.cpp"
#include "../src/odf/datatypes/styleverticalrel.cpp"
#include "../src/odf/datatypes/stylewrap.cpp"
#include "../src/odf/datatypes/stylewrapcontourmode.cpp"
#include "../src/odf/datatypes/tablealign.cpp"
#include "../src/odf/datatypes/tablecentering.cpp"
#include "../src/odf/datatypes/tablemode.cpp"
#include "../src/odf/datatypes/tablevisibility.cpp"
#include "../src/odf/datatypes/targetframename.cpp"
#include "../src/odf/datatypes/textalign.cpp"
#include "../src/odf/datatypes/textalignsource.cpp"
#include "../src/odf/datatypes/textautospace.cpp"
#include "../src/odf/datatypes/textcombine.cpp"
#include "../src/odf/datatypes/textdisplay.cpp"
#include "../src/odf/datatypes/textemphasize.cpp"
#include "../src/odf/datatypes/textposition.cpp"
#include "../src/odf/datatypes/textrotationscale.cpp"
#include "../src/odf/datatypes/texttransform.cpp"
#include "../src/odf/datatypes/underlinecolor.cpp"
#include "../src/odf/datatypes/verticalalign.cpp"
#include "../src/odf/datatypes/wrapoption.cpp"
#include "../src/odf/datatypes/writingmode.cpp"
#include "../src/odf/datatypes/xlink.cpp"
#include "../src/odf/math_elementaries.cpp"
#include "../src/odf/math_layout_elements.cpp"
#include "../src/odf/math_limit_elements.cpp"
#include "../src/odf/math_table_elements.cpp"
#include "../src/odf/math_token_elements.cpp"
#include "../src/odf/datatypes/mathvariant.cpp"
#include "../src/odf/calcext_elements.cpp"
#include "../src/odf/table_database_ranges.cpp"
#include "../src/odf/math_elements.cpp"
#include "../src/odf/odf_document_impl.cpp"

View File

@ -0,0 +1,121 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../src/odf/datatypes/anchortype.cpp"
#include "../src/odf/datatypes/backgroundcolor.cpp"
#include "../src/odf/datatypes/bool.cpp"
#include "../src/odf/datatypes/bordermodel.cpp"
#include "../src/odf/datatypes/borderstyle.cpp"
#include "../src/odf/datatypes/borderwidths.cpp"
#include "../src/odf/datatypes/calcext_type.cpp"
#include "../src/odf/datatypes/chartdatalabelnumber.cpp"
#include "../src/odf/datatypes/charterrorcategory.cpp"
#include "../src/odf/datatypes/chartinterpolation.cpp"
#include "../src/odf/datatypes/chartlabelarrangement.cpp"
#include "../src/odf/datatypes/chartregressiontype.cpp"
#include "../src/odf/datatypes/chartseriessource.cpp"
#include "../src/odf/datatypes/chartsolidtype.cpp"
#include "../src/odf/datatypes/chartsymbol.cpp"
#include "../src/odf/datatypes/clockvalue.cpp"
#include "../src/odf/datatypes/color.cpp"
#include "../src/odf/datatypes/common_attlists.cpp"
#include "../src/odf/datatypes/direction.cpp"
#include "../src/odf/datatypes/drawfill.cpp"
#include "../src/odf/datatypes/dropcaplength.cpp"
#include "../src/odf/datatypes/fillimagerefpoint.cpp"
#include "../src/odf/datatypes/fobreak.cpp"
#include "../src/odf/datatypes/fontfamilygeneric.cpp"
#include "../src/odf/datatypes/fontpitch.cpp"
#include "../src/odf/datatypes/fontrelief.cpp"
#include "../src/odf/datatypes/fontsize.cpp"
#include "../src/odf/datatypes/fontstretch.cpp"
#include "../src/odf/datatypes/fontstyle.cpp"
#include "../src/odf/datatypes/fontvariant.cpp"
#include "../src/odf/datatypes/fontweight.cpp"
#include "../src/odf/datatypes/gradientstyle.cpp"
#include "../src/odf/datatypes/hatchstyle.cpp"
#include "../src/odf/datatypes/hyphenationkeep.cpp"
#include "../src/odf/datatypes/hyphenationladdercount.cpp"
#include "../src/odf/datatypes/iconset_type.cpp"
#include "../src/odf/datatypes/keeptogether.cpp"
#include "../src/odf/datatypes/layoutgridmode.cpp"
#include "../src/odf/datatypes/length.cpp"
#include "../src/odf/datatypes/lengthorpercent.cpp"
#include "../src/odf/datatypes/letterspacing.cpp"
#include "../src/odf/datatypes/linebreak.cpp"
#include "../src/odf/datatypes/linemode.cpp"
#include "../src/odf/datatypes/linestyle.cpp"
#include "../src/odf/datatypes/linetype.cpp"
#include "../src/odf/datatypes/linewidth.cpp"
#include "../src/odf/datatypes/markerstyle.cpp"
#include "../src/odf/datatypes/noteclass.cpp"
#include "../src/odf/datatypes/officevaluetype.cpp"
#include "../src/odf/datatypes/pageusage.cpp"
#include "../src/odf/datatypes/percent.cpp"
#include "../src/odf/datatypes/percentorscale.cpp"
#include "../src/odf/datatypes/presentationclass.cpp"
#include "../src/odf/datatypes/punctuationwrap.cpp"
#include "../src/odf/datatypes/rotationalign.cpp"
#include "../src/odf/datatypes/runthrough.cpp"
#include "../src/odf/datatypes/scripttype.cpp"
#include "../src/odf/datatypes/shadowtype.cpp"
#include "../src/odf/datatypes/smil_transitiontype.cpp"
#include "../src/odf/datatypes/stylefamily.cpp"
#include "../src/odf/datatypes/stylehorizontalpos.cpp"
#include "../src/odf/datatypes/stylehorizontalrel.cpp"
#include "../src/odf/datatypes/styleleadercolor.cpp"
#include "../src/odf/datatypes/styleposition.cpp"
#include "../src/odf/datatypes/style_ref.cpp"
#include "../src/odf/datatypes/stylerepeat.cpp"
#include "../src/odf/datatypes/styletype.cpp"
#include "../src/odf/datatypes/styleverticalpos.cpp"
#include "../src/odf/datatypes/styleverticalrel.cpp"
#include "../src/odf/datatypes/stylewrap.cpp"
#include "../src/odf/datatypes/stylewrapcontourmode.cpp"
#include "../src/odf/datatypes/tablealign.cpp"
#include "../src/odf/datatypes/tablecentering.cpp"
#include "../src/odf/datatypes/tablemode.cpp"
#include "../src/odf/datatypes/tablevisibility.cpp"
#include "../src/odf/datatypes/targetframename.cpp"
#include "../src/odf/datatypes/textalign.cpp"
#include "../src/odf/datatypes/textalignsource.cpp"
#include "../src/odf/datatypes/textautospace.cpp"
#include "../src/odf/datatypes/textcombine.cpp"
#include "../src/odf/datatypes/textdisplay.cpp"
#include "../src/odf/datatypes/textemphasize.cpp"
#include "../src/odf/datatypes/textposition.cpp"
#include "../src/odf/datatypes/textrotationscale.cpp"
#include "../src/odf/datatypes/texttransform.cpp"
#include "../src/odf/datatypes/underlinecolor.cpp"
#include "../src/odf/datatypes/verticalalign.cpp"
#include "../src/odf/datatypes/wrapoption.cpp"
#include "../src/odf/datatypes/writingmode.cpp"
#include "../src/odf/datatypes/xlink.cpp"

View File

@ -1,68 +1,102 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../src/docx/xlsx_utils.cpp"
#include "../src/odf/draw_frame_xlsx.cpp"
#include "../src/odf/draw_shapes_xlsx.cpp"
#include "../src/odf/table_xlsx.cpp"
#include "../src/docx/xlsx_alignment.cpp"
#include "../src/docx/xlsx_border.cpp"
#include "../src/docx/xlsx_borders.cpp"
#include "../src/docx/xlsx_cell_format.cpp"
#include "../src/docx/xlsx_cell_style.cpp"
#include "../src/docx/xlsx_cell_styles.cpp"
#include "../src/docx/xlsx_color.cpp"
#include "../src/docx/xlsx_comments.cpp"
#include "../src/docx/xlsx_comments_context.cpp"
#include "../src/docx/xlsx_complex_number_format.cpp"
#include "../src/docx/xlsxconversioncontext.cpp"
#include "../src/docx/xlsx_defined_names.cpp"
#include "../src/docx/xlsx_drawing.cpp"
#include "../src/docx/xlsx_drawing_context.cpp"
#include "../src/docx/xlsx_drawings.cpp"
#include "../src/docx/xlsx_fill.cpp"
#include "../src/docx/xlsx_fills.cpp"
#include "../src/docx/xlsx_font.cpp"
#include "../src/docx/xlsx_fonts.cpp"
#include "../src/docx/xlsx_hyperlinks.cpp"
#include "../src/docx/xlsx_merge_cells.cpp"
#include "../src/docx/xlsx_numFmts.cpp"
#include "../src/docx/xlsx_num_format_context.cpp"
#include "../src/docx/xlsx_output_xml.cpp"
#include "../src/docx/xlsx_package.cpp"
#include "../src/docx/xlsx_protection.cpp"
#include "../src/docx/xlsx_sharedstrings.cpp"
#include "../src/docx/xlsx_styles.cpp"
#include "../src/docx/xlsx_tablecontext.cpp"
#include "../src/docx/xlsx_table_metrics.cpp"
#include "../src/docx/xlsx_table_state.cpp"
#include "../src/docx/xlsx_textcontext.cpp"
#include "../src/docx/xlsx_xf.cpp"
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../src/docx/xlsx_conditionalFormatting.cpp"
#include "../src/docx/xlsx_dxfs.cpp"
#include "../src/docx/docx_content_type.cpp"
#include "../src/docx/docx_conversion_context.cpp"
#include "../src/docx/docx_drawing.cpp"
#include "../src/docx/docx_package.cpp"
#include "../src/docx/docx_table_context.cpp"
#include "../src/docx/headers_footers.cpp"
#include "../src/docx/hyperlinks.cpp"
#include "../src/docx/measuredigits.cpp"
#include "../src/docx/mediaitems.cpp"
#include "../src/docx/namespaces.cpp"
#include "../src/docx/oox_chart_axis.cpp"
#include "../src/docx/oox_chart_context.cpp"
#include "../src/docx/oox_chart_legend.cpp"
#include "../src/docx/oox_chart_series.cpp"
#include "../src/docx/oox_chart_shape.cpp"
#include "../src/docx/oox_conversion_context.cpp"
#include "../src/docx/oox_data_labels.cpp"
#include "../src/docx/oox_drawing.cpp"
#include "../src/docx/oox_drawing_fills.cpp"
#include "../src/docx/oox_layout.cpp"
#include "../src/docx/oox_package.cpp"
#include "../src/docx/oox_plot_area.cpp"
#include "../src/docx/oox_title.cpp"
#include "../src/docx/oox_types_chart.cpp"
#include "../src/docx/oox_rels.cpp"
#include "../src/docx/pptx_comments.cpp"
#include "../src/docx/pptx_comments_context.cpp"
#include "../src/docx/pptx_conversion_context.cpp"
#include "../src/docx/pptx_drawing.cpp"
#include "../src/docx/pptx_drawings.cpp"
#include "../src/docx/pptx_output_xml.cpp"
#include "../src/docx/pptx_package.cpp"
#include "../src/docx/pptx_slide_context.cpp"
#include "../src/docx/pptx_table_context.cpp"
#include "../src/docx/pptx_text_context.cpp"
#include "../src/docx/xlsx_alignment.cpp"
#include "../src/docx/xlsx_border.cpp"
#include "../src/docx/xlsx_borders.cpp"
#include "../src/docx/xlsx_cell_format.cpp"
#include "../src/docx/xlsx_cell_style.cpp"
#include "../src/docx/xlsx_cell_styles.cpp"
#include "../src/docx/xlsx_color.cpp"
#include "../src/docx/xlsx_comments.cpp"
#include "../src/docx/xlsx_comments_context.cpp"
#include "../src/docx/xlsx_complex_number_format.cpp"
#include "../src/docx/xlsxconversioncontext.cpp"
#include "../src/docx/xlsx_defined_names.cpp"
#include "../src/docx/xlsx_drawing.cpp"
#include "../src/docx/xlsx_drawing_context.cpp"
#include "../src/docx/xlsx_drawings.cpp"
#include "../src/docx/xlsx_fill.cpp"
#include "../src/docx/xlsx_fills.cpp"
#include "../src/docx/xlsx_font.cpp"
#include "../src/docx/xlsx_fonts.cpp"
#include "../src/docx/xlsx_hyperlinks.cpp"
#include "../src/docx/xlsx_merge_cells.cpp"
#include "../src/docx/xlsx_numFmts.cpp"
#include "../src/docx/xlsx_num_format_context.cpp"
#include "../src/docx/xlsx_output_xml.cpp"
#include "../src/docx/xlsx_package.cpp"
#include "../src/docx/xlsx_protection.cpp"
#include "../src/docx/xlsx_sharedstrings.cpp"
#include "../src/docx/xlsx_styles.cpp"
#include "../src/docx/xlsx_tablecontext.cpp"
#include "../src/docx/xlsx_table_metrics.cpp"
#include "../src/docx/xlsx_table_state.cpp"
#include "../src/docx/xlsx_textcontext.cpp"
#include "../src/docx/xlsx_utils.cpp"
#include "../src/docx/xlsx_xf.cpp"

View File

@ -1,45 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../src/odf/draw_frame_pptx.cpp"
#include "../src/odf/draw_shapes_pptx.cpp"
#include "../src/odf/style_paragraph_properties_pptx.cpp"
#include "../src/odf/table_pptx.cpp"
#include "../src/docx/pptx_comments.cpp"
#include "../src/docx/pptx_comments_context.cpp"
#include "../src/docx/pptx_conversion_context.cpp"
#include "../src/docx/pptx_drawing.cpp"
#include "../src/docx/pptx_drawings.cpp"
#include "../src/docx/pptx_output_xml.cpp"
#include "../src/docx/pptx_package.cpp"
#include "../src/docx/pptx_slide_context.cpp"
#include "../src/docx/pptx_table_context.cpp"
#include "../src/docx/pptx_text_context.cpp"

View File

@ -76,7 +76,7 @@ public:
{}
std::wostream & xml_to_stream(std::wostream & _Wostream) const;
const std::wstring & part_name() const { return part_name_; }
const std::wstring & part_name() const { return part_name_; }
const std::wstring & content_type() const { return content_type_; }
public:

View File

@ -82,12 +82,15 @@ void text_tracked_context::start_changes_content()
void text_tracked_context::end_changes_content()
{
docx_context_.finish_run(); //0106GS-GettingStartedWithWriter_el.odt - удаленный заголовок
current_state_.content.push_back(changes_stream_.str());
docx_context_.set_delete_text_state (false);
docx_context_.set_paragraph_state (bParaStateDocx_);
docx_context_.set_run_state (bRunStateDocx_);
docx_context_.set_delete_text_state (false);
current_state_.content = changes_stream_.str();
docx_context_.set_stream_man(docx_stream_);
docx_context_.set_stream_man (docx_stream_);
}
void text_tracked_context::start_change (std::wstring id)
{
@ -129,29 +132,29 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
mediaitems_ (OdfDocument->get_folder() ),
next_dump_page_properties_(false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
text_tracked_context_ (*this),
table_context_ (*this),
output_document_ (NULL),
section_properties_in_table_(NULL),
process_note_ (noNote),
new_list_style_number_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_(false),
process_comment_ (false),
math_context_ (false),
odf_document_ (OdfDocument)
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
text_tracked_context_ (*this),
table_context_ (*this),
output_document_ (NULL),
process_note_ (noNote),
new_list_style_number_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_ (false),
process_comment_ (false),
mediaitems_ (OdfDocument->get_folder() ),
math_context_ (OdfDocument->odf_context().fontContainer(), false),
odf_document_ (OdfDocument)
{
streams_man_ = streams_man::create(temp_stream_);
applicationFonts_ = new CApplicationFonts();
@ -832,13 +835,20 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
//in_styles = true -> styles.xml
//почему то конструкция <pPr><rPr/></pPr><rPr/> "не работает" в части в rPr в ms2010 )
{
bool in_drawing = false;
if (get_drawing_context().get_current_shape() || get_drawing_context().get_current_frame())
{
in_drawing = true;
}
std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes();
std::wstringstream & run_style = get_styles_context().text_style();
CP_XML_WRITER(strm)
{
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
&& !get_table_context().in_table())
&& !get_table_context().in_table() && !in_drawing)
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
CP_XML_NODE(L"w:pPr")
{
@ -853,7 +863,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
{
CP_XML_NODE(L"w:pPr")
{
if ( !get_table_context().in_table() )
if ( !get_table_context().in_table() && !in_drawing)
{
CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();
@ -1102,7 +1112,7 @@ void docx_conversion_context::docx_serialize_list_properties(std::wostream & str
void docx_conversion_context::add_delayed_element(odf_reader::office_element * Elm)
{
delayed_elements_.push_back(Elm);
delayed_elements_.push_back(Elm);
}
void docx_conversion_context::docx_convert_delayed()
@ -1110,14 +1120,15 @@ void docx_conversion_context::docx_convert_delayed()
if (delayed_elements_.empty()) return;
if(delayed_converting_)return; //зацикливание иначе
if(get_drawing_context().get_current_level() > 0 )return; //вложенный frame
if(get_drawing_context().get_current_level() > 0 )
return; //вложенный frame
delayed_converting_ = true;
while(!delayed_elements_.empty())
{
odf_reader::office_element * elm = delayed_elements_.front();
elm->docx_convert(*this);
delayed_elements_.pop_front();
delayed_elements_.pop_front();
}
delayed_converting_=false;
}
@ -1128,19 +1139,6 @@ void section_context::add_section(const std::wstring & SectionName, const std::w
sections_.push_back(newSec);
}
void docx_conversion_context::section_properties_in_table(odf_reader::office_element * Elm)
{
section_properties_in_table_ = Elm;
}
odf_reader::office_element * docx_conversion_context::get_section_properties_in_table()
{
odf_reader::office_element * elm = section_properties_in_table_;
section_properties_in_table_ = NULL;
return elm;
}
namespace
{
// обработка Header/Footer
@ -1273,31 +1271,47 @@ typedef std::map<std::wstring, text_tracked_context::_state>::iterator map_chang
void docx_conversion_context::start_text_changes (std::wstring id)
{
text_tracked_context::_state &state = text_tracked_context_.get_tracked_change(id);
if (state.id != id) return;
text_tracked_context::_state &state_add = text_tracked_context_.get_tracked_change(id);
if (state_add.id != id) return;
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state));
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state_add));
if (in_paragraph_ && (state.type == 1 || state.type == 2))
if (in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
{
finish_run();
if (state.type == 1) output_stream() << L"<w:ins";
if (state.type == 2) output_stream() << L"<w:del";
output_stream() << L" w:date=\"" << state.date << L"\"";
output_stream() << L" w:author=\"" << state.author << L"\"";
output_stream() << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\"";
output_stream() << L">";
map_changes_iterator it = map_current_changes_.find(id);
text_tracked_context::_state &state = it->second;
if (state.type == 2)
output_stream() << state.content;
std::wstring format_change = L" w:date=\"" + state.date + L"\"" +
L" w:author=\"" + state.author + L"\"" ;
finish_run();
state.active = true;
if (state.type == 1)
{
output_stream() << L"<w:ins" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
}
if (state.type == 2)
{
for (int i = 0 ; i < state.content.size(); i++)
{
output_stream() << L"<w:del" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
output_stream() << state.content[i];
output_stream() << L"</w:del>";
}
map_current_changes_.erase(it);
}
}
}
void docx_conversion_context::start_changes()
{
if (map_current_changes_.empty()) return;
if (process_comment_) return;
text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear();
@ -1309,8 +1323,8 @@ void docx_conversion_context::start_changes()
{
text_tracked_context::_state &state = it->second;
if (state.type == 0) continue; //unknown change ... todooo
if (state.type == 0) continue; //unknown change ... todooo
if (state.active) continue;
std::wstring change_attr;
change_attr += L" w:date=\"" + state.date + L"\"";
@ -1396,16 +1410,21 @@ void docx_conversion_context::start_changes()
void docx_conversion_context::end_changes()
{
//for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
//{
// text_tracked_context::_state &state = it->second;
if (process_comment_) return;
// if (state.type == 0) continue; //unknown change ... libra format change skip
// if (state.type == 3) continue;
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
{
text_tracked_context::_state &state = it->second;
// if (state.type == 1) output_stream() << L"</w:ins>";
// if (state.type == 2) output_stream() << L"</w:del>";
//}
if (state.type == 0) continue; //unknown change ... libra format change skip
if (state.type == 3) continue;
if (!state.active) continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
state.active = false;
}
text_tracked_context_.dumpTcPr_.clear();
text_tracked_context_.dumpTblPr_.clear();
@ -1421,14 +1440,15 @@ void docx_conversion_context::end_text_changes (std::wstring id)
if (it == map_current_changes_.end()) return;
if (in_paragraph_)
text_tracked_context::_state &state = it->second;
if (state.active)
{
finish_run();
text_tracked_context::_state &state = it->second;
if (in_paragraph_)
finish_run();
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
}
map_current_changes_.erase(it);

View File

@ -490,13 +490,14 @@ class text_tracked_context
public:
struct _state
{
std::wstring id;
std::wstring author;
std::wstring date;
int type;
std::wstring content; //delete elements
std::wstring style_name;
std::wstring id;
std::wstring author;
std::wstring date;
int type;
std::wstring style_name;
std::vector<std::wstring> content; //delete elements
bool active;
void clear()
{
type = 0;
@ -504,6 +505,7 @@ public:
author.clear();
date.clear();
content.clear();
active = false;
}
};
std::wstring dumpPPr_;
@ -683,9 +685,6 @@ public:
docx_table_context & get_table_context() { return table_context_; }
odf_reader::office_element * get_section_properties_in_table();
void section_properties_in_table (odf_reader::office_element * Elm);
StreamsManPtr get_stream_man() const { return streams_man_; }
void set_stream_man(StreamsManPtr Sm) { streams_man_ = Sm; }
@ -752,23 +751,23 @@ private:
odf_reader::odf_document * odf_document_;
CApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_;
std::vector<odf_reader::_property> settings_properties_;
hyperlinks hyperlinks_;
mediaitems mediaitems_;
hyperlinks hyperlinks_;
mediaitems mediaitems_;
std::vector<oox_chart_context_ptr> charts_;
headers_footers headers_footers_;
std::wstring automatic_parent_style_;
std::list< const odf_reader::style_text_properties * > text_properties_stack_;
std::wstring automatic_parent_style_;
std::wstring current_master_page_name_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool page_break_after_;
bool page_break_before_;
bool page_break_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool in_automatic_style_;
bool in_drawing_content_;
bool in_paragraph_;
@ -777,25 +776,14 @@ private:
bool is_delete_text_;
bool is_rtl_; // right-to-left
bool is_paragraph_keep_;
NoteType process_note_;
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
NoteType process_note_;
std::list<odf_reader::office_element *> delayed_elements_;
std::vector<oox_chart_context_ptr> charts_;
odf_reader::office_element * section_properties_in_table_;
headers_footers headers_footers_;
std::wstring current_master_page_name_;
// счетчик для нумерации имен созданных в процессе конвертации стилей
int new_list_style_number_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
// цепочки переименований нумераций
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;
std::list< const odf_reader::style_text_properties * > text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций
};
}

View File

@ -38,24 +38,9 @@ namespace cpdoccore {
namespace oox {
static const int _odf_to_docx_ShapeType[]=
{ 4,4,4,34,};
static const std::wstring _docxShapeType[]=
{
L"rect",
L"rect",
L"rect",
L"ellipse",
L"ellipse",
L"line",
L"custGeom"
};
namespace {
}
void serialize_wrap_top_bottom(std::wostream & strm, _docx_drawing const & val)
{
@ -187,12 +172,10 @@ void serialize_wrap(std::wostream & strm, _docx_drawing const & val)
}
}
void docx_serialize_text(std::wostream & strm, _docx_drawing & val)
void _docx_drawing::serialize_text(std::wostream & strm)
{
const std::vector<odf_reader::_property> & properties = val.additional;
_CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty(properties,L"text-content",strTextContent);
odf_reader::GetProperty(additional, L"text-content", strTextContent);
CP_XML_WRITER(strm)
{
@ -209,7 +192,7 @@ void docx_serialize_text(std::wostream & strm, _docx_drawing & val)
}
}
oox_serialize_bodyPr(strm, val, L"wps");
serialize_bodyPr(strm, L"wps");
}
//--------------------------------------------------------------------
@ -240,11 +223,11 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"pic:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(), val);
val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst",L"rect");
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
@ -280,13 +263,12 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
}
CP_XML_NODE(L"wps:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
oox_serialize_shape(CP_XML_STREAM(),val);
val.serialize_xfrm (CP_XML_STREAM());
val.serialize_shape (CP_XML_STREAM());
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
docx_serialize_text(CP_XML_STREAM(),val);
val.serialize_text(CP_XML_STREAM());
}
}
}
@ -306,13 +288,14 @@ void docx_serialize_group_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"wpg:grpSpPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
}
CP_XML_STREAM() << val.content_group_;
}
}
}
void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
@ -321,7 +304,7 @@ void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
@ -332,9 +315,9 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
{
CP_XML_NODE(L"wp:docPr")
{
CP_XML_ATTR(L"name",val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
}
CP_XML_NODE(L"wp:cNvGraphicFramePr")
@ -355,6 +338,11 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
docx_serialize_shape_child(CP_XML_STREAM(), val);
}
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
else if (val.type == typeImage)
{
CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
@ -365,11 +353,6 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
docx_serialize_chart_child(CP_XML_STREAM(), val);
}
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
}
}
}
@ -435,12 +418,11 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"y",0);
}
CP_XML_NODE(L"wp:positionH")
{
std::wstring relativeFrom = L"margin";
if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
CP_XML_ATTR(L"relativeFrom", relativeFrom);
if (val.styleHorizontalPos &&
@ -453,16 +435,15 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
else
{
CP_XML_NODE(L"wp:posOffset") {CP_XML_STREAM() << val.posOffsetH;}
}
}
}
CP_XML_NODE(L"wp:positionV")
{
std::wstring relativeFrom = L"margin";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
std::wstring relativeFrom = L"paragraph";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
CP_XML_ATTR(L"relativeFrom",relativeFrom);
CP_XML_ATTR(L"relativeFrom", relativeFrom);
if (val.styleVerticalPos &&
val.styleVerticalPos->get_type() != odf_types::vertical_pos::FromTop &&
@ -481,17 +462,49 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
}
}
}
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx",val.cx);
CP_XML_ATTR(L"cy",val.cy);
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
serialize_wrap(CP_XML_STREAM(), val);
}
docx_serialize_common(CP_XML_STREAM(), val);
if (val.pctWidth)
{
std::wstring relativeFrom = L"margin";
if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
if (relativeFrom == L"column") relativeFrom = L"margin";
CP_XML_NODE(L"wp14:sizeRelH")
{
CP_XML_ATTR(L"relativeFrom", relativeFrom);
CP_XML_NODE(L"wp14:pctWidth")
{
CP_XML_STREAM() << (val.pctWidth.get() * 1000);
}
}
}
if (val.pctHeight)
{
std::wstring relativeFrom = L"paragraph";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
if (relativeFrom == L"paragraph") relativeFrom = L"margin";
CP_XML_NODE(L"wp14:sizeRelV")
{
CP_XML_ATTR(L"relativeFrom", relativeFrom);
CP_XML_NODE(L"wp14:pctHeight")
{
CP_XML_STREAM() << (val.pctHeight.get() * 1000);
}
}
}
}
}
}
@ -547,16 +560,65 @@ void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val)
}
}
}
void docx_serialize(std::wostream & strm, _docx_drawing & val, bool insideOtherDrawing)
void docx_serialize_object(std::wostream & strm, _docx_drawing & val)
{
if (val.inGroup)
return docx_serialize_child(strm, val);
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:object")
{
CP_XML_NODE(L"v:shape")
{
CP_XML_ATTR(L"id", L"ole_" + val.objectId);
CP_XML_ATTR(L"o:ole", "");
std::wstring style_str; // = L"width:730.6pt; height:261.8pt";
style_str += L"width:" + std::to_wstring(val.cx / 12700.) + L"pt;";
style_str += L"height:" + std::to_wstring(val.cy / 12700.) + L"pt;";
CP_XML_ATTR(L"style", style_str);
if (val.fill.bitmap)
{
CP_XML_NODE(L"v:imagedata")
{
CP_XML_ATTR(L"o:title", val.name);
CP_XML_ATTR(L"r:id", val.fill.bitmap->rId);
}
}
}
CP_XML_NODE(L"o:OLEObject")
{
CP_XML_ATTR(L"Type", L"Embed");
CP_XML_ATTR(L"ProgID", val.objectProgId);
CP_XML_ATTR(L"ShapeID", L"ole_" + val.objectId);
CP_XML_ATTR(L"DrawAspect", L"Content" );
CP_XML_ATTR(L"ObjectID", 0x583A3000 + val.id );
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
}
void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
{
if (type == typeUnknown) return;
if (inGroup)
return docx_serialize_child(strm, *this);
//if (insideOtherDrawing)
docx_serialize_wps(strm, val);
//else
// docx_serialize_alt_content(strm, val);
if (type == typeMsObject ||
type == typeOleObject)
{
docx_serialize_object(strm, *this);
}
else
{
//if (insideOtherDrawing)
docx_serialize_wps(strm, *this);
//else
// docx_serialize_alt_content(strm, val);
}
}

View File

@ -44,22 +44,24 @@
namespace cpdoccore {
namespace oox {
struct _docx_drawing : _oox_drawing
class _docx_drawing : public _oox_drawing
{
_docx_drawing():_oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
public:
_docx_drawing() : _oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
{
}
unsigned int parallel;
bool isInline;
unsigned int parallel;
//_CP_OPT(run_through) styleRunThrough ;
//_CP_OPT(run_through) styleRunThrough ;
_CP_OPT(odf_types::horizontal_rel) styleHorizontalRel;
_CP_OPT(odf_types::horizontal_pos) styleHorizontalPos;
_CP_OPT(odf_types::vertical_pos) styleVerticalPos;
_CP_OPT(odf_types::vertical_rel) styleVerticalRel;
_CP_OPT(odf_types::style_wrap) styleWrap;
_CP_OPT(odf_types::style_wrap) styleWrap;
bool isInline;
int number_wrapped_paragraphs;
std::wstring relativeHeight;
@ -67,16 +69,16 @@ struct _docx_drawing : _oox_drawing
int posOffsetV;
int posOffsetH;
_CP_OPT(int) pctWidth;
_CP_OPT(int) pctHeight;
int margin_rect[4];//0-left, 1 -top, 2- right, 3 - bottom
//std::wstring distB;
// std::wstring distT;
// std::wstring distL;
// std::wstring distR;
int margin_rect[4]; //0-left, 1 -top, 2- right, 3 - bottom
std::wstring content_group_;
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val, bool insideOtherDrawing);
void serialize_text (std::wostream & strm);
void serialize (std::wostream & strm/*, bool insideOtherDrawing*/);
};
}
}

View File

@ -96,8 +96,13 @@ void word_files::write(const std::wstring & RootPath)
{
media_->write( path );
}
if (embeddings_)
{
embeddings_->write( path );
}
if (headers_footers_)
if (headers_footers_)
{
headers_footers_->write( path );
}
@ -136,7 +141,15 @@ void word_files::update_rels(docx_conversion_context & Context)
void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
embeddings_->set_main_document( get_main_document() );
}
}
void word_files::set_styles(element_ptr Element)
@ -197,6 +210,7 @@ void docx_charts_files::add_chart(chart_content_ptr chart)
{
charts_.push_back(chart);
}
void docx_charts_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";

View File

@ -148,6 +148,7 @@ private:
element_ptr fontTable_;
element_ptr numbering_;
element_ptr media_;
element_ptr embeddings_;
element_ptr headers_footers_;
element_ptr notes_;
element_ptr settings_;

View File

@ -52,6 +52,8 @@ struct drawing_object_description
oox::RelsType type_;
std::wstring name_;
std::wstring descriptor_;
_CP_OPT(_rect) svg_rect_;
std::wstring anchor_;
@ -66,7 +68,6 @@ struct drawing_object_description
_oox_fill fill_;
bool use_image_replace_;
bool in_group_;
int shape_type_; //default - frame

View File

@ -97,9 +97,12 @@ void headers_footers::dump_rels(rels & Rels) const//внешние релсы
}
}
bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const
bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_page/*not used*/, std::wostream & _Wostream)
{
if (!instances_.count(StyleName))return false;
if (!instances_.count(StyleName)) return false;
if (last_write_style_ == StyleName) return true;
last_write_style_ = StyleName;
bool first = false, left = false;
bool res = false;

Some files were not shown because too many files have changed in this diff Show More