diff --git a/MsBinaryFile/Common/Base/XmlTools.cpp b/MsBinaryFile/Common/Base/XmlTools.cpp new file mode 100644 index 0000000000..b5fa4444a6 --- /dev/null +++ b/MsBinaryFile/Common/Base/XmlTools.cpp @@ -0,0 +1,413 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "XmlTools.h" + +namespace XMLTools +{ + /*======================================================================================================== + class XMLAttribute + ========================================================================================================*/ + + XMLAttribute::XMLAttribute() + { + } + XMLAttribute::XMLAttribute( const std::wstring & name ) : m_Name(name) + { + } + XMLAttribute::XMLAttribute( const std::wstring & name, const std::wstring & value ) : m_Name(name), m_Value(value) + { + } + XMLAttribute::~XMLAttribute() + { + } + void XMLAttribute::SetValue( const std::wstring & value ) + { + m_Value = std::wstring( value ); + } + std::wstring XMLAttribute::GetName() const + { + return m_Name; + } + std::wstring XMLAttribute::GetValue() const + { + return m_Value; + } + std::wstring XMLAttribute::GetXMLString() + { + std::wstring xmlString( L"" ); + + xmlString += m_Name; + xmlString += std::wstring( L"=\"" ); + xmlString += m_Value; + xmlString += std::wstring( L"\"" ); + + return xmlString; + } + + /*======================================================================================================== + class XMLElement + ========================================================================================================*/ + + XMLElement::XMLElement() {} + XMLElement::XMLElement( const std::wstring & name ) : m_Name(name) + { + } + XMLElement::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() {} + void XMLElement::AppendText( const std::wstring & text ) + { + m_ElementText = std::wstring( text ); + } + void XMLElement::AppendTextSymbol( const wchar_t symbol ) + { + m_ElementText += std::wstring( &symbol ); + } + void XMLElement::AppendAttribute( const XMLAttribute& attribute ) + { + AttributeValuePair p( attribute.GetName(), attribute.GetValue() ); + + m_AttributeMap.insert( p ); + } + void XMLElement::AppendAttribute( const std::wstring & name, const std::wstring & value ) + { + AttributeValuePair p( name , value ); + + m_AttributeMap.insert( p ); + } + void XMLElement::AppendChild( const XMLElement& element, bool uniq) + { + if (m_ChildMap.find(element.GetName()) != m_ChildMap.end()) + { + if (uniq) return; + } + else + { + m_ChildMap.insert(m_ChildMap.end(), std::pair(element.GetName(), 0)); + } + m_Elements.push_back( element ); + } + void XMLElement::AppendChild( XMLElementPtr element, bool uniq) + { + if (!element) return; + + if (m_ChildMap.find(element->GetName()) != m_ChildMap.end()) + { + if (uniq) return; + } + else + { + m_ChildMap.insert(m_ChildMap.end(), std::pair(element->GetName(), 0)); + } + m_Elements.push_back( *element.get() ); + } + void XMLElement::RemoveChild( const XMLElement& element ) + { + m_Elements.remove( element ); + } + bool XMLElement::FindChild( const XMLElement& element ) + { + bool result = false; + + for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) + { + if ( *iter == element ) + { + result = true; + + break; + } + } + + return result; + } + bool XMLElement::FindChildByName( const std::wstring & elementName ) const + { + bool result = false; + + for ( ElementsIteratorConst iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) + { + if ( iter->m_Name == std::wstring( elementName ) ) + { + result = true; + + break; + } + } + + return result; + } + bool XMLElement::RemoveChildByName( const std::wstring& elementName ) + { + bool result = false; + + for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) + { + if ( iter->m_Name == elementName ) + { + m_Elements.erase( iter ); + + result = true; + + break; + } + } + + return result; + } + bool XMLElement::operator == ( const XMLElement& element ) const + { + bool result = false; + + result = ( m_Name == element.m_Name ); + + if ( m_AttributeMap.size() != element.m_AttributeMap.size() ) + { + result = false; + } + else + { + + AttMapIteratorConst thisIter = m_AttributeMap.begin(); + AttMapIteratorConst elementIter = element.m_AttributeMap.begin(); + + for ( ; thisIter != m_AttributeMap.end(); thisIter++, elementIter++ ) + { + if ( ( thisIter->first != elementIter->first ) || ( thisIter->second != elementIter->second ) ) + { + result = false; + } + } + } + + if ( m_Elements.size() != element.m_Elements.size() ) + { + result = false; + } + else + { + ElementsIteratorConst thisIter = m_Elements.begin(); + ElementsIteratorConst elementIter = element.m_Elements.begin(); + + for ( ; thisIter != m_Elements.end(); thisIter++, elementIter++ ) + { + if ( !( (*thisIter) == (*elementIter) ) ) + { + result = false; + } + } + } + + return result; + } + std::wstring XMLElement::GetName() const + { + return m_Name; + } + std::wstring XMLElement::GetXMLString() + { + std::wstring xmlString( L""); + + bool bIsNameExists = ( m_Name != std::wstring( L"") ); + bool bIsTextExists = ( m_ElementText != std::wstring( L"") ); + + if ( bIsNameExists ) + { + 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::wstring( L" " ); + xmlString += iter->first; + xmlString += std::wstring( L"=\"" ); + xmlString += iter->second; + xmlString += std::wstring( L"\"" ); + } + } + + if ( ( m_Elements.size() > 0 ) || ( bIsTextExists ) ) + { + if ( bIsNameExists ) + { + xmlString += std::wstring( L">" ); + } + + for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) + { + xmlString += iter->GetXMLString(); + } + + if ( bIsTextExists ) + { + xmlString += m_ElementText; + } + + if ( bIsNameExists ) + { + xmlString += std::wstring( L"" ); + } + } + else + { + if ( bIsNameExists ) + { + xmlString += std::wstring( L"/>" ); + } + } + + return xmlString; + } + unsigned int XMLElement::GetAttributeCount() const + { + return (unsigned int)m_AttributeMap.size(); + } + unsigned int XMLElement::GetChildCount() const + { + return (unsigned int)m_Elements.size(); + } + + CStringXmlWriter::CStringXmlWriter(){} + std::wstring CStringXmlWriter::GetXmlString() + { + return m_str; + } + void CStringXmlWriter::SetXmlString(const std::wstring& strValue) + { + m_str = strValue; + } + void CStringXmlWriter::Clear() + { + m_str.clear(); + } + bool CStringXmlWriter::SaveToFile(const std::wstring& strFilePath, bool bEncodingToUTF8) + { + NSFile::CFileBinary file; + if (!file.CreateFileW(strFilePath)) return false; + + if (bEncodingToUTF8) + file.WriteStringUTF8(m_str); + else + { + std::string s(m_str.begin(), m_str.end()); + file.WriteFile((unsigned char*)s.c_str(), (DWORD)s.length()); + } + file.CloseFile(); + return true; + } + void CStringXmlWriter::WriteString(const std::wstring & strValue) + { + m_str += strValue; + } + void CStringXmlWriter::WriteInteger(int Value, int Base) + { + m_str += std::to_wstring(Value); + } + void CStringXmlWriter::WriteDouble(double Value) + { + m_str += std::to_wstring(Value); + } + void CStringXmlWriter::WriteBoolean(bool Value) + { + if (Value) + m_str += L"true"; + else + m_str += L"false"; + } + void CStringXmlWriter::WriteNodeBegin(const std::wstring& strNodeName, bool bAttributed) + { + m_str += L"<" + strNodeName; + + if (!bAttributed) + m_str += L">"; + } + void CStringXmlWriter::WriteNodeEnd(const std::wstring& strNodeName, bool bEmptyNode, bool bEndNode) + { + if (bEmptyNode) + { + if (bEndNode) + m_str += L"/>"; + else + m_str += L">"; + } + else + m_str += L""; + } + void CStringXmlWriter::WriteNode(const std::wstring& strNodeName, const std::wstring& strNodeValue) + { + if (strNodeValue.length() == 0) + m_str += L"<" + strNodeName + L"/>"; + else + m_str += L"<" + strNodeName + L">" + strNodeValue + L""; + } + void CStringXmlWriter::WriteNode(const std::wstring& strNodeName, int nValue, int nBase, const std::wstring& strTextBeforeValue, const std::wstring& strTextAfterValue) + { + WriteNodeBegin(strNodeName); + WriteString(strTextBeforeValue); + WriteInteger(nValue, nBase); + WriteString(strTextAfterValue); + WriteNodeEnd(strNodeName); + } + void CStringXmlWriter::WriteNode(const std::wstring& strNodeName, double dValue) + { + WriteNodeBegin(strNodeName); + WriteDouble(dValue); + WriteNodeEnd(strNodeName); + } + void CStringXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const std::wstring& strAttributeValue) + { + m_str += L" " + strAttributeName + L"=\"" + strAttributeValue + L"\""; + } + void CStringXmlWriter::WriteAttribute(const std::wstring& strAttributeName, int nValue, int nBase, const std::wstring& strTextBeforeValue, const std::wstring& strTextAfterValue) + { + WriteString(L" " + strAttributeName + L"="); + WriteString(L"\""); + WriteString(strTextBeforeValue); + WriteInteger(nValue, nBase); + WriteString(strTextAfterValue); + WriteString(L"\""); + } + void CStringXmlWriter::WriteAttribute(const std::wstring& strAttributeName, double dValue) + { + WriteString(L" " + strAttributeName + L"="); + WriteString(L"\""); + WriteDouble(dValue); + WriteString(L"\""); + } +} diff --git a/MsBinaryFile/Common/Base/XmlTools.h b/MsBinaryFile/Common/Base/XmlTools.h index 58efddc9ae..2c4f6a025d 100644 --- a/MsBinaryFile/Common/Base/XmlTools.h +++ b/MsBinaryFile/Common/Base/XmlTools.h @@ -66,47 +66,21 @@ namespace XMLTools public: - XMLAttribute() - { + XMLAttribute(); + XMLAttribute( const std::wstring & name ); + XMLAttribute( const std::wstring & name, const std::wstring & value ); + ~XMLAttribute(); - } - XMLAttribute( const std::wstring & name ) : m_Name(name) - { - } - XMLAttribute( const std::wstring & name, const std::wstring & value ) : m_Name(name), m_Value(value) - { - } - ~XMLAttribute() - { - } - void SetValue( const std::wstring & value ) - { - m_Value = std::wstring( value ); - } - std::wstring GetName() const - { - return m_Name; - } - /*========================================================================================================*/ - - std::wstring GetValue() const - { - return m_Value; - } + void SetValue( const std::wstring & value ); + std::wstring GetName() const; /*========================================================================================================*/ - std::wstring GetXMLString() - { - std::wstring xmlString( L"" ); + std::wstring GetValue() const; - xmlString += m_Name; - xmlString += std::wstring( L"=\"" ); - xmlString += m_Value; - xmlString += std::wstring( L"\"" ); + /*========================================================================================================*/ - return xmlString; - } + std::wstring GetXMLString(); }; /*======================================================================================================== @@ -134,255 +108,44 @@ namespace XMLTools typedef std::unordered_map::const_iterator AttMapIteratorConst; public: + XMLElement(); + XMLElement( const std::wstring & name ); + XMLElement( const std::wstring & prefix, const std::wstring & localName ); + ~XMLElement(); - XMLElement() {} + void AppendText( const std::wstring & text ); + void AppendTextSymbol( const wchar_t symbol ); - XMLElement( const std::wstring & name ) : m_Name(name) - { + void AppendAttribute( const XMLAttribute& attribute ); + void AppendAttribute( const std::wstring & name, const std::wstring & value ); - } - XMLElement( const std::wstring & prefix, const std::wstring & localName ) : - m_Name( std::wstring( prefix ) + std::wstring( L":" ) + std::wstring( localName ) ), m_ElementText( L"" ) - { + void AppendChild( const XMLElement& element, bool uniq = false); + void AppendChild( XMLElementPtr element, bool uniq = false); - } - ~XMLElement() {} + void RemoveChild( const XMLElement& element ); - void AppendText( const std::wstring & text ) - { - m_ElementText = std::wstring( text ); - } + bool FindChild( const XMLElement& element ); + bool FindChildByName( const std::wstring & elementName ) const; - void AppendTextSymbol( const wchar_t symbol ) - { - m_ElementText += std::wstring( &symbol ); - } + bool RemoveChildByName( const std::wstring& elementName ); - void AppendAttribute( const XMLAttribute& attribute ) - { - AttributeValuePair p( attribute.GetName(), attribute.GetValue() ); - - m_AttributeMap.insert( p ); - } - - void AppendAttribute( const std::wstring & name, const std::wstring & value ) - { - AttributeValuePair p( name , value ); - - m_AttributeMap.insert( p ); - } - - void AppendChild( const XMLElement& element, bool uniq = false) - { - if (m_ChildMap.find(element.GetName()) != m_ChildMap.end()) - { - if (uniq) return; - } - else - { - m_ChildMap.insert(m_ChildMap.end(), std::pair(element.GetName(), 0)); - } - m_Elements.push_back( element ); - } - void AppendChild( XMLElementPtr element, bool uniq = false) - { - if (!element) return; - - if (m_ChildMap.find(element->GetName()) != m_ChildMap.end()) - { - if (uniq) return; - } - else - { - m_ChildMap.insert(m_ChildMap.end(), std::pair(element->GetName(), 0)); - } - m_Elements.push_back( *element.get() ); - } - void RemoveChild( const XMLElement& element ) - { - m_Elements.remove( element ); - } - - bool FindChild( const XMLElement& element ) - { - bool result = false; - - for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) - { - if ( *iter == element ) - { - result = true; - - break; - } - } - - return result; - } - - bool FindChildByName( const std::wstring & elementName ) const - { - bool result = false; - - for ( ElementsIteratorConst iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) - { - if ( iter->m_Name == std::wstring( elementName ) ) - { - result = true; - - break; - } - } - - return result; - } - - bool RemoveChildByName( const std::wstring& elementName ) - { - bool result = false; - - for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) - { - if ( iter->m_Name == elementName ) - { - m_Elements.erase( iter ); - - result = true; - - break; - } - } - - return result; - } - - bool operator == ( const XMLElement& element ) const - { - bool result = false; - - result = ( m_Name == element.m_Name ); - - if ( m_AttributeMap.size() != element.m_AttributeMap.size() ) - { - result = false; - } - else - { - - AttMapIteratorConst thisIter = m_AttributeMap.begin(); - AttMapIteratorConst elementIter = element.m_AttributeMap.begin(); - - for ( ; thisIter != m_AttributeMap.end(); thisIter++, elementIter++ ) - { - if ( ( thisIter->first != elementIter->first ) || ( thisIter->second != elementIter->second ) ) - { - result = false; - } - } - } - - if ( m_Elements.size() != element.m_Elements.size() ) - { - result = false; - } - else - { - ElementsIteratorConst thisIter = m_Elements.begin(); - ElementsIteratorConst elementIter = element.m_Elements.begin(); - - for ( ; thisIter != m_Elements.end(); thisIter++, elementIter++ ) - { - if ( !( (*thisIter) == (*elementIter) ) ) - { - result = false; - } - } - } - - return result; - } + bool operator == ( const XMLElement& element ) const; /*========================================================================================================*/ - std::wstring GetName() const - { - return m_Name; - } + std::wstring GetName() const; /*========================================================================================================*/ - std::wstring GetXMLString() - { - std::wstring xmlString( L""); - - bool bIsNameExists = ( m_Name != std::wstring( L"") ); - bool bIsTextExists = ( m_ElementText != std::wstring( L"") ); - - if ( bIsNameExists ) - { - 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::wstring( L" " ); - xmlString += iter->first; - xmlString += std::wstring( L"=\"" ); - xmlString += iter->second; - xmlString += std::wstring( L"\"" ); - } - } - - if ( ( m_Elements.size() > 0 ) || ( bIsTextExists ) ) - { - if ( bIsNameExists ) - { - xmlString += std::wstring( L">" ); - } - - for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ ) - { - xmlString += iter->GetXMLString(); - } - - if ( bIsTextExists ) - { - xmlString += m_ElementText; - } - - if ( bIsNameExists ) - { - xmlString += std::wstring( L"" ); - } - } - else - { - if ( bIsNameExists ) - { - xmlString += std::wstring( L"/>" ); - } - } - - return xmlString; - } + std::wstring GetXMLString(); /*========================================================================================================*/ - unsigned int GetAttributeCount() const - { - return (unsigned int)m_AttributeMap.size(); - } + unsigned int GetAttributeCount() const; /*========================================================================================================*/ - unsigned int GetChildCount() const - { - return (unsigned int)m_Elements.size(); - } + unsigned int GetChildCount() const; }; class CStringXmlWriter @@ -390,117 +153,27 @@ namespace XMLTools std::wstring m_str; public: - CStringXmlWriter(){} - std::wstring GetXmlString() - { - return m_str; - } - void SetXmlString(const std::wstring& strValue) - { - m_str = strValue; - } - void Clear() - { - m_str.clear(); - } - bool SaveToFile(const std::wstring& strFilePath, bool bEncodingToUTF8 = false) - { - NSFile::CFileBinary file; - if (!file.CreateFileW(strFilePath)) return false; + CStringXmlWriter(); + std::wstring GetXmlString(); - if (bEncodingToUTF8) - file.WriteStringUTF8(m_str); - else - { - std::string s(m_str.begin(), m_str.end()); - file.WriteFile((unsigned char*)s.c_str(), (DWORD)s.length()); - } - file.CloseFile(); - return true; - } + void SetXmlString(const std::wstring& strValue); + void Clear(); + bool SaveToFile(const std::wstring& strFilePath, bool bEncodingToUTF8 = false); - void WriteString(const std::wstring & strValue) - { - m_str += strValue; - } + void WriteString(const std::wstring & strValue); + void WriteInteger(int Value, int Base = 10); + void WriteDouble(double Value); + void WriteBoolean(bool Value); - void WriteInteger(int Value, int Base = 10) - { - m_str += std::to_wstring(Value); - } + void WriteNodeBegin(const std::wstring& strNodeName, bool bAttributed = false); + void WriteNodeEnd(const std::wstring& strNodeName, bool bEmptyNode = false, bool bEndNode = true); - void WriteDouble(double Value) - { - m_str += std::to_wstring(Value); - } - void WriteBoolean(bool Value) - { - if (Value) - m_str += L"true"; - else - m_str += L"false"; - } - void WriteNodeBegin(const std::wstring& strNodeName, bool bAttributed = false) - { - m_str += L"<" + strNodeName; + void WriteNode(const std::wstring& strNodeName, const std::wstring& strNodeValue); + void WriteNode(const std::wstring& strNodeName, int nValue, int nBase = 10, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = L""); + void WriteNode(const std::wstring& strNodeName, double dValue); - if (!bAttributed) - m_str += L">"; - } - void WriteNodeEnd(const std::wstring& strNodeName, bool bEmptyNode = false, bool bEndNode = true) - { - if (bEmptyNode) - { - if (bEndNode) - m_str += L"/>"; - else - m_str += L">"; - } - else - m_str += L""; - } - void WriteNode(const std::wstring& strNodeName, const std::wstring& strNodeValue) - { - if (strNodeValue.length() == 0) - m_str += L"<" + strNodeName + L"/>"; - else - m_str += L"<" + strNodeName + L">" + strNodeValue + L""; - } - void WriteNode(const std::wstring& strNodeName, int nValue, int nBase = 10, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = L"") - { - WriteNodeBegin(strNodeName); - WriteString(strTextBeforeValue); - WriteInteger(nValue, nBase); - WriteString(strTextAfterValue); - WriteNodeEnd(strNodeName); - } - void WriteNode(const std::wstring& strNodeName, double dValue) - { - WriteNodeBegin(strNodeName); - WriteDouble(dValue); - WriteNodeEnd(strNodeName); - } - void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& strAttributeValue) - { - m_str += L" " + strAttributeName + L"=\"" + strAttributeValue + L"\""; - } - void WriteAttribute(const std::wstring& strAttributeName, int nValue, int nBase = 10, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = L"") - { - WriteString(L" " + strAttributeName + L"="); - WriteString(L"\""); - WriteString(strTextBeforeValue); - WriteInteger(nValue, nBase); - WriteString(strTextAfterValue); - WriteString(L"\""); - } - void WriteAttribute(const std::wstring& strAttributeName, double dValue) - { - WriteString(L" " + strAttributeName + L"="); - WriteString(L"\""); - WriteDouble(dValue); - WriteString(L"\""); - } + void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& strAttributeValue); + void WriteAttribute(const std::wstring& strAttributeName, int nValue, int nBase = 10, const std::wstring& strTextBeforeValue = L"", const std::wstring& strTextAfterValue = L""); + void WriteAttribute(const std::wstring& strAttributeName, double dValue); }; - - } diff --git a/MsBinaryFile/DocFile/AbstractOpenXmlMapping.cpp b/MsBinaryFile/DocFile/AbstractOpenXmlMapping.cpp new file mode 100644 index 0000000000..c97bb72746 --- /dev/null +++ b/MsBinaryFile/DocFile/AbstractOpenXmlMapping.cpp @@ -0,0 +1,43 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "AbstractOpenXmlMapping.h" + +namespace DocFileFormat +{ + AbstractOpenXmlMapping::AbstractOpenXmlMapping (XMLTools::CStringXmlWriter* pWriter) : m_pXmlWriter(pWriter) + { + } + AbstractOpenXmlMapping::~AbstractOpenXmlMapping() + { + } +} diff --git a/MsBinaryFile/DocFile/AbstractOpenXmlMapping.h b/MsBinaryFile/DocFile/AbstractOpenXmlMapping.h index 242ce870bb..c2ee95d2fc 100644 --- a/MsBinaryFile/DocFile/AbstractOpenXmlMapping.h +++ b/MsBinaryFile/DocFile/AbstractOpenXmlMapping.h @@ -38,23 +38,16 @@ namespace DocFileFormat class AbstractOpenXmlMapping { public: - AbstractOpenXmlMapping (XMLTools::CStringXmlWriter* pWriter) : m_pXmlWriter(pWriter) - { - - } + AbstractOpenXmlMapping (XMLTools::CStringXmlWriter* pWriter); inline XMLTools::CStringXmlWriter* GetXMLWriter() { return m_pXmlWriter; } - virtual ~AbstractOpenXmlMapping() - { - - } + virtual ~AbstractOpenXmlMapping(); protected: - XMLTools::CStringXmlWriter* m_pXmlWriter; }; } diff --git a/MsBinaryFile/DocFile/AnnotationOwnerList.cpp b/MsBinaryFile/DocFile/AnnotationOwnerList.cpp new file mode 100644 index 0000000000..706ad8a9bb --- /dev/null +++ b/MsBinaryFile/DocFile/AnnotationOwnerList.cpp @@ -0,0 +1,48 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "AnnotationOwnerList.h" + +namespace DocFileFormat +{ + AnnotationOwnerList::AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector() + { + VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_nWordVersion); + + if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return; + + while (reader.GetPosition() < (fib->m_FibWord97.fcGrpXstAtnOwners + fib->m_FibWord97.lcbGrpXstAtnOwners)) + { + push_back(reader.ReadXst()); + } + } +} diff --git a/MsBinaryFile/DocFile/AnnotationOwnerList.h b/MsBinaryFile/DocFile/AnnotationOwnerList.h index db59b764a4..a454afa65b 100644 --- a/MsBinaryFile/DocFile/AnnotationOwnerList.h +++ b/MsBinaryFile/DocFile/AnnotationOwnerList.h @@ -39,16 +39,6 @@ namespace DocFileFormat class AnnotationOwnerList: public std::vector { public: - AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector() - { - VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_nWordVersion); - - if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return; - - while (reader.GetPosition() < (fib->m_FibWord97.fcGrpXstAtnOwners + fib->m_FibWord97.lcbGrpXstAtnOwners)) - { - push_back(reader.ReadXst()); - } - } + AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/AutoSummaryInfo.cpp b/MsBinaryFile/DocFile/AutoSummaryInfo.cpp new file mode 100644 index 0000000000..6685f76841 --- /dev/null +++ b/MsBinaryFile/DocFile/AutoSummaryInfo.cpp @@ -0,0 +1,69 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "AutoSummaryInfo.h" +#include "../Common/Base/FormatUtils.h" + +namespace DocFileFormat +{ + AutoSummaryInfo::~AutoSummaryInfo() + { + } + AutoSummaryInfo::AutoSummaryInfo(): + fValid(false), fView(false), iViewBy(0), fUpdateProps(false), wDlgLevel(0), + lHighestLevel(0), lCurrentLevel(0) + { + } + + /// Parses the bytes to retrieve a AutoSummaryInfo + AutoSummaryInfo::AutoSummaryInfo( unsigned char* bytes, int size ): + fValid(false), fView(false), iViewBy(0), fUpdateProps(false), wDlgLevel(0), + lHighestLevel(0), lCurrentLevel(0) + { + if ( size == 12 ) + { + //split unsigned char 0 and 1 into bits + this->fValid = FormatUtils::GetBitFromBytes( bytes, size, 0 ); + this->fView = FormatUtils::GetBitFromBytes( bytes, size, 1 ); + this->iViewBy = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 2, 2 ); + this->fUpdateProps = FormatUtils::GetBitFromBytes( bytes, size, 4 ); + + this->wDlgLevel = FormatUtils::BytesToInt16( bytes, 2, size ); + this->lHighestLevel = FormatUtils::BytesToInt32( bytes, 4, size ); + this->lCurrentLevel = FormatUtils::BytesToInt32( bytes, 8, size ); + } + else + { + //throw new ByteParseException("Cannot parse the struct ASUMYI, the length of the struct doesn't match"); + } + } +} diff --git a/MsBinaryFile/DocFile/AutoSummaryInfo.h b/MsBinaryFile/DocFile/AutoSummaryInfo.h index 4f9fb71db4..c15c5717ef 100644 --- a/MsBinaryFile/DocFile/AutoSummaryInfo.h +++ b/MsBinaryFile/DocFile/AutoSummaryInfo.h @@ -57,37 +57,10 @@ namespace DocFileFormat int lCurrentLevel; public: - virtual ~AutoSummaryInfo() - { - } - - AutoSummaryInfo(): - fValid(false), fView(false), iViewBy(0), fUpdateProps(false), wDlgLevel(0), - lHighestLevel(0), lCurrentLevel(0) - { - } + virtual ~AutoSummaryInfo(); + AutoSummaryInfo(); /// Parses the bytes to retrieve a AutoSummaryInfo - AutoSummaryInfo( unsigned char* bytes, int size ): - fValid(false), fView(false), iViewBy(0), fUpdateProps(false), wDlgLevel(0), - lHighestLevel(0), lCurrentLevel(0) - { - if ( size == 12 ) - { - //split unsigned char 0 and 1 into bits - this->fValid = FormatUtils::GetBitFromBytes( bytes, size, 0 ); - this->fView = FormatUtils::GetBitFromBytes( bytes, size, 1 ); - this->iViewBy = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 2, 2 ); - this->fUpdateProps = FormatUtils::GetBitFromBytes( bytes, size, 4 ); - - this->wDlgLevel = FormatUtils::BytesToInt16( bytes, 2, size ); - this->lHighestLevel = FormatUtils::BytesToInt32( bytes, 4, size ); - this->lCurrentLevel = FormatUtils::BytesToInt32( bytes, 8, size ); - } - else - { - //throw new ByteParseException("Cannot parse the struct ASUMYI, the length of the struct doesn't match"); - } - } + AutoSummaryInfo( unsigned char* bytes, int size ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/BookmarkFirst.cpp b/MsBinaryFile/DocFile/BookmarkFirst.cpp new file mode 100644 index 0000000000..b7729ca2a2 --- /dev/null +++ b/MsBinaryFile/DocFile/BookmarkFirst.cpp @@ -0,0 +1,78 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "BookmarkFirst.h" + +namespace DocFileFormat +{ + BookmarkFirst::BookmarkFirst() + { + } + short BookmarkFirst::GetIndex() const + { + return this->ibkl; + } + short BookmarkFirst::GetInformation() const + { + return this->bkc; + } + BookmarkFirst::~BookmarkFirst() + { + } + ByteStructure* BookmarkFirst::ConstructObject( VirtualStreamReader* reader, int length ) + { + BookmarkFirst *newObject = new BookmarkFirst(); + + newObject->ibkl = reader->ReadInt16(); + newObject->bkc = reader->ReadInt16(); + + return static_cast( newObject ); + } + + AtnBookmarkFirst::AtnBookmarkFirst() + { + } + AtnBookmarkFirst::~AtnBookmarkFirst() + { + } + ByteStructure* AtnBookmarkFirst::ConstructObject( VirtualStreamReader* reader, int length ) + { + AtnBookmarkFirst *newObject = new AtnBookmarkFirst(); + + newObject->bmc = reader->ReadUInt16(); //0x0100 + newObject->lTag = reader->ReadUInt32(); + + unsigned int lTagOld = reader->ReadUInt32(); + + return static_cast( newObject ); + } +} diff --git a/MsBinaryFile/DocFile/BookmarkFirst.h b/MsBinaryFile/DocFile/BookmarkFirst.h index a358729c28..b5f3d8a6fc 100644 --- a/MsBinaryFile/DocFile/BookmarkFirst.h +++ b/MsBinaryFile/DocFile/BookmarkFirst.h @@ -45,34 +45,16 @@ namespace DocFileFormat public: static const int STRUCTURE_SIZE = 4; - BookmarkFirst() - { - } + BookmarkFirst(); - short GetIndex() const - { - return this->ibkl; - } - - short GetInformation() const - { - return this->bkc; - } + short GetIndex() const; + short GetInformation() const; - virtual ~BookmarkFirst() - { - } + virtual ~BookmarkFirst(); - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - BookmarkFirst *newObject = new BookmarkFirst(); - - newObject->ibkl = reader->ReadInt16(); - newObject->bkc = reader->ReadInt16(); - - return static_cast( newObject ); - } + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); }; + class AtnBookmarkFirst: public ByteStructure { public: @@ -81,24 +63,9 @@ public: static const int STRUCTURE_SIZE = 10; - AtnBookmarkFirst() - { - } + AtnBookmarkFirst(); + virtual ~AtnBookmarkFirst(); - virtual ~AtnBookmarkFirst() - { - } - - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - AtnBookmarkFirst *newObject = new AtnBookmarkFirst(); - - newObject->bmc = reader->ReadUInt16(); //0x0100 - newObject->lTag = reader->ReadUInt32(); - - unsigned int lTagOld = reader->ReadUInt32(); - - return static_cast( newObject ); - } + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); }; } diff --git a/MsBinaryFile/DocFile/BorderCode.cpp b/MsBinaryFile/DocFile/BorderCode.cpp new file mode 100644 index 0000000000..20464072d9 --- /dev/null +++ b/MsBinaryFile/DocFile/BorderCode.cpp @@ -0,0 +1,122 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "BorderCode.h" + +namespace DocFileFormat +{ + BorderCode::BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) + { + } + + /// Parses the unsigned char for a BRC + BorderCode::BorderCode( unsigned char* bytes, int size ): + cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) + { + if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) ) + { + fNil = true; + } + else if ( size == 8 ) + { + //it's a border code of Word 2000/2003 + cv = FormatUtils::BytesToInt32( bytes, 0, size ); + ico = std::wstring( Global::ColorIdentifier[0] ); + + dptLineWidth = bytes[4]; + brcType = bytes[5]; + + short val = FormatUtils::BytesToInt16( bytes, 6, size ); + dptSpace = val & 0x001F; + + //not sure if this is correct, the values from the spec are definitly wrong: + fShadow = FormatUtils::BitmaskToBool( val, 0x20 ); + fFrame = FormatUtils::BitmaskToBool( val, 0x40 ); + } + else if ( size == 4 ) + { + unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size ); + + dptLineWidth = (unsigned char)( val & 0x00FF ); + brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 ); + + val = FormatUtils::BytesToUInt16( bytes, 2, size ); + + ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorNameIdentifier[0][0], 17, 12 ); + dptSpace = ( val & 0x1F00 ) >> 8; + } + else if (size == 2) + { + unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size ); + + dptLineWidth = GETBITS(val, 0, 2); + brcType = GETBITS(val, 3, 4); + fShadow = GETBIT(val, 5); + ico = FormatUtils::MapValueToWideString(GETBITS(val, 6, 10), &Global::ColorNameIdentifier[0][0], 17, 12 ); + dptSpace = GETBITS(val, 11, 15); + + } + } + BorderCode::BorderCode( const BorderCode& bc ) + { + if ( this != &bc ) + { + cv = bc.cv; + dptLineWidth = bc.dptLineWidth; + brcType = bc.brcType; + ico = bc.ico; + dptSpace = bc.dptSpace; + fShadow = bc.fShadow; + fFrame = bc.fFrame; + fNil = bc.fNil; + } + } + + bool BorderCode::operator == ( const BorderCode& bc ) + { + if ( ( cv == bc.cv ) && ( dptLineWidth == bc.dptLineWidth ) && ( brcType == bc.brcType ) && + ( ico == bc.ico ) && ( dptSpace == bc.dptSpace ) && ( fShadow == bc.fShadow ) && + ( fFrame == bc.fFrame ) && ( fNil == bc.fNil ) ) + { + return true; + } + else + { + return false; + } + } + + bool BorderCode::operator != ( const BorderCode& bc ) + { + return !( *this == bc ); + } +} diff --git a/MsBinaryFile/DocFile/BorderCode.h b/MsBinaryFile/DocFile/BorderCode.h index 4511c82284..94f8e9dd41 100644 --- a/MsBinaryFile/DocFile/BorderCode.h +++ b/MsBinaryFile/DocFile/BorderCode.h @@ -118,90 +118,13 @@ namespace DocFileFormat public: /// Creates a new BorderCode with default values - BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) - { - } + BorderCode(); /// Parses the unsigned char for a BRC - BorderCode( unsigned char* bytes, int size ): - cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) - { - if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) ) - { - fNil = true; - } - else if ( size == 8 ) - { - //it's a border code of Word 2000/2003 - cv = FormatUtils::BytesToInt32( bytes, 0, size ); - ico = std::wstring( Global::ColorIdentifier[0] ); + BorderCode( unsigned char* bytes, int size ); + BorderCode( const BorderCode& bc ); - dptLineWidth = bytes[4]; - brcType = bytes[5]; - - short val = FormatUtils::BytesToInt16( bytes, 6, size ); - dptSpace = val & 0x001F; - - //not sure if this is correct, the values from the spec are definitly wrong: - fShadow = FormatUtils::BitmaskToBool( val, 0x20 ); - fFrame = FormatUtils::BitmaskToBool( val, 0x40 ); - } - else if ( size == 4 ) - { - unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size ); - - dptLineWidth = (unsigned char)( val & 0x00FF ); - brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 ); - - val = FormatUtils::BytesToUInt16( bytes, 2, size ); - - ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorNameIdentifier[0][0], 17, 12 ); - dptSpace = ( val & 0x1F00 ) >> 8; - } - else if (size == 2) - { - unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size ); - - dptLineWidth = GETBITS(val, 0, 2); - brcType = GETBITS(val, 3, 4); - fShadow = GETBIT(val, 5); - ico = FormatUtils::MapValueToWideString(GETBITS(val, 6, 10), &Global::ColorNameIdentifier[0][0], 17, 12 ); - dptSpace = GETBITS(val, 11, 15); - - } - } - BorderCode( const BorderCode& bc ) - { - if ( this != &bc ) - { - cv = bc.cv; - dptLineWidth = bc.dptLineWidth; - brcType = bc.brcType; - ico = bc.ico; - dptSpace = bc.dptSpace; - fShadow = bc.fShadow; - fFrame = bc.fFrame; - fNil = bc.fNil; - } - } - - bool operator == ( const BorderCode& bc ) - { - if ( ( cv == bc.cv ) && ( dptLineWidth == bc.dptLineWidth ) && ( brcType == bc.brcType ) && - ( ico == bc.ico ) && ( dptSpace == bc.dptSpace ) && ( fShadow == bc.fShadow ) && - ( fFrame == bc.fFrame ) && ( fNil == bc.fNil ) ) - { - return true; - } - else - { - return false; - } - } - - bool operator != ( const BorderCode& bc ) - { - return !( *this == bc ); - } + bool operator == ( const BorderCode& bc ); + bool operator != ( const BorderCode& bc ); }; } diff --git a/MsBinaryFile/DocFile/ByteStructure.cpp b/MsBinaryFile/DocFile/ByteStructure.cpp new file mode 100644 index 0000000000..ef803a79cf --- /dev/null +++ b/MsBinaryFile/DocFile/ByteStructure.cpp @@ -0,0 +1,48 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ByteStructure.h" + +namespace DocFileFormat +{ + ByteStructure::ByteStructure() {} + ByteStructure::~ByteStructure() {} + + EmptyStructure::EmptyStructure() {} + EmptyStructure::~EmptyStructure() {} + ByteStructure* EmptyStructure::ConstructObject( VirtualStreamReader* reader, int length ) + { + EmptyStructure *newObject = new EmptyStructure(); + + return static_cast( newObject ); + } +} diff --git a/MsBinaryFile/DocFile/ByteStructure.h b/MsBinaryFile/DocFile/ByteStructure.h index 9c226ed01b..02e2efde4f 100644 --- a/MsBinaryFile/DocFile/ByteStructure.h +++ b/MsBinaryFile/DocFile/ByteStructure.h @@ -38,10 +38,11 @@ namespace DocFileFormat class ByteStructure { protected: - ByteStructure() {} + ByteStructure(); public: - virtual ~ByteStructure() {} + virtual ~ByteStructure(); + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) = 0; // Virtual constructor }; @@ -50,15 +51,10 @@ namespace DocFileFormat public: static const int STRUCTURE_SIZE = 0; - EmptyStructure() {} + EmptyStructure(); - virtual ~EmptyStructure() {} + virtual ~EmptyStructure(); - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - EmptyStructure *newObject = new EmptyStructure(); - - return static_cast( newObject ); - } + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); }; } diff --git a/MsBinaryFile/DocFile/CharacterPropertyExceptions.cpp b/MsBinaryFile/DocFile/CharacterPropertyExceptions.cpp new file mode 100644 index 0000000000..32d5adb7b8 --- /dev/null +++ b/MsBinaryFile/DocFile/CharacterPropertyExceptions.cpp @@ -0,0 +1,215 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "CharacterPropertyExceptions.h" + +namespace DocFileFormat +{ + CharacterPropertyExceptions::CharacterPropertyExceptions(): PropertyExceptions() + { + } + + /// Parses the bytes to retrieve a CHPX + CharacterPropertyExceptions::CharacterPropertyExceptions( unsigned char* bytes, int size, int nWordVersion) : + PropertyExceptions( bytes, size, nWordVersion ) + { + if (nWordVersion > 1) + { + RELEASEOBJECT( grpprl ); + grpprl = new std::list(); + + MemoryStream oStream(bytes, size); + int pos = 0; + + if (nWordVersion == 3) + { + if (pos + 2 > size) return; + unsigned short fChar = oStream.ReadUInt16(); pos += 2; + + unsigned char val; + val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val)); + val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val)); + val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val)); + val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val)); + val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val)); + val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val)); + val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val)); + val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val)); + val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val)); + val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val)); + + bool fsIco = GETBIT(fChar, 10); + bool fsFtc = GETBIT(fChar, 11); + bool fsHps = GETBIT(fChar, 12); + bool fsKul = GETBIT(fChar, 13); + bool fsPos = GETBIT(fChar, 14); + bool fsSpace = GETBIT(fChar, 15); + + if (pos + 2 > size) return; + int fff = oStream.ReadUInt16(); pos += 2;//????? + + if (pos + 2 > size) return; + unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code + grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc)); + + if (pos + 1 > size) return; + unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points + + if (hps > 0) + { + grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps)); + } + + if (pos + 1 > size) return; + unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal ) + grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos)); + + if (pos + 2 > size) return; + unsigned short fText = oStream.ReadUInt16(); pos += 2; + + unsigned short qpsSpace = GETBITS(fText, 0, 5); + unsigned char wSpare2 = GETBITS(fText, 6, 7); + unsigned char ico = GETBITS(fText, 8, 11); + unsigned char kul = GETBITS(fText, 12, 14); + bool fSysVanish = GETBIT(fChar, 15); + + grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul)); + grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico)); + + //sizeof(CHP) == 12 == 0xC + if (pos + 4 > size) return; + unsigned int fcPic = oStream.ReadUInt16(); pos += 4; //pos = 8 + grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic)); + + if (pos + 1 > size) return; + unsigned char fnPic = oStream.ReadByte(); pos += 1; + + if (pos + 2 > size) return; + unsigned short hpsLargeChp = oStream.ReadUInt16(); pos += 2;// ??? type + } + else if (nWordVersion == 2) + { + if (pos + 2 > size) return; + unsigned short fChar = oStream.ReadUInt16(); pos += 2; + + unsigned char val; + val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val)); + val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val)); + val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCIbstRMark, 1, &val)); + val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val)); + val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val)); + val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val)); + val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val)); + val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val)); + val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val)); + val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val)); + val = GETBIT(fChar, 10); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val)); + val = GETBIT(fChar, 11); grpprl->push_back(SinglePropertyModifier(sprmOldCFObj, 1, &val)); + val = GETBIT(fChar, 12); grpprl->push_back(SinglePropertyModifier(sprmCFBoldBi, 1, &val)); + val = GETBIT(fChar, 13); grpprl->push_back(SinglePropertyModifier(sprmCFItalicBi, 1, &val)); + val = GETBIT(fChar, 14); grpprl->push_back(SinglePropertyModifier(sprmCFBiDi, 1, &val)); + val = GETBIT(fChar, 15); grpprl->push_back(SinglePropertyModifier(sprmCFDiacColor, 1, &val)); + + if (pos + 2 > size) return; + unsigned short fChar2 = oStream.ReadUInt16(); pos += 2; + bool fsIco = GETBIT(fChar2, 0); + bool fsFtc = GETBIT(fChar2, 1); + bool fsHps = GETBIT(fChar2, 2); + bool fsKul = GETBIT(fChar2, 3); + bool fsPos = GETBIT(fChar2, 4); + bool fsSpace = GETBIT(fChar2, 5); + bool fsLid = GETBIT(fChar2, 6); + bool fsIcoBi = GETBIT(fChar2, 7); + bool fsFtcBi = GETBIT(fChar2, 8); + bool fsHpsBi = GETBIT(fChar2, 9); + bool fsLidBi = GETBIT(fChar2, 10); + + if (pos + 2 > size) return; + unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code + grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc)); + + if (pos + 1 > size) return; + unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points + + if (hps > 0) + { + grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps)); + } + + if (pos + 1 > size) return; + unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal ) + grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos)); + + if (pos + 2 > size) return; + unsigned short fText = oStream.ReadUInt16(); pos += 2; + + unsigned short qpsSpace = GETBITS(fText, 0, 5); + unsigned char wSpare2 = GETBITS(fText, 6, 7); + unsigned char ico = GETBITS(fText, 8, 11); + unsigned char kul = GETBITS(fText, 12, 14); + bool fSysVanish = GETBIT(fChar, 15); + + grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul)); + grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico)); + + //if (pos + 1 > size) return; + //unsigned char icoBi = oStream.ReadUInt16(); pos += 1;//wSpare3 + + if (pos + 2 > size) return; + unsigned short lid = oStream.ReadUInt16(); pos += 2; + grpprl->push_back(SinglePropertyModifier(sprmOldCLid, 2, (BYTE*)&lid)); + + if (pos + 2 > size) return; + unsigned short ftcBi = oStream.ReadUInt16(); pos += 2; + grpprl->push_back(SinglePropertyModifier(sprmCFtcBi, 4, (BYTE*)&ftcBi)); + + //if (pos + 2 > size) return; + //unsigned short hpsBi = oStream.ReadUInt16(); pos += 2; + //grpprl->push_back(SinglePropertyModifier(sprmCHpsBi, 4, (BYTE*)&hpsBi)); + + //if (pos + 2 > size) return; + //unsigned short lidBi = oStream.ReadUInt16(); pos += 2; + //grpprl->push_back(SinglePropertyModifier(sprmCLidBi, 2, (BYTE*)&lidBi)); + + if (pos + 4 > size) return; + unsigned int fcPic = oStream.ReadUInt16(); pos += 4; //pos = 8 + grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic)); + + if (pos + 1 > size) return; + unsigned char fnPic = oStream.ReadByte(); pos += 1; + + if (pos + 2 > size) return; + unsigned short hpsLargeChp = oStream.ReadUInt16(); pos += 2;// ??? type + } + } + } +} diff --git a/MsBinaryFile/DocFile/CharacterPropertyExceptions.h b/MsBinaryFile/DocFile/CharacterPropertyExceptions.h index 425956e0de..bfec8f2c62 100644 --- a/MsBinaryFile/DocFile/CharacterPropertyExceptions.h +++ b/MsBinaryFile/DocFile/CharacterPropertyExceptions.h @@ -40,183 +40,9 @@ namespace DocFileFormat public: /// Creates a CHPX wich doesn't modify anything. /// The grpprl list is empty - CharacterPropertyExceptions(): PropertyExceptions() - { - } + CharacterPropertyExceptions(); /// Parses the bytes to retrieve a CHPX - CharacterPropertyExceptions( unsigned char* bytes, int size, int nWordVersion) : - PropertyExceptions( bytes, size, nWordVersion ) - { - if (nWordVersion > 1) - { - RELEASEOBJECT( grpprl ); - grpprl = new std::list(); - - MemoryStream oStream(bytes, size); - int pos = 0; - - if (nWordVersion == 3) - { - if (pos + 2 > size) return; - unsigned short fChar = oStream.ReadUInt16(); pos += 2; - - unsigned char val; - val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val)); - val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val)); - val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val)); - val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val)); - val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val)); - val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val)); - val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val)); - val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val)); - val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val)); - val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val)); - - bool fsIco = GETBIT(fChar, 10); - bool fsFtc = GETBIT(fChar, 11); - bool fsHps = GETBIT(fChar, 12); - bool fsKul = GETBIT(fChar, 13); - bool fsPos = GETBIT(fChar, 14); - bool fsSpace = GETBIT(fChar, 15); - - if (pos + 2 > size) return; - int fff = oStream.ReadUInt16(); pos += 2;//????? - - if (pos + 2 > size) return; - unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code - grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc)); - - if (pos + 1 > size) return; - unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points - - if (hps > 0) - { - grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps)); - } - - if (pos + 1 > size) return; - unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal ) - grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos)); - - if (pos + 2 > size) return; - unsigned short fText = oStream.ReadUInt16(); pos += 2; - - unsigned short qpsSpace = GETBITS(fText, 0, 5); - unsigned char wSpare2 = GETBITS(fText, 6, 7); - unsigned char ico = GETBITS(fText, 8, 11); - unsigned char kul = GETBITS(fText, 12, 14); - bool fSysVanish = GETBIT(fChar, 15); - - grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul)); - grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico)); - - //sizeof(CHP) == 12 == 0xC - if (pos + 4 > size) return; - unsigned int fcPic = oStream.ReadUInt16(); pos += 4; //pos = 8 - grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic)); - - if (pos + 1 > size) return; - unsigned char fnPic = oStream.ReadByte(); pos += 1; - - if (pos + 2 > size) return; - unsigned short hpsLargeChp = oStream.ReadUInt16(); pos += 2;// ??? type - } - else if (nWordVersion == 2) - { - if (pos + 2 > size) return; - unsigned short fChar = oStream.ReadUInt16(); pos += 2; - - unsigned char val; - val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val)); - val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val)); - val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCIbstRMark, 1, &val)); - val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val)); - val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val)); - val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val)); - val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val)); - val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val)); - val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val)); - val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val)); - val = GETBIT(fChar, 10); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val)); - val = GETBIT(fChar, 11); grpprl->push_back(SinglePropertyModifier(sprmOldCFObj, 1, &val)); - val = GETBIT(fChar, 12); grpprl->push_back(SinglePropertyModifier(sprmCFBoldBi, 1, &val)); - val = GETBIT(fChar, 13); grpprl->push_back(SinglePropertyModifier(sprmCFItalicBi, 1, &val)); - val = GETBIT(fChar, 14); grpprl->push_back(SinglePropertyModifier(sprmCFBiDi, 1, &val)); - val = GETBIT(fChar, 15); grpprl->push_back(SinglePropertyModifier(sprmCFDiacColor, 1, &val)); - - if (pos + 2 > size) return; - unsigned short fChar2 = oStream.ReadUInt16(); pos += 2; - bool fsIco = GETBIT(fChar2, 0); - bool fsFtc = GETBIT(fChar2, 1); - bool fsHps = GETBIT(fChar2, 2); - bool fsKul = GETBIT(fChar2, 3); - bool fsPos = GETBIT(fChar2, 4); - bool fsSpace = GETBIT(fChar2, 5); - bool fsLid = GETBIT(fChar2, 6); - bool fsIcoBi = GETBIT(fChar2, 7); - bool fsFtcBi = GETBIT(fChar2, 8); - bool fsHpsBi = GETBIT(fChar2, 9); - bool fsLidBi = GETBIT(fChar2, 10); - - if (pos + 2 > size) return; - unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code - grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc)); - - if (pos + 1 > size) return; - unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points - - if (hps > 0) - { - grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps)); - } - - if (pos + 1 > size) return; - unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal ) - grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos)); - - if (pos + 2 > size) return; - unsigned short fText = oStream.ReadUInt16(); pos += 2; - - unsigned short qpsSpace = GETBITS(fText, 0, 5); - unsigned char wSpare2 = GETBITS(fText, 6, 7); - unsigned char ico = GETBITS(fText, 8, 11); - unsigned char kul = GETBITS(fText, 12, 14); - bool fSysVanish = GETBIT(fChar, 15); - - grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul)); - grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico)); - - //if (pos + 1 > size) return; - //unsigned char icoBi = oStream.ReadUInt16(); pos += 1;//wSpare3 - - if (pos + 2 > size) return; - unsigned short lid = oStream.ReadUInt16(); pos += 2; - grpprl->push_back(SinglePropertyModifier(sprmOldCLid, 2, (BYTE*)&lid)); - - if (pos + 2 > size) return; - unsigned short ftcBi = oStream.ReadUInt16(); pos += 2; - grpprl->push_back(SinglePropertyModifier(sprmCFtcBi, 4, (BYTE*)&ftcBi)); - - //if (pos + 2 > size) return; - //unsigned short hpsBi = oStream.ReadUInt16(); pos += 2; - //grpprl->push_back(SinglePropertyModifier(sprmCHpsBi, 4, (BYTE*)&hpsBi)); - - //if (pos + 2 > size) return; - //unsigned short lidBi = oStream.ReadUInt16(); pos += 2; - //grpprl->push_back(SinglePropertyModifier(sprmCLidBi, 2, (BYTE*)&lidBi)); - - if (pos + 4 > size) return; - unsigned int fcPic = oStream.ReadUInt16(); pos += 4; //pos = 8 - grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic)); - - if (pos + 1 > size) return; - unsigned char fnPic = oStream.ReadByte(); pos += 1; - - if (pos + 2 > size) return; - unsigned short hpsLargeChp = oStream.ReadUInt16(); pos += 2;// ??? type - } - } - } + CharacterPropertyExceptions( unsigned char* bytes, int size, int nWordVersion); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/CharacterRange.cpp b/MsBinaryFile/DocFile/CharacterRange.cpp new file mode 100644 index 0000000000..a8c630e655 --- /dev/null +++ b/MsBinaryFile/DocFile/CharacterRange.cpp @@ -0,0 +1,62 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "CharacterRange.h" + +namespace DocFileFormat +{ + CharacterRange::CharacterRange(): + CharacterPosition(0), CharacterCount(0) + { + } + + CharacterRange::CharacterRange( int cp, int ccp ): + CharacterPosition(0), CharacterCount(0) + { + this->CharacterPosition = cp; + this->CharacterCount = ccp; + } + + CharacterRange::~CharacterRange() + { + } + + int CharacterRange::GetCharacterPosition() const + { + return this->CharacterPosition; + } + + int CharacterRange::GetCharacterCount() const + { + return this->CharacterCount; + } +} diff --git a/MsBinaryFile/DocFile/CharacterRange.h b/MsBinaryFile/DocFile/CharacterRange.h index 5ca533c335..804c78f87a 100644 --- a/MsBinaryFile/DocFile/CharacterRange.h +++ b/MsBinaryFile/DocFile/CharacterRange.h @@ -40,30 +40,11 @@ namespace DocFileFormat int CharacterCount; public: - CharacterRange(): - CharacterPosition(0), CharacterCount(0) - { - } + CharacterRange(); + CharacterRange( int cp, int ccp ); + ~CharacterRange(); - CharacterRange( int cp, int ccp ): - CharacterPosition(0), CharacterCount(0) - { - this->CharacterPosition = cp; - this->CharacterCount = ccp; - } - - ~CharacterRange() - { - } - - int GetCharacterPosition() const - { - return this->CharacterPosition; - } - - int GetCharacterCount() const - { - return this->CharacterCount; - } + int GetCharacterPosition() const; + int GetCharacterCount() const; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/CommentsMapping.cpp b/MsBinaryFile/DocFile/CommentsMapping.cpp new file mode 100644 index 0000000000..09b1bedea3 --- /dev/null +++ b/MsBinaryFile/DocFile/CommentsMapping.cpp @@ -0,0 +1,187 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "CommentsMapping.h" + +namespace DocFileFormat +{ + CommentsMapping::CommentsMapping (ConversionContext* ctx) : DocumentMapping( ctx, this ) + { + } + + void CommentsMapping::Apply( IVisitable* visited ) + { + m_document = static_cast( visited ); + + _UINT64 x = 0x10000001; + std::vector arrParaId; + + if ( ( m_document != NULL ) && ( m_document->FIB->m_RgLw97.ccpAtn > 0 ) ) + { + m_context->_docx->RegisterComments(); + + m_pXmlWriter->WriteNodeBegin( L"w:comments", TRUE ); + + 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:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" ); + m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" ); + m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" ); + m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" ); + m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" ); + 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:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" ); + m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" ); + 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 w15 w16se wp14"); + + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr; + + size_t count = m_document->AnnotationsReferencePlex->Elements.size(); + + for (size_t index = 0; index < count; ++index) + { + _paraId.clear(); + AnnotationReferenceDescriptor* atrdPre10 = static_cast(m_document->AnnotationsReferencePlex->Elements[index]); + + m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE ); + + m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString(atrdPre10->m_CommentId)); + + if (atrdPre10->m_AuthorIndex < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc + { + m_pXmlWriter->WriteAttribute( L"w:author", + FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->m_AuthorIndex ) )); + } + + if ((m_document->AnnotationsReferencesEx) && (index < m_document->AnnotationsReferencesEx->m_ReferencesEx.size())) + { + m_pXmlWriter->WriteAttribute( L"w:date", m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDTTM.getString()); + } + + m_pXmlWriter->WriteAttribute( L"w:initials", FormatUtils::XmlEncode(atrdPre10->m_UserInitials)); + + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + while ( ( cp - m_document->FIB->m_RgLw97.ccpText - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpHdr ) < (*m_document->IndividualCommentsPlex)[index + 1] ) + { + int fc = m_document->FindFileCharPos(cp); + if (fc < 0) break; + + ParagraphPropertyExceptions* papx = findValidPapx(fc); + TableInfo tai(papx, m_document->nWordVersion); + + if ( tai.fInTable ) + { + //this PAPX is for a table + Table table(this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) )); + table.Convert(this); + cp = table.GetCPEnd(); + } + else + { + if ((m_document->AnnotationsReferencesEx) && (index < m_document->AnnotationsReferencesEx->m_ReferencesEx.size())) + { + _paraId = XmlUtils::ToString(x++, L"%08X"); + } + cp = writeParagraph(cp, 0x7fffffff); + } + } + + if (false == _paraId.empty()) + arrParaId.push_back(_paraId); + + m_pXmlWriter->WriteNodeEnd(L"w:comment" ); + } + m_pXmlWriter->WriteNodeEnd( L"w:comments" ); + m_context->_docx->CommentsXML = std::wstring(m_pXmlWriter->GetXmlString()); + + m_pXmlWriter->Clear(); + + if (false == arrParaId.empty() && (m_document->AnnotationsReferencesEx) && (false == m_document->AnnotationsReferencesEx->m_ReferencesEx.empty())) + { + m_context->_docx->RegisterCommentsExtended(); + + m_pXmlWriter->WriteNodeBegin( L"w15:commentsEx", TRUE ); + + 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:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" ); + m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" ); + m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" ); + m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" ); + m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" ); + 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:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" ); + m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" ); + 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 w15 w16se wp14"); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + for (size_t index = 0; index < m_document->AnnotationsReferencesEx->m_ReferencesEx.size(); ++index) + { + m_pXmlWriter->WriteNodeBegin( L"w15:commentEx", TRUE ); + + m_pXmlWriter->WriteAttribute( L"w15:paraId", arrParaId[index]); + if (m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDepth > 0) + { + m_pXmlWriter->WriteAttribute( L"w15:paraIdParent", arrParaId[index + m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDiatrdParent]); + } + m_pXmlWriter->WriteAttribute( L"w15:done", L"0"); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + m_pXmlWriter->WriteNodeEnd(L"w15:commentEx" ); + } + m_pXmlWriter->WriteNodeEnd( L"w15:commentsEx" ); + m_context->_docx->CommentsExtendedXML = std::wstring(m_pXmlWriter->GetXmlString()); + } + } + } +} diff --git a/MsBinaryFile/DocFile/CommentsMapping.h b/MsBinaryFile/DocFile/CommentsMapping.h index bb4ec8084d..4206f80a64 100644 --- a/MsBinaryFile/DocFile/CommentsMapping.h +++ b/MsBinaryFile/DocFile/CommentsMapping.h @@ -40,155 +40,8 @@ namespace DocFileFormat class CommentsMapping: public DocumentMapping { public: - CommentsMapping (ConversionContext* ctx) : DocumentMapping( ctx, this ) - { - } + CommentsMapping (ConversionContext* ctx); - virtual void Apply( IVisitable* visited ) - { - m_document = static_cast( visited ); - - _UINT64 x = 0x10000001; - std::vector arrParaId; - - if ( ( m_document != NULL ) && ( m_document->FIB->m_RgLw97.ccpAtn > 0 ) ) - { - m_context->_docx->RegisterComments(); - - m_pXmlWriter->WriteNodeBegin( L"w:comments", TRUE ); - - 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:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" ); - m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" ); - m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" ); - m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" ); - m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" ); - 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:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" ); - m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" ); - 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 w15 w16se wp14"); - - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr; - - size_t count = m_document->AnnotationsReferencePlex->Elements.size(); - - for (size_t index = 0; index < count; ++index) - { - _paraId.clear(); - AnnotationReferenceDescriptor* atrdPre10 = static_cast(m_document->AnnotationsReferencePlex->Elements[index]); - - m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE ); - - m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString(atrdPre10->m_CommentId)); - - if (atrdPre10->m_AuthorIndex < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc - { - m_pXmlWriter->WriteAttribute( L"w:author", - FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->m_AuthorIndex ) )); - } - - if ((m_document->AnnotationsReferencesEx) && (index < m_document->AnnotationsReferencesEx->m_ReferencesEx.size())) - { - m_pXmlWriter->WriteAttribute( L"w:date", m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDTTM.getString()); - } - - m_pXmlWriter->WriteAttribute( L"w:initials", FormatUtils::XmlEncode(atrdPre10->m_UserInitials)); - - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - while ( ( cp - m_document->FIB->m_RgLw97.ccpText - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpHdr ) < (*m_document->IndividualCommentsPlex)[index + 1] ) - { - int fc = m_document->FindFileCharPos(cp); - if (fc < 0) break; - - ParagraphPropertyExceptions* papx = findValidPapx(fc); - TableInfo tai(papx, m_document->nWordVersion); - - if ( tai.fInTable ) - { - //this PAPX is for a table - Table table(this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) )); - table.Convert(this); - cp = table.GetCPEnd(); - } - else - { - if ((m_document->AnnotationsReferencesEx) && (index < m_document->AnnotationsReferencesEx->m_ReferencesEx.size())) - { - _paraId = XmlUtils::ToString(x++, L"%08X"); - } - cp = writeParagraph(cp, 0x7fffffff); - } - } - - if (false == _paraId.empty()) - arrParaId.push_back(_paraId); - - m_pXmlWriter->WriteNodeEnd(L"w:comment" ); - } - m_pXmlWriter->WriteNodeEnd( L"w:comments" ); - m_context->_docx->CommentsXML = std::wstring(m_pXmlWriter->GetXmlString()); - - m_pXmlWriter->Clear(); - - if (false == arrParaId.empty() && (m_document->AnnotationsReferencesEx) && (false == m_document->AnnotationsReferencesEx->m_ReferencesEx.empty())) - { - m_context->_docx->RegisterCommentsExtended(); - - m_pXmlWriter->WriteNodeBegin( L"w15:commentsEx", TRUE ); - - 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:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" ); - m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" ); - m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" ); - m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" ); - m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" ); - 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:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" ); - m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" ); - 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 w15 w16se wp14"); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - for (size_t index = 0; index < m_document->AnnotationsReferencesEx->m_ReferencesEx.size(); ++index) - { - m_pXmlWriter->WriteNodeBegin( L"w15:commentEx", TRUE ); - - m_pXmlWriter->WriteAttribute( L"w15:paraId", arrParaId[index]); - if (m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDepth > 0) - { - m_pXmlWriter->WriteAttribute( L"w15:paraIdParent", arrParaId[index + m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDiatrdParent]); - } - m_pXmlWriter->WriteAttribute( L"w15:done", L"0"); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - m_pXmlWriter->WriteNodeEnd(L"w15:commentEx" ); - } - m_pXmlWriter->WriteNodeEnd( L"w15:commentsEx" ); - m_context->_docx->CommentsExtendedXML = std::wstring(m_pXmlWriter->GetXmlString()); - } - } - } + virtual void Apply( IVisitable* visited ); }; } diff --git a/MsBinaryFile/DocFile/ConversionContext.cpp b/MsBinaryFile/DocFile/ConversionContext.cpp new file mode 100644 index 0000000000..3f733ec2e7 --- /dev/null +++ b/MsBinaryFile/DocFile/ConversionContext.cpp @@ -0,0 +1,45 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ConversionContext.h" + +namespace DocFileFormat +{ + ConversionContext::ConversionContext (WordDocument* doc, WordprocessingDocument* docx) + { + _doc = doc; + _docx = docx; + } + ConversionContext::~ConversionContext() + { + } +} diff --git a/MsBinaryFile/DocFile/ConversionContext.h b/MsBinaryFile/DocFile/ConversionContext.h index 26012bff6a..b3162ee0bc 100644 --- a/MsBinaryFile/DocFile/ConversionContext.h +++ b/MsBinaryFile/DocFile/ConversionContext.h @@ -39,15 +39,8 @@ namespace DocFileFormat class ConversionContext { public: - ConversionContext (WordDocument* doc, WordprocessingDocument* docx) - { - _doc = doc; - _docx = docx; - } - - virtual ~ConversionContext() - { - } + ConversionContext (WordDocument* doc, WordprocessingDocument* docx); + virtual ~ConversionContext(); inline void AddRsid(const std::wstring& rsid) { @@ -60,4 +53,4 @@ namespace DocFileFormat std::set AllRsids; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/DateAndTime.cpp b/MsBinaryFile/DocFile/DateAndTime.cpp new file mode 100644 index 0000000000..e79f0e9aa1 --- /dev/null +++ b/MsBinaryFile/DocFile/DateAndTime.cpp @@ -0,0 +1,96 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DateAndTime.h" + +namespace DocFileFormat +{ + DateAndTime::DateAndTime() + { + setDefaultValues(); + } + DateAndTime::DateAndTime( _UINT32 val ) + { + unsigned char* bytes = ((unsigned char*) &val); + + minutes = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 0, 6 ); + hour = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 6, 5 ); + day = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 11, 5 ); + month = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 16, 4 ); + year = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 20, 9 ) ); + weekday = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 29, 3 ); + } + DateAndTime::DateAndTime( unsigned char* bytes, int size ) + { + if ( size == 4 ) + { + minutes = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 0, 6 ); + hour = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 6, 5 ); + day = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 11, 5 ); + month = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 16, 4 ); + year = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 20, 9 ) ); + weekday = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 29, 3 ); + } + else + { + //throw new ByteParseException("Cannot parse the struct DTTM, the length of the struct doesn't match"); + } + } + DateAndTime& DateAndTime::operator=(const DateAndTime& oSrc) + { + minutes = oSrc.minutes; + hour = oSrc.hour; + day = oSrc.day; + month = oSrc.month; + year = oSrc.year; + weekday = oSrc.weekday; + + return (*this); + } + std::wstring DateAndTime::getString() + { + return std::to_wstring(year) + L"-" + (month < 9 ? L"0" : L"" ) + std::to_wstring(month) + L"-" + + (day < 9 ? L"0" : L"" ) + std::to_wstring(day) + L"T" + + (hour < 9 ? L"0" : L"" ) + std::to_wstring(hour) + L":" + + (minutes < 9 ? L"0" : L"" ) + std::to_wstring(minutes) + L":00Z"; + } + + void DateAndTime::setDefaultValues() + { + day = 0; + hour = 0; + minutes = 0; + month = 0; + weekday = 0; + year = 0; + } +} diff --git a/MsBinaryFile/DocFile/DateAndTime.h b/MsBinaryFile/DocFile/DateAndTime.h index 6f7b7be2f8..be6424ed20 100644 --- a/MsBinaryFile/DocFile/DateAndTime.h +++ b/MsBinaryFile/DocFile/DateAndTime.h @@ -53,64 +53,13 @@ namespace DocFileFormat short weekday; public: - DateAndTime() - { - setDefaultValues(); - } - DateAndTime( _UINT32 val ) - { - unsigned char* bytes = ((unsigned char*) &val); + DateAndTime(); + DateAndTime( _UINT32 val ); + DateAndTime( unsigned char* bytes, int size ); + DateAndTime& operator=(const DateAndTime& oSrc); + std::wstring getString(); - minutes = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 0, 6 ); - hour = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 6, 5 ); - day = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 11, 5 ); - month = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 16, 4 ); - year = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 20, 9 ) ); - weekday = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, 4 ), 29, 3 ); - } - DateAndTime( unsigned char* bytes, int size ) - { - if ( size == 4 ) - { - minutes = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 0, 6 ); - hour = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 6, 5 ); - day = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 11, 5 ); - month = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 16, 4 ); - year = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 20, 9 ) ); - weekday = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 29, 3 ); - } - else - { - //throw new ByteParseException("Cannot parse the struct DTTM, the length of the struct doesn't match"); - } - } - DateAndTime& operator=(const DateAndTime& oSrc) - { - minutes = oSrc.minutes; - hour = oSrc.hour; - day = oSrc.day; - month = oSrc.month; - year = oSrc.year; - weekday = oSrc.weekday; - - return (*this); - } - std::wstring getString() - { - return std::to_wstring(year) + L"-" + (month < 9 ? L"0" : L"" ) + std::to_wstring(month) + L"-" + - (day < 9 ? L"0" : L"" ) + std::to_wstring(day) + L"T" + - (hour < 9 ? L"0" : L"" ) + std::to_wstring(hour) + L":" + - (minutes < 9 ? L"0" : L"" ) + std::to_wstring(minutes) + L":00Z"; - } private: - void setDefaultValues() - { - day = 0; - hour = 0; - minutes = 0; - month = 0; - weekday = 0; - year = 0; - } + void setDefaultValues(); }; } diff --git a/MsBinaryFile/DocFile/DocumentTypographyInfo.cpp b/MsBinaryFile/DocFile/DocumentTypographyInfo.cpp new file mode 100644 index 0000000000..855c10deb3 --- /dev/null +++ b/MsBinaryFile/DocFile/DocumentTypographyInfo.cpp @@ -0,0 +1,79 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DocumentTypographyInfo.h" + +namespace DocFileFormat +{ + DocumentTypographyInfo::~DocumentTypographyInfo() + { + } + + DocumentTypographyInfo::DocumentTypographyInfo(): + fKerningPunct(false), iJustification(0), iLevelOfKinsoku(0), f2on1(false), fOldDefineLineBaseOnGrid(false), + iCustomKsu(0), fJapaneseUseLevel2(false), cchFollowingPunct(0), cchLeadingPunct(0) + { + } + + /// Parses the bytes to retrieve a DocumentTypographyInfo + DocumentTypographyInfo::DocumentTypographyInfo( unsigned char* bytes, int size ): + fKerningPunct(false), iJustification(0), iLevelOfKinsoku(0), f2on1(false), fOldDefineLineBaseOnGrid(false), + iCustomKsu(0), fJapaneseUseLevel2(false), cchFollowingPunct(0), cchLeadingPunct(0) + { + if ( size == 310 ) + { + //split unsigned char 0 and 1 into bits + this->fKerningPunct = FormatUtils::GetBitFromBytes( bytes, size, 0 ); + this->iJustification = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 1, 2 ); + this->iLevelOfKinsoku = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 3, 2 ); + this->f2on1 = FormatUtils::GetBitFromBytes( bytes, size, 5 ); + this->fOldDefineLineBaseOnGrid = FormatUtils::GetBitFromBytes( bytes, size, 6 ); + this->iCustomKsu = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 7, 3 ); + this->fJapaneseUseLevel2 = FormatUtils::GetBitFromBytes( bytes, size, 10 ); + + this->cchFollowingPunct = FormatUtils::BytesToInt16( bytes, 2, size ); + this->cchLeadingPunct = FormatUtils::BytesToInt16( bytes, 4, size ); + + unsigned char fpunctBytes[202]; + memcpy( fpunctBytes, ( bytes + 6 ), 202 ); + FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UTF16 ); + + unsigned char lpunctBytes[102]; + memcpy( lpunctBytes, ( bytes + 208 ), 102 ); + FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UTF16 ); + } + else + { + //throw new ByteParseException("Cannot parse the struct DOPTYPOGRAPHY, the length of the struct doesn't match"); + } + } +} diff --git a/MsBinaryFile/DocFile/DocumentTypographyInfo.h b/MsBinaryFile/DocFile/DocumentTypographyInfo.h index 51e3c2e545..9a1d6fcb2e 100644 --- a/MsBinaryFile/DocFile/DocumentTypographyInfo.h +++ b/MsBinaryFile/DocFile/DocumentTypographyInfo.h @@ -70,47 +70,10 @@ namespace DocFileFormat std::wstring rgxchLPunct; public: - virtual ~DocumentTypographyInfo() - { - } - - DocumentTypographyInfo(): - fKerningPunct(false), iJustification(0), iLevelOfKinsoku(0), f2on1(false), fOldDefineLineBaseOnGrid(false), - iCustomKsu(0), fJapaneseUseLevel2(false), cchFollowingPunct(0), cchLeadingPunct(0) - { - } + virtual ~DocumentTypographyInfo(); + DocumentTypographyInfo(); /// Parses the bytes to retrieve a DocumentTypographyInfo - DocumentTypographyInfo( unsigned char* bytes, int size ): - fKerningPunct(false), iJustification(0), iLevelOfKinsoku(0), f2on1(false), fOldDefineLineBaseOnGrid(false), - iCustomKsu(0), fJapaneseUseLevel2(false), cchFollowingPunct(0), cchLeadingPunct(0) - { - if ( size == 310 ) - { - //split unsigned char 0 and 1 into bits - this->fKerningPunct = FormatUtils::GetBitFromBytes( bytes, size, 0 ); - this->iJustification = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 1, 2 ); - this->iLevelOfKinsoku = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 3, 2 ); - this->f2on1 = FormatUtils::GetBitFromBytes( bytes, size, 5 ); - this->fOldDefineLineBaseOnGrid = FormatUtils::GetBitFromBytes( bytes, size, 6 ); - this->iCustomKsu = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 7, 3 ); - this->fJapaneseUseLevel2 = FormatUtils::GetBitFromBytes( bytes, size, 10 ); - - this->cchFollowingPunct = FormatUtils::BytesToInt16( bytes, 2, size ); - this->cchLeadingPunct = FormatUtils::BytesToInt16( bytes, 4, size ); - - unsigned char fpunctBytes[202]; - memcpy( fpunctBytes, ( bytes + 6 ), 202 ); - FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UTF16 ); - - unsigned char lpunctBytes[102]; - memcpy( lpunctBytes, ( bytes + 208 ), 102 ); - FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UTF16 ); - } - else - { - //throw new ByteParseException("Cannot parse the struct DOPTYPOGRAPHY, the length of the struct doesn't match"); - } - } + DocumentTypographyInfo( unsigned char* bytes, int size ); }; } diff --git a/MsBinaryFile/DocFile/DrawingObjectGrid.cpp b/MsBinaryFile/DocFile/DrawingObjectGrid.cpp new file mode 100644 index 0000000000..4a8aeaa557 --- /dev/null +++ b/MsBinaryFile/DocFile/DrawingObjectGrid.cpp @@ -0,0 +1,71 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DrawingObjectGrid.h" +#include "../Common/Base/FormatUtils.h" + +namespace DocFileFormat +{ + DrawingObjectGrid::~DrawingObjectGrid() + { + } + + DrawingObjectGrid::DrawingObjectGrid(): + xaGrid(0), yaGrid(0), dxaGrid(0), dyaGrid(0), dyGridDisplay(0), fTurnItOff(false), dxGridDisplay(0), + fFollowMargins(false) + { + } + + /// Parses the bytes to retrieve a DrawingObjectGrid + DrawingObjectGrid::DrawingObjectGrid( unsigned char* bytes, int size ): + xaGrid(0), yaGrid(0), dxaGrid(0), dyaGrid(0), dyGridDisplay(0), fTurnItOff(false), dxGridDisplay(0), + fFollowMargins(false) + { + if ( size == 10 ) + { + this->xaGrid = FormatUtils::BytesToInt16( bytes, 0, size ); + this->yaGrid = FormatUtils::BytesToInt16( bytes, 2, size ); + this->dxaGrid = FormatUtils::BytesToInt16( bytes, 4, size ); + this->dyaGrid = FormatUtils::BytesToInt16( bytes, 6, size ); + + //split unsigned char 8 and 9 into bits + this->dyGridDisplay = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 8 ), 2, 0, 7 ); + this->fTurnItOff = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 7 ); + this->dxGridDisplay = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 8 ), 2, 8, 7 ); + this->fFollowMargins = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 15 ); + } + else + { + //throw new ByteParseException("Cannot parse the struct DOGRID, the length of the struct doesn't match"); + } + } +} diff --git a/MsBinaryFile/DocFile/DrawingObjectGrid.h b/MsBinaryFile/DocFile/DrawingObjectGrid.h index 1a137bc424..b884a2564c 100644 --- a/MsBinaryFile/DocFile/DrawingObjectGrid.h +++ b/MsBinaryFile/DocFile/DrawingObjectGrid.h @@ -61,38 +61,10 @@ namespace DocFileFormat bool fFollowMargins; public: - virtual ~DrawingObjectGrid() - { - } - - DrawingObjectGrid(): - xaGrid(0), yaGrid(0), dxaGrid(0), dyaGrid(0), dyGridDisplay(0), fTurnItOff(false), dxGridDisplay(0), - fFollowMargins(false) - { - } + virtual ~DrawingObjectGrid(); + DrawingObjectGrid(); /// Parses the bytes to retrieve a DrawingObjectGrid - DrawingObjectGrid( unsigned char* bytes, int size ): - xaGrid(0), yaGrid(0), dxaGrid(0), dyaGrid(0), dyGridDisplay(0), fTurnItOff(false), dxGridDisplay(0), - fFollowMargins(false) - { - if ( size == 10 ) - { - this->xaGrid = FormatUtils::BytesToInt16( bytes, 0, size ); - this->yaGrid = FormatUtils::BytesToInt16( bytes, 2, size ); - this->dxaGrid = FormatUtils::BytesToInt16( bytes, 4, size ); - this->dyaGrid = FormatUtils::BytesToInt16( bytes, 6, size ); - - //split unsigned char 8 and 9 into bits - this->dyGridDisplay = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 8 ), 2, 0, 7 ); - this->fTurnItOff = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 7 ); - this->dxGridDisplay = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 8 ), 2, 8, 7 ); - this->fFollowMargins = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 15 ); - } - else - { - //throw new ByteParseException("Cannot parse the struct DOGRID, the length of the struct doesn't match"); - } - } + DrawingObjectGrid( unsigned char* bytes, int size ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/EmuValue.cpp b/MsBinaryFile/DocFile/EmuValue.cpp new file mode 100644 index 0000000000..db7f068970 --- /dev/null +++ b/MsBinaryFile/DocFile/EmuValue.cpp @@ -0,0 +1,48 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "EmuValue.h" + +namespace DocFileFormat +{ + // Creates a new EmuValue for the given value. + EmuValue::EmuValue (int value) + { + m_Value = value; + } + + // Converts the EMU to pt + double EmuValue::ToPoints() const + { + return (double) m_Value / 12700.0; + } +} diff --git a/MsBinaryFile/DocFile/EmuValue.h b/MsBinaryFile/DocFile/EmuValue.h index db2e616f9a..4ed3d2ca36 100644 --- a/MsBinaryFile/DocFile/EmuValue.h +++ b/MsBinaryFile/DocFile/EmuValue.h @@ -37,16 +37,10 @@ namespace DocFileFormat { public: // Creates a new EmuValue for the given value. - EmuValue (int value = 0) - { - m_Value = value; - } + EmuValue (int value = 0); // Converts the EMU to pt - double ToPoints() const - { - return (double) m_Value / 12700.0; - } + double ToPoints() const; // Converts the EMU to twips inline double ToTwips () const @@ -70,7 +64,6 @@ namespace DocFileFormat } private: - int m_Value; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/EndnoteDescriptor.cpp b/MsBinaryFile/DocFile/EndnoteDescriptor.cpp new file mode 100644 index 0000000000..1c8a463ff1 --- /dev/null +++ b/MsBinaryFile/DocFile/EndnoteDescriptor.cpp @@ -0,0 +1,50 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "EndnoteDescriptor.h" + +namespace DocFileFormat +{ + EndnoteDescriptor::EndnoteDescriptor(): aEndIdx(0), bUsed(false) {} + + EndnoteDescriptor::~EndnoteDescriptor() + { + } + ByteStructure* EndnoteDescriptor::ConstructObject( VirtualStreamReader* reader, int length ) + { + EndnoteDescriptor *newObject = new EndnoteDescriptor(); + + newObject->aEndIdx = reader->ReadInt16(); + + return static_cast( newObject ); + } +} diff --git a/MsBinaryFile/DocFile/EndnoteDescriptor.h b/MsBinaryFile/DocFile/EndnoteDescriptor.h index 3a2c14ee31..736a0150b7 100644 --- a/MsBinaryFile/DocFile/EndnoteDescriptor.h +++ b/MsBinaryFile/DocFile/EndnoteDescriptor.h @@ -40,19 +40,11 @@ namespace DocFileFormat public: static const int STRUCTURE_SIZE = 2; - EndnoteDescriptor(): aEndIdx(0), bUsed(false) {} + EndnoteDescriptor(); - virtual ~EndnoteDescriptor() - { - } - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - EndnoteDescriptor *newObject = new EndnoteDescriptor(); + virtual ~EndnoteDescriptor(); - newObject->aEndIdx = reader->ReadInt16(); - - return static_cast( newObject ); - } + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); bool bUsed; short aEndIdx; diff --git a/MsBinaryFile/DocFile/EndnotesMapping.cpp b/MsBinaryFile/DocFile/EndnotesMapping.cpp new file mode 100644 index 0000000000..debb9c41bc --- /dev/null +++ b/MsBinaryFile/DocFile/EndnotesMapping.cpp @@ -0,0 +1,101 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "EndnotesMapping.h" +#include "TableMapping.h" + +namespace DocFileFormat +{ + EndnotesMapping::EndnotesMapping (ConversionContext* ctx) : DocumentMapping(ctx, this) + { + } + + void EndnotesMapping::Apply( IVisitable* visited ) + { + m_document = static_cast( visited ); + + if ( ( m_document != NULL ) && ( m_document->FIB->m_RgLw97.ccpEdn > 0 ) ) + { + m_context->_docx->RegisterEndnotes(); + + int id = 0; + + m_pXmlWriter->WriteNodeBegin( L"w:endnotes", TRUE ); + + //write namespaces + 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->WriteNodeEnd( L"", TRUE, FALSE ); + + int 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 ); + + 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( L"w:endnote", TRUE ); + m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( id )); + m_pXmlWriter->WriteNodeEnd( L"", 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] ) + { + int fc = m_document->FindFileCharPos(cp); + if (fc < 0) break; + + ParagraphPropertyExceptions* papx = findValidPapx( fc ); + TableInfo tai( papx, m_document->nWordVersion ); + + if ( tai.fInTable ) + { + //this PAPX is for a table + Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) ); + table.Convert( this ); + cp = table.GetCPEnd(); + } + else + { + //this PAPX is for a normal paragraph + cp = writeParagraph( cp, 0x7fffffff ); + } + } + + m_pXmlWriter->WriteNodeEnd( L"w:endnote"); + id++; + } + + m_pXmlWriter->WriteNodeEnd( L"w:endnotes"); + + m_context->_docx->EndnotesXML = std::wstring( m_pXmlWriter->GetXmlString() ); + } + } +} diff --git a/MsBinaryFile/DocFile/EndnotesMapping.h b/MsBinaryFile/DocFile/EndnotesMapping.h index 75a5392c90..40c6485fd1 100644 --- a/MsBinaryFile/DocFile/EndnotesMapping.h +++ b/MsBinaryFile/DocFile/EndnotesMapping.h @@ -40,68 +40,8 @@ namespace DocFileFormat class EndnotesMapping: public DocumentMapping { public: - EndnotesMapping (ConversionContext* ctx) : DocumentMapping(ctx, this) - { - } + EndnotesMapping (ConversionContext* ctx); - virtual void Apply( IVisitable* visited ) - { - m_document = static_cast( visited ); - - if ( ( m_document != NULL ) && ( m_document->FIB->m_RgLw97.ccpEdn > 0 ) ) - { - m_context->_docx->RegisterEndnotes(); - - int id = 0; - - m_pXmlWriter->WriteNodeBegin( L"w:endnotes", TRUE ); - - //write namespaces - 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->WriteNodeEnd( L"", TRUE, FALSE ); - - int 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 ); - - 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( L"w:endnote", TRUE ); - m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( id )); - m_pXmlWriter->WriteNodeEnd( L"", 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] ) - { - int fc = m_document->FindFileCharPos(cp); - if (fc < 0) break; - - ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx, m_document->nWordVersion ); - - if ( tai.fInTable ) - { - //this PAPX is for a table - Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) ); - table.Convert( this ); - cp = table.GetCPEnd(); - } - else - { - //this PAPX is for a normal paragraph - cp = writeParagraph( cp, 0x7fffffff ); - } - } - - m_pXmlWriter->WriteNodeEnd( L"w:endnote"); - id++; - } - - m_pXmlWriter->WriteNodeEnd( L"w:endnotes"); - - m_context->_docx->EndnotesXML = std::wstring( m_pXmlWriter->GetXmlString() ); - } - } + virtual void Apply( IVisitable* visited ); }; } diff --git a/MsBinaryFile/DocFile/FieldCharacter.cpp b/MsBinaryFile/DocFile/FieldCharacter.cpp new file mode 100644 index 0000000000..3a2188c995 --- /dev/null +++ b/MsBinaryFile/DocFile/FieldCharacter.cpp @@ -0,0 +1,65 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FieldCharacter.h" + +namespace DocFileFormat +{ + FieldCharacter::FieldCharacter() : fldch(0), grffld(0) {} + FieldCharacter::~FieldCharacter() {} + + ByteStructure*FieldCharacter:: ConstructObject (VirtualStreamReader* pReader, int length) + { + FieldCharacter* pFldChar = new FieldCharacter(); + if (pFldChar) + { + pFldChar->fldch = pReader->ReadByte(); + pFldChar->grffld = pReader->ReadByte(); + } + + return static_cast(pFldChar); + } + + ListNumCache::ListNumCache() : value(-1) {} + ListNumCache::~ListNumCache() {} + + ByteStructure* ListNumCache::ConstructObject (VirtualStreamReader* pReader, int length) + { + ListNumCache* pList = new ListNumCache(); + if (pList) + { + pList->value = pReader->ReadInt32(); + } + + return static_cast(pList); + } +} diff --git a/MsBinaryFile/DocFile/FieldCharacter.h b/MsBinaryFile/DocFile/FieldCharacter.h index d31469b14a..a0d30959b6 100644 --- a/MsBinaryFile/DocFile/FieldCharacter.h +++ b/MsBinaryFile/DocFile/FieldCharacter.h @@ -51,20 +51,10 @@ namespace DocFileFormat }; static const int STRUCTURE_SIZE = 2; - FieldCharacter() : fldch(0), grffld(0) {} - virtual ~FieldCharacter() {} + FieldCharacter(); + virtual ~FieldCharacter(); - virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length) - { - FieldCharacter* pFldChar = new FieldCharacter(); - if (pFldChar) - { - pFldChar->fldch = pReader->ReadByte(); - pFldChar->grffld = pReader->ReadByte(); - } - - return static_cast(pFldChar); - } + virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length); unsigned char fldch; unsigned char grffld; @@ -75,20 +65,11 @@ namespace DocFileFormat public: static const int STRUCTURE_SIZE = 4; - ListNumCache() : value(-1) {} - virtual ~ListNumCache() {} + ListNumCache(); + virtual ~ListNumCache(); - virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length) - { - ListNumCache* pList = new ListNumCache(); - if (pList) - { - pList->value = pReader->ReadInt32(); - } - - return static_cast(pList); - } + virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length); int value; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/FileInformationBlock.cpp b/MsBinaryFile/DocFile/FileInformationBlock.cpp new file mode 100644 index 0000000000..7c3ef10dd6 --- /dev/null +++ b/MsBinaryFile/DocFile/FileInformationBlock.cpp @@ -0,0 +1,936 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FileInformationBlock.h" + +namespace DocFileFormat +{ + void FileInformationBlock::reset( VirtualStreamReader reader ) + { + if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995) + { + /*fcSpare0 = */reader.ReadInt32(); + /*fcSpare1 = */reader.ReadInt32(); + /*fcSpare2 = */reader.ReadInt32(); + /*fcSpare3 = */reader.ReadInt32(); //48 + m_RgLw97.ccpText = reader.ReadInt32(); + m_RgLw97.ccpFtn = reader.ReadInt32(); + m_RgLw97.ccpHdr = reader.ReadInt32(); + + /*m_FibWord97.ccpMcr = */reader.ReadInt32(); + m_RgLw97.ccpAtn = reader.ReadInt32(); + + if (m_FibBase.nFib > Fib1985) + { + m_RgLw97.ccpEdn = reader.ReadInt32(); + m_RgLw97.ccpTxbx = reader.ReadInt32(); + m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); + } + else + { + int ccpSpare0 = reader.ReadInt32(); + int ccpSpare1 = reader.ReadInt32(); + int ccpSpare2 = reader.ReadInt32(); + } + int ccpSpare3 = reader.ReadInt32(); + + if (m_FibBase.nFib > Fib1985) + { + m_FibWord97.fcStshfOrig = reader.ReadInt32(); + m_FibWord97.lcbStshfOrig = reader.ReadInt32(); + m_FibWord97.fcStshf = reader.ReadInt32(); //88 + m_FibWord97.lcbStshf = reader.ReadInt32(); + m_FibWord97.fcPlcffndRef = reader.ReadInt32(); + m_FibWord97.lcbPlcffndRef = reader.ReadInt32(); + + m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//112 + m_FibWord97.lcbPlcffndTxt = reader.ReadInt32(); + + m_FibWord97.fcPlcfandRef = reader.ReadInt32(); + m_FibWord97.lcbPlcfandRef = reader.ReadInt32(); + + m_FibWord97.fcPlcfandTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfandTxt = reader.ReadInt32(); + + m_FibWord97.fcPlcfSed = reader.ReadInt32(); //136 + m_FibWord97.lcbPlcfSed = reader.ReadInt32(); + + m_FibWord97.fcPlcPad = reader.ReadInt32(); + m_FibWord97.lcbPlcPad = reader.ReadInt32(); + + m_FibWord97.fcPlcfPhe = reader.ReadInt32(); + m_FibWord97.lcbPlcfPhe = reader.ReadInt32(); + + m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); + m_FibWord97.lcbSttbfGlsy = reader.ReadInt32(); + + m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); + m_FibWord97.lcbPlcfGlsy = reader.ReadInt32(); + m_FibWord97.fcPlcfHdd = reader.ReadInt32(); + m_FibWord97.lcbPlcfHdd = reader.ReadInt32(); + + m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBteChpx = reader.ReadInt32(); + + m_FibWord97.fcPlcfBtePapx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBtePapx = reader.ReadInt32(); + + m_FibWord97.fcPlcfSea = reader.ReadInt32(); + m_FibWord97.lcbPlcfSea = reader.ReadInt32(); + + m_FibWord97.fcSttbfFfn = reader.ReadInt32(); + m_FibWord97.lcbSttbfFfn = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); //216 + m_FibWord97.lcbPlcfFldMom = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldHdr = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldFtn = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldAtn = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldMcr = reader.ReadInt32(); + + m_FibWord97.fcSttbfBkmk = reader.ReadInt32(); + m_FibWord97.lcbSttbfBkmk = reader.ReadInt32(); + + m_FibWord97.fcPlcfBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkf = reader.ReadInt32(); + + m_FibWord97.fcPlcfBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkl = reader.ReadInt32(); + + m_FibWord97.fcCmds = reader.ReadInt32(); + m_FibWord97.lcbCmds = reader.ReadInt32(); + + /*m_FibWord97.fcPlcMcr = */reader.ReadInt32(); + /*m_FibWord97.lcbPlcMcr = */reader.ReadInt32(); + + m_FibWord97.fcSttbfMcr = reader.ReadInt32(); + m_FibWord97.lcbSttbfMcr = reader.ReadInt32(); + + m_FibWord97.fcPrDrvr = reader.ReadInt32(); + m_FibWord97.lcbPrDrvr = reader.ReadInt32(); + + m_FibWord97.fcPrEnvPort = reader.ReadInt32(); + m_FibWord97.lcbPrEnvPort = reader.ReadInt32(); //316 + + m_FibWord97.fcPrEnvLand = reader.ReadInt32(); + m_FibWord97.lcbPrEnvLand = reader.ReadInt32(); + + m_FibWord97.fcWss = reader.ReadInt32(); + m_FibWord97.lcbWss = reader.ReadInt32(); + + m_FibWord97.fcDop = reader.ReadInt32(); + m_FibWord97.lcbDop = reader.ReadInt32(); + + m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); + m_FibWord97.lcbSttbfAssoc = reader.ReadInt32(); + + m_FibWord97.fcClx = reader.ReadInt32(); + m_FibWord97.lcbClx = reader.ReadInt32(); + + m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt32(); + + m_FibWord97.fcAutosaveSource = reader.ReadInt32(); + m_FibWord97.lcbAutosaveSource = reader.ReadInt32(); + m_FibWord97.fcGrpXstAtnOwners = reader.ReadInt32(); + m_FibWord97.lcbGrpXstAtnOwners = reader.ReadInt32(); + + m_FibWord97.fcSttbfAtnBkmk = reader.ReadInt32(); + m_FibWord97.lcbSttbfAtnBkmk = reader.ReadInt32(); + + m_FibWord2.wSpare4 = reader.ReadInt16(); //392 + m_FibWord2.pnChpFirst = reader.ReadInt16(); + m_FibWord2.pnPapFirst = reader.ReadInt16(); + + m_FibWord2.cpnBteChp = reader.ReadInt16(); + m_FibWord2.cpnBtePap = reader.ReadInt16(); + + m_FibWord97.fcPlcSpaMom = reader.ReadInt32(); + m_FibWord97.lcbPlcSpaMom = reader.ReadInt32(); + + m_FibWord97.fcPlcSpaHdr = reader.ReadInt32(); /*fcPlcfdoaHdr*/ + m_FibWord97.lcbPlcSpaHdr = reader.ReadInt32(); /*lcbPlcfdoaHdr*/ + + /*m_FibWord97.fcUnused1 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused1 =*/ reader.ReadInt32(); + /*m_FibWord97.fcUnused2 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused2 =*/ reader.ReadInt32(); + + m_FibWord97.fcPlcfAtnBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfAtnBkf = reader.ReadInt32(); + m_FibWord97.fcPlcfAtnBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfAtnBkl = reader.ReadInt32(); + m_FibWord97.fcPms = reader.ReadInt32(); + m_FibWord97.lcbPms = reader.ReadInt32(); + m_FibWord97.fcFormFldSttbs/*f*/ = reader.ReadInt32(); + m_FibWord97.lcbFormFldSttbs/*f*/= reader.ReadInt32(); + + m_FibWord97.fcPlcfendRef = reader.ReadInt32(); //466 + m_FibWord97.lcbPlcfendRef = reader.ReadInt32(); + m_FibWord97.fcPlcfendTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfendTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfFldEdn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldEdn = reader.ReadInt32(); + /*m_FibWord97.fcPlcfpgdEdn =*/ reader.ReadInt32(); + /*m_FibWord97.lcbPlcfpgdEdn =*/ reader.ReadInt32(); + /*m_FibWord97.fcUnused3 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused3 =*/ reader.ReadInt32(); + m_FibWord97.fcSttbfRMark = reader.ReadInt32(); + m_FibWord97.lcbSttbfRMark = reader.ReadInt32(); + m_FibWord97.fcSttbfCaption = reader.ReadInt32(); + m_FibWord97.lcbSttbfCaption = reader.ReadInt32(); + m_FibWord97.fcSttbfAutoCaption = reader.ReadInt32(); + m_FibWord97.lcbSttbfAutoCaption = reader.ReadInt32(); + m_FibWord97.fcPlcfWkb = reader.ReadInt32(); //530 + m_FibWord97.lcbPlcfWkb = reader.ReadInt32(); + /*m_FibWord97.fcUnused4 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused4 =*/ reader.ReadInt32(); + m_FibWord97.fcPlcftxbxTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcftxbxTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfFldTxbx = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldTxbx = reader.ReadInt32(); + m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadInt32(); + m_FibWord97.fcPlcffldHdrTxbx = reader.ReadInt32(); + m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadInt32(); + m_FibWord97.fcStwUser = reader.ReadInt32(); + m_FibWord97.lcbStwUser = reader.ReadInt32(); + m_FibWord97.fcSttbTtmbd = reader.ReadInt32(); + m_FibWord97.lcbSttbTtmbd = reader.ReadInt32(); + /*m_FibWord97.fcPlcunused = */reader.ReadInt32(); + /*m_FibWord97.lcbUnused = */reader.ReadInt32(); + + m_FibWord97.fcPgdMotherOldOld = reader.ReadInt32(); /*fcpgdMother.fcPgd*/ //602 + m_FibWord97.lcbPgdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbPgd*/ + m_FibWord97.fcBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.fcBkd*/ + m_FibWord97.lcbBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbBkd*/ // ???? size 2 ???? + + m_FibWord97.fcPgdFtnOldOld = reader.ReadInt32(); /*fcPgdFtn.fcPgd*/ + m_FibWord97.lcbPgdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ + m_FibWord97.fcBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ + m_FibWord97.lcbBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + + m_FibWord97.fcPgdEdnOldOld = reader.ReadInt32(); /*fcpgdFtn.fcPgd*/ + m_FibWord97.lcbPgdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ + m_FibWord97.fcBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ + m_FibWord97.lcbBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + + m_FibWord97.fcSttbfIntlFld = reader.ReadInt32(); + m_FibWord97.lcbSttbfIntlFld = reader.ReadInt32(); + m_FibWord97.fcRouteSlip = reader.ReadInt32(); //656 + m_FibWord97.lcbRouteSlip = reader.ReadInt32(); + m_FibWord97.fcSttbSavedBy = reader.ReadInt32(); + m_FibWord97.lcbSttbSavedBy = reader.ReadInt32(); + m_FibWord97.fcSttbFnm = reader.ReadInt32(); + m_FibWord97.lcbSttbFnm = reader.ReadInt32(); //676 + } + else + { + m_FibWord97.fcStshfOrig = reader.ReadInt32();// 0x58 + m_FibWord97.lcbStshfOrig = reader.ReadInt16(); + m_FibWord97.fcStshf = reader.ReadInt32(); + m_FibWord97.lcbStshf = reader.ReadInt16();//0x62 + + m_FibWord97.fcPlcffndRef = reader.ReadInt32(); + m_FibWord97.lcbPlcffndRef = reader.ReadInt16();//0x68 + + m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//0x6a + m_FibWord97.lcbPlcffndTxt = reader.ReadInt16(); + + m_FibWord97.fcPlcfandRef = reader.ReadInt32();//0x70 + m_FibWord97.lcbPlcfandRef = reader.ReadInt16(); + + m_FibWord97.fcPlcfandTxt = reader.ReadInt32();//0x76 + m_FibWord97.lcbPlcfandTxt = reader.ReadInt16(); + + m_FibWord97.fcPlcfSed = reader.ReadInt32(); //0x7c + m_FibWord97.lcbPlcfSed = reader.ReadInt16(); + + m_FibWord97.fcPlcPad = reader.ReadInt32(); + m_FibWord97.lcbPlcPad = reader.ReadInt16(); + + m_FibWord97.fcPlcfPhe = reader.ReadInt32();// 0x88 + m_FibWord97.lcbPlcfPhe = reader.ReadInt16(); + + m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); + m_FibWord97.lcbSttbfGlsy = reader.ReadInt16(); + + m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); + m_FibWord97.lcbPlcfGlsy = reader.ReadInt16(); + + m_FibWord97.fcPlcfHdd = reader.ReadInt32();// 0x9a + m_FibWord97.lcbPlcfHdd = reader.ReadInt16(); + + m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBteChpx = reader.ReadInt16(); + + m_FibWord97.fcPlcfBtePapx = reader.ReadInt32();// 0xa0 + m_FibWord97.lcbPlcfBtePapx = reader.ReadInt16(); + + m_FibWord97.fcPlcfSea = reader.ReadInt32();// 0xac + m_FibWord97.lcbPlcfSea = reader.ReadInt16(); + + m_FibWord97.fcSttbfFfn = reader.ReadInt32();// 0xb2 + m_FibWord97.lcbSttbfFfn = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); // 0xb8=184 + m_FibWord97.lcbPlcfFldMom = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldHdr = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldFtn = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldAtn = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldMcr = reader.ReadInt16(); + + m_FibWord97.fcSttbfBkmk = reader.ReadInt32();// 0xd6 + m_FibWord97.lcbSttbfBkmk = reader.ReadInt16(); + + m_FibWord97.fcPlcfBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkf = reader.ReadInt16(); + + m_FibWord97.fcPlcfBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkl = reader.ReadInt16(); + + m_FibWord97.fcCmds = reader.ReadInt32();// 0xe8 + m_FibWord97.lcbCmds = reader.ReadInt16(); + + m_FibWord2.fcPlcMcr = reader.ReadInt32();// 0xee + m_FibWord2.lcbPlcMcr = reader.ReadInt16(); + + m_FibWord97.fcSttbfMcr = reader.ReadInt32();// 0xf4 + m_FibWord97.lcbSttbfMcr = reader.ReadInt16(); + + m_FibWord97.fcPrDrvr = reader.ReadInt32();// + m_FibWord97.lcbPrDrvr = reader.ReadInt16(); + + m_FibWord97.fcPrEnvPort = reader.ReadInt32();// + m_FibWord97.lcbPrEnvPort = reader.ReadInt16(); + + m_FibWord97.fcPrEnvLand = reader.ReadInt32();// + m_FibWord97.lcbPrEnvLand = reader.ReadInt16(); + + m_FibWord97.fcWss = reader.ReadInt32();// 268 + m_FibWord97.lcbWss = reader.ReadInt16(); + + m_FibWord97.fcDop = reader.ReadInt32(); + m_FibWord97.lcbDop = reader.ReadInt16(); + + m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); + m_FibWord97.lcbSttbfAssoc = reader.ReadInt16();; + + m_FibWord97.fcClx = reader.ReadInt32(); + m_FibWord97.lcbClx = reader.ReadInt16(); + + m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); //292 + m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt16(); + + m_FibWord97.fcAutosaveSource = reader.ReadInt32(); + m_FibWord97.lcbAutosaveSource = reader.ReadInt16(); + + m_FibWord2.fcSpare5 = reader.ReadInt32(); + m_FibWord2.lcbSpare5 = reader.ReadInt16(); + m_FibWord2.fcSpare6 = reader.ReadInt32(); + m_FibWord2.lcbSpare6 = reader.ReadInt16(); + m_FibWord2.wSpare4 = reader.ReadInt16(); + + m_FibWord2.pnChpFirst = reader.ReadInt16(); + m_FibWord2.pnPapFirst = reader.ReadInt16(); + m_FibWord2.cpnBteChp = reader.ReadInt16(); + m_FibWord2.cpnBtePap = reader.ReadInt16(); + } + } + if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0) + { + int reserv1 = reader.ReadInt32(); + int reserv2 = reader.ReadInt32(); + + m_RgLw97.ccpText = reader.ReadInt32(); //76 + m_RgLw97.ccpFtn = reader.ReadInt32(); //80 + m_RgLw97.ccpHdr = reader.ReadInt32(); //84 + + int reserv3 = reader.ReadInt32(); + + m_RgLw97.ccpAtn = reader.ReadInt32(); //92 + m_RgLw97.ccpEdn = reader.ReadInt32(); //96 + m_RgLw97.ccpTxbx = reader.ReadInt32(); //100 + m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); //104 + + int reserv4 = reader.ReadInt32(); + int reserv5 = reader.ReadInt32(); + int reserv6 = reader.ReadInt32(); + int reserv7 = reader.ReadInt32(); + int reserv8 = reader.ReadInt32(); + int reserv9 = reader.ReadInt32(); + int reserv10 = reader.ReadInt32(); + int reserv11 = reader.ReadInt32(); + int reserv12 = reader.ReadInt32(); + int reserv13 = reader.ReadInt32(); + int reserv14 = reader.ReadInt32(); + + cbRgFcLcb = reader.ReadUInt16(); //152 + + switch(cbRgFcLcb) + { + case 0x005D: m_FibBase.nFib = Fib1997; break; + case 0x006C: m_FibBase.nFib = Fib2000; break; + case 0x0088: m_FibBase.nFib = Fib2002; break; + case 0x00A4: m_FibBase.nFib = Fib2003; break; + case 0x00B7: m_FibBase.nFib = Fib2007; break; + } + + m_FibWord97.fcStshfOrig = reader.ReadUInt32(); //154 + m_FibWord97.lcbStshfOrig = reader.ReadUInt32(); //158 + m_FibWord97.fcStshf = reader.ReadUInt32(); //162 + m_FibWord97.lcbStshf = reader.ReadUInt32(); //166 + m_FibWord97.fcPlcffndRef = reader.ReadUInt32(); //170 + m_FibWord97.lcbPlcffndRef = reader.ReadUInt32(); //174 + m_FibWord97.fcPlcffndTxt = reader.ReadUInt32(); //178 + m_FibWord97.lcbPlcffndTxt = reader.ReadUInt32(); //182 + m_FibWord97.fcPlcfandRef = reader.ReadUInt32(); //186 + m_FibWord97.lcbPlcfandRef = reader.ReadUInt32(); //190 + m_FibWord97.fcPlcfandTxt = reader.ReadUInt32(); //194 + m_FibWord97.lcbPlcfandTxt = reader.ReadUInt32(); //198 + m_FibWord97.fcPlcfSed = reader.ReadUInt32(); //202 + m_FibWord97.lcbPlcfSed = reader.ReadUInt32(); //206 + m_FibWord97.fcPlcPad = reader.ReadUInt32(); //210 + m_FibWord97.lcbPlcPad = reader.ReadUInt32(); //214 + m_FibWord97.fcPlcfPhe = reader.ReadUInt32(); //218 + m_FibWord97.lcbPlcfPhe = reader.ReadUInt32(); //222 + m_FibWord97.fcSttbfGlsy = reader.ReadUInt32(); //226 + m_FibWord97.lcbSttbfGlsy = reader.ReadUInt32(); //230 + m_FibWord97.fcPlcfGlsy = reader.ReadUInt32(); //234 + m_FibWord97.lcbPlcfGlsy = reader.ReadUInt32(); //238 + m_FibWord97.fcPlcfHdd = reader.ReadUInt32(); //242 + m_FibWord97.lcbPlcfHdd = reader.ReadUInt32(); //246 + m_FibWord97.fcPlcfBteChpx = reader.ReadUInt32(); //250 + m_FibWord97.lcbPlcfBteChpx = reader.ReadUInt32(); //254 + m_FibWord97.fcPlcfBtePapx = reader.ReadUInt32(); //258 + m_FibWord97.lcbPlcfBtePapx = reader.ReadUInt32(); //262 + m_FibWord97.fcPlcfSea = reader.ReadUInt32(); //266 + m_FibWord97.lcbPlcfSea = reader.ReadUInt32(); //270 + m_FibWord97.fcSttbfFfn = reader.ReadUInt32(); //274 + m_FibWord97.lcbSttbfFfn = reader.ReadUInt32(); //278 + m_FibWord97.fcPlcfFldMom = reader.ReadUInt32(); //282 + m_FibWord97.lcbPlcfFldMom = reader.ReadUInt32(); //286 + m_FibWord97.fcPlcfFldHdr = reader.ReadUInt32(); //290 + m_FibWord97.lcbPlcfFldHdr = reader.ReadUInt32(); //294 + m_FibWord97.fcPlcfFldFtn = reader.ReadUInt32(); //298 + m_FibWord97.lcbPlcfFldFtn = reader.ReadUInt32(); //302 + m_FibWord97.fcPlcfFldAtn = reader.ReadUInt32(); //306 + m_FibWord97.lcbPlcfFldAtn = reader.ReadUInt32(); //310 + m_FibWord97.fcPlcfFldMcr = reader.ReadUInt32(); //314 + m_FibWord97.lcbPlcfFldMcr = reader.ReadUInt32(); //318 + m_FibWord97.fcSttbfBkmk = reader.ReadUInt32(); //322 + m_FibWord97.lcbSttbfBkmk = reader.ReadUInt32(); //326 + m_FibWord97.fcPlcfBkf = reader.ReadUInt32(); //330 + m_FibWord97.lcbPlcfBkf = reader.ReadUInt32(); //334 + m_FibWord97.fcPlcfBkl = reader.ReadUInt32(); //338 + m_FibWord97.lcbPlcfBkl = reader.ReadUInt32(); //342 + m_FibWord97.fcCmds = reader.ReadUInt32(); //346 + m_FibWord97.lcbCmds = reader.ReadUInt32(); //350 + + reader.ReadUInt32(); // 354 + reader.ReadUInt32(); // 358 + + m_FibWord97.fcSttbfMcr = reader.ReadUInt32(); // 362 + m_FibWord97.lcbSttbfMcr = reader.ReadUInt32(); // 366 + m_FibWord97.fcPrDrvr = reader.ReadUInt32(); // 370 + m_FibWord97.lcbPrDrvr = reader.ReadUInt32(); // 374 + m_FibWord97.fcPrEnvPort = reader.ReadUInt32(); // 378 + m_FibWord97.lcbPrEnvPort = reader.ReadUInt32(); // 382 + m_FibWord97.fcPrEnvLand = reader.ReadUInt32(); // 386 + m_FibWord97.lcbPrEnvLand = reader.ReadUInt32(); // 390 + m_FibWord97.fcWss = reader.ReadUInt32(); // 394 + m_FibWord97.lcbWss = reader.ReadUInt32(); // 398 + + m_FibWord97.fcDop = reader.ReadUInt32(); // 402 + m_FibWord97.lcbDop = reader.ReadUInt32(); // 406 + + m_FibWord97.fcSttbfAssoc = reader.ReadUInt32(); // 410 + m_FibWord97.lcbSttbfAssoc = reader.ReadUInt32(); // 414 + m_FibWord97.fcClx = reader.ReadUInt32(); // 418 + m_FibWord97.lcbClx = reader.ReadUInt32(); // 422 + m_FibWord97.fcPlcfPgdFtn = reader.ReadUInt32(); // 426 + m_FibWord97.lcbPlcfPgdFtn = reader.ReadUInt32(); // 430 + m_FibWord97.fcAutosaveSource = reader.ReadUInt32(); // 434 + m_FibWord97.lcbAutosaveSource = reader.ReadUInt32(); // 438 + m_FibWord97.fcGrpXstAtnOwners = reader.ReadUInt32(); // 442 + m_FibWord97.lcbGrpXstAtnOwners = reader.ReadUInt32(); // 446 + m_FibWord97.fcSttbfAtnBkmk = reader.ReadUInt32(); // 450 + m_FibWord97.lcbSttbfAtnBkmk = reader.ReadUInt32(); // 454 + + reader.ReadUInt32(); //458 + reader.ReadUInt32(); //462 + reader.ReadUInt32(); //466 + reader.ReadUInt32(); //470 + + m_FibWord97.fcPlcSpaMom = reader.ReadUInt32(); //474 + m_FibWord97.lcbPlcSpaMom = reader.ReadUInt32(); //478 + m_FibWord97.fcPlcSpaHdr = reader.ReadUInt32(); //482 + m_FibWord97.lcbPlcSpaHdr = reader.ReadUInt32(); //486 + m_FibWord97.fcPlcfAtnBkf = reader.ReadUInt32(); //490 + m_FibWord97.lcbPlcfAtnBkf = reader.ReadUInt32(); //494 + m_FibWord97.fcPlcfAtnBkl = reader.ReadUInt32(); //498 + m_FibWord97.lcbPlcfAtnBkl = reader.ReadUInt32(); //502 + m_FibWord97.fcPms = reader.ReadUInt32(); //506 + m_FibWord97.lcbPms = reader.ReadUInt32(); //510 + m_FibWord97.fcFormFldSttbs = reader.ReadUInt32(); //514 + m_FibWord97.lcbFormFldSttbs = reader.ReadUInt32(); //518 + m_FibWord97.fcPlcfendRef = reader.ReadUInt32(); //522 + m_FibWord97.lcbPlcfendRef = reader.ReadUInt32(); //526 + m_FibWord97.fcPlcfendTxt = reader.ReadUInt32(); //530 + m_FibWord97.lcbPlcfendTxt = reader.ReadUInt32(); //534 + m_FibWord97.fcPlcfFldEdn = reader.ReadUInt32(); //538 + m_FibWord97.lcbPlcfFldEdn = reader.ReadUInt32(); //542 + + reader.ReadUInt32(); //546 + reader.ReadUInt32(); //550 + + m_FibWord97.fcDggInfo = reader.ReadUInt32(); //554 + m_FibWord97.lcbDggInfo = reader.ReadUInt32(); //558 + m_FibWord97.fcSttbfRMark = reader.ReadUInt32(); //562 + m_FibWord97.lcbSttbfRMark = reader.ReadUInt32(); //566 + m_FibWord97.fcSttbfCaption = reader.ReadUInt32(); //570 + m_FibWord97.lcbSttbfCaption = reader.ReadUInt32(); //574 + m_FibWord97.fcSttbfAutoCaption = reader.ReadUInt32(); //578 + m_FibWord97.lcbSttbfAutoCaption = reader.ReadUInt32(); //582 + m_FibWord97.fcPlcfWkb = reader.ReadUInt32(); //586 + m_FibWord97.lcbPlcfWkb = reader.ReadUInt32(); //590 + m_FibWord97.fcPlcfSpl = reader.ReadUInt32(); //594 + m_FibWord97.lcbPlcfSpl = reader.ReadUInt32(); //598 + m_FibWord97.fcPlcftxbxTxt = reader.ReadUInt32(); //602 + m_FibWord97.lcbPlcftxbxTxt = reader.ReadUInt32(); //606 + m_FibWord97.fcPlcfFldTxbx = reader.ReadUInt32(); //610 + m_FibWord97.lcbPlcfFldTxbx = reader.ReadUInt32(); //614 + m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadUInt32(); //618 + m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadUInt32(); //622 + m_FibWord97.fcPlcffldHdrTxbx = reader.ReadUInt32(); //626 + m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadUInt32(); //630 + m_FibWord97.fcStwUser = reader.ReadUInt32(); //634 + m_FibWord97.lcbStwUser = reader.ReadUInt32(); //638 + m_FibWord97.fcSttbTtmbd = reader.ReadUInt32(); //642 + m_FibWord97.lcbSttbTtmbd = reader.ReadUInt32(); //646 + m_FibWord97.fcCookieData = reader.ReadUInt32(); //650 + m_FibWord97.lcbCookieData = reader.ReadUInt32(); //654 + m_FibWord97.fcPgdMotherOldOld = reader.ReadUInt32(); //658 + m_FibWord97.lcbPgdMotherOldOld = reader.ReadUInt32(); //662 + m_FibWord97.fcBkdMotherOldOld = reader.ReadUInt32(); //666 + m_FibWord97.lcbBkdMotherOldOld = reader.ReadUInt32(); //670 + m_FibWord97.fcPgdFtnOldOld = reader.ReadUInt32(); //674 + m_FibWord97.lcbPgdFtnOldOld = reader.ReadUInt32(); //678 + m_FibWord97.fcBkdFtnOldOld = reader.ReadUInt32(); //682 + m_FibWord97.lcbBkdFtnOldOld = reader.ReadUInt32(); //686 + m_FibWord97.fcPgdEdnOldOld = reader.ReadUInt32(); //690 + m_FibWord97.lcbPgdEdnOldOld = reader.ReadUInt32(); //694 + m_FibWord97.fcBkdEdnOldOld = reader.ReadUInt32(); //698 + m_FibWord97.lcbBkdEdnOldOld = reader.ReadUInt32(); //702 + m_FibWord97.fcSttbfIntlFld = reader.ReadUInt32(); //706 + m_FibWord97.lcbSttbfIntlFld = reader.ReadUInt32(); //710 + m_FibWord97.fcRouteSlip = reader.ReadUInt32(); //714 + m_FibWord97.lcbRouteSlip = reader.ReadUInt32(); //718 + m_FibWord97.fcSttbSavedBy = reader.ReadUInt32(); //722 + m_FibWord97.lcbSttbSavedBy = reader.ReadUInt32(); //726 + m_FibWord97.fcSttbFnm = reader.ReadUInt32(); //730 + m_FibWord97.lcbSttbFnm = reader.ReadUInt32(); //734 + m_FibWord97.fcPlfLst = reader.ReadUInt32(); //738 + m_FibWord97.lcbPlfLst = reader.ReadUInt32(); //742 + m_FibWord97.fcPlfLfo = reader.ReadUInt32(); //746 + m_FibWord97.lcbPlfLfo = reader.ReadUInt32(); //750 + m_FibWord97.fcPlcfTxbxBkd = reader.ReadUInt32(); //754 + m_FibWord97.lcbPlcfTxbxBkd = reader.ReadUInt32(); //758 + m_FibWord97.fcPlcfTxbxHdrBkd = reader.ReadUInt32(); //762 + m_FibWord97.lcbPlcfTxbxHdrBkd = reader.ReadUInt32(); //766 + m_FibWord97.fcDocUndoWord9 = reader.ReadUInt32(); //770 + m_FibWord97.lcbDocUndoWord9 = reader.ReadUInt32(); //774 + m_FibWord97.fcRgbUse = reader.ReadUInt32(); //778 + m_FibWord97.lcbRgbUse = reader.ReadUInt32(); //782 + m_FibWord97.fcUsp = reader.ReadUInt32(); //786 + m_FibWord97.lcbUsp = reader.ReadUInt32(); //790 + m_FibWord97.fcUskf = reader.ReadUInt32(); //794 + m_FibWord97.lcbUskf = reader.ReadUInt32(); //798 + m_FibWord97.fcPlcupcRgbUse = reader.ReadUInt32(); //802 + m_FibWord97.lcbPlcupcRgbUse = reader.ReadUInt32(); //806 + m_FibWord97.fcPlcupcUsp = reader.ReadUInt32(); //810 + m_FibWord97.lcbPlcupcUsp = reader.ReadUInt32(); //814 + m_FibWord97.fcSttbGlsyStyle = reader.ReadUInt32(); //818 + m_FibWord97.lcbSttbGlsyStyle = reader.ReadUInt32(); //822 + m_FibWord97.fcPlgosl = reader.ReadUInt32(); //826 + m_FibWord97.lcbPlgosl = reader.ReadUInt32(); //830 + m_FibWord97.fcPlcocx = reader.ReadUInt32(); //834 + m_FibWord97.lcbPlcocx = reader.ReadUInt32(); //838 + m_FibWord97.fcPlcfBteLvc = reader.ReadUInt32(); //842 + m_FibWord97.lcbPlcfBteLvc = reader.ReadUInt32(); //846 + m_FibWord97.dwLowDateTime = reader.ReadUInt32(); //850 + m_FibWord97.dwHighDateTime = reader.ReadUInt32(); //854 + m_FibWord97.fcPlcfLvcPre10 = reader.ReadUInt32(); //858 + m_FibWord97.lcbPlcfLvcPre10 = reader.ReadUInt32(); //862 + m_FibWord97.fcPlcfAsumy = reader.ReadUInt32(); //866 + m_FibWord97.lcbPlcfAsumy = reader.ReadUInt32(); //870 + m_FibWord97.fcPlcfGram = reader.ReadUInt32(); //874 + m_FibWord97.lcbPlcfGram = reader.ReadUInt32(); //878 + m_FibWord97.fcSttbListNames = reader.ReadUInt32(); //882 + m_FibWord97.lcbSttbListNames = reader.ReadUInt32(); //886 + m_FibWord97.fcSttbfUssr = reader.ReadUInt32(); //890 + m_FibWord97.lcbSttbfUssr = reader.ReadUInt32(); //894 + } + + if (m_FibBase.nFib >= Fib2000) + { + //Read also the FibRgFcLcb2000 + m_FibWord2000.fcPlcfTch = reader.ReadUInt32(); //898 + m_FibWord2000.lcbPlcfTch = reader.ReadUInt32(); //902 + m_FibWord2000.fcRmdThreading = reader.ReadUInt32(); //906 + m_FibWord2000.lcbRmdThreading = reader.ReadUInt32(); //910 + m_FibWord2000.fcMid = reader.ReadUInt32(); //914 + m_FibWord2000.lcbMid = reader.ReadUInt32(); //918 + m_FibWord2000.fcSttbRgtplc = reader.ReadUInt32(); //922 + m_FibWord2000.lcbSttbRgtplc = reader.ReadUInt32(); //926 + m_FibWord2000.fcMsoEnvelope = reader.ReadUInt32(); //930 + m_FibWord2000.lcbMsoEnvelope = reader.ReadUInt32(); //934 + m_FibWord2000.fcPlcfLad = reader.ReadUInt32(); //938 + m_FibWord2000.lcbPlcfLad = reader.ReadUInt32(); //942 + m_FibWord2000.fcRgDofr = reader.ReadUInt32(); //946 + m_FibWord2000.lcbRgDofr = reader.ReadUInt32(); //950 + m_FibWord2000.fcPlcosl = reader.ReadUInt32(); //954 + m_FibWord2000.lcbPlcosl = reader.ReadUInt32(); //958 + m_FibWord2000.fcPlcfCookieOld = reader.ReadUInt32(); //962 + m_FibWord2000.lcbPlcfCookieOld = reader.ReadUInt32(); //966 + m_FibWord2000.fcPgdMotherOld = reader.ReadUInt32(); //970 + m_FibWord2000.lcbPgdMotherOld = reader.ReadUInt32(); //974 + m_FibWord2000.fcBkdMotherOld = reader.ReadUInt32(); //978 + m_FibWord2000.lcbBkdMotherOld = reader.ReadUInt32(); //982 + m_FibWord2000.fcPgdFtnOld = reader.ReadUInt32(); //986 + m_FibWord2000.lcbPgdFtnOld = reader.ReadUInt32(); //990 + m_FibWord2000.fcBkdFtnOld = reader.ReadUInt32(); //994 + m_FibWord2000.lcbBkdFtnOld = reader.ReadUInt32(); //998 + m_FibWord2000.fcPgdEdnOld = reader.ReadUInt32(); //1002 + m_FibWord2000.lcbPgdEdnOld = reader.ReadUInt32(); //1006 + m_FibWord2000.fcBkdEdnOld = reader.ReadUInt32(); //1010 + m_FibWord2000.lcbBkdEdnOld = reader.ReadUInt32(); //1014 + } + if ( m_FibBase.nFib >= Fib2002 ) + { + //Read also the fibRgFcLcb2002 + reader.ReadUInt32(); //1018 + reader.ReadUInt32(); //1022 + m_FibWord2002.fcPlcfPgp = reader.ReadUInt32(); //1026 + m_FibWord2002.lcbPlcfPgp = reader.ReadUInt32(); //1030 + m_FibWord2002.fcPlcfuim = reader.ReadUInt32(); //1034 + m_FibWord2002.lcbPlcfuim = reader.ReadUInt32(); //1038 + m_FibWord2002.fcPlfguidUim = reader.ReadUInt32(); //1042 + m_FibWord2002.lcbPlfguidUim = reader.ReadUInt32(); //1046 + m_FibWord2002.fcAtrdExtra = reader.ReadUInt32(); //1050 + m_FibWord2002.lcbAtrdExtra = reader.ReadUInt32(); //1054 + m_FibWord2002.fcPlrsid = reader.ReadUInt32(); //1058 + m_FibWord2002.lcbPlrsid = reader.ReadUInt32(); //1062 + m_FibWord2002.fcSttbfBkmkFactoid = reader.ReadUInt32(); //1066 + m_FibWord2002.lcbSttbfBkmkFactoid = reader.ReadUInt32(); //1070 + m_FibWord2002.fcPlcfBkfFactoid = reader.ReadUInt32(); //1074 + m_FibWord2002.lcbPlcfBkfFactoid = reader.ReadUInt32(); //1078 + m_FibWord2002.fcPlcfcookie = reader.ReadUInt32(); //1082 + m_FibWord2002.lcbPlcfcookie = reader.ReadUInt32(); //1086 + m_FibWord2002.fcPlcfBklFactoid = reader.ReadUInt32(); //1090 + m_FibWord2002.lcbPlcfBklFactoid = reader.ReadUInt32(); //1094 + m_FibWord2002.fcFactoidData = reader.ReadUInt32(); //1098 + m_FibWord2002.lcbFactoidData = reader.ReadUInt32(); //1102 + m_FibWord2002.fcDocUndo = reader.ReadUInt32(); //1106 + m_FibWord2002.lcbDocUndo = reader.ReadUInt32(); //1110 + m_FibWord2002.fcSttbfBkmkFcc = reader.ReadUInt32(); //1114 + m_FibWord2002.lcbSttbfBkmkFcc = reader.ReadUInt32(); //1118 + m_FibWord2002.fcPlcfBkfFcc = reader.ReadUInt32(); //1122 + m_FibWord2002.lcbPlcfBkfFcc = reader.ReadUInt32(); //1126 + m_FibWord2002.fcPlcfBklFcc = reader.ReadUInt32(); //1130 + m_FibWord2002.lcbPlcfBklFcc = reader.ReadUInt32(); //1134 + m_FibWord2002.fcSttbfbkmkBPRepairs = reader.ReadUInt32(); //1138 + m_FibWord2002.lcbSttbfbkmkBPRepairs = reader.ReadUInt32(); //1142 + m_FibWord2002.fcPlcfbkfBPRepairs = reader.ReadUInt32(); //1146 + m_FibWord2002.lcbPlcfbkfBPRepairs = reader.ReadUInt32(); //1150 + m_FibWord2002.fcPlcfbklBPRepairs = reader.ReadUInt32(); //1154 + m_FibWord2002.lcbPlcfbklBPRepairs = reader.ReadUInt32(); //1158 + m_FibWord2002.fcPmsNew = reader.ReadUInt32(); //1162 + m_FibWord2002.lcbPmsNew = reader.ReadUInt32(); //1166 + m_FibWord2002.fcODSO = reader.ReadUInt32(); //1170 + m_FibWord2002.lcbODSO = reader.ReadUInt32(); //1174 + m_FibWord2002.fcPlcfpmiOldXP = reader.ReadUInt32(); //1178 + m_FibWord2002.lcbPlcfpmiOldXP = reader.ReadUInt32(); //1182 + m_FibWord2002.fcPlcfpmiNewXP = reader.ReadUInt32(); //1186 + m_FibWord2002.lcbPlcfpmiNewXP = reader.ReadUInt32(); //1190 + m_FibWord2002.fcPlcfpmiMixedXP = reader.ReadUInt32(); //1194 + m_FibWord2002.lcbPlcfpmiMixedXP = reader.ReadUInt32(); //1198 + reader.ReadUInt32(); //1202 + reader.ReadUInt32(); //1206 + m_FibWord2002.fcPlcffactoid = reader.ReadUInt32(); //1210 + m_FibWord2002.lcbPlcffactoid = reader.ReadUInt32(); //1214 + m_FibWord2002.fcPlcflvcOldXP = reader.ReadUInt32(); //1218 + m_FibWord2002.lcbPlcflvcOldXP = reader.ReadUInt32(); //1222 + m_FibWord2002.fcPlcflvcNewXP = reader.ReadUInt32(); //1226 + m_FibWord2002.lcbPlcflvcNewXP = reader.ReadUInt32(); //1230 + m_FibWord2002.fcPlcflvcMixedXP = reader.ReadUInt32(); //1234 + m_FibWord2002.lcbPlcflvcMixedXP = reader.ReadUInt32(); //1238 + } + if ( m_FibBase.nFib >= Fib2003 ) + { + //Read also the fibRgFcLcb2003 + m_FibWord2003.fcHplxsdr = reader.ReadUInt32(); + m_FibWord2003.lcbHplxsdr = reader.ReadUInt32(); + m_FibWord2003.fcSttbfBkmkSdt = reader.ReadUInt32(); + m_FibWord2003.lcbSttbfBkmkSdt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBkfSdt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBkfSdt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBklSdt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBklSdt = reader.ReadUInt32(); + m_FibWord2003.fcCustomXForm = reader.ReadUInt32(); + m_FibWord2003.lcbCustomXForm = reader.ReadUInt32(); + m_FibWord2003.fcSttbfBkmkProt = reader.ReadUInt32(); + m_FibWord2003.lcbSttbfBkmkProt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBkfProt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBkfProt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBklProt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBklProt = reader.ReadUInt32(); + m_FibWord2003.fcSttbProtUser = reader.ReadUInt32(); + m_FibWord2003.lcbSttbProtUser = reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiOld = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiOld = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiOldInline= reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiOldInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiNew = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiNew = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiNewInline= reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiNewInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcOld = reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcOld = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcOldInline= reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcOldInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcNew = reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcNew = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcNewInline= reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcNewInline = reader.ReadUInt32(); + m_FibWord2003.fcPgdMother = reader.ReadUInt32(); + m_FibWord2003.lcbPgdMother = reader.ReadUInt32(); + m_FibWord2003.fcBkdMother = reader.ReadUInt32(); + m_FibWord2003.lcbBkdMother = reader.ReadUInt32(); + m_FibWord2003.fcAfdMother = reader.ReadUInt32(); + m_FibWord2003.lcbAfdMother = reader.ReadUInt32(); + m_FibWord2003.fcPgdFtn = reader.ReadUInt32(); + m_FibWord2003.lcbPgdFtn = reader.ReadUInt32(); + m_FibWord2003.fcBkdFtn = reader.ReadUInt32(); + m_FibWord2003.lcbBkdFtn = reader.ReadUInt32(); + m_FibWord2003.fcAfdFtn = reader.ReadUInt32(); + m_FibWord2003.lcbAfdFtn = reader.ReadUInt32(); + m_FibWord2003.fcPgdEdn = reader.ReadUInt32(); + m_FibWord2003.lcbPgdEdn = reader.ReadUInt32(); + m_FibWord2003.fcBkdEdn = reader.ReadUInt32(); + m_FibWord2003.lcbBkdEdn = reader.ReadUInt32(); + m_FibWord2003.fcAfdEdn = reader.ReadUInt32(); + m_FibWord2003.lcbAfdEdn = reader.ReadUInt32(); + m_FibWord2003.fcAfd = reader.ReadUInt32(); + m_FibWord2003.lcbAfd = reader.ReadUInt32(); + } + if ( m_FibBase.nFib >= Fib2007 ) + { + //Read also the fibRgFcLcb2007 + m_FibWord2007.fcPlcfmthd = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfmthd = reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkMoveFrom = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfMoveFrom= reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklMoveFrom= reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkMoveTo= reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfMoveTo = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklMoveTo = reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkArto = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkArto = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfArto = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfArto = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklArto = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklArto = reader.ReadUInt32(); + m_FibWord2007.fcArtoData = reader.ReadUInt32(); + m_FibWord2007.lcbArtoData = reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + m_FibWord2007.fcOssTheme = reader.ReadUInt32(); + m_FibWord2007.lcbOssTheme = reader.ReadUInt32(); + m_FibWord2007.fcColorSchemeMapping = reader.ReadUInt32(); + m_FibWord2007.lcbColorSchemeMapping = reader.ReadUInt32(); + } + + cswNew = reader.ReadUInt16(); + + if (cswNew != 0) + { + //Read the FibRgCswNew + m_FibNew.nFibNew = (FibVersion)reader.ReadUInt16(); + + if (m_FibNew.nFibNew == 0) m_FibNew.nFibNew = Fib1997; + + m_FibNew.cQuickSavesNew = reader.ReadUInt16(); + + if (m_FibNew.nFibNew == 0x00D9 || + m_FibNew.nFibNew == 0x0101 || + m_FibNew.nFibNew == 0x010C ) + { + } + else if (m_FibNew.nFibNew == 0x0112) + { + m_FibNew.lidThemeOther = reader.ReadUInt16(); + m_FibNew.lidThemeFE = reader.ReadUInt16(); + m_FibNew.lidThemeCS = reader.ReadUInt16(); + } + } + } + FileInformationBlock::FileInformationBlock( VirtualStreamReader reader ) + { + m_nWordVersion = 0; + m_CodePage = 1250; + + unsigned int flag16 = 0; + unsigned char flag8 = 0; + + //read the FIB base + m_FibBase.wIdent = reader.ReadUInt16(); //0 + m_FibBase.nFib = (FibVersion)reader.ReadUInt16(); //2 + + reader.ReadBytes( 2, false ); //4 //nProduct + + m_FibBase.lid = reader.ReadUInt16(); //6 + m_FibBase.pnNext = reader.ReadInt16(); //8 + + flag16 = reader.ReadUInt16(); //10 + + m_FibBase.fDot = ((flag16 & 0x0001) >> 2) != 0; + m_FibBase.fGlsy = ((flag16 & 0x0002) >> 1) != 0; + m_FibBase.fComplex = ((flag16 & 0x0004) >> 2) != 0; + m_FibBase.fHasPic = ((flag16 & 0x0008) >> 3) != 0; + m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4); + m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100); + m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200); + m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400); + m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800); + m_FibBase.fExtChar = FormatUtils::BitmaskToBool((int)flag16, 0x1000); + m_FibBase.fLoadOverwrite = FormatUtils::BitmaskToBool((int)flag16, 0x2000); + m_FibBase.fFarEast = FormatUtils::BitmaskToBool((int)flag16, 0x4000); + m_FibBase.fObfuscation = FormatUtils::BitmaskToBool((int)flag16, 0x8000); + + m_FibBase.nFibBack = reader.ReadUInt16(); //12 + + if (m_FibBase.nFib < Fib1989) + { + m_FibWord2.Spare = reader.ReadInt32(); + m_FibWord2.rgwSpare0[0] = reader.ReadUInt16(); + m_FibWord2.rgwSpare0[1] = reader.ReadUInt16(); + m_FibWord2.rgwSpare0[2] = reader.ReadUInt16(); + } + else + { + m_FibBase.lKey = reader.ReadInt32(); //14 + m_FibBase.envr = reader.ReadByte(); //18 + + flag8 = reader.ReadByte(); //19 + + m_FibBase.fMac = FormatUtils::BitmaskToBool((int)flag8, 0x01); + m_FibBase.fEmptySpecial = FormatUtils::BitmaskToBool((int)flag8, 0x02); + m_FibBase.fLoadOverridePage = FormatUtils::BitmaskToBool((int)flag8, 0x04); + m_FibBase.fFutureSavedUndo = FormatUtils::BitmaskToBool((int)flag8, 0x08); + m_FibBase.fWord97Saved = FormatUtils::BitmaskToBool((int)flag8, 0x10); + + reader.ReadBytes( 4, false ); //20 + } + + m_FibBase.fcMin = reader.ReadInt32(); //24 + m_FibBase.fcMac = reader.ReadInt32(); //28 + + if (m_FibBase.nFib > Fib1995) + csw = reader.ReadUInt16(); //32 + + if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995) + { + m_RgLw97.cbMac = reader.ReadInt32();//32 + } + else if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0) + { + //read the RgW97 + int reserv1 = reader.ReadUInt16(); + int reserv2 = reader.ReadUInt16(); + int reserv3 = reader.ReadUInt16(); + int reserv4 = reader.ReadUInt16(); + int reserv5 = reader.ReadUInt16(); + int reserv6 = reader.ReadUInt16(); + int reserv7 = reader.ReadUInt16(); + int reserv8 = reader.ReadUInt16(); + int reserv9 = reader.ReadUInt16(); + int reserv10 = reader.ReadUInt16(); + int reserv11 = reader.ReadUInt16(); + int reserv12 = reader.ReadUInt16(); + int reserv13 = reader.ReadUInt16(); + + m_RgW97.lidFE = reader.ReadUInt16(); //60 + + cslw = reader.ReadUInt16(); //62 + + //read the RgLW97 + + m_RgLw97.cbMac = reader.ReadInt32(); //64 + } + reset(reader); + } +} diff --git a/MsBinaryFile/DocFile/FileInformationBlock.h b/MsBinaryFile/DocFile/FileInformationBlock.h index b647f3184b..4c0022cbdd 100644 --- a/MsBinaryFile/DocFile/FileInformationBlock.h +++ b/MsBinaryFile/DocFile/FileInformationBlock.h @@ -525,904 +525,8 @@ namespace DocFileFormat WORD cbRgFcLcb; WORD cswNew; - void reset( VirtualStreamReader reader ) - { - if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995) - { - /*fcSpare0 = */reader.ReadInt32(); - /*fcSpare1 = */reader.ReadInt32(); - /*fcSpare2 = */reader.ReadInt32(); - /*fcSpare3 = */reader.ReadInt32(); //48 - m_RgLw97.ccpText = reader.ReadInt32(); - m_RgLw97.ccpFtn = reader.ReadInt32(); - m_RgLw97.ccpHdr = reader.ReadInt32(); + void reset( VirtualStreamReader reader ); - /*m_FibWord97.ccpMcr = */reader.ReadInt32(); - m_RgLw97.ccpAtn = reader.ReadInt32(); - - if (m_FibBase.nFib > Fib1985) - { - m_RgLw97.ccpEdn = reader.ReadInt32(); - m_RgLw97.ccpTxbx = reader.ReadInt32(); - m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); - } - else - { - int ccpSpare0 = reader.ReadInt32(); - int ccpSpare1 = reader.ReadInt32(); - int ccpSpare2 = reader.ReadInt32(); - } - int ccpSpare3 = reader.ReadInt32(); - - if (m_FibBase.nFib > Fib1985) - { - m_FibWord97.fcStshfOrig = reader.ReadInt32(); - m_FibWord97.lcbStshfOrig = reader.ReadInt32(); - m_FibWord97.fcStshf = reader.ReadInt32(); //88 - m_FibWord97.lcbStshf = reader.ReadInt32(); - m_FibWord97.fcPlcffndRef = reader.ReadInt32(); - m_FibWord97.lcbPlcffndRef = reader.ReadInt32(); - - m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//112 - m_FibWord97.lcbPlcffndTxt = reader.ReadInt32(); - - m_FibWord97.fcPlcfandRef = reader.ReadInt32(); - m_FibWord97.lcbPlcfandRef = reader.ReadInt32(); - - m_FibWord97.fcPlcfandTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcfandTxt = reader.ReadInt32(); - - m_FibWord97.fcPlcfSed = reader.ReadInt32(); //136 - m_FibWord97.lcbPlcfSed = reader.ReadInt32(); - - m_FibWord97.fcPlcPad = reader.ReadInt32(); - m_FibWord97.lcbPlcPad = reader.ReadInt32(); - - m_FibWord97.fcPlcfPhe = reader.ReadInt32(); - m_FibWord97.lcbPlcfPhe = reader.ReadInt32(); - - m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); - m_FibWord97.lcbSttbfGlsy = reader.ReadInt32(); - - m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); - m_FibWord97.lcbPlcfGlsy = reader.ReadInt32(); - m_FibWord97.fcPlcfHdd = reader.ReadInt32(); - m_FibWord97.lcbPlcfHdd = reader.ReadInt32(); - - m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); - m_FibWord97.lcbPlcfBteChpx = reader.ReadInt32(); - - m_FibWord97.fcPlcfBtePapx = reader.ReadInt32(); - m_FibWord97.lcbPlcfBtePapx = reader.ReadInt32(); - - m_FibWord97.fcPlcfSea = reader.ReadInt32(); - m_FibWord97.lcbPlcfSea = reader.ReadInt32(); - - m_FibWord97.fcSttbfFfn = reader.ReadInt32(); - m_FibWord97.lcbSttbfFfn = reader.ReadInt32(); - - m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); //216 - m_FibWord97.lcbPlcfFldMom = reader.ReadInt32(); - - m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldHdr = reader.ReadInt32(); - - m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldFtn = reader.ReadInt32(); - - m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldAtn = reader.ReadInt32(); - - m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldMcr = reader.ReadInt32(); - - m_FibWord97.fcSttbfBkmk = reader.ReadInt32(); - m_FibWord97.lcbSttbfBkmk = reader.ReadInt32(); - - m_FibWord97.fcPlcfBkf = reader.ReadInt32(); - m_FibWord97.lcbPlcfBkf = reader.ReadInt32(); - - m_FibWord97.fcPlcfBkl = reader.ReadInt32(); - m_FibWord97.lcbPlcfBkl = reader.ReadInt32(); - - m_FibWord97.fcCmds = reader.ReadInt32(); - m_FibWord97.lcbCmds = reader.ReadInt32(); - - /*m_FibWord97.fcPlcMcr = */reader.ReadInt32(); - /*m_FibWord97.lcbPlcMcr = */reader.ReadInt32(); - - m_FibWord97.fcSttbfMcr = reader.ReadInt32(); - m_FibWord97.lcbSttbfMcr = reader.ReadInt32(); - - m_FibWord97.fcPrDrvr = reader.ReadInt32(); - m_FibWord97.lcbPrDrvr = reader.ReadInt32(); - - m_FibWord97.fcPrEnvPort = reader.ReadInt32(); - m_FibWord97.lcbPrEnvPort = reader.ReadInt32(); //316 - - m_FibWord97.fcPrEnvLand = reader.ReadInt32(); - m_FibWord97.lcbPrEnvLand = reader.ReadInt32(); - - m_FibWord97.fcWss = reader.ReadInt32(); - m_FibWord97.lcbWss = reader.ReadInt32(); - - m_FibWord97.fcDop = reader.ReadInt32(); - m_FibWord97.lcbDop = reader.ReadInt32(); - - m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); - m_FibWord97.lcbSttbfAssoc = reader.ReadInt32(); - - m_FibWord97.fcClx = reader.ReadInt32(); - m_FibWord97.lcbClx = reader.ReadInt32(); - - m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt32(); - - m_FibWord97.fcAutosaveSource = reader.ReadInt32(); - m_FibWord97.lcbAutosaveSource = reader.ReadInt32(); - m_FibWord97.fcGrpXstAtnOwners = reader.ReadInt32(); - m_FibWord97.lcbGrpXstAtnOwners = reader.ReadInt32(); - - m_FibWord97.fcSttbfAtnBkmk = reader.ReadInt32(); - m_FibWord97.lcbSttbfAtnBkmk = reader.ReadInt32(); - - m_FibWord2.wSpare4 = reader.ReadInt16(); //392 - m_FibWord2.pnChpFirst = reader.ReadInt16(); - m_FibWord2.pnPapFirst = reader.ReadInt16(); - - m_FibWord2.cpnBteChp = reader.ReadInt16(); - m_FibWord2.cpnBtePap = reader.ReadInt16(); - - m_FibWord97.fcPlcSpaMom = reader.ReadInt32(); - m_FibWord97.lcbPlcSpaMom = reader.ReadInt32(); - - m_FibWord97.fcPlcSpaHdr = reader.ReadInt32(); /*fcPlcfdoaHdr*/ - m_FibWord97.lcbPlcSpaHdr = reader.ReadInt32(); /*lcbPlcfdoaHdr*/ - - /*m_FibWord97.fcUnused1 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused1 =*/ reader.ReadInt32(); - /*m_FibWord97.fcUnused2 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused2 =*/ reader.ReadInt32(); - - m_FibWord97.fcPlcfAtnBkf = reader.ReadInt32(); - m_FibWord97.lcbPlcfAtnBkf = reader.ReadInt32(); - m_FibWord97.fcPlcfAtnBkl = reader.ReadInt32(); - m_FibWord97.lcbPlcfAtnBkl = reader.ReadInt32(); - m_FibWord97.fcPms = reader.ReadInt32(); - m_FibWord97.lcbPms = reader.ReadInt32(); - m_FibWord97.fcFormFldSttbs/*f*/ = reader.ReadInt32(); - m_FibWord97.lcbFormFldSttbs/*f*/= reader.ReadInt32(); - - m_FibWord97.fcPlcfendRef = reader.ReadInt32(); //466 - m_FibWord97.lcbPlcfendRef = reader.ReadInt32(); - m_FibWord97.fcPlcfendTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcfendTxt = reader.ReadInt32(); - m_FibWord97.fcPlcfFldEdn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldEdn = reader.ReadInt32(); - /*m_FibWord97.fcPlcfpgdEdn =*/ reader.ReadInt32(); - /*m_FibWord97.lcbPlcfpgdEdn =*/ reader.ReadInt32(); - /*m_FibWord97.fcUnused3 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused3 =*/ reader.ReadInt32(); - m_FibWord97.fcSttbfRMark = reader.ReadInt32(); - m_FibWord97.lcbSttbfRMark = reader.ReadInt32(); - m_FibWord97.fcSttbfCaption = reader.ReadInt32(); - m_FibWord97.lcbSttbfCaption = reader.ReadInt32(); - m_FibWord97.fcSttbfAutoCaption = reader.ReadInt32(); - m_FibWord97.lcbSttbfAutoCaption = reader.ReadInt32(); - m_FibWord97.fcPlcfWkb = reader.ReadInt32(); //530 - m_FibWord97.lcbPlcfWkb = reader.ReadInt32(); - /*m_FibWord97.fcUnused4 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused4 =*/ reader.ReadInt32(); - m_FibWord97.fcPlcftxbxTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcftxbxTxt = reader.ReadInt32(); - m_FibWord97.fcPlcfFldTxbx = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldTxbx = reader.ReadInt32(); - m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadInt32(); - m_FibWord97.fcPlcffldHdrTxbx = reader.ReadInt32(); - m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadInt32(); - m_FibWord97.fcStwUser = reader.ReadInt32(); - m_FibWord97.lcbStwUser = reader.ReadInt32(); - m_FibWord97.fcSttbTtmbd = reader.ReadInt32(); - m_FibWord97.lcbSttbTtmbd = reader.ReadInt32(); - /*m_FibWord97.fcPlcunused = */reader.ReadInt32(); - /*m_FibWord97.lcbUnused = */reader.ReadInt32(); - - m_FibWord97.fcPgdMotherOldOld = reader.ReadInt32(); /*fcpgdMother.fcPgd*/ //602 - m_FibWord97.lcbPgdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbPgd*/ - m_FibWord97.fcBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.fcBkd*/ - m_FibWord97.lcbBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbBkd*/ // ???? size 2 ???? - - m_FibWord97.fcPgdFtnOldOld = reader.ReadInt32(); /*fcPgdFtn.fcPgd*/ - m_FibWord97.lcbPgdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ - m_FibWord97.fcBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ - m_FibWord97.lcbBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ - - m_FibWord97.fcPgdEdnOldOld = reader.ReadInt32(); /*fcpgdFtn.fcPgd*/ - m_FibWord97.lcbPgdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ - m_FibWord97.fcBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ - m_FibWord97.lcbBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ - - m_FibWord97.fcSttbfIntlFld = reader.ReadInt32(); - m_FibWord97.lcbSttbfIntlFld = reader.ReadInt32(); - m_FibWord97.fcRouteSlip = reader.ReadInt32(); //656 - m_FibWord97.lcbRouteSlip = reader.ReadInt32(); - m_FibWord97.fcSttbSavedBy = reader.ReadInt32(); - m_FibWord97.lcbSttbSavedBy = reader.ReadInt32(); - m_FibWord97.fcSttbFnm = reader.ReadInt32(); - m_FibWord97.lcbSttbFnm = reader.ReadInt32(); //676 - } - else - { - m_FibWord97.fcStshfOrig = reader.ReadInt32();// 0x58 - m_FibWord97.lcbStshfOrig = reader.ReadInt16(); - m_FibWord97.fcStshf = reader.ReadInt32(); - m_FibWord97.lcbStshf = reader.ReadInt16();//0x62 - - m_FibWord97.fcPlcffndRef = reader.ReadInt32(); - m_FibWord97.lcbPlcffndRef = reader.ReadInt16();//0x68 - - m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//0x6a - m_FibWord97.lcbPlcffndTxt = reader.ReadInt16(); - - m_FibWord97.fcPlcfandRef = reader.ReadInt32();//0x70 - m_FibWord97.lcbPlcfandRef = reader.ReadInt16(); - - m_FibWord97.fcPlcfandTxt = reader.ReadInt32();//0x76 - m_FibWord97.lcbPlcfandTxt = reader.ReadInt16(); - - m_FibWord97.fcPlcfSed = reader.ReadInt32(); //0x7c - m_FibWord97.lcbPlcfSed = reader.ReadInt16(); - - m_FibWord97.fcPlcPad = reader.ReadInt32(); - m_FibWord97.lcbPlcPad = reader.ReadInt16(); - - m_FibWord97.fcPlcfPhe = reader.ReadInt32();// 0x88 - m_FibWord97.lcbPlcfPhe = reader.ReadInt16(); - - m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); - m_FibWord97.lcbSttbfGlsy = reader.ReadInt16(); - - m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); - m_FibWord97.lcbPlcfGlsy = reader.ReadInt16(); - - m_FibWord97.fcPlcfHdd = reader.ReadInt32();// 0x9a - m_FibWord97.lcbPlcfHdd = reader.ReadInt16(); - - m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); - m_FibWord97.lcbPlcfBteChpx = reader.ReadInt16(); - - m_FibWord97.fcPlcfBtePapx = reader.ReadInt32();// 0xa0 - m_FibWord97.lcbPlcfBtePapx = reader.ReadInt16(); - - m_FibWord97.fcPlcfSea = reader.ReadInt32();// 0xac - m_FibWord97.lcbPlcfSea = reader.ReadInt16(); - - m_FibWord97.fcSttbfFfn = reader.ReadInt32();// 0xb2 - m_FibWord97.lcbSttbfFfn = reader.ReadInt16(); - - m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); // 0xb8=184 - m_FibWord97.lcbPlcfFldMom = reader.ReadInt16(); - - m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldHdr = reader.ReadInt16(); - - m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldFtn = reader.ReadInt16(); - - m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldAtn = reader.ReadInt16(); - - m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldMcr = reader.ReadInt16(); - - m_FibWord97.fcSttbfBkmk = reader.ReadInt32();// 0xd6 - m_FibWord97.lcbSttbfBkmk = reader.ReadInt16(); - - m_FibWord97.fcPlcfBkf = reader.ReadInt32(); - m_FibWord97.lcbPlcfBkf = reader.ReadInt16(); - - m_FibWord97.fcPlcfBkl = reader.ReadInt32(); - m_FibWord97.lcbPlcfBkl = reader.ReadInt16(); - - m_FibWord97.fcCmds = reader.ReadInt32();// 0xe8 - m_FibWord97.lcbCmds = reader.ReadInt16(); - - m_FibWord2.fcPlcMcr = reader.ReadInt32();// 0xee - m_FibWord2.lcbPlcMcr = reader.ReadInt16(); - - m_FibWord97.fcSttbfMcr = reader.ReadInt32();// 0xf4 - m_FibWord97.lcbSttbfMcr = reader.ReadInt16(); - - m_FibWord97.fcPrDrvr = reader.ReadInt32();// - m_FibWord97.lcbPrDrvr = reader.ReadInt16(); - - m_FibWord97.fcPrEnvPort = reader.ReadInt32();// - m_FibWord97.lcbPrEnvPort = reader.ReadInt16(); - - m_FibWord97.fcPrEnvLand = reader.ReadInt32();// - m_FibWord97.lcbPrEnvLand = reader.ReadInt16(); - - m_FibWord97.fcWss = reader.ReadInt32();// 268 - m_FibWord97.lcbWss = reader.ReadInt16(); - - m_FibWord97.fcDop = reader.ReadInt32(); - m_FibWord97.lcbDop = reader.ReadInt16(); - - m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); - m_FibWord97.lcbSttbfAssoc = reader.ReadInt16();; - - m_FibWord97.fcClx = reader.ReadInt32(); - m_FibWord97.lcbClx = reader.ReadInt16(); - - m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); //292 - m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt16(); - - m_FibWord97.fcAutosaveSource = reader.ReadInt32(); - m_FibWord97.lcbAutosaveSource = reader.ReadInt16(); - - m_FibWord2.fcSpare5 = reader.ReadInt32(); - m_FibWord2.lcbSpare5 = reader.ReadInt16(); - m_FibWord2.fcSpare6 = reader.ReadInt32(); - m_FibWord2.lcbSpare6 = reader.ReadInt16(); - m_FibWord2.wSpare4 = reader.ReadInt16(); - - m_FibWord2.pnChpFirst = reader.ReadInt16(); - m_FibWord2.pnPapFirst = reader.ReadInt16(); - m_FibWord2.cpnBteChp = reader.ReadInt16(); - m_FibWord2.cpnBtePap = reader.ReadInt16(); - } - } - if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0) - { - int reserv1 = reader.ReadInt32(); - int reserv2 = reader.ReadInt32(); - - m_RgLw97.ccpText = reader.ReadInt32(); //76 - m_RgLw97.ccpFtn = reader.ReadInt32(); //80 - m_RgLw97.ccpHdr = reader.ReadInt32(); //84 - - int reserv3 = reader.ReadInt32(); - - m_RgLw97.ccpAtn = reader.ReadInt32(); //92 - m_RgLw97.ccpEdn = reader.ReadInt32(); //96 - m_RgLw97.ccpTxbx = reader.ReadInt32(); //100 - m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); //104 - - int reserv4 = reader.ReadInt32(); - int reserv5 = reader.ReadInt32(); - int reserv6 = reader.ReadInt32(); - int reserv7 = reader.ReadInt32(); - int reserv8 = reader.ReadInt32(); - int reserv9 = reader.ReadInt32(); - int reserv10 = reader.ReadInt32(); - int reserv11 = reader.ReadInt32(); - int reserv12 = reader.ReadInt32(); - int reserv13 = reader.ReadInt32(); - int reserv14 = reader.ReadInt32(); - - cbRgFcLcb = reader.ReadUInt16(); //152 - - switch(cbRgFcLcb) - { - case 0x005D: m_FibBase.nFib = Fib1997; break; - case 0x006C: m_FibBase.nFib = Fib2000; break; - case 0x0088: m_FibBase.nFib = Fib2002; break; - case 0x00A4: m_FibBase.nFib = Fib2003; break; - case 0x00B7: m_FibBase.nFib = Fib2007; break; - } - - m_FibWord97.fcStshfOrig = reader.ReadUInt32(); //154 - m_FibWord97.lcbStshfOrig = reader.ReadUInt32(); //158 - m_FibWord97.fcStshf = reader.ReadUInt32(); //162 - m_FibWord97.lcbStshf = reader.ReadUInt32(); //166 - m_FibWord97.fcPlcffndRef = reader.ReadUInt32(); //170 - m_FibWord97.lcbPlcffndRef = reader.ReadUInt32(); //174 - m_FibWord97.fcPlcffndTxt = reader.ReadUInt32(); //178 - m_FibWord97.lcbPlcffndTxt = reader.ReadUInt32(); //182 - m_FibWord97.fcPlcfandRef = reader.ReadUInt32(); //186 - m_FibWord97.lcbPlcfandRef = reader.ReadUInt32(); //190 - m_FibWord97.fcPlcfandTxt = reader.ReadUInt32(); //194 - m_FibWord97.lcbPlcfandTxt = reader.ReadUInt32(); //198 - m_FibWord97.fcPlcfSed = reader.ReadUInt32(); //202 - m_FibWord97.lcbPlcfSed = reader.ReadUInt32(); //206 - m_FibWord97.fcPlcPad = reader.ReadUInt32(); //210 - m_FibWord97.lcbPlcPad = reader.ReadUInt32(); //214 - m_FibWord97.fcPlcfPhe = reader.ReadUInt32(); //218 - m_FibWord97.lcbPlcfPhe = reader.ReadUInt32(); //222 - m_FibWord97.fcSttbfGlsy = reader.ReadUInt32(); //226 - m_FibWord97.lcbSttbfGlsy = reader.ReadUInt32(); //230 - m_FibWord97.fcPlcfGlsy = reader.ReadUInt32(); //234 - m_FibWord97.lcbPlcfGlsy = reader.ReadUInt32(); //238 - m_FibWord97.fcPlcfHdd = reader.ReadUInt32(); //242 - m_FibWord97.lcbPlcfHdd = reader.ReadUInt32(); //246 - m_FibWord97.fcPlcfBteChpx = reader.ReadUInt32(); //250 - m_FibWord97.lcbPlcfBteChpx = reader.ReadUInt32(); //254 - m_FibWord97.fcPlcfBtePapx = reader.ReadUInt32(); //258 - m_FibWord97.lcbPlcfBtePapx = reader.ReadUInt32(); //262 - m_FibWord97.fcPlcfSea = reader.ReadUInt32(); //266 - m_FibWord97.lcbPlcfSea = reader.ReadUInt32(); //270 - m_FibWord97.fcSttbfFfn = reader.ReadUInt32(); //274 - m_FibWord97.lcbSttbfFfn = reader.ReadUInt32(); //278 - m_FibWord97.fcPlcfFldMom = reader.ReadUInt32(); //282 - m_FibWord97.lcbPlcfFldMom = reader.ReadUInt32(); //286 - m_FibWord97.fcPlcfFldHdr = reader.ReadUInt32(); //290 - m_FibWord97.lcbPlcfFldHdr = reader.ReadUInt32(); //294 - m_FibWord97.fcPlcfFldFtn = reader.ReadUInt32(); //298 - m_FibWord97.lcbPlcfFldFtn = reader.ReadUInt32(); //302 - m_FibWord97.fcPlcfFldAtn = reader.ReadUInt32(); //306 - m_FibWord97.lcbPlcfFldAtn = reader.ReadUInt32(); //310 - m_FibWord97.fcPlcfFldMcr = reader.ReadUInt32(); //314 - m_FibWord97.lcbPlcfFldMcr = reader.ReadUInt32(); //318 - m_FibWord97.fcSttbfBkmk = reader.ReadUInt32(); //322 - m_FibWord97.lcbSttbfBkmk = reader.ReadUInt32(); //326 - m_FibWord97.fcPlcfBkf = reader.ReadUInt32(); //330 - m_FibWord97.lcbPlcfBkf = reader.ReadUInt32(); //334 - m_FibWord97.fcPlcfBkl = reader.ReadUInt32(); //338 - m_FibWord97.lcbPlcfBkl = reader.ReadUInt32(); //342 - m_FibWord97.fcCmds = reader.ReadUInt32(); //346 - m_FibWord97.lcbCmds = reader.ReadUInt32(); //350 - - reader.ReadUInt32(); // 354 - reader.ReadUInt32(); // 358 - - m_FibWord97.fcSttbfMcr = reader.ReadUInt32(); // 362 - m_FibWord97.lcbSttbfMcr = reader.ReadUInt32(); // 366 - m_FibWord97.fcPrDrvr = reader.ReadUInt32(); // 370 - m_FibWord97.lcbPrDrvr = reader.ReadUInt32(); // 374 - m_FibWord97.fcPrEnvPort = reader.ReadUInt32(); // 378 - m_FibWord97.lcbPrEnvPort = reader.ReadUInt32(); // 382 - m_FibWord97.fcPrEnvLand = reader.ReadUInt32(); // 386 - m_FibWord97.lcbPrEnvLand = reader.ReadUInt32(); // 390 - m_FibWord97.fcWss = reader.ReadUInt32(); // 394 - m_FibWord97.lcbWss = reader.ReadUInt32(); // 398 - - m_FibWord97.fcDop = reader.ReadUInt32(); // 402 - m_FibWord97.lcbDop = reader.ReadUInt32(); // 406 - - m_FibWord97.fcSttbfAssoc = reader.ReadUInt32(); // 410 - m_FibWord97.lcbSttbfAssoc = reader.ReadUInt32(); // 414 - m_FibWord97.fcClx = reader.ReadUInt32(); // 418 - m_FibWord97.lcbClx = reader.ReadUInt32(); // 422 - m_FibWord97.fcPlcfPgdFtn = reader.ReadUInt32(); // 426 - m_FibWord97.lcbPlcfPgdFtn = reader.ReadUInt32(); // 430 - m_FibWord97.fcAutosaveSource = reader.ReadUInt32(); // 434 - m_FibWord97.lcbAutosaveSource = reader.ReadUInt32(); // 438 - m_FibWord97.fcGrpXstAtnOwners = reader.ReadUInt32(); // 442 - m_FibWord97.lcbGrpXstAtnOwners = reader.ReadUInt32(); // 446 - m_FibWord97.fcSttbfAtnBkmk = reader.ReadUInt32(); // 450 - m_FibWord97.lcbSttbfAtnBkmk = reader.ReadUInt32(); // 454 - - reader.ReadUInt32(); //458 - reader.ReadUInt32(); //462 - reader.ReadUInt32(); //466 - reader.ReadUInt32(); //470 - - m_FibWord97.fcPlcSpaMom = reader.ReadUInt32(); //474 - m_FibWord97.lcbPlcSpaMom = reader.ReadUInt32(); //478 - m_FibWord97.fcPlcSpaHdr = reader.ReadUInt32(); //482 - m_FibWord97.lcbPlcSpaHdr = reader.ReadUInt32(); //486 - m_FibWord97.fcPlcfAtnBkf = reader.ReadUInt32(); //490 - m_FibWord97.lcbPlcfAtnBkf = reader.ReadUInt32(); //494 - m_FibWord97.fcPlcfAtnBkl = reader.ReadUInt32(); //498 - m_FibWord97.lcbPlcfAtnBkl = reader.ReadUInt32(); //502 - m_FibWord97.fcPms = reader.ReadUInt32(); //506 - m_FibWord97.lcbPms = reader.ReadUInt32(); //510 - m_FibWord97.fcFormFldSttbs = reader.ReadUInt32(); //514 - m_FibWord97.lcbFormFldSttbs = reader.ReadUInt32(); //518 - m_FibWord97.fcPlcfendRef = reader.ReadUInt32(); //522 - m_FibWord97.lcbPlcfendRef = reader.ReadUInt32(); //526 - m_FibWord97.fcPlcfendTxt = reader.ReadUInt32(); //530 - m_FibWord97.lcbPlcfendTxt = reader.ReadUInt32(); //534 - m_FibWord97.fcPlcfFldEdn = reader.ReadUInt32(); //538 - m_FibWord97.lcbPlcfFldEdn = reader.ReadUInt32(); //542 - - reader.ReadUInt32(); //546 - reader.ReadUInt32(); //550 - - m_FibWord97.fcDggInfo = reader.ReadUInt32(); //554 - m_FibWord97.lcbDggInfo = reader.ReadUInt32(); //558 - m_FibWord97.fcSttbfRMark = reader.ReadUInt32(); //562 - m_FibWord97.lcbSttbfRMark = reader.ReadUInt32(); //566 - m_FibWord97.fcSttbfCaption = reader.ReadUInt32(); //570 - m_FibWord97.lcbSttbfCaption = reader.ReadUInt32(); //574 - m_FibWord97.fcSttbfAutoCaption = reader.ReadUInt32(); //578 - m_FibWord97.lcbSttbfAutoCaption = reader.ReadUInt32(); //582 - m_FibWord97.fcPlcfWkb = reader.ReadUInt32(); //586 - m_FibWord97.lcbPlcfWkb = reader.ReadUInt32(); //590 - m_FibWord97.fcPlcfSpl = reader.ReadUInt32(); //594 - m_FibWord97.lcbPlcfSpl = reader.ReadUInt32(); //598 - m_FibWord97.fcPlcftxbxTxt = reader.ReadUInt32(); //602 - m_FibWord97.lcbPlcftxbxTxt = reader.ReadUInt32(); //606 - m_FibWord97.fcPlcfFldTxbx = reader.ReadUInt32(); //610 - m_FibWord97.lcbPlcfFldTxbx = reader.ReadUInt32(); //614 - m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadUInt32(); //618 - m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadUInt32(); //622 - m_FibWord97.fcPlcffldHdrTxbx = reader.ReadUInt32(); //626 - m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadUInt32(); //630 - m_FibWord97.fcStwUser = reader.ReadUInt32(); //634 - m_FibWord97.lcbStwUser = reader.ReadUInt32(); //638 - m_FibWord97.fcSttbTtmbd = reader.ReadUInt32(); //642 - m_FibWord97.lcbSttbTtmbd = reader.ReadUInt32(); //646 - m_FibWord97.fcCookieData = reader.ReadUInt32(); //650 - m_FibWord97.lcbCookieData = reader.ReadUInt32(); //654 - m_FibWord97.fcPgdMotherOldOld = reader.ReadUInt32(); //658 - m_FibWord97.lcbPgdMotherOldOld = reader.ReadUInt32(); //662 - m_FibWord97.fcBkdMotherOldOld = reader.ReadUInt32(); //666 - m_FibWord97.lcbBkdMotherOldOld = reader.ReadUInt32(); //670 - m_FibWord97.fcPgdFtnOldOld = reader.ReadUInt32(); //674 - m_FibWord97.lcbPgdFtnOldOld = reader.ReadUInt32(); //678 - m_FibWord97.fcBkdFtnOldOld = reader.ReadUInt32(); //682 - m_FibWord97.lcbBkdFtnOldOld = reader.ReadUInt32(); //686 - m_FibWord97.fcPgdEdnOldOld = reader.ReadUInt32(); //690 - m_FibWord97.lcbPgdEdnOldOld = reader.ReadUInt32(); //694 - m_FibWord97.fcBkdEdnOldOld = reader.ReadUInt32(); //698 - m_FibWord97.lcbBkdEdnOldOld = reader.ReadUInt32(); //702 - m_FibWord97.fcSttbfIntlFld = reader.ReadUInt32(); //706 - m_FibWord97.lcbSttbfIntlFld = reader.ReadUInt32(); //710 - m_FibWord97.fcRouteSlip = reader.ReadUInt32(); //714 - m_FibWord97.lcbRouteSlip = reader.ReadUInt32(); //718 - m_FibWord97.fcSttbSavedBy = reader.ReadUInt32(); //722 - m_FibWord97.lcbSttbSavedBy = reader.ReadUInt32(); //726 - m_FibWord97.fcSttbFnm = reader.ReadUInt32(); //730 - m_FibWord97.lcbSttbFnm = reader.ReadUInt32(); //734 - m_FibWord97.fcPlfLst = reader.ReadUInt32(); //738 - m_FibWord97.lcbPlfLst = reader.ReadUInt32(); //742 - m_FibWord97.fcPlfLfo = reader.ReadUInt32(); //746 - m_FibWord97.lcbPlfLfo = reader.ReadUInt32(); //750 - m_FibWord97.fcPlcfTxbxBkd = reader.ReadUInt32(); //754 - m_FibWord97.lcbPlcfTxbxBkd = reader.ReadUInt32(); //758 - m_FibWord97.fcPlcfTxbxHdrBkd = reader.ReadUInt32(); //762 - m_FibWord97.lcbPlcfTxbxHdrBkd = reader.ReadUInt32(); //766 - m_FibWord97.fcDocUndoWord9 = reader.ReadUInt32(); //770 - m_FibWord97.lcbDocUndoWord9 = reader.ReadUInt32(); //774 - m_FibWord97.fcRgbUse = reader.ReadUInt32(); //778 - m_FibWord97.lcbRgbUse = reader.ReadUInt32(); //782 - m_FibWord97.fcUsp = reader.ReadUInt32(); //786 - m_FibWord97.lcbUsp = reader.ReadUInt32(); //790 - m_FibWord97.fcUskf = reader.ReadUInt32(); //794 - m_FibWord97.lcbUskf = reader.ReadUInt32(); //798 - m_FibWord97.fcPlcupcRgbUse = reader.ReadUInt32(); //802 - m_FibWord97.lcbPlcupcRgbUse = reader.ReadUInt32(); //806 - m_FibWord97.fcPlcupcUsp = reader.ReadUInt32(); //810 - m_FibWord97.lcbPlcupcUsp = reader.ReadUInt32(); //814 - m_FibWord97.fcSttbGlsyStyle = reader.ReadUInt32(); //818 - m_FibWord97.lcbSttbGlsyStyle = reader.ReadUInt32(); //822 - m_FibWord97.fcPlgosl = reader.ReadUInt32(); //826 - m_FibWord97.lcbPlgosl = reader.ReadUInt32(); //830 - m_FibWord97.fcPlcocx = reader.ReadUInt32(); //834 - m_FibWord97.lcbPlcocx = reader.ReadUInt32(); //838 - m_FibWord97.fcPlcfBteLvc = reader.ReadUInt32(); //842 - m_FibWord97.lcbPlcfBteLvc = reader.ReadUInt32(); //846 - m_FibWord97.dwLowDateTime = reader.ReadUInt32(); //850 - m_FibWord97.dwHighDateTime = reader.ReadUInt32(); //854 - m_FibWord97.fcPlcfLvcPre10 = reader.ReadUInt32(); //858 - m_FibWord97.lcbPlcfLvcPre10 = reader.ReadUInt32(); //862 - m_FibWord97.fcPlcfAsumy = reader.ReadUInt32(); //866 - m_FibWord97.lcbPlcfAsumy = reader.ReadUInt32(); //870 - m_FibWord97.fcPlcfGram = reader.ReadUInt32(); //874 - m_FibWord97.lcbPlcfGram = reader.ReadUInt32(); //878 - m_FibWord97.fcSttbListNames = reader.ReadUInt32(); //882 - m_FibWord97.lcbSttbListNames = reader.ReadUInt32(); //886 - m_FibWord97.fcSttbfUssr = reader.ReadUInt32(); //890 - m_FibWord97.lcbSttbfUssr = reader.ReadUInt32(); //894 - } - - if (m_FibBase.nFib >= Fib2000) - { - //Read also the FibRgFcLcb2000 - m_FibWord2000.fcPlcfTch = reader.ReadUInt32(); //898 - m_FibWord2000.lcbPlcfTch = reader.ReadUInt32(); //902 - m_FibWord2000.fcRmdThreading = reader.ReadUInt32(); //906 - m_FibWord2000.lcbRmdThreading = reader.ReadUInt32(); //910 - m_FibWord2000.fcMid = reader.ReadUInt32(); //914 - m_FibWord2000.lcbMid = reader.ReadUInt32(); //918 - m_FibWord2000.fcSttbRgtplc = reader.ReadUInt32(); //922 - m_FibWord2000.lcbSttbRgtplc = reader.ReadUInt32(); //926 - m_FibWord2000.fcMsoEnvelope = reader.ReadUInt32(); //930 - m_FibWord2000.lcbMsoEnvelope = reader.ReadUInt32(); //934 - m_FibWord2000.fcPlcfLad = reader.ReadUInt32(); //938 - m_FibWord2000.lcbPlcfLad = reader.ReadUInt32(); //942 - m_FibWord2000.fcRgDofr = reader.ReadUInt32(); //946 - m_FibWord2000.lcbRgDofr = reader.ReadUInt32(); //950 - m_FibWord2000.fcPlcosl = reader.ReadUInt32(); //954 - m_FibWord2000.lcbPlcosl = reader.ReadUInt32(); //958 - m_FibWord2000.fcPlcfCookieOld = reader.ReadUInt32(); //962 - m_FibWord2000.lcbPlcfCookieOld = reader.ReadUInt32(); //966 - m_FibWord2000.fcPgdMotherOld = reader.ReadUInt32(); //970 - m_FibWord2000.lcbPgdMotherOld = reader.ReadUInt32(); //974 - m_FibWord2000.fcBkdMotherOld = reader.ReadUInt32(); //978 - m_FibWord2000.lcbBkdMotherOld = reader.ReadUInt32(); //982 - m_FibWord2000.fcPgdFtnOld = reader.ReadUInt32(); //986 - m_FibWord2000.lcbPgdFtnOld = reader.ReadUInt32(); //990 - m_FibWord2000.fcBkdFtnOld = reader.ReadUInt32(); //994 - m_FibWord2000.lcbBkdFtnOld = reader.ReadUInt32(); //998 - m_FibWord2000.fcPgdEdnOld = reader.ReadUInt32(); //1002 - m_FibWord2000.lcbPgdEdnOld = reader.ReadUInt32(); //1006 - m_FibWord2000.fcBkdEdnOld = reader.ReadUInt32(); //1010 - m_FibWord2000.lcbBkdEdnOld = reader.ReadUInt32(); //1014 - } - if ( m_FibBase.nFib >= Fib2002 ) - { - //Read also the fibRgFcLcb2002 - reader.ReadUInt32(); //1018 - reader.ReadUInt32(); //1022 - m_FibWord2002.fcPlcfPgp = reader.ReadUInt32(); //1026 - m_FibWord2002.lcbPlcfPgp = reader.ReadUInt32(); //1030 - m_FibWord2002.fcPlcfuim = reader.ReadUInt32(); //1034 - m_FibWord2002.lcbPlcfuim = reader.ReadUInt32(); //1038 - m_FibWord2002.fcPlfguidUim = reader.ReadUInt32(); //1042 - m_FibWord2002.lcbPlfguidUim = reader.ReadUInt32(); //1046 - m_FibWord2002.fcAtrdExtra = reader.ReadUInt32(); //1050 - m_FibWord2002.lcbAtrdExtra = reader.ReadUInt32(); //1054 - m_FibWord2002.fcPlrsid = reader.ReadUInt32(); //1058 - m_FibWord2002.lcbPlrsid = reader.ReadUInt32(); //1062 - m_FibWord2002.fcSttbfBkmkFactoid = reader.ReadUInt32(); //1066 - m_FibWord2002.lcbSttbfBkmkFactoid = reader.ReadUInt32(); //1070 - m_FibWord2002.fcPlcfBkfFactoid = reader.ReadUInt32(); //1074 - m_FibWord2002.lcbPlcfBkfFactoid = reader.ReadUInt32(); //1078 - m_FibWord2002.fcPlcfcookie = reader.ReadUInt32(); //1082 - m_FibWord2002.lcbPlcfcookie = reader.ReadUInt32(); //1086 - m_FibWord2002.fcPlcfBklFactoid = reader.ReadUInt32(); //1090 - m_FibWord2002.lcbPlcfBklFactoid = reader.ReadUInt32(); //1094 - m_FibWord2002.fcFactoidData = reader.ReadUInt32(); //1098 - m_FibWord2002.lcbFactoidData = reader.ReadUInt32(); //1102 - m_FibWord2002.fcDocUndo = reader.ReadUInt32(); //1106 - m_FibWord2002.lcbDocUndo = reader.ReadUInt32(); //1110 - m_FibWord2002.fcSttbfBkmkFcc = reader.ReadUInt32(); //1114 - m_FibWord2002.lcbSttbfBkmkFcc = reader.ReadUInt32(); //1118 - m_FibWord2002.fcPlcfBkfFcc = reader.ReadUInt32(); //1122 - m_FibWord2002.lcbPlcfBkfFcc = reader.ReadUInt32(); //1126 - m_FibWord2002.fcPlcfBklFcc = reader.ReadUInt32(); //1130 - m_FibWord2002.lcbPlcfBklFcc = reader.ReadUInt32(); //1134 - m_FibWord2002.fcSttbfbkmkBPRepairs = reader.ReadUInt32(); //1138 - m_FibWord2002.lcbSttbfbkmkBPRepairs = reader.ReadUInt32(); //1142 - m_FibWord2002.fcPlcfbkfBPRepairs = reader.ReadUInt32(); //1146 - m_FibWord2002.lcbPlcfbkfBPRepairs = reader.ReadUInt32(); //1150 - m_FibWord2002.fcPlcfbklBPRepairs = reader.ReadUInt32(); //1154 - m_FibWord2002.lcbPlcfbklBPRepairs = reader.ReadUInt32(); //1158 - m_FibWord2002.fcPmsNew = reader.ReadUInt32(); //1162 - m_FibWord2002.lcbPmsNew = reader.ReadUInt32(); //1166 - m_FibWord2002.fcODSO = reader.ReadUInt32(); //1170 - m_FibWord2002.lcbODSO = reader.ReadUInt32(); //1174 - m_FibWord2002.fcPlcfpmiOldXP = reader.ReadUInt32(); //1178 - m_FibWord2002.lcbPlcfpmiOldXP = reader.ReadUInt32(); //1182 - m_FibWord2002.fcPlcfpmiNewXP = reader.ReadUInt32(); //1186 - m_FibWord2002.lcbPlcfpmiNewXP = reader.ReadUInt32(); //1190 - m_FibWord2002.fcPlcfpmiMixedXP = reader.ReadUInt32(); //1194 - m_FibWord2002.lcbPlcfpmiMixedXP = reader.ReadUInt32(); //1198 - reader.ReadUInt32(); //1202 - reader.ReadUInt32(); //1206 - m_FibWord2002.fcPlcffactoid = reader.ReadUInt32(); //1210 - m_FibWord2002.lcbPlcffactoid = reader.ReadUInt32(); //1214 - m_FibWord2002.fcPlcflvcOldXP = reader.ReadUInt32(); //1218 - m_FibWord2002.lcbPlcflvcOldXP = reader.ReadUInt32(); //1222 - m_FibWord2002.fcPlcflvcNewXP = reader.ReadUInt32(); //1226 - m_FibWord2002.lcbPlcflvcNewXP = reader.ReadUInt32(); //1230 - m_FibWord2002.fcPlcflvcMixedXP = reader.ReadUInt32(); //1234 - m_FibWord2002.lcbPlcflvcMixedXP = reader.ReadUInt32(); //1238 - } - if ( m_FibBase.nFib >= Fib2003 ) - { - //Read also the fibRgFcLcb2003 - m_FibWord2003.fcHplxsdr = reader.ReadUInt32(); - m_FibWord2003.lcbHplxsdr = reader.ReadUInt32(); - m_FibWord2003.fcSttbfBkmkSdt = reader.ReadUInt32(); - m_FibWord2003.lcbSttbfBkmkSdt = reader.ReadUInt32(); - m_FibWord2003.fcPlcfBkfSdt = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfBkfSdt = reader.ReadUInt32(); - m_FibWord2003.fcPlcfBklSdt = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfBklSdt = reader.ReadUInt32(); - m_FibWord2003.fcCustomXForm = reader.ReadUInt32(); - m_FibWord2003.lcbCustomXForm = reader.ReadUInt32(); - m_FibWord2003.fcSttbfBkmkProt = reader.ReadUInt32(); - m_FibWord2003.lcbSttbfBkmkProt = reader.ReadUInt32(); - m_FibWord2003.fcPlcfBkfProt = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfBkfProt = reader.ReadUInt32(); - m_FibWord2003.fcPlcfBklProt = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfBklProt = reader.ReadUInt32(); - m_FibWord2003.fcSttbProtUser = reader.ReadUInt32(); - m_FibWord2003.lcbSttbProtUser = reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - m_FibWord2003.fcPlcfpmiOld = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfpmiOld = reader.ReadUInt32(); - m_FibWord2003.fcPlcfpmiOldInline= reader.ReadUInt32(); - m_FibWord2003.lcbPlcfpmiOldInline = reader.ReadUInt32(); - m_FibWord2003.fcPlcfpmiNew = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfpmiNew = reader.ReadUInt32(); - m_FibWord2003.fcPlcfpmiNewInline= reader.ReadUInt32(); - m_FibWord2003.lcbPlcfpmiNewInline = reader.ReadUInt32(); - m_FibWord2003.fcPlcflvcOld = reader.ReadUInt32(); - m_FibWord2003.lcbPlcflvcOld = reader.ReadUInt32(); - m_FibWord2003.fcPlcflvcOldInline= reader.ReadUInt32(); - m_FibWord2003.lcbPlcflvcOldInline = reader.ReadUInt32(); - m_FibWord2003.fcPlcflvcNew = reader.ReadUInt32(); - m_FibWord2003.lcbPlcflvcNew = reader.ReadUInt32(); - m_FibWord2003.fcPlcflvcNewInline= reader.ReadUInt32(); - m_FibWord2003.lcbPlcflvcNewInline = reader.ReadUInt32(); - m_FibWord2003.fcPgdMother = reader.ReadUInt32(); - m_FibWord2003.lcbPgdMother = reader.ReadUInt32(); - m_FibWord2003.fcBkdMother = reader.ReadUInt32(); - m_FibWord2003.lcbBkdMother = reader.ReadUInt32(); - m_FibWord2003.fcAfdMother = reader.ReadUInt32(); - m_FibWord2003.lcbAfdMother = reader.ReadUInt32(); - m_FibWord2003.fcPgdFtn = reader.ReadUInt32(); - m_FibWord2003.lcbPgdFtn = reader.ReadUInt32(); - m_FibWord2003.fcBkdFtn = reader.ReadUInt32(); - m_FibWord2003.lcbBkdFtn = reader.ReadUInt32(); - m_FibWord2003.fcAfdFtn = reader.ReadUInt32(); - m_FibWord2003.lcbAfdFtn = reader.ReadUInt32(); - m_FibWord2003.fcPgdEdn = reader.ReadUInt32(); - m_FibWord2003.lcbPgdEdn = reader.ReadUInt32(); - m_FibWord2003.fcBkdEdn = reader.ReadUInt32(); - m_FibWord2003.lcbBkdEdn = reader.ReadUInt32(); - m_FibWord2003.fcAfdEdn = reader.ReadUInt32(); - m_FibWord2003.lcbAfdEdn = reader.ReadUInt32(); - m_FibWord2003.fcAfd = reader.ReadUInt32(); - m_FibWord2003.lcbAfd = reader.ReadUInt32(); - } - if ( m_FibBase.nFib >= Fib2007 ) - { - //Read also the fibRgFcLcb2007 - m_FibWord2007.fcPlcfmthd = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfmthd = reader.ReadUInt32(); - m_FibWord2007.fcSttbfBkmkMoveFrom = reader.ReadUInt32(); - m_FibWord2007.lcbSttbfBkmkMoveFrom = reader.ReadUInt32(); - m_FibWord2007.fcPlcfBkfMoveFrom = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBkfMoveFrom= reader.ReadUInt32(); - m_FibWord2007.fcPlcfBklMoveFrom = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBklMoveFrom= reader.ReadUInt32(); - m_FibWord2007.fcSttbfBkmkMoveTo = reader.ReadUInt32(); - m_FibWord2007.lcbSttbfBkmkMoveTo= reader.ReadUInt32(); - m_FibWord2007.fcPlcfBkfMoveTo = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBkfMoveTo = reader.ReadUInt32(); - m_FibWord2007.fcPlcfBklMoveTo = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBklMoveTo = reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - m_FibWord2007.fcSttbfBkmkArto = reader.ReadUInt32(); - m_FibWord2007.lcbSttbfBkmkArto = reader.ReadUInt32(); - m_FibWord2007.fcPlcfBkfArto = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBkfArto = reader.ReadUInt32(); - m_FibWord2007.fcPlcfBklArto = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBklArto = reader.ReadUInt32(); - m_FibWord2007.fcArtoData = reader.ReadUInt32(); - m_FibWord2007.lcbArtoData = reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - m_FibWord2007.fcOssTheme = reader.ReadUInt32(); - m_FibWord2007.lcbOssTheme = reader.ReadUInt32(); - m_FibWord2007.fcColorSchemeMapping = reader.ReadUInt32(); - m_FibWord2007.lcbColorSchemeMapping = reader.ReadUInt32(); - } - - cswNew = reader.ReadUInt16(); - - if (cswNew != 0) - { - //Read the FibRgCswNew - m_FibNew.nFibNew = (FibVersion)reader.ReadUInt16(); - - if (m_FibNew.nFibNew == 0) m_FibNew.nFibNew = Fib1997; - - m_FibNew.cQuickSavesNew = reader.ReadUInt16(); - - if (m_FibNew.nFibNew == 0x00D9 || - m_FibNew.nFibNew == 0x0101 || - m_FibNew.nFibNew == 0x010C ) - { - } - else if (m_FibNew.nFibNew == 0x0112) - { - m_FibNew.lidThemeOther = reader.ReadUInt16(); - m_FibNew.lidThemeFE = reader.ReadUInt16(); - m_FibNew.lidThemeCS = reader.ReadUInt16(); - } - } - } - FileInformationBlock( VirtualStreamReader reader ) - { - m_nWordVersion = 0; - m_CodePage = 1250; - - unsigned int flag16 = 0; - unsigned char flag8 = 0; - - //read the FIB base - m_FibBase.wIdent = reader.ReadUInt16(); //0 - m_FibBase.nFib = (FibVersion)reader.ReadUInt16(); //2 - - reader.ReadBytes( 2, false ); //4 //nProduct - - m_FibBase.lid = reader.ReadUInt16(); //6 - m_FibBase.pnNext = reader.ReadInt16(); //8 - - flag16 = reader.ReadUInt16(); //10 - - m_FibBase.fDot = ((flag16 & 0x0001) >> 2) != 0; - m_FibBase.fGlsy = ((flag16 & 0x0002) >> 1) != 0; - m_FibBase.fComplex = ((flag16 & 0x0004) >> 2) != 0; - m_FibBase.fHasPic = ((flag16 & 0x0008) >> 3) != 0; - m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4); - m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100); - m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200); - m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400); - m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800); - m_FibBase.fExtChar = FormatUtils::BitmaskToBool((int)flag16, 0x1000); - m_FibBase.fLoadOverwrite = FormatUtils::BitmaskToBool((int)flag16, 0x2000); - m_FibBase.fFarEast = FormatUtils::BitmaskToBool((int)flag16, 0x4000); - m_FibBase.fObfuscation = FormatUtils::BitmaskToBool((int)flag16, 0x8000); - - m_FibBase.nFibBack = reader.ReadUInt16(); //12 - - if (m_FibBase.nFib < Fib1989) - { - m_FibWord2.Spare = reader.ReadInt32(); - m_FibWord2.rgwSpare0[0] = reader.ReadUInt16(); - m_FibWord2.rgwSpare0[1] = reader.ReadUInt16(); - m_FibWord2.rgwSpare0[2] = reader.ReadUInt16(); - } - else - { - m_FibBase.lKey = reader.ReadInt32(); //14 - m_FibBase.envr = reader.ReadByte(); //18 - - flag8 = reader.ReadByte(); //19 - - m_FibBase.fMac = FormatUtils::BitmaskToBool((int)flag8, 0x01); - m_FibBase.fEmptySpecial = FormatUtils::BitmaskToBool((int)flag8, 0x02); - m_FibBase.fLoadOverridePage = FormatUtils::BitmaskToBool((int)flag8, 0x04); - m_FibBase.fFutureSavedUndo = FormatUtils::BitmaskToBool((int)flag8, 0x08); - m_FibBase.fWord97Saved = FormatUtils::BitmaskToBool((int)flag8, 0x10); - - reader.ReadBytes( 4, false ); //20 - } - - m_FibBase.fcMin = reader.ReadInt32(); //24 - m_FibBase.fcMac = reader.ReadInt32(); //28 - - if (m_FibBase.nFib > Fib1995) - csw = reader.ReadUInt16(); //32 - - if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995) - { - m_RgLw97.cbMac = reader.ReadInt32();//32 - } - else if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0) - { - //read the RgW97 - int reserv1 = reader.ReadUInt16(); - int reserv2 = reader.ReadUInt16(); - int reserv3 = reader.ReadUInt16(); - int reserv4 = reader.ReadUInt16(); - int reserv5 = reader.ReadUInt16(); - int reserv6 = reader.ReadUInt16(); - int reserv7 = reader.ReadUInt16(); - int reserv8 = reader.ReadUInt16(); - int reserv9 = reader.ReadUInt16(); - int reserv10 = reader.ReadUInt16(); - int reserv11 = reader.ReadUInt16(); - int reserv12 = reader.ReadUInt16(); - int reserv13 = reader.ReadUInt16(); - - m_RgW97.lidFE = reader.ReadUInt16(); //60 - - cslw = reader.ReadUInt16(); //62 - - //read the RgLW97 - - m_RgLw97.cbMac = reader.ReadInt32(); //64 - } - reset(reader); - } + FileInformationBlock( VirtualStreamReader reader ); }; } diff --git a/MsBinaryFile/DocFile/FixedPointNumber.cpp b/MsBinaryFile/DocFile/FixedPointNumber.cpp new file mode 100644 index 0000000000..4d4cf74bdc --- /dev/null +++ b/MsBinaryFile/DocFile/FixedPointNumber.cpp @@ -0,0 +1,83 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FixedPointNumber.h" +#include "../Common/Base/FormatUtils.h" + +namespace DocFileFormat +{ + FixedPointNumber::FixedPointNumber( unsigned short integral, unsigned short fractional ) + { + this->Integral = integral; + this->Fractional = fractional; + } + + FixedPointNumber::FixedPointNumber( _UINT32 value ) + { + unsigned short* bytes = (unsigned short*)(&value); + + this->Integral = bytes[0]; + this->Fractional = bytes[1]; + } + + FixedPointNumber::FixedPointNumber( const unsigned char* bytes, unsigned int size ) + { + if ( ( bytes != NULL ) && ( size >= 4 ) ) + { + this->Integral = FormatUtils::BytesToUInt16( bytes, 0, size ); + this->Fractional = FormatUtils::BytesToUInt16( bytes, 2, size ); + } + } + + double FixedPointNumber::ToAngle() const + { + if ( this->Fractional != 0 ) + { + // negative angle + return ( this->Fractional - 65536.0 ); + } + else if ( this->Integral != 0 ) + { + //positive angle + return ( 65536.0 - this->Integral ); + } + else + { + return 0.0; + } + } + + double FixedPointNumber::GetValue() const + { + return (double)( this->Integral + ( (double)this->Fractional / 65536.0 ) ); + } +} diff --git a/MsBinaryFile/DocFile/FixedPointNumber.h b/MsBinaryFile/DocFile/FixedPointNumber.h index 0e596f17ee..7461cf4f89 100644 --- a/MsBinaryFile/DocFile/FixedPointNumber.h +++ b/MsBinaryFile/DocFile/FixedPointNumber.h @@ -31,6 +31,8 @@ */ #pragma once +#include "../../OOXML/Base/Base.h" + namespace DocFileFormat { /// Specifies an approximation of a real number, where the approximation has a fixed number of digits after the radix point. @@ -47,50 +49,11 @@ namespace DocFileFormat unsigned short Integral; unsigned short Fractional; - FixedPointNumber( unsigned short integral = 0, unsigned short fractional = 0 ) - { - this->Integral = integral; - this->Fractional = fractional; - } + FixedPointNumber( unsigned short integral = 0, unsigned short fractional = 0 ); + FixedPointNumber( _UINT32 value ); + FixedPointNumber( const unsigned char* bytes, unsigned int size ); - FixedPointNumber( _UINT32 value ) - { - unsigned short* bytes = (unsigned short*)(&value); - - this->Integral = bytes[0]; - this->Fractional = bytes[1]; - } - - FixedPointNumber( const unsigned char* bytes, unsigned int size ) - { - if ( ( bytes != NULL ) && ( size >= 4 ) ) - { - this->Integral = FormatUtils::BytesToUInt16( bytes, 0, size ); - this->Fractional = FormatUtils::BytesToUInt16( bytes, 2, size ); - } - } - - double ToAngle() const - { - if ( this->Fractional != 0 ) - { - // negative angle - return ( this->Fractional - 65536.0 ); - } - else if ( this->Integral != 0 ) - { - //positive angle - return ( 65536.0 - this->Integral ); - } - else - { - return 0.0; - } - } - - double GetValue() const - { - return (double)( this->Integral + ( (double)this->Fractional / 65536.0 ) ); - } + double ToAngle() const; + double GetValue() const; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/FootnoteDescriptor.cpp b/MsBinaryFile/DocFile/FootnoteDescriptor.cpp new file mode 100644 index 0000000000..dce7f16f12 --- /dev/null +++ b/MsBinaryFile/DocFile/FootnoteDescriptor.cpp @@ -0,0 +1,51 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FootnoteDescriptor.h" + +namespace DocFileFormat +{ + FootnoteDescriptor::FootnoteDescriptor() : aFtnIdx(0), bUsed(false) {} + + FootnoteDescriptor::~FootnoteDescriptor() + { + } + + ByteStructure* FootnoteDescriptor::ConstructObject( VirtualStreamReader* reader, int length ) + { + FootnoteDescriptor *newObject = new FootnoteDescriptor(); + + newObject->aFtnIdx = reader->ReadInt16(); + + return static_cast( newObject ); + } +} diff --git a/MsBinaryFile/DocFile/FootnoteDescriptor.h b/MsBinaryFile/DocFile/FootnoteDescriptor.h index ba587e91c7..5f4320af7f 100644 --- a/MsBinaryFile/DocFile/FootnoteDescriptor.h +++ b/MsBinaryFile/DocFile/FootnoteDescriptor.h @@ -35,27 +35,18 @@ namespace DocFileFormat { - class FootnoteDescriptor: public ByteStructure - { + class FootnoteDescriptor: public ByteStructure + { - public: - static const int STRUCTURE_SIZE = 2; + public: + static const int STRUCTURE_SIZE = 2; - FootnoteDescriptor() : aFtnIdx(0), bUsed(false) {} + FootnoteDescriptor(); + virtual ~FootnoteDescriptor(); - virtual ~FootnoteDescriptor() - { - } - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - FootnoteDescriptor *newObject = new FootnoteDescriptor(); + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); - newObject->aFtnIdx = reader->ReadInt16(); - - return static_cast( newObject ); - } - - short aFtnIdx; - bool bUsed; - }; + short aFtnIdx; + bool bUsed; + }; } diff --git a/MsBinaryFile/DocFile/FootnotesMapping.cpp b/MsBinaryFile/DocFile/FootnotesMapping.cpp new file mode 100644 index 0000000000..f84bcfef92 --- /dev/null +++ b/MsBinaryFile/DocFile/FootnotesMapping.cpp @@ -0,0 +1,133 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FootnotesMapping.h" +#include "TableMapping.h" + +namespace DocFileFormat +{ + FootnotesMapping::FootnotesMapping (ConversionContext* ctx): DocumentMapping( ctx, this ) + { + } + + void FootnotesMapping::Apply( IVisitable* visited ) + { + m_document = static_cast( visited ); + + if ( m_document && ( m_document->FIB->m_RgLw97.ccpFtn > 0 ) ) + { + m_context->_docx->RegisterFootnotes(); + + int id = 0; + + m_pXmlWriter->WriteNodeBegin( L"w:footnotes", TRUE ); + + //write namespaces + 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: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"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main" ); + m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" ); + m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 wp14" ); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + //m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE ); + //m_pXmlWriter->WriteAttribute( L"w:type", L"separator"); + //m_pXmlWriter->WriteAttribute( L"w:id", L"-1"); + //m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + //m_pXmlWriter->WriteString(L""); + //m_pXmlWriter->WriteNodeEnd( L"w:footnote"); + + //m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE ); + //m_pXmlWriter->WriteAttribute( L"w:type", L"continuationSeparator"); + //m_pXmlWriter->WriteAttribute( L"w:id", L"0"); + //m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + //m_pXmlWriter->WriteString(L""); + //m_pXmlWriter->WriteNodeEnd( L"w:footnote"); + + int cp = m_document->FIB->m_RgLw97.ccpText; + + while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn - 2 ) ) + { + m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE ); + m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( id )); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + while ( ( cp - m_document->FIB->m_RgLw97.ccpText ) < (*m_document->IndividualFootnotesPlex)[id + 1] ) + { + int cpStart = cp; + + int fc = m_document->FindFileCharPos(cp); + if (fc < 0) break; + + ParagraphPropertyExceptions* papx = findValidPapx( fc ); + TableInfo tai( papx, m_document->nWordVersion ); + + if ( tai.fInTable ) + { + //this PAPX is for a table + Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) ); + table.Convert( this ); + cp = table.GetCPEnd(); + } + else + { + //this PAPX is for a normal paragraph + cp = writeParagraph( cp, 0x7fffffff ); + } + while (cp <= cpStart) //conv_fQioC665ib4ngHkDGY4__docx.doc + cp++; + } + + m_pXmlWriter->WriteNodeEnd( L"w:footnote"); + id++; + } + + m_pXmlWriter->WriteNodeEnd( L"w:footnotes"); + + m_context->_docx->FootnotesXML = std::wstring(m_pXmlWriter->GetXmlString()); + } + } +} diff --git a/MsBinaryFile/DocFile/FootnotesMapping.h b/MsBinaryFile/DocFile/FootnotesMapping.h index 4165fec2ee..fec13c6004 100644 --- a/MsBinaryFile/DocFile/FootnotesMapping.h +++ b/MsBinaryFile/DocFile/FootnotesMapping.h @@ -40,100 +40,8 @@ namespace DocFileFormat class FootnotesMapping: public DocumentMapping { public: - FootnotesMapping (ConversionContext* ctx): DocumentMapping( ctx, this ) - { - } + FootnotesMapping (ConversionContext* ctx); - virtual void Apply( IVisitable* visited ) - { - m_document = static_cast( visited ); - - if ( m_document && ( m_document->FIB->m_RgLw97.ccpFtn > 0 ) ) - { - m_context->_docx->RegisterFootnotes(); - - int id = 0; - - m_pXmlWriter->WriteNodeBegin( L"w:footnotes", TRUE ); - - //write namespaces - 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: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"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main" ); - m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" ); - m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 wp14" ); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - //m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE ); - //m_pXmlWriter->WriteAttribute( L"w:type", L"separator"); - //m_pXmlWriter->WriteAttribute( L"w:id", L"-1"); - //m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - //m_pXmlWriter->WriteString(L""); - //m_pXmlWriter->WriteNodeEnd( L"w:footnote"); - - //m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE ); - //m_pXmlWriter->WriteAttribute( L"w:type", L"continuationSeparator"); - //m_pXmlWriter->WriteAttribute( L"w:id", L"0"); - //m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - //m_pXmlWriter->WriteString(L""); - //m_pXmlWriter->WriteNodeEnd( L"w:footnote"); - - int cp = m_document->FIB->m_RgLw97.ccpText; - - while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn - 2 ) ) - { - m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE ); - m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( id )); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - while ( ( cp - m_document->FIB->m_RgLw97.ccpText ) < (*m_document->IndividualFootnotesPlex)[id + 1] ) - { - int cpStart = cp; - - int fc = m_document->FindFileCharPos(cp); - if (fc < 0) break; - - ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx, m_document->nWordVersion ); - - if ( tai.fInTable ) - { - //this PAPX is for a table - Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) ); - table.Convert( this ); - cp = table.GetCPEnd(); - } - else - { - //this PAPX is for a normal paragraph - cp = writeParagraph( cp, 0x7fffffff ); - } - while (cp <= cpStart) //conv_fQioC665ib4ngHkDGY4__docx.doc - cp++; - } - - m_pXmlWriter->WriteNodeEnd( L"w:footnote"); - id++; - } - - m_pXmlWriter->WriteNodeEnd( L"w:footnotes"); - - m_context->_docx->FootnotesXML = std::wstring(m_pXmlWriter->GetXmlString()); - } - } + virtual void Apply( IVisitable* visited ); }; } diff --git a/MsBinaryFile/DocFile/FormFieldDataMapping.cpp b/MsBinaryFile/DocFile/FormFieldDataMapping.cpp new file mode 100644 index 0000000000..daf8ece8b1 --- /dev/null +++ b/MsBinaryFile/DocFile/FormFieldDataMapping.cpp @@ -0,0 +1,136 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FormFieldDataMapping.h" + +namespace DocFileFormat +{ + FormFieldDataMapping::FormFieldDataMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, IMapping* caller) + : AbstractOpenXmlMapping(writer), m_context(NULL),_caller(NULL) + { + m_context = context; + _caller = caller; + } + + void FormFieldDataMapping::Apply(IVisitable* visited) + { + FormFieldData* ffData = static_cast(visited); + + if ( ffData == NULL ) return; + + if (ffData->FFData.bExist) + { + m_pXmlWriter->WriteNodeBegin( L"w:ffData"); + + m_pXmlWriter->WriteNodeBegin( L"w:name", true); + m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzName)); + m_pXmlWriter->WriteNodeEnd(L"w:name", true, true ); + + m_pXmlWriter->WriteNodeBegin(L"w:enabled", true); + if (ffData->FFData.fProt) + m_pXmlWriter->WriteAttribute(L"w:val", 0); + m_pXmlWriter->WriteNodeEnd(L"w:enabled", true, true); + + m_pXmlWriter->WriteNodeBegin( L"w:calcOnExit", true); + m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.fRecalc); + m_pXmlWriter->WriteNodeEnd(L"w:calcOnExit", true, true ); + + if (false == ffData->FFData.xstzHelpText.empty()) + { + m_pXmlWriter->WriteNodeBegin(L"w:helpText", true); + m_pXmlWriter->WriteAttribute(L"w:type", ffData->FFData.fOwnHelp ? L"text" : L"autoText"); + m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzHelpText)); + m_pXmlWriter->WriteNodeEnd(L"w:helpText", true, true); + } + if (false == ffData->FFData.xstzStatText.empty()) + { + m_pXmlWriter->WriteNodeBegin(L"w:statusText", true); + m_pXmlWriter->WriteAttribute(L"w:type", ffData->FFData.fOwnStat ? L"text" : L"autoText"); + m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzStatText)); + m_pXmlWriter->WriteNodeEnd(L"w:statusText", true, true); + } + if (false == ffData->FFData.xstzEntryMcr.empty()) + { + m_pXmlWriter->WriteNodeBegin(L"w:entryMacro", true); + m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzEntryMcr)); + m_pXmlWriter->WriteNodeEnd(L"w:entryMacro", true, true); + } + if (false == ffData->FFData.xstzExitMcr.empty()) + { + m_pXmlWriter->WriteNodeBegin(L"w:exitMacro", true); + m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzExitMcr)); + m_pXmlWriter->WriteNodeEnd(L"w:exitMacro", true, true); + } + if (ffData->FFData.iType == 1) + { + m_pXmlWriter->WriteNodeBegin(L"w:checkBox"); + + if (ffData->FFData.iSize) + { + m_pXmlWriter->WriteNodeBegin(L"w:size", true); + m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.hps); + m_pXmlWriter->WriteNodeEnd(L"w:size", true, true); + } + else + { + m_pXmlWriter->WriteNodeBegin(L"w:sizeAuto", true); + m_pXmlWriter->WriteNodeEnd(L"w:sizeAuto", true, true); + } + + m_pXmlWriter->WriteNodeBegin(L"w:default", true); + m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.wDef); + m_pXmlWriter->WriteNodeEnd(L"w:default", true, true); + + m_pXmlWriter->WriteNodeEnd(L"w:checkBox"); + } + else if (ffData->FFData.iType == 2) + { + m_pXmlWriter->WriteNodeBegin(L"w:ddList"); + + + m_pXmlWriter->WriteNodeEnd(L"w:ddList"); + } + else + { + m_pXmlWriter->WriteNodeBegin(L"w:textInput"); + + m_pXmlWriter->WriteNodeBegin(L"w:maxLength", true); + m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.cch_field); + m_pXmlWriter->WriteNodeEnd(L"w:maxLength", true, true); + + m_pXmlWriter->WriteNodeEnd(L"w:textInput"); + } + + m_pXmlWriter->WriteNodeEnd( L"w:ffData" ); + } + } +} diff --git a/MsBinaryFile/DocFile/FormFieldDataMapping.h b/MsBinaryFile/DocFile/FormFieldDataMapping.h index 13abb9324a..df04137787 100644 --- a/MsBinaryFile/DocFile/FormFieldDataMapping.h +++ b/MsBinaryFile/DocFile/FormFieldDataMapping.h @@ -42,106 +42,9 @@ namespace DocFileFormat class FormFieldDataMapping: public AbstractOpenXmlMapping, public IMapping { public: - FormFieldDataMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, IMapping* caller) - : AbstractOpenXmlMapping(writer), m_context(NULL),_caller(NULL) - { - m_context = context; - _caller = caller; - } - - virtual void Apply(IVisitable* visited) - { - FormFieldData* ffData = static_cast(visited); - - if ( ffData == NULL ) return; - - if (ffData->FFData.bExist) - { - m_pXmlWriter->WriteNodeBegin( L"w:ffData"); - - m_pXmlWriter->WriteNodeBegin( L"w:name", true); - m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzName)); - m_pXmlWriter->WriteNodeEnd(L"w:name", true, true ); - - m_pXmlWriter->WriteNodeBegin(L"w:enabled", true); - if (ffData->FFData.fProt) - m_pXmlWriter->WriteAttribute(L"w:val", 0); - m_pXmlWriter->WriteNodeEnd(L"w:enabled", true, true); - - m_pXmlWriter->WriteNodeBegin( L"w:calcOnExit", true); - m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.fRecalc); - m_pXmlWriter->WriteNodeEnd(L"w:calcOnExit", true, true ); - - if (false == ffData->FFData.xstzHelpText.empty()) - { - m_pXmlWriter->WriteNodeBegin(L"w:helpText", true); - m_pXmlWriter->WriteAttribute(L"w:type", ffData->FFData.fOwnHelp ? L"text" : L"autoText"); - m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzHelpText)); - m_pXmlWriter->WriteNodeEnd(L"w:helpText", true, true); - } - if (false == ffData->FFData.xstzStatText.empty()) - { - m_pXmlWriter->WriteNodeBegin(L"w:statusText", true); - m_pXmlWriter->WriteAttribute(L"w:type", ffData->FFData.fOwnStat ? L"text" : L"autoText"); - m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzStatText)); - m_pXmlWriter->WriteNodeEnd(L"w:statusText", true, true); - } - if (false == ffData->FFData.xstzEntryMcr.empty()) - { - m_pXmlWriter->WriteNodeBegin(L"w:entryMacro", true); - m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzEntryMcr)); - m_pXmlWriter->WriteNodeEnd(L"w:entryMacro", true, true); - } - if (false == ffData->FFData.xstzExitMcr.empty()) - { - m_pXmlWriter->WriteNodeBegin(L"w:exitMacro", true); - m_pXmlWriter->WriteAttribute(L"w:val", XmlUtils::EncodeXmlString(ffData->FFData.xstzExitMcr)); - m_pXmlWriter->WriteNodeEnd(L"w:exitMacro", true, true); - } - if (ffData->FFData.iType == 1) - { - m_pXmlWriter->WriteNodeBegin(L"w:checkBox"); - - if (ffData->FFData.iSize) - { - m_pXmlWriter->WriteNodeBegin(L"w:size", true); - m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.hps); - m_pXmlWriter->WriteNodeEnd(L"w:size", true, true); - } - else - { - m_pXmlWriter->WriteNodeBegin(L"w:sizeAuto", true); - m_pXmlWriter->WriteNodeEnd(L"w:sizeAuto", true, true); - } - - m_pXmlWriter->WriteNodeBegin(L"w:default", true); - m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.wDef); - m_pXmlWriter->WriteNodeEnd(L"w:default", true, true); - - m_pXmlWriter->WriteNodeEnd(L"w:checkBox"); - } - else if (ffData->FFData.iType == 2) - { - m_pXmlWriter->WriteNodeBegin(L"w:ddList"); - - - m_pXmlWriter->WriteNodeEnd(L"w:ddList"); - } - else - { - m_pXmlWriter->WriteNodeBegin(L"w:textInput"); - - m_pXmlWriter->WriteNodeBegin(L"w:maxLength", true); - m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.cch_field); - m_pXmlWriter->WriteNodeEnd(L"w:maxLength", true, true); - - m_pXmlWriter->WriteNodeEnd(L"w:textInput"); - } - - m_pXmlWriter->WriteNodeEnd( L"w:ffData" ); - } - } + FormFieldDataMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, IMapping* caller); + virtual void Apply(IVisitable* visited); private: ConversionContext* m_context; diff --git a/MsBinaryFile/DocFile/FormattedDiskPage.cpp b/MsBinaryFile/DocFile/FormattedDiskPage.cpp new file mode 100644 index 0000000000..bac3581056 --- /dev/null +++ b/MsBinaryFile/DocFile/FormattedDiskPage.cpp @@ -0,0 +1,40 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "FormattedDiskPage.h" + +namespace DocFileFormat +{ + FormattedDiskPage::FormattedDiskPage(): Type(Character), WordStream(NULL), crun(0), rgfc(NULL), rgfcSize(0) + { + } +} diff --git a/MsBinaryFile/DocFile/FormattedDiskPage.h b/MsBinaryFile/DocFile/FormattedDiskPage.h index bbf3c19069..b7dd1e40d5 100644 --- a/MsBinaryFile/DocFile/FormattedDiskPage.h +++ b/MsBinaryFile/DocFile/FormattedDiskPage.h @@ -60,8 +60,6 @@ namespace DocFileFormat unsigned int rgfcSize; public: - FormattedDiskPage(): Type(Character), WordStream(NULL), crun(0), rgfc(NULL), rgfcSize(0) - { - } + FormattedDiskPage(); }; } diff --git a/MsBinaryFile/DocFile/LanguageId.cpp b/MsBinaryFile/DocFile/LanguageId.cpp new file mode 100644 index 0000000000..a9e0c058b0 --- /dev/null +++ b/MsBinaryFile/DocFile/LanguageId.cpp @@ -0,0 +1,42 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "LanguageId.h" + +namespace DocFileFormat +{ + LanguageId::LanguageId( int id ) + { + this->Id = id; + this->Code = (LanguageCode)id; + } +} diff --git a/MsBinaryFile/DocFile/LanguageId.h b/MsBinaryFile/DocFile/LanguageId.h index 203efe24e3..06387044b7 100644 --- a/MsBinaryFile/DocFile/LanguageId.h +++ b/MsBinaryFile/DocFile/LanguageId.h @@ -42,10 +42,6 @@ namespace DocFileFormat int Id; LanguageCode Code; - LanguageId( int id ) - { - this->Id = id; - this->Code = (LanguageCode)id; - } + LanguageId( int id ); }; } diff --git a/MsBinaryFile/DocFile/LineSpacingDescriptor.cpp b/MsBinaryFile/DocFile/LineSpacingDescriptor.cpp new file mode 100644 index 0000000000..d82a52feb2 --- /dev/null +++ b/MsBinaryFile/DocFile/LineSpacingDescriptor.cpp @@ -0,0 +1,58 @@ +/* +* (c) Copyright Ascensio System SIA 2010-2019 +* +* 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 20A-12 Ernesta Birznieka-Upisha +* street, Riga, Latvia, EU, LV-1050. +* +* 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 "LineSpacingDescriptor.h" +#include "../Common/Base/FormatUtils.h" + +namespace DocFileFormat +{ + /// Creates a new LineSpacingDescriptor with empty values + LineSpacingDescriptor::LineSpacingDescriptor(): dyaLine(0), fMultLinespace(false) + { + } + + /// Parses the bytes to retrieve a LineSpacingDescriptor + LineSpacingDescriptor::LineSpacingDescriptor( unsigned char* bytes, int size ) : dyaLine(0), fMultLinespace(false) + { + dyaLine = FormatUtils::BytesToInt16( bytes, 0, size ); + + if ( FormatUtils::BytesToInt16( bytes, 2, size ) == 1 ) + { + fMultLinespace = true; + } + + if ( size > 4 ) + { + } + + } +} diff --git a/MsBinaryFile/DocFile/LineSpacingDescriptor.h b/MsBinaryFile/DocFile/LineSpacingDescriptor.h index b8e1a36766..619e8053d7 100644 --- a/MsBinaryFile/DocFile/LineSpacingDescriptor.h +++ b/MsBinaryFile/DocFile/LineSpacingDescriptor.h @@ -43,24 +43,9 @@ namespace DocFileFormat public: /// Creates a new LineSpacingDescriptor with empty values - LineSpacingDescriptor(): dyaLine(0), fMultLinespace(false) - { - } + LineSpacingDescriptor(); /// Parses the bytes to retrieve a LineSpacingDescriptor - LineSpacingDescriptor( unsigned char* bytes, int size ) : dyaLine(0), fMultLinespace(false) - { - dyaLine = FormatUtils::BytesToInt16( bytes, 0, size ); - - if ( FormatUtils::BytesToInt16( bytes, 2, size ) == 1 ) - { - fMultLinespace = true; - } - - if ( size > 4 ) - { - } - - } + LineSpacingDescriptor( unsigned char* bytes, int size ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/ListFormatOverride.cpp b/MsBinaryFile/DocFile/ListFormatOverride.cpp new file mode 100644 index 0000000000..1adf777cd8 --- /dev/null +++ b/MsBinaryFile/DocFile/ListFormatOverride.cpp @@ -0,0 +1,66 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ListFormatOverride.h" + +namespace DocFileFormat +{ + /// Parses the given Stream Reader to retrieve a ListFormatOverride + ListFormatOverride::ListFormatOverride( VirtualStreamReader* reader, int length ): + lsid(0), clfolvl(0), ibstFltAutoNum(0), grfhic(0) + { + long startPos = reader->GetPosition(); + + this->lsid = reader->ReadInt32(); + reader->ReadBytes( 8, false ); + this->clfolvl = reader->ReadByte(); + this->ibstFltAutoNum = reader->ReadByte(); + this->grfhic = reader->ReadByte(); + reader->ReadByte(); + + if ( this->clfolvl != 0 ) + { + this->rgLfoLvl = std::vector( this->clfolvl ); + } + + reader->Seek( startPos, 0/*STREAM_SEEK_SET*/ ); + reader->ReadBytes( LFO_LENGTH, false ); + } + + ListFormatOverride::~ListFormatOverride() + { + for ( std::vector::iterator iter = this->rgLfoLvl.begin(); iter != this->rgLfoLvl.end(); iter++ ) + { + RELEASEOBJECT( *iter ); + } + } +} diff --git a/MsBinaryFile/DocFile/ListFormatOverride.h b/MsBinaryFile/DocFile/ListFormatOverride.h index 2b97fd9f0a..d1e77ac8e6 100644 --- a/MsBinaryFile/DocFile/ListFormatOverride.h +++ b/MsBinaryFile/DocFile/ListFormatOverride.h @@ -62,33 +62,7 @@ namespace DocFileFormat public: /// Parses the given Stream Reader to retrieve a ListFormatOverride - ListFormatOverride( VirtualStreamReader* reader, int length ): - lsid(0), clfolvl(0), ibstFltAutoNum(0), grfhic(0) - { - long startPos = reader->GetPosition(); - - this->lsid = reader->ReadInt32(); - reader->ReadBytes( 8, false ); - this->clfolvl = reader->ReadByte(); - this->ibstFltAutoNum = reader->ReadByte(); - this->grfhic = reader->ReadByte(); - reader->ReadByte(); - - if ( this->clfolvl != 0 ) - { - this->rgLfoLvl = std::vector( this->clfolvl ); - } - - reader->Seek( startPos, 0/*STREAM_SEEK_SET*/ ); - reader->ReadBytes( LFO_LENGTH, false ); - } - - virtual ~ListFormatOverride() - { - for ( std::vector::iterator iter = this->rgLfoLvl.begin(); iter != this->rgLfoLvl.end(); iter++ ) - { - RELEASEOBJECT( *iter ); - } - } + ListFormatOverride( VirtualStreamReader* reader, int length ); + virtual ~ListFormatOverride(); }; } diff --git a/MsBinaryFile/DocFile/ListFormatOverrideLevel.cpp b/MsBinaryFile/DocFile/ListFormatOverrideLevel.cpp new file mode 100644 index 0000000000..7887385d0e --- /dev/null +++ b/MsBinaryFile/DocFile/ListFormatOverrideLevel.cpp @@ -0,0 +1,63 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ListFormatOverrideLevel.h" + +namespace DocFileFormat +{ + ListFormatOverrideLevel::ListFormatOverrideLevel(): + iStartAt(0), ilvl(0), fStartAt(false), fFormatting(false), grfhic(0), lvl(NULL) + { + } + ListFormatOverrideLevel::~ListFormatOverrideLevel() + { + RELEASEOBJECT( this->lvl ); + } + + /// Parses the bytes to retrieve a ListFormatOverrideLevel + ListFormatOverrideLevel::ListFormatOverrideLevel( VirtualStreamReader* reader, int length ): + iStartAt(0), ilvl(0), fStartAt(false), fFormatting(false), grfhic(0), lvl(NULL) + { + this->iStartAt = reader->ReadInt32(); + unsigned int flag = (int)reader->ReadUInt32(); + this->ilvl = (unsigned char)( flag & 0x000F ); + this->fStartAt = FormatUtils::BitmaskToBool( flag, 0x0010 ); + this->fFormatting = FormatUtils::BitmaskToBool( flag, 0x0020 ); + this->grfhic = FormatUtils::GetIntFromBits( flag, 6, 8 ); + + //it's a complete override, so the fix part is followed by LVL struct + if ( this->fFormatting ) + { + this->lvl = new ListLevel( reader, length ); + } + } +} diff --git a/MsBinaryFile/DocFile/ListFormatOverrideLevel.h b/MsBinaryFile/DocFile/ListFormatOverrideLevel.h index 0b54265871..59ae1122a2 100644 --- a/MsBinaryFile/DocFile/ListFormatOverrideLevel.h +++ b/MsBinaryFile/DocFile/ListFormatOverrideLevel.h @@ -56,32 +56,10 @@ namespace DocFileFormat public: - ListFormatOverrideLevel(): - iStartAt(0), ilvl(0), fStartAt(false), fFormatting(false), grfhic(0), lvl(NULL) - { - } - - virtual ~ListFormatOverrideLevel() - { - RELEASEOBJECT( this->lvl ); - } + ListFormatOverrideLevel(); + virtual ~ListFormatOverrideLevel(); /// Parses the bytes to retrieve a ListFormatOverrideLevel - ListFormatOverrideLevel( VirtualStreamReader* reader, int length ): - iStartAt(0), ilvl(0), fStartAt(false), fFormatting(false), grfhic(0), lvl(NULL) - { - this->iStartAt = reader->ReadInt32(); - unsigned int flag = (int)reader->ReadUInt32(); - this->ilvl = (unsigned char)( flag & 0x000F ); - this->fStartAt = FormatUtils::BitmaskToBool( flag, 0x0010 ); - this->fFormatting = FormatUtils::BitmaskToBool( flag, 0x0020 ); - this->grfhic = FormatUtils::GetIntFromBits( flag, 6, 8 ); - - //it's a complete override, so the fix part is followed by LVL struct - if ( this->fFormatting ) - { - this->lvl = new ListLevel( reader, length ); - } - } + ListFormatOverrideLevel( VirtualStreamReader* reader, int length ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/ListFormatOverrideTable.cpp b/MsBinaryFile/DocFile/ListFormatOverrideTable.cpp new file mode 100644 index 0000000000..e0e7cfe9ba --- /dev/null +++ b/MsBinaryFile/DocFile/ListFormatOverrideTable.cpp @@ -0,0 +1,74 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ListFormatOverrideTable.h" + +namespace DocFileFormat +{ + ListFormatOverrideTable::ListFormatOverrideTable( FileInformationBlock* fib, POLE::Stream* tableStream ) + { + if ( fib->m_FibWord97.lcbPlfLfo > 0 ) + { + VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_nWordVersion); + + if (fib->m_FibWord97.fcPlfLfo > reader.GetSize()) return; + + //read the count of LFOs + int count = reader.ReadInt32(); + + //read the LFOs + for ( int i = 0; i < count; i++ ) + { + this->push_back( new ListFormatOverride( &reader, LFO_LENGTH ) ); + } + + //read the LFOLVLs + for ( int i = 0; i < count; i++ ) + { + this->cps.push_back( reader.ReadUInt32() ); + + for ( int j = 0; j < this->at( i )->clfolvl; j++ ) + { + this->at( i )->rgLfoLvl[j] = new ListFormatOverrideLevel( &reader, LFOLVL_LENGTH ); + } + } + } + } + + ListFormatOverrideTable::~ListFormatOverrideTable() + { + for ( vector::iterator iter = this->begin(); iter != this->end(); iter++ ) + { + RELEASEOBJECT( *iter ); + } + } +} diff --git a/MsBinaryFile/DocFile/ListFormatOverrideTable.h b/MsBinaryFile/DocFile/ListFormatOverrideTable.h index 3da8e37681..054afa3371 100644 --- a/MsBinaryFile/DocFile/ListFormatOverrideTable.h +++ b/MsBinaryFile/DocFile/ListFormatOverrideTable.h @@ -37,50 +37,15 @@ namespace DocFileFormat { - class ListFormatOverrideTable: public std::vector - { - private: - static const int LFO_LENGTH = 16; - static const int LFOLVL_LENGTH = 6; - std::vector cps; + class ListFormatOverrideTable: public std::vector + { + private: + static const int LFO_LENGTH = 16; + static const int LFOLVL_LENGTH = 6; + std::vector cps; - public: - ListFormatOverrideTable( FileInformationBlock* fib, POLE::Stream* tableStream ) - { - if ( fib->m_FibWord97.lcbPlfLfo > 0 ) - { - VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_nWordVersion); - - if (fib->m_FibWord97.fcPlfLfo > reader.GetSize()) return; - - //read the count of LFOs - int count = reader.ReadInt32(); - - //read the LFOs - for ( int i = 0; i < count; i++ ) - { - this->push_back( new ListFormatOverride( &reader, LFO_LENGTH ) ); - } - - //read the LFOLVLs - for ( int i = 0; i < count; i++ ) - { - this->cps.push_back( reader.ReadUInt32() ); - - for ( int j = 0; j < this->at( i )->clfolvl; j++ ) - { - this->at( i )->rgLfoLvl[j] = new ListFormatOverrideLevel( &reader, LFOLVL_LENGTH ); - } - } - } - } - - virtual ~ListFormatOverrideTable() - { - for ( vector::iterator iter = this->begin(); iter != this->end(); iter++ ) - { - RELEASEOBJECT( *iter ); - } - } - }; -} \ No newline at end of file + public: + ListFormatOverrideTable( FileInformationBlock* fib, POLE::Stream* tableStream ); + virtual ~ListFormatOverrideTable(); + }; +} diff --git a/MsBinaryFile/DocFile/MemoryStream.cpp b/MsBinaryFile/DocFile/MemoryStream.cpp new file mode 100644 index 0000000000..3ed74c3be0 --- /dev/null +++ b/MsBinaryFile/DocFile/MemoryStream.cpp @@ -0,0 +1,216 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "MemoryStream.h" + +MemoryStream::MemoryStream (unsigned char* data, unsigned long size, bool bMemCopy) : m_Data(NULL), m_Size(0), m_Position(0), bMemoryCopy(bMemCopy) +{ + if ( ( data != NULL ) && ( size != 0 ) ) + { + m_Size = size; + + if (bMemoryCopy) + { + m_Data = new unsigned char[m_Size]; + if (m_Data) + { + memcpy (m_Data, data, m_Size); + } + } + else + { + m_Data = data; + } + } +} +MemoryStream::~MemoryStream() +{ + if (bMemoryCopy) + RELEASEARRAYOBJECTS (m_Data); +} +_UINT64 MemoryStream::ReadUInt64() +{ + _UINT64 rdU64 = 0; + + if (m_Data) + { + rdU64 = DocFileFormat::FormatUtils::BytesToUInt64(m_Data, m_Position, m_Size); + m_Position += 8; + } + + return rdU64; +} +unsigned short MemoryStream::ReadUInt16() +{ + unsigned short rdUShort = 0; + + if (m_Data) + { + rdUShort = DocFileFormat::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size); + m_Position += 2; + } + + return rdUShort; +} +void MemoryStream::WriteUInt16(unsigned short val) +{ + if (m_Data && (m_Position + sizeof(unsigned short) <= m_Size)) + { + ((unsigned short *)(m_Data + m_Position))[0] = val; + m_Position += 2; + } +} +short MemoryStream::ReadInt16() +{ + short rdShort = 0; + + if (m_Data) + { + rdShort = DocFileFormat::FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size); + m_Position += 2; + } + + return rdShort; +} + +int MemoryStream::ReadInt32() +{ + int rdInt = 0; + + if (m_Data) + { + rdInt = DocFileFormat::FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size); + m_Position += 4; + } + + return rdInt; +} +void MemoryStream::WriteInt32(_INT32 val) +{ + if (m_Data && (m_Position + sizeof(_INT32) <= m_Size)) + { + ((_INT32 *)(m_Data + m_Position))[0] = val; + m_Position += 4; + } +} +void MemoryStream::Align(_UINT32 val) +{ + _UINT32 padding = val - (m_Position % val); + + if (padding > 0 && padding < 4) + m_Position += padding; +} + +unsigned int MemoryStream::ReadUInt32() +{ + int rdUInt = 0; + + if (m_Data ) + { + rdUInt = DocFileFormat::FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size); + m_Position += 4; + } + + return rdUInt; +} +void MemoryStream::WriteByte(unsigned char val) +{ + if (m_Data && (m_Position + 1 <= m_Size)) + { + m_Data[m_Position] = val; + m_Position += 1; + } +} +void MemoryStream::WriteUInt32(_UINT32 val) +{ + if (m_Data && (m_Position + sizeof(_UINT32) <= m_Size)) + { + ((_UINT32 *)(m_Data + m_Position))[0] = val; + m_Position += sizeof(_UINT32); + } +} +unsigned char MemoryStream::ReadByte() +{ + unsigned char rdByte = 0; + + if (m_Data) + { + rdByte = (m_Position < m_Size) ? m_Data[m_Position] : 0; + m_Position += sizeof(rdByte); + } + + return rdByte; +} + +unsigned char* MemoryStream::ReadBytes (unsigned int count, bool isResultNeeded) +{ + if (!m_Data) return NULL; + + unsigned int size = ( count <= (m_Size - m_Position) ) ? (count) : (m_Size - m_Position); + + unsigned char* pBytes = (isResultNeeded && count > 0) ? new unsigned char[count] : NULL; + + if (pBytes) + { + memcpy(pBytes, (m_Data + m_Position), size); + } + m_Position += size; + + return pBytes; +} +void MemoryStream::WriteBytes(unsigned char* pData, int size) +{ + if (m_Data && (m_Position + size <= m_Size)) + { + memcpy(m_Data + m_Position, pData, size); + m_Position += size; + } +} + +unsigned long MemoryStream::GetPosition() const +{ + return m_Position; +} +unsigned long MemoryStream::GetSize() const +{ + return m_Size; +} +int MemoryStream::Seek (int offset, int origin) +{ + if (origin == 2) offset = m_Position + offset; + if (origin == 1) offset = m_Size - offset; + + if ( (m_Data != NULL) && (offset >= 0) && ((unsigned int)offset < m_Size) ) + return m_Position = offset; + + return 0; +} diff --git a/MsBinaryFile/DocFile/MemoryStream.h b/MsBinaryFile/DocFile/MemoryStream.h index 3ad02e6141..4ac0bf3c69 100644 --- a/MsBinaryFile/DocFile/MemoryStream.h +++ b/MsBinaryFile/DocFile/MemoryStream.h @@ -37,192 +37,29 @@ class MemoryStream: public IBinaryReader { public: + MemoryStream (unsigned char* data, unsigned long size, bool bMemCopy = true); - MemoryStream (unsigned char* data, unsigned long size, bool bMemCopy = true) : m_Data(NULL), m_Size(0), m_Position(0), bMemoryCopy(bMemCopy) - { - if ( ( data != NULL ) && ( size != 0 ) ) - { - m_Size = size; + virtual ~MemoryStream(); + virtual _UINT64 ReadUInt64(); + virtual unsigned short ReadUInt16(); + void WriteUInt16(unsigned short val); + virtual short ReadInt16(); - if (bMemoryCopy) - { - m_Data = new unsigned char[m_Size]; - if (m_Data) - { - memcpy (m_Data, data, m_Size); - } - } - else - { - m_Data = data; - } - } - } + virtual int ReadInt32(); + void WriteInt32(_INT32 val); + void Align(_UINT32 val); - virtual ~MemoryStream() - { - if (bMemoryCopy) - RELEASEARRAYOBJECTS (m_Data); - } - virtual _UINT64 ReadUInt64() - { - _UINT64 rdU64 = 0; + virtual unsigned int ReadUInt32(); + void WriteByte(unsigned char val); + void WriteUInt32(_UINT32 val); + virtual unsigned char ReadByte(); - if (m_Data) - { - rdU64 = DocFileFormat::FormatUtils::BytesToUInt64(m_Data, m_Position, m_Size); - m_Position += 8; - } + virtual unsigned char* ReadBytes (unsigned int count, bool isResultNeeded); + void WriteBytes(unsigned char* pData, int size); - return rdU64; - } - virtual unsigned short ReadUInt16() - { - unsigned short rdUShort = 0; - - if (m_Data) - { - rdUShort = DocFileFormat::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size); - m_Position += 2; - } - - return rdUShort; - } - void WriteUInt16(unsigned short val) - { - if (m_Data && (m_Position + sizeof(unsigned short) <= m_Size)) - { - ((unsigned short *)(m_Data + m_Position))[0] = val; - m_Position += 2; - } - } - virtual short ReadInt16() - { - short rdShort = 0; - - if (m_Data) - { - rdShort = DocFileFormat::FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size); - m_Position += 2; - } - - return rdShort; - } - - virtual int ReadInt32() - { - int rdInt = 0; - - if (m_Data) - { - rdInt = DocFileFormat::FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size); - m_Position += 4; - } - - return rdInt; - } - void WriteInt32(_INT32 val) - { - if (m_Data && (m_Position + sizeof(_INT32) <= m_Size)) - { - ((_INT32 *)(m_Data + m_Position))[0] = val; - m_Position += 4; - } - } - void Align(_UINT32 val) - { - _UINT32 padding = val - (m_Position % val); - - if (padding > 0 && padding < 4) - m_Position += padding; - } - - virtual unsigned int ReadUInt32() - { - int rdUInt = 0; - - if (m_Data ) - { - rdUInt = DocFileFormat::FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size); - m_Position += 4; - } - - return rdUInt; - } - void WriteByte(unsigned char val) - { - if (m_Data && (m_Position + 1 <= m_Size)) - { - m_Data[m_Position] = val; - m_Position += 1; - } - } - void WriteUInt32(_UINT32 val) - { - if (m_Data && (m_Position + sizeof(_UINT32) <= m_Size)) - { - ((_UINT32 *)(m_Data + m_Position))[0] = val; - m_Position += sizeof(_UINT32); - } - } - virtual unsigned char ReadByte() - { - unsigned char rdByte = 0; - - if (m_Data) - { - rdByte = (m_Position < m_Size) ? m_Data[m_Position] : 0; - m_Position += sizeof(rdByte); - } - - return rdByte; - } - - virtual unsigned char* ReadBytes (unsigned int count, bool isResultNeeded) - { - if (!m_Data) return NULL; - - unsigned int size = ( count <= (m_Size - m_Position) ) ? (count) : (m_Size - m_Position); - - unsigned char* pBytes = (isResultNeeded && count > 0) ? new unsigned char[count] : NULL; - - if (pBytes) - { - memcpy(pBytes, (m_Data + m_Position), size); - } - m_Position += size; - - return pBytes; - } - void WriteBytes(unsigned char* pData, int size) - { - if (m_Data && (m_Position + size <= m_Size)) - { - memcpy(m_Data + m_Position, pData, size); - m_Position += size; - } - } - - virtual unsigned long GetPosition() const - { - return m_Position; - } - - virtual unsigned long GetSize() const - { - return m_Size; - } - - virtual int Seek (int offset, int origin = 0/*STREAM_SEEK_SET*/) - { - if (origin == 2) offset = m_Position + offset; - if (origin == 1) offset = m_Size - offset; - - if ( (m_Data != NULL) && (offset >= 0) && ((unsigned int)offset < m_Size) ) - return m_Position = offset; - - return 0; - } + virtual unsigned long GetPosition() const; + virtual unsigned long GetSize() const; + virtual int Seek (int offset, int origin = 0/*STREAM_SEEK_SET*/); private: diff --git a/MsBinaryFile/DocFile/OfficeArtContent.cpp b/MsBinaryFile/DocFile/OfficeArtContent.cpp new file mode 100644 index 0000000000..14518582aa --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeArtContent.cpp @@ -0,0 +1,163 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "OfficeArtContent.h" + +namespace DocFileFormat +{ + OfficeArtContent::OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL), m_uLastShapeId(1024) + { + VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion); + + if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return; + + oStearmReader.Seek (pFIB->m_FibWord97.fcDggInfo, 0/*STREAM_SEEK_SET*/); + + if (pFIB->m_FibWord97.lcbDggInfo > 0) + { + unsigned int maxPosition = (int)(pFIB->m_FibWord97.fcDggInfo + pFIB->m_FibWord97.lcbDggInfo); + + // read the DrawingGroupData + m_pDrawingGroupData = static_cast(RecordFactory::ReadRecord (&oStearmReader, 0)); + + while (oStearmReader.GetPosition() < maxPosition) + { + OfficeArtWordDrawing drawing; + drawing.dgglbl = (DrawingType)oStearmReader.ReadByte(); + drawing.container = static_cast(RecordFactory::ReadRecord (&oStearmReader, 0)); + + for (size_t i = 0; i < drawing.container->Children.size(); ++i) + { + Record* groupChild = drawing.container->Children[i]; + if (groupChild) + { + if (GroupContainer::TYPE_CODE_0xF003 == groupChild->TypeCode) + { + GroupContainer* group = static_cast(groupChild); + if (group) + { + group->Index = (int)i; + } + } + else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode) + { + ShapeContainer* shape = static_cast(groupChild); + if (shape) + { + shape->m_nIndex = (int)i; + if (shape->m_bBackground) + { + m_pBackgroud = shape; + } + } + } + else if (DrawingRecord::TYPE_CODE_0xF008 == groupChild->TypeCode) + { + DrawingRecord* dr = static_cast(groupChild); + if (dr) + { + m_uLastShapeId = dr->spidCur; + } + } + } + } + + m_arrDrawings.push_back( drawing ); + } + } + } + OfficeArtContent::~OfficeArtContent() + { + RELEASEOBJECT (m_pDrawingGroupData); + + for ( std::list::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) + RELEASEOBJECT(iter->container); + } + + ShapeContainer* OfficeArtContent::GetShapeContainer (int spid) + { + ShapeContainer* ret = NULL; + + for (std::list::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) + { + GroupContainer* group = iter->container->FirstChildWithType(); + if (group) + { + for (size_t i = 1; i < group->Children.size(); ++i) + { + Record* groupChild = group->Children[i]; + + if ( groupChild->TypeCode == GroupContainer::TYPE_CODE_0xF003) + { + //It's a group of shapes + GroupContainer* subgroup = static_cast(groupChild); + + //the referenced shape must be the first shape in the group + ShapeContainer* container = static_cast(subgroup->Children[0]); + Shape* shape = static_cast(container->Children[1]); + + if (shape->GetShapeID() == spid) + { + ret = container; + break; + } + } + else if ( groupChild->TypeCode == ShapeContainer::TYPE_CODE_0xF004 ) + { + //It's a singe shape + ShapeContainer* container = static_cast(groupChild); + Shape* shape = static_cast(container->Children[0]); + + if (shape->GetShapeID() == spid) + { + ret = container; + break; + } + } + } + } + else + { + continue; + } + + if (ret) + break; + } + + return ret; + } + const DrawingGroup* OfficeArtContent::GetDrawingGroup () const + { + return m_pDrawingGroupData; + } +} diff --git a/MsBinaryFile/DocFile/OfficeArtContent.h b/MsBinaryFile/DocFile/OfficeArtContent.h index aefeba519a..5404904d50 100644 --- a/MsBinaryFile/DocFile/OfficeArtContent.h +++ b/MsBinaryFile/DocFile/OfficeArtContent.h @@ -31,6 +31,7 @@ */ #pragma once +#include "FileInformationBlock.h" #include "OfficeDrawing/RecordFactory.h" #include "OfficeDrawing/DrawingContainer.h" @@ -58,138 +59,19 @@ namespace DocFileFormat public: - OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL), m_uLastShapeId(1024) - { - VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion); + OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream); + ~OfficeArtContent(); - if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return; - - oStearmReader.Seek (pFIB->m_FibWord97.fcDggInfo, 0/*STREAM_SEEK_SET*/); - - if (pFIB->m_FibWord97.lcbDggInfo > 0) - { - unsigned int maxPosition = (int)(pFIB->m_FibWord97.fcDggInfo + pFIB->m_FibWord97.lcbDggInfo); - - // read the DrawingGroupData - m_pDrawingGroupData = static_cast(RecordFactory::ReadRecord (&oStearmReader, 0)); - - while (oStearmReader.GetPosition() < maxPosition) - { - OfficeArtWordDrawing drawing; - drawing.dgglbl = (DrawingType)oStearmReader.ReadByte(); - drawing.container = static_cast(RecordFactory::ReadRecord (&oStearmReader, 0)); - - for (size_t i = 0; i < drawing.container->Children.size(); ++i) - { - Record* groupChild = drawing.container->Children[i]; - if (groupChild) - { - if (GroupContainer::TYPE_CODE_0xF003 == groupChild->TypeCode) - { - GroupContainer* group = static_cast(groupChild); - if (group) - { - group->Index = (int)i; - } - } - else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode) - { - ShapeContainer* shape = static_cast(groupChild); - if (shape) - { - shape->m_nIndex = (int)i; - if (shape->m_bBackground) - { - m_pBackgroud = shape; - } - } - } - else if (DrawingRecord::TYPE_CODE_0xF008 == groupChild->TypeCode) - { - DrawingRecord* dr = static_cast(groupChild); - if (dr) - { - m_uLastShapeId = dr->spidCur; - } - } - } - } - - m_arrDrawings.push_back( drawing ); - } - } - } - - ~OfficeArtContent() - { - RELEASEOBJECT (m_pDrawingGroupData); - - for ( std::list::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; - for (std::list::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) - { - GroupContainer* group = iter->container->FirstChildWithType(); - if (group) - { - for (size_t i = 1; i < group->Children.size(); ++i) - { - Record* groupChild = group->Children[i]; + ShapeContainer* GetShapeContainer (int spid); + const DrawingGroup* GetDrawingGroup () const; - if ( groupChild->TypeCode == GroupContainer::TYPE_CODE_0xF003) - { - //It's a group of shapes - GroupContainer* subgroup = static_cast(groupChild); - - //the referenced shape must be the first shape in the group - ShapeContainer* container = static_cast(subgroup->Children[0]); - Shape* shape = static_cast(container->Children[1]); - - if (shape->GetShapeID() == spid) - { - ret = container; - break; - } - } - else if ( groupChild->TypeCode == ShapeContainer::TYPE_CODE_0xF004 ) - { - //It's a singe shape - ShapeContainer* container = static_cast(groupChild); - Shape* shape = static_cast(container->Children[0]); - - if (shape->GetShapeID() == spid) - { - ret = container; - break; - } - } - } - } - else - { - continue; - } - - if (ret) - break; - } - - return ret; - } - - inline const DrawingGroup* GetDrawingGroup () const - { - return m_pDrawingGroupData; - } unsigned int m_uLastShapeId; + private: ShapeContainer* m_pBackgroud; DrawingGroup* m_pDrawingGroupData; diff --git a/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.cpp b/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.cpp new file mode 100644 index 0000000000..ee87507b17 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.cpp @@ -0,0 +1,72 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "BitmapBlip.h" + +namespace DocFileFormat +{ + BitmapBlip::BitmapBlip() : Record(), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_bTag(0), m_pvBits(NULL) + { + } + BitmapBlip::BitmapBlip(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : + Record(_reader, size, typeCode, version, instance ), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_bTag(0), m_pvBits(NULL), pvBitsSize(0) + { + m_rgbUid = Reader->ReadBytes(16, true); + + if ((instance == 0x46B) || (instance == 0x6E3) || (instance == 0x6E1) || (instance == 0x7A9) || (instance == 0x6E5)) + { + m_rgbUidPrimary = Reader->ReadBytes(16, true); + } + + m_bTag = Reader->ReadByte(); + + pvBitsSize = (size - 17); + + if (m_rgbUidPrimary) + { + pvBitsSize -= 16; + } + + m_pvBits = Reader->ReadBytes((int)(pvBitsSize), true); + } + + BitmapBlip::~BitmapBlip() + { + RELEASEARRAYOBJECTS(m_rgbUid); + RELEASEARRAYOBJECTS(m_rgbUidPrimary); + RELEASEARRAYOBJECTS(m_pvBits); + } + Record* BitmapBlip::NewObject(IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new BitmapBlip(_reader, bodySize, typeCode, version, instance); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.h b/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.h index 8734719b96..2334baed0f 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/BitmapBlip.h @@ -47,43 +47,11 @@ namespace DocFileFormat static const unsigned short TYPE_CODE_0xF029 = 0xF029; public: - BitmapBlip() : Record(), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_bTag(0), m_pvBits(NULL) - { - } + BitmapBlip(); + BitmapBlip(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~BitmapBlip(); - BitmapBlip(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : - Record(_reader, size, typeCode, version, instance ), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_bTag(0), m_pvBits(NULL), pvBitsSize(0) - { - m_rgbUid = Reader->ReadBytes(16, true); - - if ((instance == 0x46B) || (instance == 0x6E3) || (instance == 0x6E1) || (instance == 0x7A9) || (instance == 0x6E5)) - { - m_rgbUidPrimary = Reader->ReadBytes(16, true); - } - - m_bTag = Reader->ReadByte(); - - pvBitsSize = (size - 17); - - if (m_rgbUidPrimary) - { - pvBitsSize -= 16; - } - - m_pvBits = Reader->ReadBytes((int)(pvBitsSize), true); - } - - virtual ~BitmapBlip() - { - RELEASEARRAYOBJECTS(m_rgbUid); - RELEASEARRAYOBJECTS(m_rgbUidPrimary); - RELEASEARRAYOBJECTS(m_pvBits); - } - - virtual Record* NewObject(IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new BitmapBlip(_reader, bodySize, typeCode, version, instance); - } + virtual Record* NewObject(IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); public: @@ -98,4 +66,4 @@ namespace DocFileFormat unsigned char* m_pvBits; unsigned int pvBitsSize; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.cpp new file mode 100644 index 0000000000..1744e97570 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.cpp @@ -0,0 +1,50 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "BlipStoreContainer.h" + +namespace DocFileFormat +{ + BlipStoreContainer::BlipStoreContainer () : RegularContainer() + { + } + BlipStoreContainer::BlipStoreContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer (_reader, size, typeCode, version, instance) + { + } + BlipStoreContainer::~BlipStoreContainer() + { + } + Record* BlipStoreContainer::NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new BlipStoreContainer( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.h index 0d97e505e6..2edb97904b 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreContainer.h @@ -40,21 +40,10 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF001 = 0xF001; - BlipStoreContainer () : RegularContainer() - { - } + BlipStoreContainer(); + BlipStoreContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~BlipStoreContainer(); - BlipStoreContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer (_reader, size, typeCode, version, instance) - { - } - - virtual ~BlipStoreContainer() - { - } - - virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new BlipStoreContainer( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.cpp b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.cpp new file mode 100644 index 0000000000..8c91807f5f --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.cpp @@ -0,0 +1,81 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "BlipStoreEntry.h" + +namespace DocFileFormat +{ + BlipStoreEntry::BlipStoreEntry() : Record(), btWin32(Global::msoblipERROR), btMacOS(Global::msoblipERROR), rgbUid(NULL), tag(0), size(0), cRef(0), + foDelay(0), usage(Global::msoblipUsageDefault), cbName(0), unused2(0), unused3(0), m_rgbUid(NULL), m_rgbUidPrimary(NULL), + m_bTag(0), m_cb(0), m_cbSave(0), m_fCompression(0), m_fFilter(0), Blip(NULL) + { + } + + BlipStoreEntry::BlipStoreEntry(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): + Record( _reader, size, typeCode, version, instance ), btWin32(Global::msoblipERROR), btMacOS(Global::msoblipERROR), rgbUid(NULL), tag(0), size(0), cRef(0), + foDelay(0), usage(Global::msoblipUsageDefault), cbName(0), unused2(0), unused3(0), m_rgbUid(NULL), m_rgbUidPrimary(NULL), + m_bTag(0), m_cb(0), m_cbSave(0), m_fCompression(0), m_fFilter(0), Blip(NULL) + { + btWin32 = (Global::BlipType)Reader->ReadByte(); + btMacOS = (Global::BlipType)Reader->ReadByte(); + rgbUid = Reader->ReadBytes(16, true); + tag = Reader->ReadInt16(); + size = Reader->ReadUInt32(); + cRef = Reader->ReadUInt32(); + foDelay = Reader->ReadUInt32(); + usage = (Global::BlipUsage) Reader->ReadByte(); + cbName = Reader->ReadByte(); + unused2 = Reader->ReadByte(); + unused3 = Reader->ReadByte(); + + if (btMacOS != btWin32) + { + btWin32 = btMacOS = (Global::BlipType)this->Instance; + } + + if (BodySize > 0x24) + { + Blip = RecordFactory::ReadRecord(Reader, 0); + } + } + BlipStoreEntry::~BlipStoreEntry() + { + RELEASEARRAYOBJECTS(rgbUid); + RELEASEARRAYOBJECTS(m_rgbUid); + RELEASEARRAYOBJECTS(m_rgbUidPrimary); + RELEASEOBJECT(Blip); + } + Record* BlipStoreEntry::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new BlipStoreEntry( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.h b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.h index fca4f44830..b9e3bd9037 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/BlipStoreEntry.h @@ -86,52 +86,10 @@ namespace DocFileFormat unsigned char m_fFilter; public: + BlipStoreEntry(); + BlipStoreEntry(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); - BlipStoreEntry() : Record(), btWin32(Global::msoblipERROR), btMacOS(Global::msoblipERROR), rgbUid(NULL), tag(0), size(0), cRef(0), - foDelay(0), usage(Global::msoblipUsageDefault), cbName(0), unused2(0), unused3(0), m_rgbUid(NULL), m_rgbUidPrimary(NULL), - m_bTag(0), m_cb(0), m_cbSave(0), m_fCompression(0), m_fFilter(0), Blip(NULL) - { - } - - BlipStoreEntry(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): - Record( _reader, size, typeCode, version, instance ), btWin32(Global::msoblipERROR), btMacOS(Global::msoblipERROR), rgbUid(NULL), tag(0), size(0), cRef(0), - foDelay(0), usage(Global::msoblipUsageDefault), cbName(0), unused2(0), unused3(0), m_rgbUid(NULL), m_rgbUidPrimary(NULL), - m_bTag(0), m_cb(0), m_cbSave(0), m_fCompression(0), m_fFilter(0), Blip(NULL) - { - btWin32 = (Global::BlipType)Reader->ReadByte(); - btMacOS = (Global::BlipType)Reader->ReadByte(); - rgbUid = Reader->ReadBytes(16, true); - tag = Reader->ReadInt16(); - size = Reader->ReadUInt32(); - cRef = Reader->ReadUInt32(); - foDelay = Reader->ReadUInt32(); - usage = (Global::BlipUsage) Reader->ReadByte(); - cbName = Reader->ReadByte(); - unused2 = Reader->ReadByte(); - unused3 = Reader->ReadByte(); - - if (btMacOS != btWin32) - { - btWin32 = btMacOS = (Global::BlipType)this->Instance; - } - - if (BodySize > 0x24) - { - Blip = RecordFactory::ReadRecord(Reader, 0); - } - } - - virtual ~BlipStoreEntry() - { - RELEASEARRAYOBJECTS(rgbUid); - RELEASEARRAYOBJECTS(m_rgbUid); - RELEASEARRAYOBJECTS(m_rgbUidPrimary); - RELEASEOBJECT(Blip); - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new BlipStoreEntry( _reader, bodySize, typeCode, version, instance ); - } + virtual ~BlipStoreEntry(); + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); }; } diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.cpp b/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.cpp new file mode 100644 index 0000000000..b953467548 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.cpp @@ -0,0 +1,64 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ChildAnchor.h" + +namespace DocFileFormat +{ + ChildAnchor::ChildAnchor() : Record(), rcgBounds(), Left(0), Top(0), Right(0), Bottom(0) + { + } + ChildAnchor::ChildAnchor(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), rcgBounds(), Left(0), Top(0), Right(0), Bottom(0) + { + Left = Reader->ReadInt32(); + Top = Reader->ReadInt32(); + Right = Reader->ReadInt32(); + Bottom = Reader->ReadInt32(); + + POINT _point; + _point.x = Left; + _point.y = Top; + + SIZE _size; + _size.cx = Right - Left; + _size.cy = Bottom - Top; + + rcgBounds = DocFileFormat::Rectangle (_point, _size); + } + ChildAnchor::~ChildAnchor() + { + } + Record* ChildAnchor::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new ChildAnchor( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.h b/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.h index f158bccd2d..581d69a1a2 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/ChildAnchor.h @@ -40,40 +40,13 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF00F = 0xF00F; - ChildAnchor() : Record(), rcgBounds(), Left(0), Top(0), Right(0), Bottom(0) - { + ChildAnchor(); + ChildAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~ChildAnchor(); - } - - ChildAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), rcgBounds(), Left(0), Top(0), Right(0), Bottom(0) - { - Left = Reader->ReadInt32(); - Top = Reader->ReadInt32(); - Right = Reader->ReadInt32(); - Bottom = Reader->ReadInt32(); - - POINT _point; - _point.x = Left; - _point.y = Top; - - SIZE _size; - _size.cx = Right - Left; - _size.cy = Bottom - Top; - - rcgBounds = DocFileFormat::Rectangle (_point, _size); - } - - virtual ~ChildAnchor() - { - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new ChildAnchor( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); public: - /// Rectangle that describes the bounds of the anchor DocFileFormat::Rectangle rcgBounds; int Left; @@ -81,4 +54,4 @@ namespace DocFileFormat int Right; int Bottom; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.cpp b/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.cpp new file mode 100644 index 0000000000..ce2af90427 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.cpp @@ -0,0 +1,51 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ClientAnchor.h" + +namespace DocFileFormat +{ + ClientAnchor::ClientAnchor() : Record(), value(0) + { + } + ClientAnchor::ClientAnchor(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), value(0) + { + value = Reader->ReadInt32(); //index PlcfSpa + } + ClientAnchor::~ClientAnchor() + { + } + Record* ClientAnchor::NewObject(IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new ClientAnchor (_reader, bodySize, typeCode, version, instance); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.h b/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.h index f6d4a23b57..754a4e7145 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/ClientAnchor.h @@ -40,24 +40,12 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF010 = 0xF010; - ClientAnchor() : Record(), value(0) - { - } + ClientAnchor(); + ClientAnchor(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~ClientAnchor(); - ClientAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), value(0) - { - value = Reader->ReadInt32(); //index PlcfSpa - } - - virtual ~ClientAnchor() - { - } - - virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new ClientAnchor (_reader, bodySize, typeCode, version, instance); - } + virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); unsigned int value; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ClientData.cpp b/MsBinaryFile/DocFile/OfficeDrawing/ClientData.cpp new file mode 100644 index 0000000000..c721a2cd3f --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/ClientData.cpp @@ -0,0 +1,51 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ClientData.h" + +namespace DocFileFormat +{ + ClientData::ClientData () : Record(), clientdata(0) + { + } + ClientData::ClientData (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), clientdata(0) + { + clientdata = Reader->ReadInt32(); + } + ClientData::~ClientData() + { + } + Record* ClientData::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new ClientData( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ClientData.h b/MsBinaryFile/DocFile/OfficeDrawing/ClientData.h index 890c13f7ac..7b69370f77 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/ClientData.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/ClientData.h @@ -41,29 +41,14 @@ namespace DocFileFormat static const unsigned short TYPE_CODE_0xF011 = 0xF011; public: + ClientData (); + ClientData (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~ClientData(); - ClientData () : Record(), clientdata(0) - { - - } - - ClientData (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), clientdata(0) - { - clientdata = Reader->ReadInt32(); - } - - virtual ~ClientData() - { - - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new ClientData( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); private: int clientdata; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.cpp b/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.cpp new file mode 100644 index 0000000000..b1b04d1940 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.cpp @@ -0,0 +1,52 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DiagramBooleanProperties.h" +#include "../../Common/Base/FormatUtils.h" + +namespace DocFileFormat +{ + DiagramBooleanProperties::DiagramBooleanProperties(unsigned int op) + { + fPseudoInline = FormatUtils::BitmaskToBool(op, 0x1); + fDoLayout = FormatUtils::BitmaskToBool(op, 0x2); + fReverse = FormatUtils::BitmaskToBool(op, 0x4); + fDoFormat = FormatUtils::BitmaskToBool(op, 0x8); + + //unused: 0x10 - 0x8000 + + fUsefPseudoInline = FormatUtils::BitmaskToBool(op, 0x10000); + fUsefDoLayout = FormatUtils::BitmaskToBool(op, 0x20000); + fUsefReverse = FormatUtils::BitmaskToBool(op, 0x40000); + fUsefDoFormat = FormatUtils::BitmaskToBool(op, 0x80000); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.h b/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.h index f09a64f71f..47a805907e 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/DiagramBooleanProperties.h @@ -38,20 +38,7 @@ namespace DocFileFormat class DiagramBooleanProperties { public: - DiagramBooleanProperties(unsigned int op) - { - fPseudoInline = FormatUtils::BitmaskToBool(op, 0x1); - fDoLayout = FormatUtils::BitmaskToBool(op, 0x2); - fReverse = FormatUtils::BitmaskToBool(op, 0x4); - fDoFormat = FormatUtils::BitmaskToBool(op, 0x8); - - //unused: 0x10 - 0x8000 - - fUsefPseudoInline = FormatUtils::BitmaskToBool(op, 0x10000); - fUsefDoLayout = FormatUtils::BitmaskToBool(op, 0x20000); - fUsefReverse = FormatUtils::BitmaskToBool(op, 0x40000); - fUsefDoFormat = FormatUtils::BitmaskToBool(op, 0x80000); - } + DiagramBooleanProperties(unsigned int op); public: @@ -65,4 +52,4 @@ namespace DocFileFormat bool fUsefReverse; bool fUsefDoFormat; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.cpp new file mode 100644 index 0000000000..a95596491b --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.cpp @@ -0,0 +1,52 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DrawingContainer.h" + +namespace DocFileFormat +{ + DrawingContainer::DrawingContainer() : RegularContainer() + { + } + DrawingContainer::DrawingContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ) : + RegularContainer( _reader, size, typeCode, version, instance ) + { + } + DrawingContainer::~DrawingContainer() + { + } + + Record* DrawingContainer::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new DrawingContainer( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.h index 97baf143f4..65bc06a5bb 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingContainer.h @@ -40,23 +40,11 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF002 = 0xF002; - DrawingContainer(): - RegularContainer() - { - } - - DrawingContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): - RegularContainer( _reader, size, typeCode, version, instance ) - { - } + DrawingContainer(); + DrawingContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); + virtual ~DrawingContainer(); - virtual ~DrawingContainer() - { - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new DrawingContainer( _reader, bodySize, typeCode, version, instance ); - } }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.cpp b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.cpp new file mode 100644 index 0000000000..b1adab394a --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.cpp @@ -0,0 +1,51 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DrawingGroup.h" + +namespace DocFileFormat +{ + DrawingGroup::DrawingGroup(): RegularContainer() + { + } + DrawingGroup::DrawingGroup (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer( _reader, size, typeCode, version, instance ) + { + } + DrawingGroup::~DrawingGroup() + { + } + + Record* DrawingGroup::NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new DrawingGroup (_reader, bodySize, typeCode, version, instance); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.h b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.h index 2199019da9..e4e96d1418 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroup.h @@ -40,21 +40,10 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF000 = 0xF000; - DrawingGroup(): RegularContainer() - { - } + DrawingGroup(); + DrawingGroup (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~DrawingGroup(); - DrawingGroup (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer( _reader, size, typeCode, version, instance ) - { - } - - virtual ~DrawingGroup() - { - } - - virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new DrawingGroup (_reader, bodySize, typeCode, version, instance); - } + virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.cpp b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.cpp new file mode 100644 index 0000000000..d1208a1dae --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.cpp @@ -0,0 +1,57 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DrawingGroupRecord.h" + +namespace DocFileFormat +{ + DrawingGroupRecord::DrawingGroupRecord () : Record(), MaxShapeId(0), IdClustersCount(0), ShapesSavedCount(0), DrawingsSavedCount(0) + { + } + DrawingGroupRecord::DrawingGroupRecord (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record( _reader, size, typeCode, version, instance ) + { + MaxShapeId = Reader->ReadUInt32(); + IdClustersCount = Reader->ReadUInt32() - 1; // Office saves the actual value + 1 -- flgr + ShapesSavedCount = Reader->ReadUInt32(); + DrawingsSavedCount = Reader->ReadUInt32(); + + for (unsigned int i = 0; i < IdClustersCount; ++i) + Clusters.push_back(FileIdCluster(Reader)); + } + DrawingGroupRecord::~DrawingGroupRecord() + { + } + Record* DrawingGroupRecord::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new DrawingGroupRecord( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.h b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.h index 2bb77c8aa4..982f297c12 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingGroupRecord.h @@ -58,29 +58,10 @@ namespace DocFileFormat std::list Clusters; - DrawingGroupRecord () : Record(), MaxShapeId(0), IdClustersCount(0), ShapesSavedCount(0), DrawingsSavedCount(0) - { + DrawingGroupRecord (); + DrawingGroupRecord (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~DrawingGroupRecord(); - } - - DrawingGroupRecord (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record( _reader, size, typeCode, version, instance ) - { - MaxShapeId = Reader->ReadUInt32(); - IdClustersCount = Reader->ReadUInt32() - 1; // Office saves the actual value + 1 -- flgr - ShapesSavedCount = Reader->ReadUInt32(); - DrawingsSavedCount = Reader->ReadUInt32(); - - for (unsigned int i = 0; i < IdClustersCount; ++i) - Clusters.push_back(FileIdCluster(Reader)); - } - - virtual ~DrawingGroupRecord() - { - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new DrawingGroupRecord( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.cpp b/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.cpp new file mode 100644 index 0000000000..e1f05f9ad3 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.cpp @@ -0,0 +1,53 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "DrawingRecord.h" + +namespace DocFileFormat +{ + DrawingRecord::DrawingRecord():Record(), csp(0), spidCur(0) + { + } + DrawingRecord::DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): + Record( _reader, size, typeCode, version, instance ) + { + csp = Reader->ReadUInt32(); + spidCur = Reader->ReadInt32(); + } + DrawingRecord::~DrawingRecord() + { + } + Record* DrawingRecord::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new DrawingRecord( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.h b/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.h index 94ce65eb8f..318e2e8369 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/DrawingRecord.h @@ -43,25 +43,10 @@ namespace DocFileFormat unsigned int csp; // The number of shapes in this drawing unsigned int spidCur; // The last MSOSPID given to an SP in this DG - DrawingRecord(): - Record(), csp(0), spidCur(0) - { - } + DrawingRecord(); + DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); - DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): - Record( _reader, size, typeCode, version, instance ) - { - csp = Reader->ReadUInt32(); - spidCur = Reader->ReadInt32(); - } - - virtual ~DrawingRecord() - { - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new DrawingRecord( _reader, bodySize, typeCode, version, instance ); - } + virtual ~DrawingRecord(); + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.cpp new file mode 100644 index 0000000000..18ccdba844 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.cpp @@ -0,0 +1,73 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "GroupContainer.h" + +namespace DocFileFormat +{ + GroupContainer::GroupContainer() : RegularContainer(), Index(0) + { + } + GroupContainer::GroupContainer(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer(_reader, size, typeCode, version, instance), Index(0) + { + for ( unsigned int i = 0; i < this->Children.size(); i++ ) + { + Record* groupChild = this->Children[i]; + + if ( groupChild != NULL ) + { + if ( groupChild->TypeCode == 0xF003 ) + { + // the child is a subgroup + GroupContainer* group = static_cast(groupChild); + group->Index = i; + this->Children[i] = group; + } + else if ( groupChild->TypeCode == 0xF004 ) + { + // the child is a shape + ShapeContainer* shape = static_cast(groupChild); + shape->m_nIndex = i; + this->Children[i] = shape; + } + } + } + } + GroupContainer::~GroupContainer() + { + } + + Record* GroupContainer::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new GroupContainer( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.h index f8694d90e6..78b8089511 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/GroupContainer.h @@ -42,43 +42,10 @@ namespace DocFileFormat int Index; - GroupContainer() : RegularContainer(), Index(0) - { - } + GroupContainer(); + GroupContainer(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~GroupContainer(); - GroupContainer(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer(_reader, size, typeCode, version, instance), Index(0) - { - for ( unsigned int i = 0; i < this->Children.size(); i++ ) - { - Record* groupChild = this->Children[i]; - - if ( groupChild != NULL ) - { - if ( groupChild->TypeCode == 0xF003 ) - { - // the child is a subgroup - GroupContainer* group = static_cast(groupChild); - group->Index = i; - this->Children[i] = group; - } - else if ( groupChild->TypeCode == 0xF004 ) - { - // the child is a shape - ShapeContainer* shape = static_cast(groupChild); - shape->m_nIndex = i; - this->Children[i] = shape; - } - } - } - } - - virtual ~GroupContainer() - { - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new GroupContainer( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.cpp b/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.cpp new file mode 100644 index 0000000000..70af4b4cb1 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.cpp @@ -0,0 +1,71 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "GroupShapeRecord.h" + +namespace DocFileFormat +{ + GroupShapeRecord::GroupShapeRecord () : Record(), rcgBounds() + { + } + GroupShapeRecord::GroupShapeRecord(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record(_reader, size, typeCode, version, instance), rcgBounds() + { + int left = Reader->ReadInt32(); + int top = Reader->ReadInt32(); + int right = Reader->ReadInt32(); + int bottom = Reader->ReadInt32(); + + //left = max( 0, left ); + //top = max( 0, top ); + //right = max( 0, right ); + //bottom = max( 0, bottom ); + + POINT oPoint; + oPoint.x = left; + oPoint.y = top; + + SIZE oSize; + oSize.cx = ( right - left ); + oSize.cy = ( bottom - top ); + + rcgBounds = DocFileFormat::Rectangle(oPoint,oSize); + } + GroupShapeRecord::~GroupShapeRecord() + { + + } + + Record* GroupShapeRecord::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new GroupShapeRecord( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.h b/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.h index 78ccea34ba..56dbdf3b24 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/GroupShapeRecord.h @@ -40,42 +40,11 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF009 = 0xF009; - GroupShapeRecord () : Record(), rcgBounds() - { - } + GroupShapeRecord (); + GroupShapeRecord(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~GroupShapeRecord(); - GroupShapeRecord(IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record(_reader, size, typeCode, version, instance), rcgBounds() - { - int left = Reader->ReadInt32(); - int top = Reader->ReadInt32(); - int right = Reader->ReadInt32(); - int bottom = Reader->ReadInt32(); - - //left = max( 0, left ); - //top = max( 0, top ); - //right = max( 0, right ); - //bottom = max( 0, bottom ); - - POINT oPoint; - oPoint.x = left; - oPoint.y = top; - - SIZE oSize; - oSize.cx = ( right - left ); - oSize.cy = ( bottom - top ); - - rcgBounds = DocFileFormat::Rectangle(oPoint,oSize); - } - - virtual ~GroupShapeRecord() - { - - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new GroupShapeRecord( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); DocFileFormat::Rectangle rcgBounds; }; diff --git a/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.cpp b/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.cpp new file mode 100644 index 0000000000..ecae82c09f --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.cpp @@ -0,0 +1,273 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "MetafilePictBlip.h" + +namespace DocFileFormat +{ + CMetaHeader::CMetaHeader() + { + cbSize = cbSave = 0; + filter = compression = 0; + ptSize.x = ptSize.y = 0; + + rcBounds.bottom = rcBounds.left = rcBounds.right = rcBounds.top = 0; + + } + void CMetaHeader::ToWMFHeader(WmfPlaceableFileHeader* pHeader) + { + if (NULL == pHeader) + return; + + pHeader->Key = 0x9AC6CDD7; + pHeader->Hmf = 0; + + pHeader->BoundingBox.Left = (short)rcBounds.left; + pHeader->BoundingBox.Top = (short)rcBounds.top; + pHeader->BoundingBox.Right = (short)rcBounds.right; + pHeader->BoundingBox.Bottom = (short)rcBounds.bottom; + + pHeader->Inch = 1440; // 1:1 + pHeader->Reserved = 0; + + pHeader->Checksum = 0; + pHeader->Checksum ^= (pHeader->Key & 0x0000FFFFL); + pHeader->Checksum ^= ((pHeader->Key & 0xFFFF0000L) >> 16); + + pHeader->Checksum ^= pHeader->Hmf; + + pHeader->Checksum ^= pHeader->BoundingBox.Left; + pHeader->Checksum ^= pHeader->BoundingBox.Top; + pHeader->Checksum ^= pHeader->BoundingBox.Right; + pHeader->Checksum ^= pHeader->BoundingBox.Bottom; + + pHeader->Checksum ^= pHeader->Inch; + pHeader->Checksum ^= (pHeader->Reserved & 0x0000FFFFL); + pHeader->Checksum ^= ((pHeader->Reserved & 0xFFFF0000L) >> 16); + } + + CMetaFileBuffer::CMetaFileBuffer() + { + m_bIsValid = false; + + m_pMetaHeader = NULL; + m_pMetaFile = NULL; + + m_lMetaHeaderSize = 0; + m_lMetaFileSize = 0; + } + CMetaFileBuffer::~CMetaFileBuffer() + { + RELEASEARRAYOBJECTS(m_pMetaHeader); + RELEASEARRAYOBJECTS(m_pMetaFile); + } + void CMetaFileBuffer::SetHeader(BYTE* pHeader, LONG lSize) + { + m_pMetaHeader = pHeader; + m_lMetaHeaderSize = lSize; + } + void CMetaFileBuffer::SetData(BYTE* pCompress, LONG lCompressSize, LONG lUncompressSize, bool bIsCompressed) + { + if (!bIsCompressed) + { + m_pMetaFile = new BYTE[lCompressSize]; + m_lMetaFileSize = lCompressSize; + memcpy(m_pMetaFile, pCompress, lCompressSize); + } + else + { + ULONG lSize = lUncompressSize; + m_pMetaFile = new BYTE[lUncompressSize]; + + HRESULT res = S_OK; + COfficeUtils* pOfficeUtils = new COfficeUtils(NULL); + + if (pOfficeUtils) + { + pOfficeUtils->Uncompress( m_pMetaFile, &lSize, pCompress, lCompressSize ); + + delete pOfficeUtils; + pOfficeUtils = NULL; + + m_lMetaFileSize = (LONG)lSize; + } + else + { + RELEASEARRAYOBJECTS(m_pMetaFile); + m_lMetaFileSize = 0; + } + } + } + int CMetaFileBuffer::ToBuffer(BYTE *& Data) + { + int sz = 0; + + if (NULL != m_pMetaHeader) sz += m_lMetaHeaderSize; + if (NULL != m_pMetaFile) sz += m_lMetaFileSize; + + Data = new BYTE[sz]; + int pos = 0; + + if (NULL != m_pMetaHeader) + { + memcpy(Data, (BYTE*)m_pMetaHeader, m_lMetaHeaderSize); + pos += m_lMetaHeaderSize; + } + if (NULL != m_pMetaFile) + { + memcpy(Data + pos, (BYTE*)m_pMetaFile, m_lMetaFileSize); + } + + return sz; + } + void CMetaFileBuffer::ToFile(NSFile::CFileBinary* pFile) + { + if (NULL != m_pMetaHeader) + { + pFile->WriteFile((BYTE*)m_pMetaHeader, m_lMetaHeaderSize); + } + } + + MetafilePictBlip::MetafilePictBlip(): + Record(), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_cb(0), m_cbSave(0), m_fCompression(BlipCompressionNone), m_fFilter(false), + m_pvBits(NULL) + { + } + + MetafilePictBlip::MetafilePictBlip( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): + Record( _reader, size, typeCode, version, instance ), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_cb(0), m_cbSave(0), + m_fCompression(BlipCompressionNone), m_fFilter(false), m_pvBits(NULL) + { + m_rgbUid = Reader->ReadBytes( 16, true ); + + if ( ( instance == 0x3D5 ) || ( instance == 0x217 ) || ( instance == 0x543 ) ) + { + m_rgbUidPrimary = Reader->ReadBytes( 16, true ); + } + + oMetaFile.m_bIsValid = TRUE; + oMetaFile.m_sExtension = L".emf"; + + CMetaHeader oMetaHeader; + + m_cb = Reader->ReadInt32(); + + m_rcBounds.left = Reader->ReadInt32(); + m_rcBounds.top = Reader->ReadInt32(); + m_rcBounds.right = Reader->ReadInt32() + m_rcBounds.left; + m_rcBounds.bottom = Reader->ReadInt32() + m_rcBounds.top; + + m_ptSize.x = Reader->ReadInt32(); + m_ptSize.y = Reader->ReadInt32(); + + m_cbSave = Reader->ReadInt32(); + m_fCompression = (BlipCompression)Reader->ReadByte(); + m_fFilter = ( Reader->ReadByte() == 1 ) ? (true) : (false); + + int sz = Reader->GetSize() - Reader->GetPosition(); + m_pvBits = Reader->ReadBytes( sz/*m_cbSave*/, true ); + + oMetaHeader.rcBounds = m_rcBounds; + oMetaHeader.cbSize = m_cb; + oMetaHeader.ptSize = m_ptSize; + oMetaHeader.cbSave = m_cbSave ; + oMetaHeader.compression = m_fCompression; + oMetaHeader.filter = m_fFilter; + + if (typeCode == 0xf01b) + { + oMetaFile.m_sExtension = L".wmf"; + + WmfPlaceableFileHeader oWmfHeader = {}; + oMetaHeader.ToWMFHeader(&oWmfHeader); + + LONG lLenHeader = 22; + BYTE* pMetaHeader = new BYTE[lLenHeader]; + memcpy(pMetaHeader, (void*)(&oWmfHeader), lLenHeader); + + oMetaFile.SetHeader(pMetaHeader, lLenHeader); + } + if (typeCode == 0xf01c) + { + oMetaFile.m_sExtension = L".pcz"; + //decompress??? + } + oMetaFile.SetData(m_pvBits, oMetaHeader.cbSave, oMetaHeader.cbSize, 0 == oMetaHeader.compression); + } + + MetafilePictBlip::~MetafilePictBlip() + { + RELEASEARRAYOBJECTS( m_rgbUid ); + RELEASEARRAYOBJECTS( m_rgbUidPrimary ); + RELEASEARRAYOBJECTS( m_pvBits ); + } + + Record* MetafilePictBlip::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new MetafilePictBlip( _reader, bodySize, typeCode, version, instance ); + } + + /// Decompresses the bits of the picture if the picture is decompressed. + /// If the picture is not compressed, it returns original unsigned char array. + unsigned long MetafilePictBlip::Decompress( unsigned char **buffer ) + { + unsigned long uncomprLen = 0; + + + if ( m_fCompression == BlipCompressionDeflate ) + { + uncomprLen = m_cb; + *buffer = new unsigned char[uncomprLen]; + + HRESULT res = S_OK; + COfficeUtils* pOfficeUtils = new COfficeUtils(NULL); + + if (pOfficeUtils) + { + pOfficeUtils->Uncompress( *buffer, &uncomprLen, m_pvBits, m_cbSave ); + + delete pOfficeUtils; + pOfficeUtils = NULL; + } + } + else if ( m_fCompression == BlipCompressionNone ) + + { + uncomprLen = m_cbSave; + *buffer = new unsigned char[uncomprLen]; + + memcpy( *buffer, m_pvBits , m_cbSave ); + } + + return uncomprLen; + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.h b/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.h index 8aef4a202e..caf795d8cb 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/MetafilePictBlip.h @@ -34,7 +34,7 @@ #include "Record.h" #include "../../../OfficeUtils/src/OfficeUtils.h" #include "../../../OOXML/Base/Base.h" - +#include "../../../DesktopEditor/common/File.h" namespace DocFileFormat { @@ -67,47 +67,9 @@ public: BYTE compression; BYTE filter; - CMetaHeader() - { - cbSize = cbSave = 0; - filter = compression = 0; - ptSize.x = ptSize.y = 0; + CMetaHeader(); - rcBounds.bottom = rcBounds.left = rcBounds.right = rcBounds.top = 0; - - } - - void ToWMFHeader(WmfPlaceableFileHeader* pHeader) - { - if (NULL == pHeader) - return; - - pHeader->Key = 0x9AC6CDD7; - pHeader->Hmf = 0; - - pHeader->BoundingBox.Left = (short)rcBounds.left; - pHeader->BoundingBox.Top = (short)rcBounds.top; - pHeader->BoundingBox.Right = (short)rcBounds.right; - pHeader->BoundingBox.Bottom = (short)rcBounds.bottom; - - pHeader->Inch = 1440; // 1:1 - pHeader->Reserved = 0; - - pHeader->Checksum = 0; - pHeader->Checksum ^= (pHeader->Key & 0x0000FFFFL); - pHeader->Checksum ^= ((pHeader->Key & 0xFFFF0000L) >> 16); - - pHeader->Checksum ^= pHeader->Hmf; - - pHeader->Checksum ^= pHeader->BoundingBox.Left; - pHeader->Checksum ^= pHeader->BoundingBox.Top; - pHeader->Checksum ^= pHeader->BoundingBox.Right; - pHeader->Checksum ^= pHeader->BoundingBox.Bottom; - - pHeader->Checksum ^= pHeader->Inch; - pHeader->Checksum ^= (pHeader->Reserved & 0x0000FFFFL); - pHeader->Checksum ^= ((pHeader->Reserved & 0xFFFF0000L) >> 16); - } + void ToWMFHeader(WmfPlaceableFileHeader* pHeader); }; class CMetaFileBuffer @@ -123,91 +85,16 @@ private: LONG m_lMetaFileSize; public: - CMetaFileBuffer() - { - m_bIsValid = false; + CMetaFileBuffer(); + ~CMetaFileBuffer(); - m_pMetaHeader = NULL; - m_pMetaFile = NULL; + void SetHeader(BYTE* pHeader, LONG lSize); - m_lMetaHeaderSize = 0; - m_lMetaFileSize = 0; - } - ~CMetaFileBuffer() - { - RELEASEARRAYOBJECTS(m_pMetaHeader); - RELEASEARRAYOBJECTS(m_pMetaFile); - } + void SetData(BYTE* pCompress, LONG lCompressSize, LONG lUncompressSize, bool bIsCompressed); - void SetHeader(BYTE* pHeader, LONG lSize) - { - m_pMetaHeader = pHeader; - m_lMetaHeaderSize = lSize; - } + int ToBuffer(BYTE *& Data); - void SetData(BYTE* pCompress, LONG lCompressSize, LONG lUncompressSize, bool bIsCompressed) - { - if (!bIsCompressed) - { - m_pMetaFile = new BYTE[lCompressSize]; - m_lMetaFileSize = lCompressSize; - memcpy(m_pMetaFile, pCompress, lCompressSize); - } - else - { - ULONG lSize = lUncompressSize; - m_pMetaFile = new BYTE[lUncompressSize]; - - HRESULT res = S_OK; - COfficeUtils* pOfficeUtils = new COfficeUtils(NULL); - - if (pOfficeUtils) - { - pOfficeUtils->Uncompress( m_pMetaFile, &lSize, pCompress, lCompressSize ); - - delete pOfficeUtils; - pOfficeUtils = NULL; - - m_lMetaFileSize = (LONG)lSize; - } - else - { - RELEASEARRAYOBJECTS(m_pMetaFile); - m_lMetaFileSize = 0; - } - } - } - - - int ToBuffer(BYTE *& Data) - { - int sz = 0; - - if (NULL != m_pMetaHeader) sz += m_lMetaHeaderSize; - if (NULL != m_pMetaFile) sz += m_lMetaFileSize; - - Data = new BYTE[sz]; - int pos = 0; - - if (NULL != m_pMetaHeader) - { - memcpy(Data, (BYTE*)m_pMetaHeader, m_lMetaHeaderSize); - pos += m_lMetaHeaderSize; - } - if (NULL != m_pMetaFile) - { - memcpy(Data + pos, (BYTE*)m_pMetaFile, m_lMetaFileSize); - } - - return sz; - } - void ToFile(NSFile::CFileBinary* pFile) - { - if (NULL != m_pMetaHeader) - { - pFile->WriteFile((BYTE*)m_pMetaHeader, m_lMetaHeaderSize); - } - } + void ToFile(NSFile::CFileBinary* pFile); }; @@ -249,118 +136,14 @@ typedef enum _BlipCompression static const unsigned short TYPE_CODE_0xF01B = 0xF01B; static const unsigned short TYPE_CODE_0xF01C = 0xF01C; - MetafilePictBlip(): - Record(), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_cb(0), m_cbSave(0), m_fCompression(BlipCompressionNone), m_fFilter(false), - m_pvBits(NULL) - { - } + MetafilePictBlip(); + MetafilePictBlip( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); + virtual ~MetafilePictBlip(); - MetafilePictBlip( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): - Record( _reader, size, typeCode, version, instance ), m_rgbUid(NULL), m_rgbUidPrimary(NULL), m_cb(0), m_cbSave(0), - m_fCompression(BlipCompressionNone), m_fFilter(false), m_pvBits(NULL) - { - m_rgbUid = Reader->ReadBytes( 16, true ); - - if ( ( instance == 0x3D5 ) || ( instance == 0x217 ) || ( instance == 0x543 ) ) - { - m_rgbUidPrimary = Reader->ReadBytes( 16, true ); - } - - oMetaFile.m_bIsValid = TRUE; - oMetaFile.m_sExtension = L".emf"; - - CMetaHeader oMetaHeader; - - m_cb = Reader->ReadInt32(); - - m_rcBounds.left = Reader->ReadInt32(); - m_rcBounds.top = Reader->ReadInt32(); - m_rcBounds.right = Reader->ReadInt32() + m_rcBounds.left; - m_rcBounds.bottom = Reader->ReadInt32() + m_rcBounds.top; - - m_ptSize.x = Reader->ReadInt32(); - m_ptSize.y = Reader->ReadInt32(); - - m_cbSave = Reader->ReadInt32(); - m_fCompression = (BlipCompression)Reader->ReadByte(); - m_fFilter = ( Reader->ReadByte() == 1 ) ? (true) : (false); - - int sz = Reader->GetSize() - Reader->GetPosition(); - m_pvBits = Reader->ReadBytes( sz/*m_cbSave*/, true ); - - oMetaHeader.rcBounds = m_rcBounds; - oMetaHeader.cbSize = m_cb; - oMetaHeader.ptSize = m_ptSize; - oMetaHeader.cbSave = m_cbSave ; - oMetaHeader.compression = m_fCompression; - oMetaHeader.filter = m_fFilter; - - if (typeCode == 0xf01b) - { - oMetaFile.m_sExtension = L".wmf"; - - WmfPlaceableFileHeader oWmfHeader = {}; - oMetaHeader.ToWMFHeader(&oWmfHeader); - - LONG lLenHeader = 22; - BYTE* pMetaHeader = new BYTE[lLenHeader]; - memcpy(pMetaHeader, (void*)(&oWmfHeader), lLenHeader); - - oMetaFile.SetHeader(pMetaHeader, lLenHeader); - } - if (typeCode == 0xf01c) - { - oMetaFile.m_sExtension = L".pcz"; - //decompress??? - } - oMetaFile.SetData(m_pvBits, oMetaHeader.cbSave, oMetaHeader.cbSize, 0 == oMetaHeader.compression); - } - - virtual ~MetafilePictBlip() - { - RELEASEARRAYOBJECTS( m_rgbUid ); - RELEASEARRAYOBJECTS( m_rgbUidPrimary ); - RELEASEARRAYOBJECTS( m_pvBits ); - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new MetafilePictBlip( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); /// Decompresses the bits of the picture if the picture is decompressed. /// If the picture is not compressed, it returns original unsigned char array. - unsigned long Decompress( unsigned char **buffer ) - { - unsigned long uncomprLen = 0; - - - if ( m_fCompression == BlipCompressionDeflate ) - { - uncomprLen = m_cb; - *buffer = new unsigned char[uncomprLen]; - - HRESULT res = S_OK; - COfficeUtils* pOfficeUtils = new COfficeUtils(NULL); - - if (pOfficeUtils) - { - pOfficeUtils->Uncompress( *buffer, &uncomprLen, m_pvBits, m_cbSave ); - - delete pOfficeUtils; - pOfficeUtils = NULL; - } - } - else if ( m_fCompression == BlipCompressionNone ) - - { - uncomprLen = m_cbSave; - *buffer = new unsigned char[uncomprLen]; - - memcpy( *buffer, m_pvBits , m_cbSave ); - } - - return uncomprLen; - } + unsigned long Decompress( unsigned char **buffer ); }; } diff --git a/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.cpp b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.cpp new file mode 100644 index 0000000000..9f271e7c43 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.cpp @@ -0,0 +1,53 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "OfficeArtClientTextbox.h" + +namespace DocFileFormat +{ + OfficeArtClientTextbox::OfficeArtClientTextbox () : Record() + { + } + OfficeArtClientTextbox::OfficeArtClientTextbox (IBinaryReader* reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record(reader, size, typeCode, version, instance), m_nIndex(0) + { + unsigned int number = Reader->ReadUInt16(); + m_nIndex = Reader->ReadUInt16(); + } + OfficeArtClientTextbox::~OfficeArtClientTextbox() + { + + } + Record* OfficeArtClientTextbox::NewObject(IBinaryReader* reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new OfficeArtClientTextbox(reader, bodySize, typeCode, version, instance); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.h b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.h index 3799849b8d..2a7b65ebe4 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtClientTextbox.h @@ -40,25 +40,12 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF00D = 0xF00D; - OfficeArtClientTextbox () : Record() - { + OfficeArtClientTextbox (); + OfficeArtClientTextbox (IBinaryReader* reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~OfficeArtClientTextbox(); - } - - OfficeArtClientTextbox (IBinaryReader* reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record(reader, size, typeCode, version, instance), m_nIndex(0) - { - unsigned int number = Reader->ReadUInt16(); - m_nIndex = Reader->ReadUInt16(); - } - virtual ~OfficeArtClientTextbox() - { - - } - virtual Record* NewObject(IBinaryReader* reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new OfficeArtClientTextbox(reader, bodySize, typeCode, version, instance); - } + virtual Record* NewObject(IBinaryReader* reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); int m_nIndex = 0; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.cpp new file mode 100644 index 0000000000..ed2885aa38 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.cpp @@ -0,0 +1,51 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "OfficeArtFRITContainer.h" + +namespace DocFileFormat +{ + OfficeArtFRITContainer::OfficeArtFRITContainer () : RegularContainer() + { + } + OfficeArtFRITContainer::OfficeArtFRITContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer (_reader, size, typeCode, version, instance) + { + } + OfficeArtFRITContainer::~OfficeArtFRITContainer() + { + } + + Record* OfficeArtFRITContainer::NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new OfficeArtFRITContainer( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.h index 98328a856b..5b19499678 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/OfficeArtFRITContainer.h @@ -40,21 +40,10 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF118 = 0xF118; - OfficeArtFRITContainer () : RegularContainer() - { - } + OfficeArtFRITContainer (); + OfficeArtFRITContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~OfficeArtFRITContainer(); - OfficeArtFRITContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer (_reader, size, typeCode, version, instance) - { - } - - virtual ~OfficeArtFRITContainer() - { - } - - virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new OfficeArtFRITContainer( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/Record.cpp b/MsBinaryFile/DocFile/OfficeDrawing/Record.cpp index f5123da733..0d4efaf479 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/Record.cpp +++ b/MsBinaryFile/DocFile/OfficeDrawing/Record.cpp @@ -33,43 +33,35 @@ namespace DocFileFormat { - Record::~Record() - { - RELEASEARRAYOBJECTS( RawData ); - RELEASEOBJECT( Reader ); - } - - /*========================================================================================================*/ - - Record::Record(): - HeaderSize(0), BodySize(0), RawData(NULL), SiblingIdx(0), TypeCode(0), Version(0), Instance(0), Reader(NULL), - _ParentRecord(NULL) - { - } - - /*========================================================================================================*/ - - Record::Record( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ): - HeaderSize(Record::HEADER_SIZE_IN_BYTES), BodySize(bodySize), RawData(NULL), SiblingIdx(0), TypeCode(typeCode), Version(version), Instance(instance), Reader(NULL), - _ParentRecord(NULL) - { - HeaderSize = Record::HEADER_SIZE_IN_BYTES; - - int real_size = _reader->GetSize() - _reader->GetPosition(); - - if (real_size < BodySize) + Record::~Record() { - BodySize = real_size; + RELEASEARRAYOBJECTS( RawData ); + RELEASEOBJECT( Reader ); + } + Record::Record(): + HeaderSize(0), BodySize(0), RawData(NULL), SiblingIdx(0), TypeCode(0), Version(0), Instance(0), Reader(NULL), + _ParentRecord(NULL) + { + } + Record::Record( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ): + HeaderSize(Record::HEADER_SIZE_IN_BYTES), BodySize(bodySize), RawData(NULL), SiblingIdx(0), TypeCode(typeCode), Version(version), Instance(instance), Reader(NULL), + _ParentRecord(NULL) + { + HeaderSize = Record::HEADER_SIZE_IN_BYTES; + + int real_size = _reader->GetSize() - _reader->GetPosition(); + + if (real_size < BodySize) + { + BodySize = real_size; + } + + RawData = _reader->ReadBytes( BodySize, true ); + Reader = new MemoryStream( RawData, BodySize, false ); } - RawData = _reader->ReadBytes( BodySize, true ); - Reader = new MemoryStream( RawData, BodySize, false ); - } - - /*========================================================================================================*/ - - unsigned int Record::GetTotalSize() const - { - return ( HeaderSize + BodySize ); - } + unsigned int Record::GetTotalSize() const + { + return ( HeaderSize + BodySize ); + } } diff --git a/MsBinaryFile/DocFile/OfficeDrawing/Record.h b/MsBinaryFile/DocFile/OfficeDrawing/Record.h index 17025b11fd..a66a372fae 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/Record.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/Record.h @@ -63,6 +63,7 @@ namespace DocFileFormat virtual ~Record(); Record(); Record( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); + unsigned int GetTotalSize() const; virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) = 0; }; diff --git a/MsBinaryFile/DocFile/OfficeDrawing/RecordFactory.h b/MsBinaryFile/DocFile/OfficeDrawing/RecordFactory.h index eb8edd33d9..ba602b3dc2 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/RecordFactory.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/RecordFactory.h @@ -35,9 +35,9 @@ namespace DocFileFormat { - struct RecordFactory - { - static Record* ReadRecord( IBinaryReader* reader, unsigned int siblingIdx ); - static Record* NewRecord( unsigned short typeCode ); - }; -} \ No newline at end of file + struct RecordFactory + { + static Record* ReadRecord( IBinaryReader* reader, unsigned int siblingIdx ); + static Record* NewRecord( unsigned short typeCode ); + }; +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.cpp new file mode 100644 index 0000000000..1ecf02c354 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.cpp @@ -0,0 +1,74 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "RegularContainer.h" + +namespace DocFileFormat +{ + RegularContainer::RegularContainer() : Record() + { + } + RegularContainer::~RegularContainer() + { + for (std::vector::iterator iter = Children.begin(); iter != Children.end(); ++iter) + { + RELEASEOBJECT (*iter); + } + } + RegularContainer::RegularContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance) + { + unsigned int readSize = 0; + unsigned int idx = 0; + + while ( readSize < this->BodySize ) + { + Record* child = NULL; + + child = RecordFactory::ReadRecord( this->Reader, idx ); + + if ( child != NULL ) + { + this->Children.push_back( child ); + child->_ParentRecord = this; + + readSize += child->GetTotalSize(); + + idx++; + } + else + { + readSize += this->BodySize; + } + } + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.h index d3c0f9c17e..99bbe3bea8 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/RegularContainer.h @@ -40,44 +40,9 @@ namespace DocFileFormat class RegularContainer: public Record { public: - RegularContainer() : Record() - { - } - - virtual ~RegularContainer() - { - for (std::vector::iterator iter = Children.begin(); iter != Children.end(); ++iter) - { - RELEASEOBJECT (*iter); - } - } - - RegularContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance) - { - unsigned int readSize = 0; - unsigned int idx = 0; - - while ( readSize < this->BodySize ) - { - Record* child = NULL; - - child = RecordFactory::ReadRecord( this->Reader, idx ); - - if ( child != NULL ) - { - this->Children.push_back( child ); - child->_ParentRecord = this; - - readSize += child->GetTotalSize(); - - idx++; - } - else - { - readSize += this->BodySize; - } - } - } + RegularContainer(); + virtual ~RegularContainer(); + RegularContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); /// Finds the first child of the given type. template T* FirstChildWithType() const @@ -98,7 +63,6 @@ namespace DocFileFormat } public: - std::vector Children; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/Shape.cpp b/MsBinaryFile/DocFile/OfficeDrawing/Shape.cpp new file mode 100644 index 0000000000..5c37c34767 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/Shape.cpp @@ -0,0 +1,81 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "Shape.h" + +namespace DocFileFormat +{ + Shape::Shape(): + Record(), spid(0), fGroup(false), fChild(false), fPatriarch(false), fDeleted(false), fOleShape(false), + fHaveMaster(false), fFlipH(false), fFlipV(false), fConnector(false), fHaveAnchor(false), fBackground(false), + fHaveSpt(false), shapeType(NULL) + { + } + Shape::~Shape() + { + RELEASEOBJECT( shapeType ); + } + Shape::Shape( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): + Record( _reader, size, typeCode, version, instance ), spid(0), fGroup(false), fChild(false), fPatriarch(false), fDeleted(false), fOleShape(false), + fHaveMaster(false), fFlipH(false), fFlipV(false), fConnector(false), fHaveAnchor(false), fBackground(false), + fHaveSpt(false), shapeType(NULL) + { + spid = Reader->ReadInt32(); + + unsigned int flag = Reader->ReadUInt32(); + + fGroup = FormatUtils::BitmaskToBool( flag, 0x1 ); + fChild = FormatUtils::BitmaskToBool( flag, 0x2 ); + fPatriarch = FormatUtils::BitmaskToBool( flag, 0x4 ); + fDeleted = FormatUtils::BitmaskToBool( flag, 0x8 ); + fOleShape = FormatUtils::BitmaskToBool( flag, 0x10 ); + fHaveMaster = FormatUtils::BitmaskToBool( flag, 0x20 ); + fFlipH = FormatUtils::BitmaskToBool( flag, 0x40 ); + fFlipV = FormatUtils::BitmaskToBool( flag, 0x80 ); + fConnector = FormatUtils::BitmaskToBool( flag, 0x100 ); + fHaveAnchor = FormatUtils::BitmaskToBool( flag, 0x200 ); + fBackground = FormatUtils::BitmaskToBool( flag, 0x400 ); + fHaveSpt = FormatUtils::BitmaskToBool( flag, 0x800 ); + + if (Instance > 0) + shapeType = ShapeTypeFactory::NewShapeType((MSOSPT)Instance); + else if (!fHaveSpt) + { + shapeType = ShapeTypeFactory::NewShapeType(msosptNotPrimitive); + } + } + + Record* Shape::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new Shape( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/Shape.h b/MsBinaryFile/DocFile/OfficeDrawing/Shape.h index 33ea2e1014..60b9404b32 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/Shape.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/Shape.h @@ -58,52 +58,11 @@ namespace DocFileFormat public: static const unsigned short TYPE_CODE_0xF00A = 0xF00A; - Shape(): - Record(), spid(0), fGroup(false), fChild(false), fPatriarch(false), fDeleted(false), fOleShape(false), - fHaveMaster(false), fFlipH(false), fFlipV(false), fConnector(false), fHaveAnchor(false), fBackground(false), - fHaveSpt(false), shapeType(NULL) - { - } + Shape(); + virtual ~Shape(); + Shape( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); - virtual ~Shape() - { - RELEASEOBJECT( shapeType ); - } - - Shape( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): - Record( _reader, size, typeCode, version, instance ), spid(0), fGroup(false), fChild(false), fPatriarch(false), fDeleted(false), fOleShape(false), - fHaveMaster(false), fFlipH(false), fFlipV(false), fConnector(false), fHaveAnchor(false), fBackground(false), - fHaveSpt(false), shapeType(NULL) - { - spid = Reader->ReadInt32(); - - unsigned int flag = Reader->ReadUInt32(); - - fGroup = FormatUtils::BitmaskToBool( flag, 0x1 ); - fChild = FormatUtils::BitmaskToBool( flag, 0x2 ); - fPatriarch = FormatUtils::BitmaskToBool( flag, 0x4 ); - fDeleted = FormatUtils::BitmaskToBool( flag, 0x8 ); - fOleShape = FormatUtils::BitmaskToBool( flag, 0x10 ); - fHaveMaster = FormatUtils::BitmaskToBool( flag, 0x20 ); - fFlipH = FormatUtils::BitmaskToBool( flag, 0x40 ); - fFlipV = FormatUtils::BitmaskToBool( flag, 0x80 ); - fConnector = FormatUtils::BitmaskToBool( flag, 0x100 ); - fHaveAnchor = FormatUtils::BitmaskToBool( flag, 0x200 ); - fBackground = FormatUtils::BitmaskToBool( flag, 0x400 ); - fHaveSpt = FormatUtils::BitmaskToBool( flag, 0x800 ); - - if (Instance > 0) - shapeType = ShapeTypeFactory::NewShapeType((MSOSPT)Instance); - else if (!fHaveSpt) - { - shapeType = ShapeTypeFactory::NewShapeType(msosptNotPrimitive); - } - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new Shape( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); inline int GetShapeID() const { @@ -127,4 +86,4 @@ namespace DocFileFormat return isResult; } }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.cpp new file mode 100644 index 0000000000..8a84ae02ad --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.cpp @@ -0,0 +1,127 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ShapeContainer.h" + +namespace DocFileFormat +{ + ShapeContainer::ShapeContainer(): + RegularContainer(), m_nIndex(0), m_nShapeType(0), m_bSkip(false), m_bBackground(false), m_bOLE(false), m_bOleInPicture(false) + { + } + + ShapeContainer::ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ) : + m_bSkip(false), m_bBackground(false), m_bOLE(false), m_nIndex(0), m_nShapeType(0), RegularContainer( _reader, size, typeCode, version, instance ) + { + for ( size_t i = 0; i < this->Children.size(); ++i ) + { + ClientAnchor *clientAnchor = dynamic_cast( this->Children[i] ); + //if ( (clientAnchor) && (clientAnchor->value == 0x80000000)) + // m_bSkip = true; //О реорганизации территориальных органов ПФР с 01.11.2018.doc + + Shape* sh = dynamic_cast( this->Children[i] ); + if (sh) + { + m_bBackground = sh->fBackground; + m_bOLE = sh->fOleShape; + + if (sh->shapeType) + { + m_nShapeType = sh->shapeType->GetTypeCode(); + } + else + { + for ( size_t j = 0; j < this->Children.size(); ++j) + { + ShapeOptions* sh_options = dynamic_cast( this->Children[j] ); + if (sh_options) + { + if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(ODRAW::pib)) + { + m_nShapeType = msosptPictureFrame; + } + } + } + } + } + + } + } + + ShapeContainer::~ShapeContainer() + { + } + + Record* ShapeContainer::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new ShapeContainer( _reader, bodySize, typeCode, version, instance ); + } + + ODRAW::OfficeArtFOPTEPtr ShapeContainer::ExtractOption(const ODRAW::ePropertyId & prop) const + { + ODRAW::OfficeArtFOPTEPtr ret; + + for ( size_t i = 0; i < this->Children.size(); ++i ) + { + ShapeOptions* opt = dynamic_cast( this->Children[i] ); + + if ( opt == NULL ) continue; + + std::map::iterator pFind = opt->OptionsByID.find(prop); + if (pFind != opt->OptionsByID.end()) + { + ret = pFind->second; + } + } + return ret; + } + + std::vector ShapeContainer::ExtractOptions() const + { + std::vector ret; + + //build the list of all option entries of this shape + for ( size_t i = 0; i < this->Children.size(); ++i ) + { + ShapeOptions* opt = dynamic_cast( this->Children[i] ); + + if ( opt == NULL ) continue; + + for ( size_t i = 0; i < opt->Options.size(); i++) + { + ret.push_back( opt->Options[i]); + } + } + + return ret; + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.h index 515f146aba..7b78d98dd3 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/ShapeContainer.h @@ -50,95 +50,13 @@ namespace DocFileFormat bool m_bOleInPicture; bool m_bSkip; - ShapeContainer(): - RegularContainer(), m_nIndex(0), m_nShapeType(0), m_bSkip(false), m_bBackground(false), m_bOLE(false), m_bOleInPicture(false) - { - } + ShapeContainer(); + ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); + virtual ~ShapeContainer(); - ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ) : - m_bSkip(false), m_bBackground(false), m_bOLE(false), m_nIndex(0), m_nShapeType(0), RegularContainer( _reader, size, typeCode, version, instance ) - { - for ( size_t i = 0; i < this->Children.size(); ++i ) - { - ClientAnchor *clientAnchor = dynamic_cast( this->Children[i] ); - //if ( (clientAnchor) && (clientAnchor->value == 0x80000000)) - // m_bSkip = true; //О реорганизации территориальных органов ПФР с 01.11.2018.doc + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); - Shape* sh = dynamic_cast( this->Children[i] ); - if (sh) - { - m_bBackground = sh->fBackground; - m_bOLE = sh->fOleShape; - - if (sh->shapeType) - { - m_nShapeType = sh->shapeType->GetTypeCode(); - } - else - { - for ( size_t j = 0; j < this->Children.size(); ++j) - { - ShapeOptions* sh_options = dynamic_cast( this->Children[j] ); - if (sh_options) - { - if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(ODRAW::pib)) - { - m_nShapeType = msosptPictureFrame; - } - } - } - } - } - - } - } - - virtual ~ShapeContainer() - { - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new ShapeContainer( _reader, bodySize, typeCode, version, instance ); - } - - ODRAW::OfficeArtFOPTEPtr ExtractOption(const ODRAW::ePropertyId & prop) const - { - ODRAW::OfficeArtFOPTEPtr ret; - - for ( size_t i = 0; i < this->Children.size(); ++i ) - { - ShapeOptions* opt = dynamic_cast( this->Children[i] ); - - if ( opt == NULL ) continue; - - std::map::iterator pFind = opt->OptionsByID.find(prop); - if (pFind != opt->OptionsByID.end()) - { - ret = pFind->second; - } - } - return ret; - } - - std::vector ExtractOptions() const - { - std::vector ret; - - //build the list of all option entries of this shape - for ( size_t i = 0; i < this->Children.size(); ++i ) - { - ShapeOptions* opt = dynamic_cast( this->Children[i] ); - - if ( opt == NULL ) continue; - - for ( size_t i = 0; i < opt->Options.size(); i++) - { - ret.push_back( opt->Options[i]); - } - } - - return ret; - } + ODRAW::OfficeArtFOPTEPtr ExtractOption(const ODRAW::ePropertyId & prop) const; + std::vector ExtractOptions() const; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.cpp b/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.cpp new file mode 100644 index 0000000000..e6d6592b4c --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.cpp @@ -0,0 +1,72 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ShapeOptions.h" + +namespace DocFileFormat +{ + ShapeOptions::ShapeOptions() : Record() + { + } + ShapeOptions::~ShapeOptions() + { + } + ShapeOptions::ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance) + { + long pos = Reader->GetPosition(); + + // parse the flags and the simple values + for (unsigned int i = 0; i < instance; ++i) + { + ODRAW::OfficeArtFOPTEPtr fopte = ODRAW::OfficeArtFOPTE::load_and_create(Reader); + if (!fopte)continue; + + + Options.push_back(fopte); + } + // complex load + for(size_t i = 0; i < Options.size(); ++i) + { + if(Options[i]->fComplex && Options[i]->op > 0) + { + Options[i]->ReadComplexData(Reader); + } + OptionsByID.insert(std::make_pair((ODRAW::ePropertyId)Options[i]->opid, Options[i])); + } + + Reader->Seek(( pos + size ), 0/*STREAM_SEEK_SET*/); + } + Record* ShapeOptions::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return new ShapeOptions( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.h b/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.h index ed38ab3522..19e135298e 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/ShapeOptions.h @@ -111,44 +111,10 @@ namespace DocFileFormat std::vector Options; std::map OptionsByID; - ShapeOptions() : Record() - { - } + ShapeOptions(); + virtual ~ShapeOptions(); + ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); - virtual ~ShapeOptions() - { - } - - ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance) - { - long pos = Reader->GetPosition(); - - // parse the flags and the simple values - for (unsigned int i = 0; i < instance; ++i) - { - ODRAW::OfficeArtFOPTEPtr fopte = ODRAW::OfficeArtFOPTE::load_and_create(Reader); - if (!fopte)continue; - - - Options.push_back(fopte); - } - // complex load - - for(size_t i = 0; i < Options.size(); ++i) - { - if(Options[i]->fComplex && Options[i]->op > 0) - { - Options[i]->ReadComplexData(Reader); - } - OptionsByID.insert(std::make_pair((ODRAW::ePropertyId)Options[i]->opid, Options[i])); - } - - Reader->Seek(( pos + size ), 0/*STREAM_SEEK_SET*/); - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return new ShapeOptions( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); }; } diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.cpp b/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.cpp new file mode 100644 index 0000000000..41da4e928a --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.cpp @@ -0,0 +1,56 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ShapeType.h" + +namespace DocFileFormat +{ + Handle::Handle() + { + } + Handle::Handle(std::wstring pos, std::wstring xRange) + { + position = pos; + xrange = xRange; + } + + ShapeType::ShapeType (unsigned int typeCode) : Filled(true), Stroked(true), TypeCode(typeCode), Joins(miter), ShapeConcentricFill(false) + { + } + ShapeType::~ShapeType() + { + } + unsigned int ShapeType::GetTypeCode() const + { + return TypeCode; + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.h b/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.h index 730ef09f78..81443ae451 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/ShapeType.h @@ -265,17 +265,10 @@ namespace DocFileFormat class Handle { - public: + public: + Handle(); + Handle(std::wstring pos, std::wstring xRange); - Handle() - { - } - - Handle(std::wstring pos, std::wstring xRange) - { - position = pos; - xrange = xRange; - } std::wstring position; std::wstring xrange; std::wstring switchHandle; @@ -288,18 +281,10 @@ namespace DocFileFormat { public: - ShapeType (unsigned int typeCode) : Filled(true), Stroked(true), TypeCode(typeCode), Joins(miter), ShapeConcentricFill(false) - { - } + ShapeType (unsigned int typeCode); + virtual ~ShapeType(); - virtual ~ShapeType() - { - } - - unsigned int GetTypeCode() const - { - return TypeCode; - } + unsigned int GetTypeCode() const; /// This string describes a sequence of commands that define the shape’s path. /// This string describes both the pSegmentInfo array and pVertices array in the shape’s geometry properties. diff --git a/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.cpp b/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.cpp new file mode 100644 index 0000000000..874609f5ab --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.cpp @@ -0,0 +1,55 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "SplitMenuColorContainer.h" + +namespace DocFileFormat +{ + SplitMenuColorContainer::SplitMenuColorContainer () : Record(), fillColor(0), lineColor(0), shadowColor(0), color3D(0) + { + } + SplitMenuColorContainer::SplitMenuColorContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance) + { + fillColor = Reader->ReadUInt32(); + lineColor = Reader->ReadUInt32(); + shadowColor = Reader->ReadUInt32(); + color3D = Reader->ReadUInt32(); + } + SplitMenuColorContainer::~SplitMenuColorContainer() + { + } + + Record* SplitMenuColorContainer::NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) + { + return new SplitMenuColorContainer( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.h b/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.h index 32b9aa4d2d..28987e2fd2 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/SplitMenuColorContainer.h @@ -41,34 +41,16 @@ namespace DocFileFormat static const unsigned short TYPE_CODE_0xF11E = 0xF11E; public: + SplitMenuColorContainer(); + SplitMenuColorContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance); + virtual ~SplitMenuColorContainer(); - SplitMenuColorContainer () : Record(), fillColor(0), lineColor(0), shadowColor(0), color3D(0) - { - - } - - SplitMenuColorContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance) - { - fillColor = Reader->ReadUInt32(); - lineColor = Reader->ReadUInt32(); - shadowColor = Reader->ReadUInt32(); - color3D = Reader->ReadUInt32(); - } - - virtual ~SplitMenuColorContainer() - { - } - - virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance) - { - return new SplitMenuColorContainer( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance); public: - unsigned int fillColor; // fill color unsigned int lineColor; // line color unsigned int shadowColor; // shadow color unsigned int color3D; // 3D color }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.cpp b/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.cpp new file mode 100644 index 0000000000..aee67f9a73 --- /dev/null +++ b/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.cpp @@ -0,0 +1,62 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "UnknownRecord.h" + +namespace DocFileFormat +{ + UnknownRecord::UnknownRecord(): + Record(), _bytes(NULL), _size(0) + { + } + UnknownRecord::UnknownRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): + Record( _reader, size, typeCode, version, instance ), _bytes(NULL), _size(0) + { + this->_size = (unsigned int)( this->Reader->GetSize() - this->Reader->GetPosition() ); + + if ( this->_size >= size ) + { + this->_size = size; + } + + this->_bytes = this->Reader->ReadBytes( this->_size, true ); + } + UnknownRecord::~UnknownRecord() + { + RELEASEARRAYOBJECTS( this->_bytes ); + } + + Record* UnknownRecord::NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) + { + return NULL;//new UnknownRecord( _reader, bodySize, typeCode, version, instance ); + } +} diff --git a/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.h b/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.h index 8e97cd2c5a..58b579ea55 100644 --- a/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.h +++ b/MsBinaryFile/DocFile/OfficeDrawing/UnknownRecord.h @@ -41,32 +41,10 @@ namespace DocFileFormat unsigned char* _bytes; unsigned int _size; - UnknownRecord(): - Record(), _bytes(NULL), _size(0) - { - } + UnknownRecord(); + UnknownRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ); + virtual ~UnknownRecord(); - UnknownRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ): - Record( _reader, size, typeCode, version, instance ), _bytes(NULL), _size(0) - { - this->_size = (unsigned int)( this->Reader->GetSize() - this->Reader->GetPosition() ); - - if ( this->_size >= size ) - { - this->_size = size; - } - - this->_bytes = this->Reader->ReadBytes( this->_size, true ); - } - - virtual ~UnknownRecord() - { - RELEASEARRAYOBJECTS( this->_bytes ); - } - - virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ) - { - return NULL;//new UnknownRecord( _reader, bodySize, typeCode, version, instance ); - } + virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/OleObjectMapping.cpp b/MsBinaryFile/DocFile/OleObjectMapping.cpp new file mode 100644 index 0000000000..0ee026de87 --- /dev/null +++ b/MsBinaryFile/DocFile/OleObjectMapping.cpp @@ -0,0 +1,172 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "OleObjectMapping.h" + +namespace DocFileFormat +{ + OleObjectMapping::OleObjectMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const std::wstring& shapeId) + : + OleObjectMapping::AbstractOpenXmlMapping(writer), m_context(NULL), _pict(NULL), _caller(NULL), _shapeId(shapeId) + { + m_context = context; + _pict = pict; + _caller = caller; + } + + void OleObjectMapping::Apply(IVisitable* visited) + { + OleObject* ole = static_cast(visited); + + if ( ole != NULL ) + { + if (ole->isEmbedded) + { + if (ole->isEquation) ole->ClipboardFormat = L"Equation"; + else ole->ClipboardFormat = L"MSWordDocx"; + + ole->Program = L"Word.Document"; + } + m_pXmlWriter->WriteNodeBegin( L"o:OLEObject", TRUE ); + + int relID = -1; + + if ( ole->bLinked ) + { + relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link); + + m_pXmlWriter->WriteAttribute( L"Type", L"Link" ); + m_pXmlWriter->WriteAttribute( L"UpdateMode", ole->UpdateMode); + } + else + { + if (ole->isEmbedded) + relID = m_context->_docx->RegisterPackage(_caller, ole->ClipboardFormat); + else + relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat); + + m_pXmlWriter->WriteAttribute( L"Type", L"Embed" ); + + copyEmbeddedObject( ole ); + } + + m_pXmlWriter->WriteAttribute( L"ProgID", ole->Program); + m_pXmlWriter->WriteAttribute( L"ShapeID", _shapeId); + m_pXmlWriter->WriteAttribute( L"DrawAspect", L"Content" ); + m_pXmlWriter->WriteAttribute( L"ObjectID", ole->ObjectId); + m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) ); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + + m_pXmlWriter->WriteNodeEnd( L"o:OLEObject" ); + } + } + + std::wstring OleObjectMapping::GetTargetExt(const std::wstring& objectType) + { + std::wstring objectExt = L".bin"; + + if ( objectType == L"Biff8" ) + { + objectExt = L".xls"; + } + else if ( objectType == L"MSWordDoc" ) + { + objectExt = L".doc"; + } + else if ( objectType == L"MSPresentation" ) + { + objectExt = L".ppt"; + } + else if ( objectType == L"MSWordDocx" ) + { + objectExt = L".docx"; + } + else if ( objectType == L"Equation" ) + { + objectExt = L".xml"; + } + return objectExt; + } + + std::wstring OleObjectMapping::GetContentType(const std::wstring& objectType) + { + std::wstring objectContentType = OpenXmlContentTypes::OleObject; + + if ( objectType == L"Biff8" ) + { + objectContentType = OpenXmlContentTypes::MSExcel; + } + else if ( objectType == L"MSWordDoc" ) + { + objectContentType = OpenXmlContentTypes::MSWord; + } + else if ( objectType == L"MSPresentation" ) + { + objectContentType = OpenXmlContentTypes::MSPowerpoint; + } + else if ( objectType == L"MSWordDocx" ) + { + objectContentType = OpenXmlContentTypes::MSWordDocx; + } + else if ( objectType == L"Equation" ) + { + objectContentType = OpenXmlContentTypes::Xml; + } + return objectContentType; + } + + void OleObjectMapping::copyEmbeddedObject( const OleObject* ole ) + { + if ( ole == NULL ) return; + + std::wstring clsid; + std::wstring exelChart = L"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); + + if (ole->nWordVersion == 2) + { + object_descr.clsid = ole->ClipboardFormat; + object_descr.bNativeOnly = true; + } + if (ole->isEquation || ole->isEmbedded || ole->nWordVersion == 2) + { + object_descr.data = ole->emeddedData; + } + + m_context->_docx->OleObjectsList.push_back(object_descr); + } +} diff --git a/MsBinaryFile/DocFile/OleObjectMapping.h b/MsBinaryFile/DocFile/OleObjectMapping.h index 01107b3425..9cdac005be 100644 --- a/MsBinaryFile/DocFile/OleObjectMapping.h +++ b/MsBinaryFile/DocFile/OleObjectMapping.h @@ -43,143 +43,15 @@ namespace DocFileFormat class OleObjectMapping: public AbstractOpenXmlMapping, public IMapping { public: - OleObjectMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const std::wstring& shapeId) - : - AbstractOpenXmlMapping(writer), m_context(NULL), _pict(NULL), _caller(NULL), _shapeId(shapeId) - { - m_context = context; - _pict = pict; - _caller = caller; - } + OleObjectMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const std::wstring& shapeId); - virtual void Apply(IVisitable* visited) - { - OleObject* ole = static_cast(visited); + virtual void Apply(IVisitable* visited); - if ( ole != NULL ) - { - if (ole->isEmbedded) - { - if (ole->isEquation) ole->ClipboardFormat = L"Equation"; - else ole->ClipboardFormat = L"MSWordDocx"; - - ole->Program = L"Word.Document"; - } - m_pXmlWriter->WriteNodeBegin( L"o:OLEObject", TRUE ); - - int relID = -1; - - if ( ole->bLinked ) - { - relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link); - - m_pXmlWriter->WriteAttribute( L"Type", L"Link" ); - m_pXmlWriter->WriteAttribute( L"UpdateMode", ole->UpdateMode); - } - else - { - if (ole->isEmbedded) - relID = m_context->_docx->RegisterPackage(_caller, ole->ClipboardFormat); - else - relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat); - - m_pXmlWriter->WriteAttribute( L"Type", L"Embed" ); - - copyEmbeddedObject( ole ); - } - - m_pXmlWriter->WriteAttribute( L"ProgID", ole->Program); - m_pXmlWriter->WriteAttribute( L"ShapeID", _shapeId); - m_pXmlWriter->WriteAttribute( L"DrawAspect", L"Content" ); - m_pXmlWriter->WriteAttribute( L"ObjectID", ole->ObjectId); - m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) ); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - m_pXmlWriter->WriteNodeEnd( L"o:OLEObject" ); - } - } - - static std::wstring GetTargetExt(const std::wstring& objectType) - { - std::wstring objectExt = L".bin"; - - if ( objectType == L"Biff8" ) - { - objectExt = L".xls"; - } - else if ( objectType == L"MSWordDoc" ) - { - objectExt = L".doc"; - } - else if ( objectType == L"MSPresentation" ) - { - objectExt = L".ppt"; - } - else if ( objectType == L"MSWordDocx" ) - { - objectExt = L".docx"; - } - else if ( objectType == L"Equation" ) - { - objectExt = L".xml"; - } - return objectExt; - } - - static std::wstring GetContentType(const std::wstring& objectType) - { - std::wstring objectContentType = OpenXmlContentTypes::OleObject; - - if ( objectType == L"Biff8" ) - { - objectContentType = OpenXmlContentTypes::MSExcel; - } - else if ( objectType == L"MSWordDoc" ) - { - objectContentType = OpenXmlContentTypes::MSWord; - } - else if ( objectType == L"MSPresentation" ) - { - objectContentType = OpenXmlContentTypes::MSPowerpoint; - } - else if ( objectType == L"MSWordDocx" ) - { - objectContentType = OpenXmlContentTypes::MSWordDocx; - } - else if ( objectType == L"Equation" ) - { - objectContentType = OpenXmlContentTypes::Xml; - } - return objectContentType; - } + static std::wstring GetTargetExt(const std::wstring& objectType); + static std::wstring GetContentType(const std::wstring& objectType); private: - inline void copyEmbeddedObject( const OleObject* ole ) - { - if ( ole == NULL ) return; - - std::wstring clsid; - std::wstring exelChart = L"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); - - if (ole->nWordVersion == 2) - { - object_descr.clsid = ole->ClipboardFormat; - object_descr.bNativeOnly = true; - } - if (ole->isEquation || ole->isEmbedded || ole->nWordVersion == 2) - { - object_descr.data = ole->emeddedData; - } - - m_context->_docx->OleObjectsList.push_back(object_descr); - } - + void copyEmbeddedObject( const OleObject* ole ); ConversionContext* m_context; diff --git a/MsBinaryFile/DocFile/ParagraphPropertyExceptions.cpp b/MsBinaryFile/DocFile/ParagraphPropertyExceptions.cpp index 9ce3b1acf4..b7ff41dcd3 100644 --- a/MsBinaryFile/DocFile/ParagraphPropertyExceptions.cpp +++ b/MsBinaryFile/DocFile/ParagraphPropertyExceptions.cpp @@ -34,6 +34,17 @@ namespace DocFileFormat { + ParagraphPropertyExceptions::ParagraphPropertyExceptions() : PropertyExceptions(), istd(0) + { + } + ParagraphPropertyExceptions::ParagraphPropertyExceptions( const std::list& grpprl ): + PropertyExceptions( grpprl ), istd(0) + { + } + ParagraphPropertyExceptions::~ParagraphPropertyExceptions() + { + } + ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion): PropertyExceptions( ( bytes + 2 ), ( size - 2 ), nWordVersion) { diff --git a/MsBinaryFile/DocFile/ParagraphPropertyExceptions.h b/MsBinaryFile/DocFile/ParagraphPropertyExceptions.h index 2ce08c77e3..7e47f5164e 100644 --- a/MsBinaryFile/DocFile/ParagraphPropertyExceptions.h +++ b/MsBinaryFile/DocFile/ParagraphPropertyExceptions.h @@ -45,18 +45,9 @@ namespace DocFileFormat /// Creates a PAPX wich doesn't modify anything. /// The grpprl list is empty - ParagraphPropertyExceptions() : PropertyExceptions(), istd(0) - { - } - - ParagraphPropertyExceptions( const std::list& grpprl ): - PropertyExceptions( grpprl ), istd(0) - { - } - - virtual ~ParagraphPropertyExceptions() - { - } + ParagraphPropertyExceptions(); + ParagraphPropertyExceptions( const std::list& grpprl ); + virtual ~ParagraphPropertyExceptions(); /// Parses the bytes to retrieve a PAPX ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion); diff --git a/MsBinaryFile/DocFile/PieceDescriptor.cpp b/MsBinaryFile/DocFile/PieceDescriptor.cpp new file mode 100644 index 0000000000..0f15ce06c4 --- /dev/null +++ b/MsBinaryFile/DocFile/PieceDescriptor.cpp @@ -0,0 +1,63 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "PieceDescriptor.h" + +namespace DocFileFormat +{ + PieceDescriptor::PieceDescriptor(unsigned char *bytes, unsigned int size, int code_page_) : fc(0), code_page(code_page_), cpStart(0), cpEnd(0) + { + if (8 == size) + { + //get the fc value + unsigned int fcValue = FormatUtils::BytesToUInt32(bytes, 2, size); + + //get the flag + bool flag = FormatUtils::BitmaskToBool((int)fcValue, 0x40000000); + + //delete the flag + fcValue = fcValue & 0xBFFFFFFF; + + //find encoding and offset + if (flag) + { + code_page = ENCODING_WINDOWS_1250; + this->fc = (unsigned int)( fcValue / 2 ); + } + else + { + code_page = (code_page == ENCODING_WINDOWS_1250 ? ENCODING_UTF16 : code_page_); + this->fc = fcValue; + } + } + } +} diff --git a/MsBinaryFile/DocFile/PieceDescriptor.h b/MsBinaryFile/DocFile/PieceDescriptor.h index 928578fcf3..b21265063d 100644 --- a/MsBinaryFile/DocFile/PieceDescriptor.h +++ b/MsBinaryFile/DocFile/PieceDescriptor.h @@ -41,32 +41,7 @@ namespace DocFileFormat friend class PieceTable; public: /// Parses the bytes to retrieve a PieceDescriptor - PieceDescriptor(unsigned char *bytes, unsigned int size, int code_page_) : fc(0), code_page(code_page_), cpStart(0), cpEnd(0) - { - if (8 == size) - { - //get the fc value - unsigned int fcValue = FormatUtils::BytesToUInt32(bytes, 2, size); - - //get the flag - bool flag = FormatUtils::BitmaskToBool((int)fcValue, 0x40000000); - - //delete the flag - fcValue = fcValue & 0xBFFFFFFF; - - //find encoding and offset - if (flag) - { - code_page = ENCODING_WINDOWS_1250; - this->fc = (unsigned int)( fcValue / 2 ); - } - else - { - code_page = (code_page == ENCODING_WINDOWS_1250 ? ENCODING_UTF16 : code_page_); - this->fc = fcValue; - } - } - } + PieceDescriptor(unsigned char *bytes, unsigned int size, int code_page_); public: /// File offset of beginning of piece. diff --git a/MsBinaryFile/DocFile/PieceTable.cpp b/MsBinaryFile/DocFile/PieceTable.cpp index f0dda157f7..9436d23e75 100644 --- a/MsBinaryFile/DocFile/PieceTable.cpp +++ b/MsBinaryFile/DocFile/PieceTable.cpp @@ -474,7 +474,7 @@ namespace DocFileFormat return encodingChars; } - inline bool PieceTable::ReadSymbolsBuffer(int pos, int size, int coding, POLE::Stream* word, std::vector* encodingChars) + bool PieceTable::ReadSymbolsBuffer(int pos, int size, int coding, POLE::Stream* word, std::vector* encodingChars) { unsigned char* bytes = new unsigned char[size]; if (NULL == bytes) diff --git a/MsBinaryFile/DocFile/PieceTable.h b/MsBinaryFile/DocFile/PieceTable.h index 277aae07d4..e68b5323c0 100644 --- a/MsBinaryFile/DocFile/PieceTable.h +++ b/MsBinaryFile/DocFile/PieceTable.h @@ -45,7 +45,7 @@ namespace DocFileFormat friend class FootnotesMapping; friend class EndnotesMapping; friend class CommentsMapping; - friend class Table; + friend class Table; friend class TextboxMapping; friend class NumberingMapping; diff --git a/MsBinaryFile/DocFile/RGBColor.cpp b/MsBinaryFile/DocFile/RGBColor.cpp new file mode 100644 index 0000000000..7e52eccd55 --- /dev/null +++ b/MsBinaryFile/DocFile/RGBColor.cpp @@ -0,0 +1,75 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 +#include "RGBColor.h" + +namespace DocFileFormat +{ + RGBColor::RGBColor( _UINT32 cv, ByteOrder order ) + { + unsigned char bytes[4]; + bytes[0] = cv & 0x000000FF; + bytes[1] = (cv >> 8) & 0x000000FF; + bytes[2] = (cv >> 16) & 0x000000FF; + bytes[3] = (cv >> 24) & 0x000000FF; + + std::wstringstream rgbColor6, rgbColor8; + + if( order == RedFirst ) + { + this->Red = bytes[0]; + this->Green = bytes[1]; + this->Blue = bytes[2]; + this->Alpha = bytes[3]; + + rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % Red % Green % Blue; + rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % Red % Green % Blue % Alpha; + + SixDigitHexCode = rgbColor6.str(); + EightDigitHexCode = rgbColor8.str(); + } + else if ( order == RedLast ) + { + this->Red = bytes[2]; + this->Green = bytes[1]; + this->Blue = bytes[0]; + this->Alpha = bytes[3]; + + rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % Red % Green % Blue; + rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % Red % Green % Blue % Alpha; + + SixDigitHexCode = rgbColor6.str(); + EightDigitHexCode = rgbColor8.str(); + } + } +} diff --git a/MsBinaryFile/DocFile/RGBColor.h b/MsBinaryFile/DocFile/RGBColor.h index 2187c46961..9ddb726a44 100644 --- a/MsBinaryFile/DocFile/RGBColor.h +++ b/MsBinaryFile/DocFile/RGBColor.h @@ -54,42 +54,6 @@ namespace DocFileFormat std::wstring SixDigitHexCode; std::wstring EightDigitHexCode; - RGBColor( _UINT32 cv, ByteOrder order ) - { - unsigned char bytes[4]; - bytes[0] = cv & 0x000000FF; - bytes[1] = (cv >> 8) & 0x000000FF; - bytes[2] = (cv >> 16) & 0x000000FF; - bytes[3] = (cv >> 24) & 0x000000FF; - - std::wstringstream rgbColor6, rgbColor8; - - if( order == RedFirst ) - { - this->Red = bytes[0]; - this->Green = bytes[1]; - this->Blue = bytes[2]; - this->Alpha = bytes[3]; - - rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % Red % Green % Blue; - rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % Red % Green % Blue % Alpha; - - SixDigitHexCode = rgbColor6.str(); - EightDigitHexCode = rgbColor8.str(); - } - else if ( order == RedLast ) - { - this->Red = bytes[2]; - this->Green = bytes[1]; - this->Blue = bytes[0]; - this->Alpha = bytes[3]; - - rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % Red % Green % Blue; - rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % Red % Green % Blue % Alpha; - - SixDigitHexCode = rgbColor6.str(); - EightDigitHexCode = rgbColor8.str(); - } - } + RGBColor( _UINT32 cv, ByteOrder order ); }; } diff --git a/MsBinaryFile/DocFile/SectionDescriptor.cpp b/MsBinaryFile/DocFile/SectionDescriptor.cpp new file mode 100644 index 0000000000..c522addbe3 --- /dev/null +++ b/MsBinaryFile/DocFile/SectionDescriptor.cpp @@ -0,0 +1,70 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "SectionDescriptor.h" + +namespace DocFileFormat +{ + const int SectionDescriptor::GetSize(int nWordVersion) + { + return (nWordVersion == 2) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE; + } + SectionDescriptor::SectionDescriptor() : fn(0), fnMpr(0), fcMpr(0), fcSepx(0) + { + } + + SectionDescriptor::~SectionDescriptor() + { + } + + ByteStructure* SectionDescriptor::ConstructObject( VirtualStreamReader* reader, int length ) + { + SectionDescriptor *newObject = new SectionDescriptor(); + + if (reader->nWordVersion == 2) + { + newObject->fn = reader->ReadInt16(); + newObject->fcSepx = reader->ReadInt32(); + //newObject->fnMpr = reader->ReadInt16(); + //newObject->fcMpr = reader->ReadInt16(); + } + else + { + newObject->fn = reader->ReadInt16(); + newObject->fcSepx = reader->ReadInt32(); + newObject->fnMpr = reader->ReadInt16(); + newObject->fcMpr = reader->ReadInt32(); + } + + return static_cast( newObject ); + } +} diff --git a/MsBinaryFile/DocFile/SectionDescriptor.h b/MsBinaryFile/DocFile/SectionDescriptor.h index c7867c1fad..5cc324764d 100644 --- a/MsBinaryFile/DocFile/SectionDescriptor.h +++ b/MsBinaryFile/DocFile/SectionDescriptor.h @@ -36,52 +36,26 @@ namespace DocFileFormat { - class SectionDescriptor: public ByteStructure - { - friend class WordDocument; + class SectionDescriptor: public ByteStructure + { + friend class WordDocument; - private: - short fn; - short fnMpr; - int fcMpr; - /// A signed integer that specifies the position in the WordDocument Stream where a Sepx structure is located. - int fcSepx; + private: + short fn; + short fnMpr; + int fcMpr; + /// A signed integer that specifies the position in the WordDocument Stream where a Sepx structure is located. + int fcSepx; static const int STRUCTURE_SIZE = 12; static const int STRUCTURE_SIZE_OLD = 6; - public: - static const int GetSize(int nWordVersion) - { - return (nWordVersion == 2) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE; - } - SectionDescriptor() : fn(0), fnMpr(0), fcMpr(0), fcSepx(0) - { - } - virtual ~SectionDescriptor() - { - } + public: + static const int GetSize(int nWordVersion); - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - SectionDescriptor *newObject = new SectionDescriptor(); + SectionDescriptor(); + virtual ~SectionDescriptor(); - if (reader->nWordVersion == 2) - { - newObject->fn = reader->ReadInt16(); - newObject->fcSepx = reader->ReadInt32(); - //newObject->fnMpr = reader->ReadInt16(); - //newObject->fcMpr = reader->ReadInt16(); - } - else - { - newObject->fn = reader->ReadInt16(); - newObject->fcSepx = reader->ReadInt32(); - newObject->fnMpr = reader->ReadInt16(); - newObject->fcMpr = reader->ReadInt32(); - } - - return static_cast( newObject ); - } - }; + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); + }; } diff --git a/MsBinaryFile/DocFile/SectionPropertyExceptions.cpp b/MsBinaryFile/DocFile/SectionPropertyExceptions.cpp new file mode 100644 index 0000000000..941177f18d --- /dev/null +++ b/MsBinaryFile/DocFile/SectionPropertyExceptions.cpp @@ -0,0 +1,58 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "SectionPropertyExceptions.h" + +namespace DocFileFormat +{ + SectionPropertyExceptions::SectionPropertyExceptions( unsigned char* bytes, int size, int nWordVersion ): + PropertyExceptions( bytes, size, nWordVersion ), isBidi(false) + { + if (nWordVersion >= 2) + { + ReadExceptions(bytes, size, nWordVersion); + } + for ( std::list::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ ) + { + SinglePropertyModifier sprm( *iter ); + + if( sprm.OpCode == sprmSFBiDi && sprm.Arguments[0] != 0) + { + isBidi = true; + } + } + } + + SectionPropertyExceptions::~SectionPropertyExceptions() + { + } +} diff --git a/MsBinaryFile/DocFile/SectionPropertyExceptions.h b/MsBinaryFile/DocFile/SectionPropertyExceptions.h index 4aa00e30ae..3f4b9123e2 100644 --- a/MsBinaryFile/DocFile/SectionPropertyExceptions.h +++ b/MsBinaryFile/DocFile/SectionPropertyExceptions.h @@ -37,30 +37,11 @@ namespace DocFileFormat { class SectionPropertyExceptions: public PropertyExceptions { - public: + public: /// Parses the bytes to retrieve a SectionPropertyExceptions - SectionPropertyExceptions( unsigned char* bytes, int size, int nWordVersion ): - PropertyExceptions( bytes, size, nWordVersion ), isBidi(false) - { - if (nWordVersion >= 2) - { - ReadExceptions(bytes, size, nWordVersion); - } - for ( std::list::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ ) - { - SinglePropertyModifier sprm( *iter ); - - if( sprm.OpCode == sprmSFBiDi && sprm.Arguments[0] != 0) - { - isBidi = true; - } - } - } - - virtual ~SectionPropertyExceptions() - { - } + SectionPropertyExceptions( unsigned char* bytes, int size, int nWordVersion ); + virtual ~SectionPropertyExceptions(); bool isBidi; }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/ShadingDescriptor.cpp b/MsBinaryFile/DocFile/ShadingDescriptor.cpp new file mode 100644 index 0000000000..847fe7983e --- /dev/null +++ b/MsBinaryFile/DocFile/ShadingDescriptor.cpp @@ -0,0 +1,173 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "ShadingDescriptor.h" +#include "../Common/Base/FormatUtils.h" + +namespace DocFileFormat +{ + /// Creates a new ShadingDescriptor with default values + ShadingDescriptor::ShadingDescriptor() + { + setDefaultValues(); + } + + /// Parses the bytes to retrieve a ShadingDescriptor. + ShadingDescriptor::ShadingDescriptor(unsigned char* bytes, int size) + { + setDefaultValues(); + + if (NULL != bytes) + { + if (10 == size) + { + //it's a Word 2000/2003 descriptor + unsigned char cvForeBytes[4] = { bytes[2], bytes[1], bytes[0], 0 }; + unsigned char cvBackBytes[4] = { bytes[6], bytes[5], bytes[4], 0 }; + + cvFore = FormatUtils::BytesToUInt32( cvForeBytes, 0, 4 ); + + if ( bytes[3] == 0xFF ) + { + cvForeAuto = true; + } + + cvBack = FormatUtils::BytesToUInt32( cvBackBytes, 0, 4 ); + + if ( bytes[7] == 0xFF ) + { + cvBackAuto = true; + } + + ipat = (ShadingPattern)FormatUtils::BytesToUInt16( bytes, 8, size ); + + shadingType = shadingTypeShd; + + if ( ( cvFore == 0 ) && ( bytes[3] == 0xFF ) && ( cvBack == 0 ) && ( bytes[7] == 0xFF ) && ( ipat == Automatic ) ) + { + shadingSpecialValue = shadingSpecialValueShdAuto; + } + else if ( ( cvFore == 0xFFFFFF ) && ( bytes[3] == 0xFF ) && ( cvBack == 0xFFFFFF ) && ( bytes[7] == 0xFF ) && ( ipat == Automatic ) ) + { + shadingSpecialValue = shadingSpecialValueShdNil; + } + } + else if (2 == size) + { + //it's a Word 97 SPRM + short val = FormatUtils::BytesToInt16(bytes, 0, size); + + icoFore = GETBITS(val, 0, 4); + icoBack = GETBITS(val, 5, 9); + ipat = (ShadingPattern) GETBITS(val, 10, 15); + + shadingType = shadingTypeShd80; + + if ((icoFore == 0x1F) && (icoBack == 0x1F) && (ipat == 0x3F)) + { + shadingSpecialValue = shadingSpecialValueShd80Nil; + } + else + { + shadingType = shadingTypeShd; + + cvForeAuto = false; + cvBackAuto = false; + + if (0x00 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0x00); cvForeAuto = true; } + else if (0x01 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0x00); } + else if (0x02 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0xFF); } + else if (0x03 == icoFore) { cvFore = RGB2 (0x00, 0xFF, 0xFF); } + else if (0x04 == icoFore) { cvFore = RGB2 (0x00, 0xFF, 0x00); } + else if (0x05 == icoFore) { cvFore = RGB2 (0xFF, 0x00, 0xFF); } + else if (0x06 == icoFore) { cvFore = RGB2 (0xFF, 0x00, 0x00); } + else if (0x07 == icoFore) { cvFore = RGB2 (0xFF, 0xFF, 0x00); } + else if (0x08 == icoFore) { cvFore = RGB2 (0xFF, 0xFF, 0xFF); } + else if (0x09 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0x80); } + else if (0x0A == icoFore) { cvFore = RGB2 (0x00, 0x80, 0x80); } + else if (0x0B == icoFore) { cvFore = RGB2 (0x00, 0x80, 0x00); } + else if (0x0C == icoFore) { cvFore = RGB2 (0x80, 0x00, 0x80); } + else if (0x0D == icoFore) { cvFore = RGB2 (0x80, 0x00, 0x80); } + else if (0x0E == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x00); } + else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); } + else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); } + + if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; } + else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); } + else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); } + else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); } + else if (0x04 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0x00); } + else if (0x05 == icoBack) { cvBack = RGB2 (0xFF, 0x00, 0xFF); } + else if (0x06 == icoBack) { cvBack = RGB2 (0xFF, 0x00, 0x00); } + else if (0x07 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0x00); } + else if (0x08 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); } + else if (0x09 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x80); } + else if (0x0A == icoBack) { cvBack = RGB2 (0x00, 0x80, 0x80); } + else if (0x0B == icoBack) { cvBack = RGB2 (0x00, 0x80, 0x00); } + else if (0x0C == icoBack) { cvBack = RGB2 (0x80, 0x00, 0x80); } + else if (0x0D == icoBack) { cvBack = RGB2 (0x80, 0x00, 0x80); } + else if (0x0E == icoBack) { cvBack = RGB2 (0x80, 0x80, 0x00); } + else if (0x0F == icoBack) { cvBack = RGB2 (0x80, 0x80, 0x80); } + else if (0x10 == icoBack) { cvBack = RGB2 (0xC0, 0xC0, 0xC0); } + + // .... если будут документы с такими цветовыми палитрами + + //if ((cvFore == 0) && (icoFore == 0x0) && (cvBack == 0) && (icoBack == 0x0) && (ipat == Automatic)) + //{ + // shadingSpecialValue = shadingSpecialValueShdAuto; + //} + //else if ((cvFore == 0xFFFFFF) && (icoFore == 0x0) && (cvBack == 0xFFFFFF) && (icoBack == 0x0) && (ipat == Automatic)) + //{ + // shadingSpecialValue = shadingSpecialValueShdNil; + //} + } + } + else + { + } + } + } + + void ShadingDescriptor::setDefaultValues() + { + cvBack = 0; + cvBackAuto = false; + cvFore = 0; + cvForeAuto = false; + icoBack = 0; + icoFore = 0; + ipat = Automatic; + + shadingType = shadingTypeShd80; + shadingSpecialValue = shadingSpecialValueNormal; + } +} diff --git a/MsBinaryFile/DocFile/ShadingDescriptor.h b/MsBinaryFile/DocFile/ShadingDescriptor.h index bcc82d0b03..630e492708 100644 --- a/MsBinaryFile/DocFile/ShadingDescriptor.h +++ b/MsBinaryFile/DocFile/ShadingDescriptor.h @@ -124,146 +124,17 @@ namespace DocFileFormat public: /// Creates a new ShadingDescriptor with default values - ShadingDescriptor() - { - setDefaultValues(); - } + ShadingDescriptor(); /// Parses the bytes to retrieve a ShadingDescriptor. - ShadingDescriptor(unsigned char* bytes, int size) - { - setDefaultValues(); - - if (NULL != bytes) - { - if (10 == size) - { - //it's a Word 2000/2003 descriptor - unsigned char cvForeBytes[4] = { bytes[2], bytes[1], bytes[0], 0 }; - unsigned char cvBackBytes[4] = { bytes[6], bytes[5], bytes[4], 0 }; - - cvFore = FormatUtils::BytesToUInt32( cvForeBytes, 0, 4 ); - - if ( bytes[3] == 0xFF ) - { - cvForeAuto = true; - } - - cvBack = FormatUtils::BytesToUInt32( cvBackBytes, 0, 4 ); - - if ( bytes[7] == 0xFF ) - { - cvBackAuto = true; - } - - ipat = (ShadingPattern)FormatUtils::BytesToUInt16( bytes, 8, size ); - - shadingType = shadingTypeShd; - - if ( ( cvFore == 0 ) && ( bytes[3] == 0xFF ) && ( cvBack == 0 ) && ( bytes[7] == 0xFF ) && ( ipat == Automatic ) ) - { - shadingSpecialValue = shadingSpecialValueShdAuto; - } - else if ( ( cvFore == 0xFFFFFF ) && ( bytes[3] == 0xFF ) && ( cvBack == 0xFFFFFF ) && ( bytes[7] == 0xFF ) && ( ipat == Automatic ) ) - { - shadingSpecialValue = shadingSpecialValueShdNil; - } - } - else if (2 == size) - { - //it's a Word 97 SPRM - short val = FormatUtils::BytesToInt16(bytes, 0, size); - - icoFore = GETBITS(val, 0, 4); - icoBack = GETBITS(val, 5, 9); - ipat = (ShadingPattern) GETBITS(val, 10, 15); - - shadingType = shadingTypeShd80; - - if ((icoFore == 0x1F) && (icoBack == 0x1F) && (ipat == 0x3F)) - { - shadingSpecialValue = shadingSpecialValueShd80Nil; - } - else - { - shadingType = shadingTypeShd; - - cvForeAuto = false; - cvBackAuto = false; - - if (0x00 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0x00); cvForeAuto = true; } - else if (0x01 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0x00); } - else if (0x02 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0xFF); } - else if (0x03 == icoFore) { cvFore = RGB2 (0x00, 0xFF, 0xFF); } - else if (0x04 == icoFore) { cvFore = RGB2 (0x00, 0xFF, 0x00); } - else if (0x05 == icoFore) { cvFore = RGB2 (0xFF, 0x00, 0xFF); } - else if (0x06 == icoFore) { cvFore = RGB2 (0xFF, 0x00, 0x00); } - else if (0x07 == icoFore) { cvFore = RGB2 (0xFF, 0xFF, 0x00); } - else if (0x08 == icoFore) { cvFore = RGB2 (0xFF, 0xFF, 0xFF); } - else if (0x09 == icoFore) { cvFore = RGB2 (0x00, 0x00, 0x80); } - else if (0x0A == icoFore) { cvFore = RGB2 (0x00, 0x80, 0x80); } - else if (0x0B == icoFore) { cvFore = RGB2 (0x00, 0x80, 0x00); } - else if (0x0C == icoFore) { cvFore = RGB2 (0x80, 0x00, 0x80); } - else if (0x0D == icoFore) { cvFore = RGB2 (0x80, 0x00, 0x80); } - else if (0x0E == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x00); } - else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); } - else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); } - - if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; } - else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); } - else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); } - else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); } - else if (0x04 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0x00); } - else if (0x05 == icoBack) { cvBack = RGB2 (0xFF, 0x00, 0xFF); } - else if (0x06 == icoBack) { cvBack = RGB2 (0xFF, 0x00, 0x00); } - else if (0x07 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0x00); } - else if (0x08 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); } - else if (0x09 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x80); } - else if (0x0A == icoBack) { cvBack = RGB2 (0x00, 0x80, 0x80); } - else if (0x0B == icoBack) { cvBack = RGB2 (0x00, 0x80, 0x00); } - else if (0x0C == icoBack) { cvBack = RGB2 (0x80, 0x00, 0x80); } - else if (0x0D == icoBack) { cvBack = RGB2 (0x80, 0x00, 0x80); } - else if (0x0E == icoBack) { cvBack = RGB2 (0x80, 0x80, 0x00); } - else if (0x0F == icoBack) { cvBack = RGB2 (0x80, 0x80, 0x80); } - else if (0x10 == icoBack) { cvBack = RGB2 (0xC0, 0xC0, 0xC0); } - - // .... если будут документы с такими цветовыми палитрами - - //if ((cvFore == 0) && (icoFore == 0x0) && (cvBack == 0) && (icoBack == 0x0) && (ipat == Automatic)) - //{ - // shadingSpecialValue = shadingSpecialValueShdAuto; - //} - //else if ((cvFore == 0xFFFFFF) && (icoFore == 0x0) && (cvBack == 0xFFFFFF) && (icoBack == 0x0) && (ipat == Automatic)) - //{ - // shadingSpecialValue = shadingSpecialValueShdNil; - //} - } - } - else - { - } - } - } + ShadingDescriptor(unsigned char* bytes, int size); private: - inline unsigned int RGB2 (unsigned char r, unsigned char g, unsigned char b) { return ( (r<<16) | (g<<8) | (b) ); } - void setDefaultValues() - { - cvBack = 0; - cvBackAuto = false; - cvFore = 0; - cvForeAuto = false; - icoBack = 0; - icoFore = 0; - ipat = Automatic; - - shadingType = shadingTypeShd80; - shadingSpecialValue = shadingSpecialValueNormal; - } + void setDefaultValues(); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/SprmTDefTable.cpp b/MsBinaryFile/DocFile/SprmTDefTable.cpp new file mode 100644 index 0000000000..b7a43c7236 --- /dev/null +++ b/MsBinaryFile/DocFile/SprmTDefTable.cpp @@ -0,0 +1,112 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "SprmTDefTable.h" + +namespace DocFileFormat +{ + SprmTDefTable::SprmTDefTable (unsigned char* bytes, int size) + { + numberOfColumns = bytes[0]; + int pointer = 1; + + // rgdxaCenter + for (int i = 0; i < numberOfColumns + 1; ++i) + { + int pos = FormatUtils::BytesToInt16(bytes, pointer, size); + rgdxaCenter.push_back(pos); + pointer += 2; + } + + + // rgTc80 + + for (int i = 0; i < numberOfColumns; ++i) + { + if (size <= pointer) + { + for (int j = i; j < numberOfColumns; ++j) + { + TC80 oTC80; + + oTC80.ftsWidth = Global::dxa; + oTC80.wWidth = 0; + + oTC80.brcTop = new BorderCode(); + oTC80.brcLeft = new BorderCode(); + oTC80.brcBottom = new BorderCode(); + oTC80.brcRight = new BorderCode(); + + rgTc80.push_back(oTC80); + } + + break; + } + + TC80 tc; + // the flags + + unsigned short flags = FormatUtils::BytesToUInt16(bytes, pointer, size); + + tc.horzMerge = (unsigned char)FormatUtils::BitmaskToInt((int)flags, 0x3); + tc.textFlow = (Global::TextFlow)FormatUtils::BitmaskToInt((int)flags, 0x1C); + tc.vertMerge = (Global::VerticalMergeFlag)FormatUtils::BitmaskToInt((int)flags, 0x60); + tc.vertAlign = (Global::VerticalAlign)FormatUtils::BitmaskToInt((int)flags, 0x180); + tc.ftsWidth = (Global::CellWidthType)FormatUtils::BitmaskToInt((int)flags, 0xE00); + tc.fFitText = FormatUtils::BitmaskToBool(flags, 0x1000); + tc.fNoWrap = FormatUtils::BitmaskToBool(flags, 0x2000); + tc.fHideMark = FormatUtils::BitmaskToBool(flags, 0x4000); + + pointer += 2; + + // cell width + tc.wWidth = FormatUtils::BytesToInt16(bytes, pointer, size); + pointer += 2; + + const int borderCodeBytes = 4; + + tc.brcTop = new BorderCode((bytes + pointer), borderCodeBytes); + pointer += borderCodeBytes; + + tc.brcLeft = new BorderCode((bytes + pointer), borderCodeBytes); + pointer += borderCodeBytes; + + tc.brcBottom = new BorderCode((bytes + pointer), borderCodeBytes); + pointer += borderCodeBytes; + + tc.brcRight = new BorderCode((bytes + pointer), borderCodeBytes); + pointer += borderCodeBytes; + + rgTc80.push_back(tc); + } + } +} diff --git a/MsBinaryFile/DocFile/SprmTDefTable.h b/MsBinaryFile/DocFile/SprmTDefTable.h index fc155a281b..580cea5277 100644 --- a/MsBinaryFile/DocFile/SprmTDefTable.h +++ b/MsBinaryFile/DocFile/SprmTDefTable.h @@ -88,82 +88,9 @@ namespace DocFileFormat { private: friend class TableCellPropertiesMapping; + public: - SprmTDefTable (unsigned char* bytes, int size) - { - numberOfColumns = bytes[0]; - int pointer = 1; - - // rgdxaCenter - for (int i = 0; i < numberOfColumns + 1; ++i) - { - int pos = FormatUtils::BytesToInt16(bytes, pointer, size); - rgdxaCenter.push_back(pos); - pointer += 2; - } - - - // rgTc80 - - for (int i = 0; i < numberOfColumns; ++i) - { - if (size <= pointer) - { - for (int j = i; j < numberOfColumns; ++j) - { - TC80 oTC80; - - oTC80.ftsWidth = Global::dxa; - oTC80.wWidth = 0; - - oTC80.brcTop = new BorderCode(); - oTC80.brcLeft = new BorderCode(); - oTC80.brcBottom = new BorderCode(); - oTC80.brcRight = new BorderCode(); - - rgTc80.push_back(oTC80); - } - - break; - } - - TC80 tc; - // the flags - - unsigned short flags = FormatUtils::BytesToUInt16(bytes, pointer, size); - - tc.horzMerge = (unsigned char)FormatUtils::BitmaskToInt((int)flags, 0x3); - tc.textFlow = (Global::TextFlow)FormatUtils::BitmaskToInt((int)flags, 0x1C); - tc.vertMerge = (Global::VerticalMergeFlag)FormatUtils::BitmaskToInt((int)flags, 0x60); - tc.vertAlign = (Global::VerticalAlign)FormatUtils::BitmaskToInt((int)flags, 0x180); - tc.ftsWidth = (Global::CellWidthType)FormatUtils::BitmaskToInt((int)flags, 0xE00); - tc.fFitText = FormatUtils::BitmaskToBool(flags, 0x1000); - tc.fNoWrap = FormatUtils::BitmaskToBool(flags, 0x2000); - tc.fHideMark = FormatUtils::BitmaskToBool(flags, 0x4000); - - pointer += 2; - - // cell width - tc.wWidth = FormatUtils::BytesToInt16(bytes, pointer, size); - pointer += 2; - - const int borderCodeBytes = 4; - - tc.brcTop = new BorderCode((bytes + pointer), borderCodeBytes); - pointer += borderCodeBytes; - - tc.brcLeft = new BorderCode((bytes + pointer), borderCodeBytes); - pointer += borderCodeBytes; - - tc.brcBottom = new BorderCode((bytes + pointer), borderCodeBytes); - pointer += borderCodeBytes; - - tc.brcRight = new BorderCode((bytes + pointer), borderCodeBytes); - pointer += borderCodeBytes; - - rgTc80.push_back(tc); - } - } + SprmTDefTable (unsigned char* bytes, int size); unsigned char numberOfColumns; diff --git a/MsBinaryFile/DocFile/StructuredStorageReader.cpp b/MsBinaryFile/DocFile/StructuredStorageReader.cpp new file mode 100644 index 0000000000..ba18301a09 --- /dev/null +++ b/MsBinaryFile/DocFile/StructuredStorageReader.cpp @@ -0,0 +1,149 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "StructuredStorageReader.h" + +namespace DocFileFormat +{ + StructuredStorageReader::StructuredStorageReader () : m_pStorage(NULL) + { + + } + StructuredStorageReader::~StructuredStorageReader() + { + if(m_pStorage) + { + delete m_pStorage; + m_pStorage = NULL; + } + } + + bool StructuredStorageReader::SetFile (const wchar_t* filename) + { + m_pStorage = new POLE::Storage(filename); + + if (m_pStorage)//return true; + { + return m_pStorage->open(); + } + return false; + } + bool StructuredStorageReader::isDirectory( const std::wstring& name ) + { + if (!m_pStorage) return false; + + return m_pStorage->isDirectory(name); + } + + bool StructuredStorageReader::GetStream (const std::wstring & path, POLE::Stream** ppStream) + { + if (( m_pStorage != NULL ) && ( !path.empty() )) + { + *ppStream = new POLE::Stream(m_pStorage, path.c_str()); + } + if ((*ppStream) && ((*ppStream)->size() > 0)) + return true; + + return false; + } + + void StructuredStorageReader::copy( int indent, std::wstring path, POLE::Storage * storageOut, bool withRoot) + { + std::list entries, entries_sort; + entries = m_pStorage->entries_with_prefix( path ); + + for( std::list::iterator it = entries.begin(); it != entries.end(); ++it ) + { + std::wstring name = *it; + std::wstring fullname = path + name; + + if( m_pStorage->isDirectory( fullname ) ) + { + entries_sort.push_back(name); + } + else + { + entries_sort.push_front(name); + } + } + //for( std::list::iterator it = entries.begin(); it != entries.end(); ++it ) + for( std::list::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it ) + { + std::wstring name = *it; + std::wstring fullname = path + name; + + if( m_pStorage->isDirectory( fullname ) ) + { + copy( indent + 1, fullname + L"/", storageOut, withRoot ); + } + else + { + copy_stream(fullname, storageOut, withRoot); + } + } + } + + void StructuredStorageReader::copy_stream(std::wstring streamName, POLE::Storage * storageOut, bool withRoot) + { + POLE::Stream *stream = new POLE::Stream(m_pStorage, streamName); + if (!stream) return; + + stream->seek(0); + POLE::int64 size_stream = stream->size(); + + if (withRoot == false) + { + int pos = (int)streamName.find(L"/"); + if (pos >= 0) + streamName = streamName.substr(pos + 1); + } + + POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream); + if (!streamNew) return; + + unsigned char* data_stream = new unsigned char[(unsigned int)size_stream]; + if (data_stream) + { + stream->read(data_stream, size_stream); + + streamNew->write(data_stream, size_stream); + + delete []data_stream; + data_stream = NULL; + } + + streamNew->flush(); + + delete streamNew; + delete stream; + } +} diff --git a/MsBinaryFile/DocFile/StructuredStorageReader.h b/MsBinaryFile/DocFile/StructuredStorageReader.h index 961d43eb5b..83d90d1ff4 100644 --- a/MsBinaryFile/DocFile/StructuredStorageReader.h +++ b/MsBinaryFile/DocFile/StructuredStorageReader.h @@ -38,124 +38,23 @@ namespace DocFileFormat class StructuredStorageReader { public: - StructuredStorageReader () : m_pStorage(NULL) - { + StructuredStorageReader (); + ~StructuredStorageReader(); - } - ~StructuredStorageReader() - { - if(m_pStorage) - { - delete m_pStorage; - m_pStorage = NULL; - } - } + bool SetFile (const wchar_t* filename); + bool isDirectory( const std::wstring& name ); - bool SetFile (const wchar_t* filename) - { - m_pStorage = new POLE::Storage(filename); - - if (m_pStorage)//return true; - { - return m_pStorage->open(); - } - return false; - } - bool isDirectory( const std::wstring& name ) - { - if (!m_pStorage) return false; - - return m_pStorage->isDirectory(name); - } - - bool GetStream (const std::wstring & path, POLE::Stream** ppStream) - { - if (( m_pStorage != NULL ) && ( !path.empty() )) - { - *ppStream = new POLE::Stream(m_pStorage, path.c_str()); - } - if ((*ppStream) && ((*ppStream)->size() > 0)) - return true; - - return false; - } + bool GetStream (const std::wstring & path, POLE::Stream** ppStream); inline POLE::Storage* GetStorage() { return m_pStorage; } - void copy( int indent, std::wstring path, POLE::Storage * storageOut, bool withRoot = true) - { - std::list entries, entries_sort; - entries = m_pStorage->entries_with_prefix( path ); - - for( std::list::iterator it = entries.begin(); it != entries.end(); ++it ) - { - std::wstring name = *it; - std::wstring fullname = path + name; - - if( m_pStorage->isDirectory( fullname ) ) - { - entries_sort.push_back(name); - } - else - { - entries_sort.push_front(name); - } - } - //for( std::list::iterator it = entries.begin(); it != entries.end(); ++it ) - for( std::list::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it ) - { - std::wstring name = *it; - std::wstring fullname = path + name; - - if( m_pStorage->isDirectory( fullname ) ) - { - copy( indent + 1, fullname + L"/", storageOut, withRoot ); - } - else - { - copy_stream(fullname, storageOut, withRoot); - } - } - } + void copy( int indent, std::wstring path, POLE::Storage * storageOut, bool withRoot = true); private: - void copy_stream(std::wstring streamName, POLE::Storage * storageOut, bool withRoot = true) - { - POLE::Stream *stream = new POLE::Stream(m_pStorage, streamName); - if (!stream) return; - - stream->seek(0); - POLE::int64 size_stream = stream->size(); - - if (withRoot == false) - { - int pos = (int)streamName.find(L"/"); - if (pos >= 0) - streamName = streamName.substr(pos + 1); - } - - POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream); - if (!streamNew) return; - - unsigned char* data_stream = new unsigned char[(unsigned int)size_stream]; - if (data_stream) - { - stream->read(data_stream, size_stream); - - streamNew->write(data_stream, size_stream); - - delete []data_stream; - data_stream = NULL; - } - - streamNew->flush(); - - delete streamNew; - delete stream; - } + void copy_stream(std::wstring streamName, POLE::Storage * storageOut, bool withRoot = true); POLE::Storage* m_pStorage; }; diff --git a/MsBinaryFile/DocFile/TabDescriptor.cpp b/MsBinaryFile/DocFile/TabDescriptor.cpp new file mode 100644 index 0000000000..5e33b35e6c --- /dev/null +++ b/MsBinaryFile/DocFile/TabDescriptor.cpp @@ -0,0 +1,44 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "TabDescriptor.h" + +namespace DocFileFormat +{ + /// Parses the bytes to retrieve a TabDescriptor + TabDescriptor::TabDescriptor( unsigned char b ): + jc(0), tlc(0) + { + this->jc = b & 0x07; + this->tlc = b >> 3; + } +} diff --git a/MsBinaryFile/DocFile/TabDescriptor.h b/MsBinaryFile/DocFile/TabDescriptor.h index d5eb3b4a06..86f2071612 100644 --- a/MsBinaryFile/DocFile/TabDescriptor.h +++ b/MsBinaryFile/DocFile/TabDescriptor.h @@ -54,11 +54,6 @@ namespace DocFileFormat unsigned char tlc; /// Parses the bytes to retrieve a TabDescriptor - TabDescriptor( unsigned char b ): - jc(0), tlc(0) - { - this->jc = b & 0x07; - this->tlc = b >> 3; - } + TabDescriptor( unsigned char b ); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/TableInfo.cpp b/MsBinaryFile/DocFile/TableInfo.cpp new file mode 100644 index 0000000000..74e77052b7 --- /dev/null +++ b/MsBinaryFile/DocFile/TableInfo.cpp @@ -0,0 +1,97 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "TableInfo.h" + +namespace DocFileFormat +{ + TableInfo::TableInfo( ParagraphPropertyExceptions* papx, int nWordVersion): + fInTable(false), fTtp(false), fInnerTtp(false), fInnerTableCell(false), iTap(0) + { + if ( papx != NULL ) + { + for ( std::list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) + { + switch(iter->OpCode) + { + case sprmOldPFInTable: + case sprmPFInTable: + { + fInTable = ( iter->Arguments[0] == 1 ) ? (true) : (false); + + if (iTap < 1 && fInTable) iTap = 1; + }break; + + //case sprmOldPFTtp: + case sprmOldPTtp: + case sprmPFTtp: + { + fTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false); + }break; + + //case sprmOldPFInnerTableCell: + case sprmPFInnerTableCell: + { + fInnerTableCell = ( iter->Arguments[0] == 1 ) ? (true) : (false); + }break; + + //case sprmOldPFInnerTtp: + case sprmPFInnerTtp: + { + fInnerTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false); + }break; + + //case sprmOldPItap: + case sprmPItap: + { + iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ); + + if ( iTap > 0 ) + { + fInTable = true; + } + }break; + } + + if ( (int)( iter->OpCode ) == sprmTCnf )//66a + { + iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ); + + if ( iTap > 0 ) + { + fInTable = true; + } + } + } + } + } +} diff --git a/MsBinaryFile/DocFile/TableInfo.h b/MsBinaryFile/DocFile/TableInfo.h index 386ae91eb9..aad8b13090 100644 --- a/MsBinaryFile/DocFile/TableInfo.h +++ b/MsBinaryFile/DocFile/TableInfo.h @@ -44,65 +44,6 @@ namespace DocFileFormat bool fInnerTableCell; unsigned int iTap; - TableInfo( ParagraphPropertyExceptions* papx, int nWordVersion): - fInTable(false), fTtp(false), fInnerTtp(false), fInnerTableCell(false), iTap(0) - { - if ( papx != NULL ) - { - for ( std::list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) - { - switch(iter->OpCode) - { - case sprmOldPFInTable: - case sprmPFInTable: - { - fInTable = ( iter->Arguments[0] == 1 ) ? (true) : (false); - - if (iTap < 1 && fInTable) iTap = 1; - }break; - - //case sprmOldPFTtp: - case sprmOldPTtp: - case sprmPFTtp: - { - fTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false); - }break; - - //case sprmOldPFInnerTableCell: - case sprmPFInnerTableCell: - { - fInnerTableCell = ( iter->Arguments[0] == 1 ) ? (true) : (false); - }break; - - //case sprmOldPFInnerTtp: - case sprmPFInnerTtp: - { - fInnerTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false); - }break; - - //case sprmOldPItap: - case sprmPItap: - { - iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ); - - if ( iTap > 0 ) - { - fInTable = true; - } - }break; - } - - if ( (int)( iter->OpCode ) == sprmTCnf )//66a - { - iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ); - - if ( iTap > 0 ) - { - fInTable = true; - } - } - } - } - } + TableInfo( ParagraphPropertyExceptions* papx, int nWordVersion); }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/TablePropertyExceptions.cpp b/MsBinaryFile/DocFile/TablePropertyExceptions.cpp new file mode 100644 index 0000000000..593e13dba4 --- /dev/null +++ b/MsBinaryFile/DocFile/TablePropertyExceptions.cpp @@ -0,0 +1,98 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "TablePropertyExceptions.h" + +namespace DocFileFormat +{ + /// Parses the bytes to retrieve a TAPX + TablePropertyExceptions::TablePropertyExceptions(unsigned char* bytes, int size, int nWordVersion) : + PropertyExceptions(bytes, size, nWordVersion), m_bSkipShading97 (FALSE) + { + //not yet implemented + } + TablePropertyExceptions::~TablePropertyExceptions() + { + + } + + /// Extracts the TAPX SPRMs out of a PAPX + TablePropertyExceptions::TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, int nWordVersion) : + PropertyExceptions() + { + VirtualStreamReader oBinReader(dataStream, 0, nWordVersion); + + m_bSkipShading97 = FALSE; + + for (std::list::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter) + { + if (oSpmIter->OpCode == sprmTDefTableShd || + oSpmIter->OpCode == sprmTDefTableShd2nd || + oSpmIter->OpCode == sprmTDefTableShd3rd) + { + m_bSkipShading97 = TRUE; + } + + if (oSpmIter->Type == TAP) + { + grpprl->push_back(*oSpmIter); + } + else if (oSpmIter->OpCode == sprmPTableProps) + { + //there is a native TAP in the data stream + unsigned int fc = FormatUtils::BytesToUInt32(oSpmIter->Arguments, 0, oSpmIter->argumentsSize); + + //get the size of the following grpprl + oBinReader.Seek(fc, 0/* STREAM_SEEK_SET*/); + unsigned char* sizebytes = oBinReader.ReadBytes(2, true); + unsigned short grpprlSize = FormatUtils::BytesToUInt16(sizebytes, 0, 2); + + //read the grpprl + unsigned char* grpprlBytes = oBinReader.ReadBytes(grpprlSize, true); + + //parse the grpprl + PropertyExceptions externalPx(grpprlBytes, grpprlSize, nWordVersion); + + for (std::list::iterator oIter = externalPx.grpprl->begin(); oIter != externalPx.grpprl->end(); ++oIter) + { + if (oIter->Type == TAP) + { + grpprl->push_back(*oIter); + } + } + + RELEASEARRAYOBJECTS(grpprlBytes); + RELEASEARRAYOBJECTS(sizebytes); + } + } + } +} diff --git a/MsBinaryFile/DocFile/TablePropertyExceptions.h b/MsBinaryFile/DocFile/TablePropertyExceptions.h index 0d5f028655..6f0ad210b5 100644 --- a/MsBinaryFile/DocFile/TablePropertyExceptions.h +++ b/MsBinaryFile/DocFile/TablePropertyExceptions.h @@ -41,75 +41,19 @@ namespace DocFileFormat { public: /// Parses the bytes to retrieve a TAPX - TablePropertyExceptions(unsigned char* bytes, int size, int nWordVersion) : - PropertyExceptions(bytes, size, nWordVersion), m_bSkipShading97 (FALSE) - { - //not yet implemented - } + TablePropertyExceptions(unsigned char* bytes, int size, int nWordVersion); - virtual ~TablePropertyExceptions() - { - - } + virtual ~TablePropertyExceptions(); /// Extracts the TAPX SPRMs out of a PAPX - TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, int nWordVersion) : - PropertyExceptions() - { - VirtualStreamReader oBinReader(dataStream, 0, nWordVersion); + TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, int nWordVersion); - m_bSkipShading97 = FALSE; - - for (std::list::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter) - { - if (oSpmIter->OpCode == sprmTDefTableShd || - oSpmIter->OpCode == sprmTDefTableShd2nd || - oSpmIter->OpCode == sprmTDefTableShd3rd) - { - m_bSkipShading97 = TRUE; - } - - if (oSpmIter->Type == TAP) - { - grpprl->push_back(*oSpmIter); - } - else if (oSpmIter->OpCode == sprmPTableProps) - { - //there is a native TAP in the data stream - unsigned int fc = FormatUtils::BytesToUInt32(oSpmIter->Arguments, 0, oSpmIter->argumentsSize); - - //get the size of the following grpprl - oBinReader.Seek(fc, 0/* STREAM_SEEK_SET*/); - unsigned char* sizebytes = oBinReader.ReadBytes(2, true); - unsigned short grpprlSize = FormatUtils::BytesToUInt16(sizebytes, 0, 2); - - //read the grpprl - unsigned char* grpprlBytes = oBinReader.ReadBytes(grpprlSize, true); - - //parse the grpprl - PropertyExceptions externalPx(grpprlBytes, grpprlSize, nWordVersion); - - for (std::list::iterator oIter = externalPx.grpprl->begin(); oIter != externalPx.grpprl->end(); ++oIter) - { - if (oIter->Type == TAP) - { - grpprl->push_back(*oIter); - } - } - - RELEASEARRAYOBJECTS(grpprlBytes); - RELEASEARRAYOBJECTS(sizebytes); - } - } - } - - inline bool IsSkipShading97 () + inline bool IsSkipShading97() { return m_bSkipShading97; } private: - - bool m_bSkipShading97; // пропускать правило от Word97 + bool m_bSkipShading97; // пропускать правило от Word97 }; } diff --git a/MsBinaryFile/DocFile/Tbkd.cpp b/MsBinaryFile/DocFile/Tbkd.cpp new file mode 100644 index 0000000000..ab27cf750d --- /dev/null +++ b/MsBinaryFile/DocFile/Tbkd.cpp @@ -0,0 +1,87 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "Tbkd.h" + +namespace DocFileFormat +{ + Tbkd::Tbkd() : ipgd(0), itxbxs(0), dcpDepend(0), icol(0), fTableBreak(false), fColumnBreak(false), fMarked(false), fUnk(false), fTextOverflow(false) + { + } + Tbkd::~Tbkd() + { + } + + ByteStructure* Tbkd::ConstructObject (VirtualStreamReader* reader, int length) + { + Tbkd* pTbkd = new Tbkd(); + + pTbkd->ipgd = reader->ReadInt16(); + pTbkd->itxbxs = pTbkd->ipgd; + pTbkd->dcpDepend = reader->ReadInt16(); + + int flag = (int)reader->ReadInt16(); + + pTbkd->icol = (unsigned short)FormatUtils::BitmaskToInt(flag, 0x00FF); + pTbkd->fTableBreak = FormatUtils::BitmaskToBool(flag, 0x0100); + pTbkd->fColumnBreak = FormatUtils::BitmaskToBool(flag, 0x0200); + pTbkd->fMarked = FormatUtils::BitmaskToBool(flag, 0x0400); + pTbkd->fUnk = FormatUtils::BitmaskToBool(flag, 0x0800); + pTbkd->fTextOverflow = FormatUtils::BitmaskToBool(flag, 0x1000); + + return static_cast(pTbkd); + } + + FTXBXS::FTXBXS() + { + } + FTXBXS::~FTXBXS() + { + } + + ByteStructure* FTXBXS::ConstructObject (VirtualStreamReader* reader, int length) + { + FTXBXS* pFTXBXS = new FTXBXS(); + if (!pFTXBXS) return NULL; + + pFTXBXS->reusable01 = reader->ReadInt32(); + pFTXBXS->reusable02 = reader->ReadInt32(); + + pFTXBXS->fReusable = reader->ReadInt16(); + + pFTXBXS->itxbxsDest = reader->ReadInt32(); + pFTXBXS->lid = reader->ReadInt32(); + pFTXBXS->txidUndo = reader->ReadInt32(); + + return static_cast(pFTXBXS); + } +} diff --git a/MsBinaryFile/DocFile/Tbkd.h b/MsBinaryFile/DocFile/Tbkd.h index 639cdad1c4..6bf3e90af3 100644 --- a/MsBinaryFile/DocFile/Tbkd.h +++ b/MsBinaryFile/DocFile/Tbkd.h @@ -43,33 +43,10 @@ namespace DocFileFormat static const int STRUCTURE_SIZE = 6; - Tbkd() : ipgd(0), itxbxs(0), dcpDepend(0), icol(0), fTableBreak(false), fColumnBreak(false), fMarked(false), fUnk(false), fTextOverflow(false) - { - } + Tbkd(); + virtual ~Tbkd(); - virtual ~Tbkd() - { - } - - virtual ByteStructure* ConstructObject (VirtualStreamReader* reader, int length) - { - Tbkd* pTbkd = new Tbkd(); - - pTbkd->ipgd = reader->ReadInt16(); - pTbkd->itxbxs = pTbkd->ipgd; - pTbkd->dcpDepend = reader->ReadInt16(); - - int flag = (int)reader->ReadInt16(); - - pTbkd->icol = (unsigned short)FormatUtils::BitmaskToInt(flag, 0x00FF); - pTbkd->fTableBreak = FormatUtils::BitmaskToBool(flag, 0x0100); - pTbkd->fColumnBreak = FormatUtils::BitmaskToBool(flag, 0x0200); - pTbkd->fMarked = FormatUtils::BitmaskToBool(flag, 0x0400); - pTbkd->fUnk = FormatUtils::BitmaskToBool(flag, 0x0800); - pTbkd->fTextOverflow = FormatUtils::BitmaskToBool(flag, 0x1000); - - return static_cast(pTbkd); - } + virtual ByteStructure* ConstructObject (VirtualStreamReader* reader, int length); private: bool bUsed = false; @@ -95,6 +72,7 @@ namespace DocFileFormat class FTXBXS : public ByteStructure { friend class TextboxMapping; + public: static const int STRUCTURE_SIZE = 22; @@ -110,33 +88,10 @@ namespace DocFileFormat int cTxbxEdit; // This value MUST be zero and MUST be ignored. }; - FTXBXS () - { - - } - - virtual ~FTXBXS() - { - - } - + FTXBXS(); + virtual ~FTXBXS(); - virtual ByteStructure* ConstructObject (VirtualStreamReader* reader, int length) - { - FTXBXS* pFTXBXS = new FTXBXS(); - if (!pFTXBXS) return NULL; - - pFTXBXS->reusable01 = reader->ReadInt32(); - pFTXBXS->reusable02 = reader->ReadInt32(); - - pFTXBXS->fReusable = reader->ReadInt16(); - - pFTXBXS->itxbxsDest = reader->ReadInt32(); - pFTXBXS->lid = reader->ReadInt32(); - pFTXBXS->txidUndo = reader->ReadInt32(); - - return static_cast(pFTXBXS); - } + virtual ByteStructure* ConstructObject (VirtualStreamReader* reader, int length); private: int reusable01; @@ -148,4 +103,4 @@ namespace DocFileFormat int lid; int txidUndo; // This value MUST be zero and MUST be ignored. }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/TwipsValue.cpp b/MsBinaryFile/DocFile/TwipsValue.cpp new file mode 100644 index 0000000000..c0967c57d6 --- /dev/null +++ b/MsBinaryFile/DocFile/TwipsValue.cpp @@ -0,0 +1,53 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "TwipsValue.h" + +namespace DocFileFormat +{ + /// Creates a new TwipsValue for the given value. + TwipsValue::TwipsValue( double _value ): value(_value) + { + } + TwipsValue::TwipsValue( const TwipsValue& _twipsValue ) + { + value = _twipsValue.value; + } + + TwipsValue& TwipsValue::operator = ( const TwipsValue& _twipsValue ) + { + if ( this != &_twipsValue ) + value = _twipsValue.value; + + return *this; + } +} diff --git a/MsBinaryFile/DocFile/TwipsValue.h b/MsBinaryFile/DocFile/TwipsValue.h index 550e91b228..dc9c9a4dd4 100644 --- a/MsBinaryFile/DocFile/TwipsValue.h +++ b/MsBinaryFile/DocFile/TwipsValue.h @@ -44,22 +44,10 @@ namespace DocFileFormat static const unsigned char Dpi = 72; /// Creates a new TwipsValue for the given value. - TwipsValue( double _value = 0 ): value(_value) - { - } + TwipsValue( double _value = 0 ); + TwipsValue( const TwipsValue& _twipsValue ); - TwipsValue( const TwipsValue& _twipsValue ) - { - value = _twipsValue.value; - } - - TwipsValue& operator = ( const TwipsValue& _twipsValue ) - { - if ( this != &_twipsValue ) - value = _twipsValue.value; - - return *this; - } + TwipsValue& operator = ( const TwipsValue& _twipsValue ); /// Converts the twips to pt inline double ToPoints() const @@ -85,4 +73,4 @@ namespace DocFileFormat return ToMm() / 10.0; } }; -} \ No newline at end of file +} diff --git a/MsBinaryFile/DocFile/VMLShapeTypeMapping.h b/MsBinaryFile/DocFile/VMLShapeTypeMapping.h index b0e2f02cc4..68611117c3 100644 --- a/MsBinaryFile/DocFile/VMLShapeTypeMapping.h +++ b/MsBinaryFile/DocFile/VMLShapeTypeMapping.h @@ -47,6 +47,7 @@ namespace DocFileFormat VMLShapeTypeMapping(XMLTools::CStringXmlWriter* writer, bool isInlineShape = false ); virtual ~VMLShapeTypeMapping(); virtual void Apply( IVisitable* visited ); + /// Returns the id of the referenced type static std::wstring GenerateTypeId (const ShapeType* pShape); }; diff --git a/MsBinaryFile/DocFile/VirtualStreamReader.cpp b/MsBinaryFile/DocFile/VirtualStreamReader.cpp new file mode 100644 index 0000000000..e61949925b --- /dev/null +++ b/MsBinaryFile/DocFile/VirtualStreamReader.cpp @@ -0,0 +1,281 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "VirtualStreamReader.h" + +VirtualStreamReader::VirtualStreamReader (POLE::Stream* _stream, ULONG _position , int _nWordVersion) : + nWordVersion(_nWordVersion), stream(_stream), position(_position) +{ + if ( stream == NULL )return; + + stream->seek(position); +} + +VirtualStreamReader::~VirtualStreamReader() +{ +} + +unsigned short VirtualStreamReader::ReadUInt16() +{ + unsigned short rdUShort = 0; + + if (( stream != NULL ) && (position + 2 < stream->size())) + { + stream->seek( position ); + stream->read((unsigned char*)(&rdUShort), sizeof( rdUShort )); + } + position += sizeof( rdUShort ); + + return rdUShort; +} + +short VirtualStreamReader::ReadInt16() +{ + short rdShort = 0; + + if (( stream != NULL ) && (position + 2 < stream->size())) + { + stream->seek( position ); + stream->read((unsigned char*)(&rdShort), sizeof( rdShort )); + + } + position += sizeof( rdShort ); + + return rdShort; +} + +int VirtualStreamReader::ReadInt32() +{ + _INT32 rdInt = 0; + + if (( stream != NULL ) && (position + 4 < stream->size())) + { + stream->seek( position ); + stream->read( (unsigned char*) &rdInt, sizeof( rdInt ) ); + + } + position += sizeof( rdInt ); + + return rdInt; +} + +unsigned int VirtualStreamReader::ReadUInt32() +{ + _UINT32 rdUInt = 0; + + if (( stream != NULL ) && (position + 4 < stream->size())) + { + stream->seek( position ); + stream->read((unsigned char*) &rdUInt, sizeof( rdUInt ) ); + + } + position += sizeof( rdUInt ); + + return rdUInt; +} + +unsigned char VirtualStreamReader::ReadByte() +{ + unsigned char rdByte = 0; + + if (( stream != NULL ) && (position + 1 < stream->size())) + { + stream->seek( position); + stream->read( (unsigned char*)&rdByte, sizeof( rdByte ) ); + + } + position += sizeof( rdByte ); + + return rdByte; +} + +unsigned char* VirtualStreamReader::ReadBytes( unsigned int count, bool isResultNeeded ) +{ + unsigned char *rdBytes = NULL; + + if ( count > 0 && isResultNeeded) + { + if (position + count > stream->size()) + { + if (position > stream->size()) count = 0; + else count = (unsigned int)(stream->size() - position); + } + rdBytes = new unsigned char[count]; + } + + if ( stream != NULL && rdBytes != NULL ) + { + stream->seek( position ); + count = (unsigned int)stream->read( rdBytes, count ); + } + + position += count; + + return rdBytes; +} + +unsigned long VirtualStreamReader::GetPosition() const +{ + return (unsigned long)this->position; +} + +unsigned long VirtualStreamReader::GetSize() const +{ + unsigned long size = 0; + + if ( stream != NULL ) + { + size = (unsigned long)stream->size(); + } + + return size; +} + +int VirtualStreamReader::Seek( int offset, int origin ) +{ + if ( stream != NULL ) + { + if (origin > 1) + { + + } + stream->seek( offset ); + position = offset; + return offset; + } + else + { + return 0; + } +} + +std::wstring VirtualStreamReader::ReadXst() +{ + if (!stream) return L""; + std::wstring wstrResult; + + unsigned char* xstz = NULL; + unsigned char* cch = NULL; + + if (nWordVersion > 0) + { + int cchSize = 1; + cch = ReadBytes( cchSize, true ); + + int xstzSize = DocFileFormat::FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1; + xstz = ReadBytes(xstzSize, true); + + DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 ); + } + else + { + int cchSize = 2; + cch = ReadBytes( cchSize, true ); + + int xstzSize = DocFileFormat::FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2; + xstz = ReadBytes(xstzSize, true); + + DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_UTF16 ); + } + + RELEASEARRAYOBJECTS(xstz); + RELEASEARRAYOBJECTS(cch); + + return wstrResult; +} + +/// Read a length prefixed Unicode string from the given stream. +/// The string must have the following structure: +/// unsigned char 1 - 4: Character count (cch) +/// unsigned char 5 - (cch*2)+4: Unicode characters terminated by \0 +std::wstring VirtualStreamReader::ReadLengthPrefixedUnicodeString() +{ + std::wstring result; + + int cch = ReadInt32(); + + if ( cch > 0 ) + { + //dont read the terminating zero + unsigned char* stringBytes = ReadBytes( ( cch * 2 ), true ); + + DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 ); + + RELEASEARRAYOBJECTS( stringBytes ); + } + + return result; +} + +/// Read a length prefixed ANSI string from the given stream. +/// The string must have the following structure: +/// unsigned char 1-4: Character count (cch) +/// unsigned char 5-cch+4: ANSI characters terminated by \0 +std::wstring VirtualStreamReader::ReadLengthPrefixedAnsiString(unsigned int max_size) +{ + std::wstring result; + + unsigned int cch = ReadUInt32(); + + unsigned char* stringBytes = NULL; + + if (cch > max_size) + { + //error ... skip to 0 + unsigned int pos_orinal = GetPosition(); + unsigned int pos = 0; + + stringBytes = ReadBytes( max_size, true ); + + if (stringBytes) + { + while(pos < max_size) + { + if (stringBytes[pos] == 0) + break; + pos++; + } + } + Seek(pos_orinal + pos - 1, 0); + }else + if ( cch > 0 ) + { + //dont read the terminating zero + stringBytes = ReadBytes( cch, true ); + + DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250); + + } + RELEASEARRAYOBJECTS( stringBytes ); + + return result; +} diff --git a/MsBinaryFile/DocFile/VirtualStreamReader.h b/MsBinaryFile/DocFile/VirtualStreamReader.h index df7a97034d..d13463cfda 100644 --- a/MsBinaryFile/DocFile/VirtualStreamReader.h +++ b/MsBinaryFile/DocFile/VirtualStreamReader.h @@ -39,254 +39,38 @@ class VirtualStreamReader : public IBinaryReader { public: - VirtualStreamReader (POLE::Stream* _stream, ULONG _position , int _nWordVersion) : - nWordVersion(_nWordVersion), stream(_stream), position(_position) - { - if ( stream == NULL )return; + VirtualStreamReader (POLE::Stream* _stream, ULONG _position , int _nWordVersion); + virtual ~VirtualStreamReader(); - stream->seek(position); - } + virtual unsigned short ReadUInt16(); + virtual short ReadInt16(); - virtual ~VirtualStreamReader() - { - } + virtual int ReadInt32(); + virtual unsigned int ReadUInt32(); - virtual unsigned short ReadUInt16() - { - unsigned short rdUShort = 0; + virtual unsigned char ReadByte(); + virtual unsigned char* ReadBytes( unsigned int count, bool isResultNeeded ); - if (( stream != NULL ) && (position + 2 < stream->size())) - { - stream->seek( position ); - stream->read((unsigned char*)(&rdUShort), sizeof( rdUShort )); - } - position += sizeof( rdUShort ); + virtual unsigned long GetPosition() const; + virtual unsigned long GetSize() const; + virtual int Seek( int offset, int origin ); - return rdUShort; - } - - virtual short ReadInt16() - { - short rdShort = 0; - - if (( stream != NULL ) && (position + 2 < stream->size())) - { - stream->seek( position ); - stream->read((unsigned char*)(&rdShort), sizeof( rdShort )); - - } - position += sizeof( rdShort ); - - return rdShort; - } - - virtual int ReadInt32() - { - _INT32 rdInt = 0; - - if (( stream != NULL ) && (position + 4 < stream->size())) - { - stream->seek( position ); - stream->read( (unsigned char*) &rdInt, sizeof( rdInt ) ); - - } - position += sizeof( rdInt ); - - return rdInt; - } - - virtual unsigned int ReadUInt32() - { - _UINT32 rdUInt = 0; - - if (( stream != NULL ) && (position + 4 < stream->size())) - { - stream->seek( position ); - stream->read((unsigned char*) &rdUInt, sizeof( rdUInt ) ); - - } - position += sizeof( rdUInt ); - - return rdUInt; - } - - virtual unsigned char ReadByte() - { - unsigned char rdByte = 0; - - if (( stream != NULL ) && (position + 1 < stream->size())) - { - stream->seek( position); - stream->read( (unsigned char*)&rdByte, sizeof( rdByte ) ); - - } - position += sizeof( rdByte ); - - return rdByte; - } - - virtual unsigned char* ReadBytes( unsigned int count, bool isResultNeeded ) - { - unsigned char *rdBytes = NULL; - - if ( count > 0 && isResultNeeded) - { - if (position + count > stream->size()) - { - if (position > stream->size()) count = 0; - else count = (unsigned int)(stream->size() - position); - } - rdBytes = new unsigned char[count]; - } - - if ( stream != NULL && rdBytes != NULL ) - { - stream->seek( position ); - count = (unsigned int)stream->read( rdBytes, count ); - } - - position += count; - - return rdBytes; - } - - virtual unsigned long GetPosition() const - { - return (unsigned long)this->position; - } - - virtual unsigned long GetSize() const - { - unsigned long size = 0; - - if ( stream != NULL ) - { - size = (unsigned long)stream->size(); - } - - return size; - } - - virtual int Seek( int offset, int origin ) - { - if ( stream != NULL ) - { - if (origin > 1) - { - - } - stream->seek( offset ); - position = offset; - return offset; - } - else - { - return 0; - } - } - - std::wstring ReadXst() - { - if (!stream) return L""; - std::wstring wstrResult; - - unsigned char* xstz = NULL; - unsigned char* cch = NULL; - - if (nWordVersion > 0) - { - int cchSize = 1; - cch = ReadBytes( cchSize, true ); - - int xstzSize = DocFileFormat::FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1; - xstz = ReadBytes(xstzSize, true); - - DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 ); - } - else - { - int cchSize = 2; - cch = ReadBytes( cchSize, true ); - - int xstzSize = DocFileFormat::FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2; - xstz = ReadBytes(xstzSize, true); - - DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_UTF16 ); - } - - RELEASEARRAYOBJECTS(xstz); - RELEASEARRAYOBJECTS(cch); - - return wstrResult; - } + std::wstring ReadXst(); /// Read a length prefixed Unicode string from the given stream. /// The string must have the following structure: /// unsigned char 1 - 4: Character count (cch) /// unsigned char 5 - (cch*2)+4: Unicode characters terminated by \0 - std::wstring ReadLengthPrefixedUnicodeString() - { - std::wstring result; - - int cch = ReadInt32(); - - if ( cch > 0 ) - { - //dont read the terminating zero - unsigned char* stringBytes = ReadBytes( ( cch * 2 ), true ); - - DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 ); - - RELEASEARRAYOBJECTS( stringBytes ); - } - - return result; - } + std::wstring ReadLengthPrefixedUnicodeString(); /// Read a length prefixed ANSI string from the given stream. /// The string must have the following structure: /// unsigned char 1-4: Character count (cch) /// unsigned char 5-cch+4: ANSI characters terminated by \0 - std::wstring ReadLengthPrefixedAnsiString(unsigned int max_size) - { - std::wstring result; + std::wstring ReadLengthPrefixedAnsiString(unsigned int max_size); - unsigned int cch = ReadUInt32(); - - unsigned char* stringBytes = NULL; - - if (cch > max_size) - { - //error ... skip to 0 - unsigned int pos_orinal = GetPosition(); - unsigned int pos = 0; - - stringBytes = ReadBytes( max_size, true ); - - if (stringBytes) - { - while(pos < max_size) - { - if (stringBytes[pos] == 0) - break; - pos++; - } - } - Seek(pos_orinal + pos - 1, 0); - }else - if ( cch > 0 ) - { - //dont read the terminating zero - stringBytes = ReadBytes( cch, true ); - - DocFileFormat::FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250); - - } - RELEASEARRAYOBJECTS( stringBytes ); - - return result; - } int nWordVersion; + private: POLE::uint64 position; diff --git a/MsBinaryFile/DocFile/WideString.cpp b/MsBinaryFile/DocFile/WideString.cpp new file mode 100644 index 0000000000..4e0ba39ae3 --- /dev/null +++ b/MsBinaryFile/DocFile/WideString.cpp @@ -0,0 +1,67 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 "WideString.h" + +namespace DocFileFormat +{ + WideString::WideString( VirtualStreamReader reader, int length ): std::wstring() + { + } + WideString::WideString(): std::wstring() + { + } + WideString::~WideString() + { + } + + ByteStructure* WideString::ConstructObject( VirtualStreamReader* reader, int length ) + { + WideString* newObject = new WideString(); + + unsigned char *bytes = NULL; + bytes = reader->ReadBytes( length, true ); + + //It's a real string table + if (reader->nWordVersion > 0) + { + FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_WINDOWS_1250 ); + } + else + { + FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_UTF16 ); + } + RELEASEARRAYOBJECTS( bytes ); + + return static_cast( newObject ); + } +} diff --git a/MsBinaryFile/DocFile/WideString.h b/MsBinaryFile/DocFile/WideString.h index b117b9c48b..d7c654ff34 100644 --- a/MsBinaryFile/DocFile/WideString.h +++ b/MsBinaryFile/DocFile/WideString.h @@ -39,37 +39,10 @@ namespace DocFileFormat class WideString: public std::wstring, public ByteStructure { public: - WideString( VirtualStreamReader reader, int length ): std::wstring() - { - } + WideString( VirtualStreamReader reader, int length ); + WideString(); + virtual ~WideString(); - WideString(): std::wstring() - { - } - - virtual ~WideString() - { - } - - virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) - { - WideString* newObject = new WideString(); - - unsigned char *bytes = NULL; - bytes = reader->ReadBytes( length, true ); - - //It's a real string table - if (reader->nWordVersion > 0) - { - FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_WINDOWS_1250 ); - } - else - { - FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_UTF16 ); - } - RELEASEARRAYOBJECTS( bytes ); - - return static_cast( newObject ); - } + virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ); }; } diff --git a/MsBinaryFile/Projects/DocFormatLib/Linux/DocFormatLib.pro b/MsBinaryFile/Projects/DocFormatLib/Linux/DocFormatLib.pro index e29970e8ae..e0fc759546 100644 --- a/MsBinaryFile/Projects/DocFormatLib/Linux/DocFormatLib.pro +++ b/MsBinaryFile/Projects/DocFormatLib/Linux/DocFormatLib.pro @@ -33,7 +33,8 @@ SOURCES += \ ../../../DocFile/EncryptionHeader.cpp \ ../../../DocFile/DrawingPrimitives.cpp \ ../../../DocFile/Spa.cpp \ - ../../../DocFile/OleObject.cpp + ../../../DocFile/OleObject.cpp \ + ../../../Common/Base/XmlTools.cpp core_release { SOURCES += \ @@ -87,9 +88,78 @@ SOURCES += \ ../../../DocFile/WordDocument.cpp \ ../../../DocFile/WordprocessingDocument.cpp \ ../../../DocFile/FormFieldData.cpp \ + ../../../DocFile/AbstractOpenXmlMapping.cpp \ + ../../../DocFile/AnnotationOwnerList.cpp \ + ../../../DocFile/AutoSummaryInfo.cpp \ + ../../../DocFile/BookmarkFirst.cpp \ + ../../../DocFile/BorderCode.cpp \ + ../../../DocFile/ByteStructure.cpp \ + ../../../DocFile/CharacterPropertyExceptions.cpp \ + ../../../DocFile/CharacterRange.cpp \ + ../../../DocFile/CommentsMapping.cpp \ + ../../../DocFile/ConversionContext.cpp \ + ../../../DocFile/DateAndTime.cpp \ + ../../../DocFile/DocumentTypographyInfo.cpp \ + ../../../DocFile/DrawingObjectGrid.cpp \ + ../../../DocFile/EmuValue.cpp \ + ../../../DocFile/EndnoteDescriptor.cpp \ + ../../../DocFile/EndnotesMapping.cpp \ + ../../../DocFile/FieldCharacter.cpp \ + ../../../DocFile/FileInformationBlock.cpp \ + ../../../DocFile/FixedPointNumber.cpp \ + ../../../DocFile/FootnoteDescriptor.cpp \ + ../../../DocFile/FootnotesMapping.cpp \ + ../../../DocFile/FormattedDiskPage.cpp \ + ../../../DocFile/FormFieldDataMapping.cpp \ + ../../../DocFile/LanguageId.cpp \ + ../../../DocFile/LineSpacingDescriptor.cpp \ + ../../../DocFile/ListFormatOverride.cpp \ + ../../../DocFile/ListFormatOverrideLevel.cpp \ + ../../../DocFile/ListFormatOverrideTable.cpp \ + ../../../DocFile/MemoryStream.cpp \ + ../../../DocFile/OfficeArtContent.cpp \ + ../../../DocFile/OleObjectMapping.cpp \ + ../../../DocFile/PieceDescriptor.cpp \ + ../../../DocFile/RGBColor.cpp \ + ../../../DocFile/SectionDescriptor.cpp \ + ../../../DocFile/SectionPropertyExceptions.cpp \ + ../../../DocFile/ShadingDescriptor.cpp \ + ../../../DocFile/SprmTDefTable.cpp \ + ../../../DocFile/StructuredStorageReader.cpp \ + ../../../DocFile/TabDescriptor.cpp \ + ../../../DocFile/TableInfo.cpp \ + ../../../DocFile/TablePropertyExceptions.cpp \ + ../../../DocFile/Tbkd.cpp \ + ../../../DocFile/TwipsValue.cpp \ + ../../../DocFile/VirtualStreamReader.cpp \ + ../../../DocFile/WideString.cpp \ + \ ../../../DocFile/OfficeDrawing/Record.cpp \ ../../../DocFile/OfficeDrawing/RecordFactory.cpp \ - ../../../DocFile/OfficeDrawing/ShapeTypeFactory.cpp + ../../../DocFile/OfficeDrawing/ShapeTypeFactory.cpp \ + ../../../DocFile/OfficeDrawing/BitmapBlip.cpp \ + ../../../DocFile/OfficeDrawing/BlipStoreContainer.cpp \ + ../../../DocFile/OfficeDrawing/BlipStoreEntry.cpp \ + ../../../DocFile/OfficeDrawing/ChildAnchor.cpp \ + ../../../DocFile/OfficeDrawing/ClientAnchor.cpp \ + ../../../DocFile/OfficeDrawing/ClientData.cpp \ + ../../../DocFile/OfficeDrawing/DiagramBooleanProperties.cpp \ + ../../../DocFile/OfficeDrawing/DrawingContainer.cpp \ + ../../../DocFile/OfficeDrawing/DrawingGroup.cpp \ + ../../../DocFile/OfficeDrawing/DrawingGroupRecord.cpp \ + ../../../DocFile/OfficeDrawing/DrawingRecord.cpp \ + ../../../DocFile/OfficeDrawing/GroupContainer.cpp \ + ../../../DocFile/OfficeDrawing/GroupShapeRecord.cpp \ + ../../../DocFile/OfficeDrawing/MetafilePictBlip.cpp \ + ../../../DocFile/OfficeDrawing/OfficeArtClientTextbox.cpp \ + ../../../DocFile/OfficeDrawing/OfficeArtFRITContainer.cpp \ + ../../../DocFile/OfficeDrawing/RegularContainer.cpp \ + ../../../DocFile/OfficeDrawing/Shape.cpp \ + ../../../DocFile/OfficeDrawing/ShapeContainer.cpp \ + ../../../DocFile/OfficeDrawing/ShapeOptions.cpp \ + ../../../DocFile/OfficeDrawing/ShapeType.cpp \ + ../../../DocFile/OfficeDrawing/SplitMenuColorContainer.cpp \ + ../../../DocFile/OfficeDrawing/UnknownRecord.cpp } HEADERS += \ @@ -203,6 +273,7 @@ HEADERS += \ ../../../DocFile/WideString.h \ ../../../DocFile/WordDocument.h \ ../../../DocFile/WordprocessingDocument.h \ + \ ../../../DocFile/OfficeDrawing/BitmapBlip.h \ ../../../DocFile/OfficeDrawing/BlipStoreContainer.h \ ../../../DocFile/OfficeDrawing/BlipStoreEntry.h \ @@ -229,6 +300,7 @@ HEADERS += \ ../../../DocFile/OfficeDrawing/ShapeTypeFactory.h \ ../../../DocFile/OfficeDrawing/SplitMenuColorContainer.h \ ../../../DocFile/OfficeDrawing/UnknownRecord.h \ + \ ../../../DocFile/OfficeDrawing/Shapetypes/ArcType.h \ ../../../DocFile/OfficeDrawing/Shapetypes/ArrowType.h \ ../../../DocFile/OfficeDrawing/Shapetypes/BevelType.h \ diff --git a/MsBinaryFile/Projects/DocFormatLib/Linux/doc_converter.cpp b/MsBinaryFile/Projects/DocFormatLib/Linux/doc_converter.cpp index 563ff6c5a3..1bfffe4f95 100644 --- a/MsBinaryFile/Projects/DocFormatLib/Linux/doc_converter.cpp +++ b/MsBinaryFile/Projects/DocFormatLib/Linux/doc_converter.cpp @@ -75,6 +75,75 @@ #include "../../../DocFile/WordDocument.cpp" #include "../../../DocFile/WordprocessingDocument.cpp" #include "../../../DocFile/FormFieldData.cpp" +#include "../../../DocFile/AbstractOpenXmlMapping.cpp" +#include "../../../DocFile/AnnotationOwnerList.cpp" +#include "../../../DocFile/AutoSummaryInfo.cpp" +#include "../../../DocFile/BookmarkFirst.cpp" +#include "../../../DocFile/BorderCode.cpp" +#include "../../../DocFile/ByteStructure.cpp" +#include "../../../DocFile/CharacterPropertyExceptions.cpp" +#include "../../../DocFile/CharacterRange.cpp" +#include "../../../DocFile/CommentsMapping.cpp" +#include "../../../DocFile/ConversionContext.cpp" +#include "../../../DocFile/DateAndTime.cpp" +#include "../../../DocFile/DocumentTypographyInfo.cpp" +#include "../../../DocFile/DrawingObjectGrid.cpp" +#include "../../../DocFile/EmuValue.cpp" +#include "../../../DocFile/EndnoteDescriptor.cpp" +#include "../../../DocFile/EndnotesMapping.cpp" +#include "../../../DocFile/FieldCharacter.cpp" +#include "../../../DocFile/FileInformationBlock.cpp" +#include "../../../DocFile/FixedPointNumber.cpp" +#include "../../../DocFile/FootnoteDescriptor.cpp" +#include "../../../DocFile/FootnotesMapping.cpp" +#include "../../../DocFile/FormattedDiskPage.cpp" +#include "../../../DocFile/FormFieldDataMapping.cpp" +#include "../../../DocFile/LanguageId.cpp" +#include "../../../DocFile/LineSpacingDescriptor.cpp" +#include "../../../DocFile/ListFormatOverride.cpp" +#include "../../../DocFile/ListFormatOverrideLevel.cpp" +#include "../../../DocFile/ListFormatOverrideTable.cpp" +#include "../../../DocFile/MemoryStream.cpp" +#include "../../../DocFile/OfficeArtContent.cpp" +#include "../../../DocFile/OleObjectMapping.cpp" +#include "../../../DocFile/PieceDescriptor.cpp" +#include "../../../DocFile/RGBColor.cpp" +#include "../../../DocFile/SectionDescriptor.cpp" +#include "../../../DocFile/SectionPropertyExceptions.cpp" +#include "../../../DocFile/ShadingDescriptor.cpp" +#include "../../../DocFile/SprmTDefTable.cpp" +#include "../../../DocFile/StructuredStorageReader.cpp" +#include "../../../DocFile/TabDescriptor.cpp" +#include "../../../DocFile/TableInfo.cpp" +#include "../../../DocFile/TablePropertyExceptions.cpp" +#include "../../../DocFile/Tbkd.cpp" +#include "../../../DocFile/TwipsValue.cpp" +#include "../../../DocFile/VirtualStreamReader.cpp" +#include "../../../DocFile/WideString.cpp" + #include "../../../DocFile/OfficeDrawing/Record.cpp" #include "../../../DocFile/OfficeDrawing/RecordFactory.cpp" #include "../../../DocFile/OfficeDrawing/ShapeTypeFactory.cpp" +#include "../../../DocFile/OfficeDrawing/BitmapBlip.cpp" +#include "../../../DocFile/OfficeDrawing/BlipStoreContainer.cpp" +#include "../../../DocFile/OfficeDrawing/BlipStoreEntry.cpp" +#include "../../../DocFile/OfficeDrawing/ChildAnchor.cpp" +#include "../../../DocFile/OfficeDrawing/ClientAnchor.cpp" +#include "../../../DocFile/OfficeDrawing/ClientData.cpp" +#include "../../../DocFile/OfficeDrawing/DiagramBooleanProperties.cpp" +#include "../../../DocFile/OfficeDrawing/DrawingContainer.cpp" +#include "../../../DocFile/OfficeDrawing/DrawingGroup.cpp" +#include "../../../DocFile/OfficeDrawing/DrawingGroupRecord.cpp" +#include "../../../DocFile/OfficeDrawing/DrawingRecord.cpp" +#include "../../../DocFile/OfficeDrawing/GroupContainer.cpp" +#include "../../../DocFile/OfficeDrawing/GroupShapeRecord.cpp" +#include "../../../DocFile/OfficeDrawing/MetafilePictBlip.cpp" +#include "../../../DocFile/OfficeDrawing/OfficeArtClientTextbox.cpp" +#include "../../../DocFile/OfficeDrawing/OfficeArtFRITContainer.cpp" +#include "../../../DocFile/OfficeDrawing/RegularContainer.cpp" +#include "../../../DocFile/OfficeDrawing/Shape.cpp" +#include "../../../DocFile/OfficeDrawing/ShapeContainer.cpp" +#include "../../../DocFile/OfficeDrawing/ShapeOptions.cpp" +#include "../../../DocFile/OfficeDrawing/ShapeType.cpp" +#include "../../../DocFile/OfficeDrawing/SplitMenuColorContainer.cpp" +#include "../../../DocFile/OfficeDrawing/UnknownRecord.cpp" diff --git a/OOXML/Binary/Document/BinReader/FileWriter.cpp b/OOXML/Binary/Document/BinReader/FileWriter.cpp index 847e851e10..9efa4cbac7 100644 --- a/OOXML/Binary/Document/BinReader/FileWriter.cpp +++ b/OOXML/Binary/Document/BinReader/FileWriter.cpp @@ -76,5 +76,19 @@ void FileWriter::WriteGlossary() { m_oGlossary.Write(true); } +int FileWriter::getNextDocPr() +{ + m_nDocPrIndex++; + return m_nDocPrIndex; +} +void FileWriter::AddSetting(std::wstring sSetting) +{ + if (m_bGlossaryMode) m_oGlossary.settings.AddSetting(sSetting); + else m_oMain.settings.AddSetting(sSetting); +} +bool FileWriter::IsEmptyGlossary() +{ + return m_oGlossary.document.m_oContent.GetSize() < 1; +} } diff --git a/OOXML/Binary/Document/BinReader/FileWriter.h b/OOXML/Binary/Document/BinReader/FileWriter.h index 5f85504c10..7c3105015c 100644 --- a/OOXML/Binary/Document/BinReader/FileWriter.h +++ b/OOXML/Binary/Document/BinReader/FileWriter.h @@ -114,6 +114,7 @@ namespace Writers FontTableWriter font_table; CommentsWriter comments; }; + class FileWriter { private: @@ -135,23 +136,14 @@ namespace Writers StylesWriter& get_style_writers() { return m_bGlossaryMode ? m_oGlossary.styles : m_oMain.styles; } WebSettingsWriter& get_web_settings_writer() { return m_bGlossaryMode ? m_oGlossary.web_settings : m_oMain.web_settings; } - int getNextDocPr() - { - m_nDocPrIndex++; - return m_nDocPrIndex; - } - void AddSetting(std::wstring sSetting) - { - if (m_bGlossaryMode) m_oGlossary.settings.AddSetting(sSetting); - else m_oMain.settings.AddSetting(sSetting); - } + int getNextDocPr(); + + void AddSetting(std::wstring sSetting); + void Write(); void WriteGlossary(); - bool IsEmptyGlossary() - { - return m_oGlossary.document.m_oContent.GetSize() < 1; - } + bool IsEmptyGlossary(); MediaWriter m_oMediaWriter; ChartWriter m_oChartWriter; diff --git a/OOXML/Binary/Document/BinReader/HeaderFooterWriter.cpp b/OOXML/Binary/Document/BinReader/HeaderFooterWriter.cpp index 641bfcf2d7..2a317c725f 100644 --- a/OOXML/Binary/Document/BinReader/HeaderFooterWriter.cpp +++ b/OOXML/Binary/Document/BinReader/HeaderFooterWriter.cpp @@ -38,6 +38,7 @@ namespace Writers { eType = _eType; } + bool HdrFtrItem::IsEmpty() { return m_sFilename.empty(); diff --git a/OOXML/Binary/Document/BinReader/HeaderFooterWriter.h b/OOXML/Binary/Document/BinReader/HeaderFooterWriter.h index 5d94f9feb9..682ff59d8f 100644 --- a/OOXML/Binary/Document/BinReader/HeaderFooterWriter.h +++ b/OOXML/Binary/Document/BinReader/HeaderFooterWriter.h @@ -36,26 +36,6 @@ namespace Writers { - class ContentWriter - { - public: - NSStringUtils::CStringBuilder m_oBackground; - NSStringUtils::CStringBuilder m_oContent; - NSStringUtils::CStringBuilder m_oSecPr; - }; - - class HdrFtrItem - { - public: - HdrFtrItem(SimpleTypes::EHdrFtr _eType); - - bool IsEmpty(); - - std::wstring m_sFilename; - ContentWriter Header; - std::wstring rId; - SimpleTypes::EHdrFtr eType; - }; static std::wstring g_string_xml_start = L""; static std::wstring g_string_xmlns = L"xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \ @@ -76,18 +56,39 @@ xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \ xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \ xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \ mc:Ignorable=\"w14 w15 wp14\">"; - - static std::wstring g_string_hdr_Start = g_string_xml_start + L""; - static std::wstring g_string_ftr_Start = g_string_xml_start + L""; + static std::wstring g_string_hdr_Start = g_string_xml_start + L""; + + static std::wstring g_string_ftr_Start = g_string_xml_start + L""; static std::wstring g_string_footnotes_Start = g_string_xml_start + L""; static std::wstring g_string_endnotes_Start = g_string_xml_start + L""; + static std::wstring g_string_endnotes_End = L""; + class ContentWriter + + { + public: + NSStringUtils::CStringBuilder m_oBackground; + NSStringUtils::CStringBuilder m_oContent; + NSStringUtils::CStringBuilder m_oSecPr; + }; + + class HdrFtrItem + { + public: + HdrFtrItem(SimpleTypes::EHdrFtr _eType); + + bool IsEmpty(); + + std::wstring m_sFilename; + ContentWriter Header; + std::wstring rId; + SimpleTypes::EHdrFtr eType; + }; class HeaderFooterWriter { diff --git a/OOXML/Binary/Document/BinReader/ReaderClasses.cpp b/OOXML/Binary/Document/BinReader/ReaderClasses.cpp index de3c36526c..05a05a345a 100644 --- a/OOXML/Binary/Document/BinReader/ReaderClasses.cpp +++ b/OOXML/Binary/Document/BinReader/ReaderClasses.cpp @@ -32,6 +32,2011 @@ #include "ReaderClasses.h" namespace BinDocxRW { + + SectPr::SectPr() + { + sHeaderFooterReference = _T(""); + cols = _T(""); + + bW = false; + bH = false; + bOrientation = false; + bLeft = false; + bTop = false; + bRight = false; + bBottom = false; + bHeader = false; + bFooter = false; + bTitlePg = false; + bEvenAndOddHeaders = false; + bSectionType = false; + bPageNumStart = false; + bRtlGutter = false; + bGutter = false; + } + std::wstring SectPr::Write() + { + std::wstring sRes = _T(""); + + if(!sHeaderFooterReference.empty()) + sRes += sHeaderFooterReference; + if(!footnotePr.empty()) + sRes += footnotePr; + if(!endnotePr.empty()) + sRes += endnotePr; + if(bSectionType) + { + std::wstring sType; + switch(SectionType) + { + case 0: sType = _T("continuous");break; + case 1: sType = _T("evenPage");break; + case 2: sType = _T("nextColumn");break; + case 3: sType = _T("nextPage");break; + case 4: sType = _T("oddPage");break; + default: sType = _T("nextPage");break; + } + sRes += L""; + } + if((bW && bH) || bOrientation) + { + sRes += L""; + } + + if(bLeft || bTop || bRight || bBottom || bHeader || bFooter) + { + sRes += L""; + } + if(!pgBorders.empty()) + sRes += pgBorders; + + if(!lineNum.empty()) + sRes += lineNum; + + if(bPageNumStart) + sRes += L""; + + if(bRtlGutter) + { + if(RtlGutter) + sRes += L""; + else + sRes += L""; + } + + if(!cols.empty()) + sRes += cols; + sRes += L""; + + if(bTitlePg && TitlePg) + sRes += L""; + + if(!sectPrChange.empty()) + sRes += sectPrChange; + return sRes; + } + + docRGB::docRGB() + { + R = 255; + G = 255; + B = 255; + } + std::wstring docRGB::ToString() + { + return XmlUtils::ToString(R, L"%02X") + XmlUtils::ToString(G, L"%02X") + XmlUtils::ToString(B, L"%02X"); + } + + CThemeColor::CThemeColor() + { + Reset(); + } + void CThemeColor::Reset() + { + bShade = false; + bTint = false; + bColor = false; + Auto = false; + } + bool CThemeColor::IsNoEmpty() + { + return bShade || bTint || bColor || Auto; + } + std::wstring CThemeColor::ToStringColor() + { + std::wstring sRes; + if(bColor) + { + switch(Color) + { + case 0: sRes = _T("accent1");break; + case 1: sRes = _T("accent2");break; + case 2: sRes = _T("accent3");break; + case 3: sRes = _T("accent4");break; + case 4: sRes = _T("accent5");break; + case 5: sRes = _T("accent6");break; + case 6: sRes = _T("background1");break; + case 7: sRes = _T("background2");break; + case 8: sRes = _T("dark1");break; + case 9: sRes = _T("dark2");break; + case 10: sRes = _T("followedHyperlink");break; + case 11: sRes = _T("hyperlink");break; + case 12: sRes = _T("light1");break; + case 13: sRes = _T("light2");break; + case 14: sRes = _T("none");break; + case 15: sRes = _T("text1");break; + case 16: sRes = _T("text2");break; + default : sRes = _T("none");break; + } + } + return sRes; + } + std::wstring CThemeColor::ToStringTint() + { + std::wstring sRes; + if(bTint) + { + sRes = XmlUtils::ToString(Tint, L"%02X"); + } + return sRes; + } + std::wstring CThemeColor::ToStringShade() + { + std::wstring sRes; + if(bShade) + { + sRes = XmlUtils::ToString(Shade, L"%02X"); + } + return sRes; + } + void CThemeColor::ToCThemeColor( nullable& oColor, + nullable& oThemeColor, + nullable& oThemeTint, + nullable& oThemeShade) + { + if (Auto) + { + if(!oColor.IsInit()) + oColor.Init(); + oColor->SetValue(SimpleTypes::hexcolorAuto); + } + if (bColor) + { + oThemeColor.Init(); + oThemeColor->SetValue((SimpleTypes::EThemeColor)Color); + } + if (bTint) + { + oThemeTint.Init(); + oThemeTint->SetValue(Tint); + } + if (bShade) + { + oThemeShade.Init(); + oThemeShade->SetValue(Shade); + } + } + Spacing::Spacing() + { + bLineRule = false; + bLine = false; + bLineTwips = false; + bAfter = false; + bBefore = false; + bAfterAuto = false; + bBeforeAuto = false; + } + + Background::Background() : bColor (false), bThemeColor(false) {} + std::wstring Background::Write() + { + std::wstring sBackground = L""; + + sBackground += sObject; + + sBackground += L""; + return sBackground; + } + + Tab::Tab() + { + Pos = 0; + bLeader = false; + } + + docStyle::docStyle() + { + byteType = styletype_Paragraph; + bDefault = false; + bCustom = false; + + bqFormat = false; + buiPriority = false; + bhidden = false; + bsemiHidden = false; + bunhideWhenUsed = false; + bautoRedefine = false; + blocked = false; + bpersonal = false; + bpersonalCompose = false; + bpersonalReply = false; + } + void docStyle::Write(NSStringUtils::CStringBuilder* pCStringWriter) + { + std::wstring sType; + switch(byteType) + { + case styletype_Character: sType = _T("character");break; + case styletype_Numbering: sType = _T("numbering");break; + case styletype_Table: sType = _T("table");break; + default: sType = _T("paragraph");break; + } + if(!Id.empty()) + { + std::wstring sStyle = L""; + pCStringWriter->WriteString(sStyle); + + if(!Name.empty()) + { + pCStringWriter->WriteString(L""); + } + if (!Aliases.empty()) + { + pCStringWriter->WriteString(L"WriteEncodeXmlString(Aliases); + pCStringWriter->WriteString(L"\"/>"); + } + if (!BasedOn.empty()) + { + pCStringWriter->WriteString(L""); + } + if (!NextId.empty()) + { + pCStringWriter->WriteString(L""); + } + if (!Link.empty()) + { + pCStringWriter->WriteString(L"WriteEncodeXmlString(Link); + pCStringWriter->WriteString(L"\"/>"); + } + if(bautoRedefine) + { + if(autoRedefine) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if (bhidden) + { + if (hidden) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if (buiPriority) + { + pCStringWriter->WriteString(L""); + } + if (bsemiHidden) + { + if (semiHidden) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if (bunhideWhenUsed) + { + if (unhideWhenUsed) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if (bqFormat) + { + if (qFormat) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if (blocked) + { + if (locked) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if(bpersonal) + { + if(personal) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if(bpersonalCompose) + { + if(personalCompose) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if(bpersonalReply) + { + if(personalReply) + pCStringWriter->WriteString(L""); + else + pCStringWriter->WriteString(L""); + } + if(!ParaPr.empty()) + { + pCStringWriter->WriteString(L""); + pCStringWriter->WriteString(ParaPr); + pCStringWriter->WriteString(L""); + } + if(!TextPr.empty()) + { + pCStringWriter->WriteString(TextPr); + } + + if(!TablePr.empty()) + pCStringWriter->WriteString(TablePr); + if(!RowPr.empty()) + { + pCStringWriter->WriteString(L""); + pCStringWriter->WriteString(RowPr); + pCStringWriter->WriteString(L""); + } + if(!CellPr.empty()) + { + pCStringWriter->WriteString(L""); + pCStringWriter->WriteString(CellPr); + pCStringWriter->WriteString(L""); + } + for(int i = 0, length = (int)TblStylePr.size(); i < length; ++i) + { + pCStringWriter->WriteString(TblStylePr[i]); + } + pCStringWriter->WriteString(L""); + } + } + + tblStylePr::tblStylePr() + { + bType = false; + } + + PaddingsToWrite::PaddingsToWrite() + { + bLeft = false; + bTop = false; + bRight = false; + bBottom = false; + } + + PaddingsToWriteMM::PaddingsToWriteMM() + { + bLeft = false; + bTop = false; + bRight = false; + bBottom = false; + } + + docImg::docImg(int nDocPr) + { + m_nDocPr = nDocPr; + bMediaId = false; + bType = false; + bX = false; + bY = false; + bWidth = false; + bHeight = false; + bPaddings = false; + } + void docImg::Write(NSStringUtils::CStringBuilder* pCStringWriter) + { + if(bType) + { + if(c_oAscWrapStyle::Inline == Type) + { + if(bWidth && bHeight) + { + __int64 nWidth = (__int64)(g_dKoef_mm_to_emu * Width); + __int64 nHeight = (__int64)(g_dKoef_mm_to_emu * Height); + std::wstring sDrawing = L""; + pCStringWriter->WriteString(sDrawing); + } + } + else if(c_oAscWrapStyle::Flow == Type) + { + if(bX && bY && bWidth && bHeight) + { + __int64 nX = (__int64)(g_dKoef_mm_to_emu * X); + __int64 nY = (__int64)(g_dKoef_mm_to_emu * Y); + __int64 nWidth = (__int64)(g_dKoef_mm_to_emu * Width); + __int64 nHeight = (__int64)(g_dKoef_mm_to_emu * Height); + unsigned long nPaddingLeft = 0; + unsigned long nPaddingTop = 0; + unsigned long nPaddingRight = 0; + unsigned long nPaddingBottom = 0; + if(bPaddings) + { + if(Paddings.bLeft) nPaddingLeft = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Left); + if(Paddings.bTop) nPaddingTop = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Top); + if(Paddings.bRight) nPaddingRight = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Right); + if(Paddings.bBottom) nPaddingBottom = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Bottom); + + } + std::wstring sDrawing = L"" + + std::to_wstring(nX) + L"" + + std::to_wstring(nY) + L"\ +\ +"; + + pCStringWriter->WriteString(sDrawing); + } + } + } + } + + docW::docW() + { + bType = false; + bW = false; + bWDocx = false; + } + void docW::Write(NSStringUtils::CStringBuilder& pCStringWriter, const std::wstring& sName) + { + pCStringWriter.WriteString(Write(sName)); + } + std::wstring docW::Write(const std::wstring& sName) + { + std::wstring sXml; + if(bW || (bType && bWDocx)) + { + std::wstring sType; + int nVal; + if(bW) + { + sType = _T("dxa"); + nVal = SerializeCommon::Round( g_dKoef_mm_to_twips * W); + } + else + { + switch(Type) + { + case 0: sType = _T("auto"); break; + case 1: sType = _T("dxa"); break; + case 2: sType = _T("nil"); break; + case 3: sType = _T("pct"); break; + } + nVal = WDocx; + } + sXml = L"<" + sName + L" w:w=\"" + std::to_wstring(nVal) + L"\" w:type=\"" + sType + L"\"/>"; + } + return sXml; + } + + docBorder::docBorder() + { + bColor = false; + bSpace = false; + bSize = false; + bValue = false; + bThemeColor = false; + } + void docBorder::Write(std::wstring sName, NSStringUtils::CStringBuilder* pCStringWriter, bool bCell) + { + if(bValue) + { + pCStringWriter->WriteString(L"<"); + pCStringWriter->WriteString(sName); + if(border_Single == Value) + pCStringWriter->WriteString(L" w:val=\"single\""); + else + pCStringWriter->WriteString(L" w:val=\"none\""); + if(bColor) + { + pCStringWriter->WriteString(L" w:color=\"" + Color.ToString() + L"\""); + } + if(bThemeColor && ThemeColor.IsNoEmpty()) + { + if(ThemeColor.Auto && !bColor) + { + std::wstring sAuto(L" w:color=\"auto\""); + pCStringWriter->WriteString(sAuto); + } + if(ThemeColor.bColor) + { + pCStringWriter->WriteString(L" w:themeColor=\"" + ThemeColor.ToStringColor() + L"\""); + } + if(ThemeColor.bTint) + { + pCStringWriter->WriteString(L" w:themeTint=\"" + ThemeColor.ToStringTint() + L"\""); + } + if(ThemeColor.bShade) + { + pCStringWriter->WriteString(L" w:themeShade=\"" + ThemeColor.ToStringShade() + L"\""); + } + } + if(bSize) + { + pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(Size) + L"\""); + } + if(bSpace) + { + pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(Space) + L"\""); + } + pCStringWriter->WriteString(L"/>"); + } + else + { + pCStringWriter->WriteString(L"<"); + pCStringWriter->WriteString(sName); + if(false != bCell) + pCStringWriter->WriteString(L" w:val=\"nil\""); + else + pCStringWriter->WriteString(L" w:val=\"none\" w:sz=\"0\" w:space=\"0\" w:color=\"auto\""); + pCStringWriter->WriteString(L"/>"); + } + } + + docBorders::docBorders() + { + bLeft = false; + bTop = false; + bRight = false; + bBottom = false; + bInsideV = false; + bInsideH = false; + bBetween = false; + } + bool docBorders::IsEmpty() + { + return !(bLeft || bTop || bRight || bBottom || bInsideV || bInsideH || bBetween); + } + void docBorders::Write(NSStringUtils::CStringBuilder* pCStringWriter, bool bCell) + { + if(bTop) + oTop.Write(L"w:top", pCStringWriter, bCell); + if(bLeft) + oLeft.Write(L"w:left", pCStringWriter, bCell); + if(bBottom) + oBottom.Write(L"w:bottom", pCStringWriter, bCell); + if(bRight) + oRight.Write(L"w:right", pCStringWriter, bCell); + if(bInsideH) + oInsideH.Write(L"w:insideH", pCStringWriter, bCell); + if(bInsideV) + oInsideV.Write(L"w:insideV", pCStringWriter, bCell); + if(bBetween) + oBetween.Write(L"w:between", pCStringWriter, bCell); + } + + docLvlText::docLvlText() + { + bText = false; + bNumber = false; + } + + docLvl::docLvl() + { + bILvl = false; + bFormat = false; + bJc = false; + bText = false; + bRestart = false; + bStart = false; + bSuff = false; + bParaPr = false; + bTextPr = false; + bPStyle = false; + bTentative = false; + bTplc = false; + bIsLgl = false; + bLvlLegacy = false; + bLegacy = false; + bLegacyIndent = false; + bLegacySpace = false; + } + docLvl::~docLvl() + { + for(int i = 0,length = (int)Text.size(); i < length; i++) + { + delete Text[i]; + } + } + void docLvl::Write(NSStringUtils::CStringBuilder& oWriter) + { + oWriter.WriteString(L""); + if(bStart) + { + oWriter.WriteString(L""); + } + if(!sFormat.empty()) + { + oWriter.WriteString(sFormat); + } + else if(bFormat) + { + std::wstring sFormat; + switch(Format) + { + case numbering_numfmt_None: sFormat = L"none"; break; + case numbering_numfmt_Bullet: sFormat = L"bullet"; break; + case numbering_numfmt_Decimal: sFormat = L"decimal"; break; + case numbering_numfmt_LowerRoman: sFormat = L"lowerRoman"; break; + case numbering_numfmt_UpperRoman: sFormat = L"upperRoman"; break; + case numbering_numfmt_LowerLetter: sFormat = L"lowerLetter"; break; + case numbering_numfmt_UpperLetter: sFormat = L"upperLetter"; break; + case numbering_numfmt_DecimalZero: sFormat = L"decimalZero"; break; + default: + { + Format -= 0x2008; + if (Format >= 0) + { + SimpleTypes::CNumberFormat numFormat; + numFormat.SetValue((SimpleTypes::ENumberFormat)Format); + + sFormat = numFormat.ToString(); + } + }break; + } + if(!sFormat.empty()) + { + oWriter.WriteString(L""); + } + } + if(bRestart) + { + oWriter.WriteString(L""); + } + if(bPStyle) + { + std::wstring sStyleName = XmlUtils::EncodeXmlString(PStyle); + oWriter.WriteString(L""); + } + if(bIsLgl) + { + if(IsLgl) + oWriter.WriteString(L""); + else + oWriter.WriteString(L""); + } + if(bSuff) + { + std::wstring sSuff; + switch(Suff) + { + case numbering_suff_Nothing: sSuff = _T("nothing");break; + case numbering_suff_Space: sSuff = _T("space");break; + default: sSuff = _T("tab");break; + } + oWriter.WriteString(L""); + } + if(bText) + { + std::wstring sText; + for(int i = 0, length = (int)Text.size(); i < length; ++i) + { + docLvlText* item = Text[i]; + if(item->bText) + { + sText += (item->Text); + } + else if(item->bNumber) + { + sText += L"%" + std::to_wstring(item->Number+1); + } + } + sText = XmlUtils::EncodeXmlString(sText); + + //std::wstring sTextXml;sTextXml.Format(L"", sText); + + std::wstring sTextXml(L""); + + oWriter.WriteString(sTextXml); + } + if(bLvlLegacy) + { + oWriter.WriteString(L""); + } + if(!sJc.empty()) + { + oWriter.WriteString(sJc); + } + else if(bJc) + { + std::wstring sJcType; + switch(Jc) + { + case align_Right:sJcType = _T("right");break; + case align_Left:sJcType = _T("left");break; + case align_Center:sJcType = _T("center");break; + case align_Justify:sJcType = _T("distribute");break; + } + if(!sJcType.empty()) + { + oWriter.WriteString(L""); + } + } + if(bParaPr) + { + oWriter.Write(ParaPr); + } + if(bTextPr) + { + oWriter.Write(TextPr); + } + oWriter.WriteString(L""); + } + + docLvlOverride::docLvlOverride() + { + bILvl = false; + bStartOverride = false; + Lvl = NULL; + } + docLvlOverride::~docLvlOverride() + { + RELEASEOBJECT(Lvl); + } + void docLvlOverride::Write(NSStringUtils::CStringBuilder& oWriter) + { + oWriter.WriteString(L""); + if (bStartOverride) + { + oWriter.WriteString(L""); + } + if(NULL != Lvl) + { + Lvl->Write(oWriter); + } + oWriter.WriteString(L""); + } + + docANum::docANum() + { + bId = false; + } + docANum::~docANum() + { + for(int i = 0, length = (int)Lvls.size(); i < length; i++) + { + delete Lvls[i]; + } + } + void docANum::Write(NSStringUtils::CStringBuilder& oWriterANum) + { + if(bId) + { + oWriterANum.WriteString(L""); + if(!StyleLink.empty()) + { + std::wstring sCorrectStyleLink = XmlUtils::EncodeXmlString(StyleLink); + oWriterANum.WriteString(L""); + } + if(!NumStyleLink.empty()) + { + std::wstring sCorrectNumStyleLink = XmlUtils::EncodeXmlString(NumStyleLink); + oWriterANum.WriteString(L""); + } + for(int i = 0, length = (int)Lvls.size(); i < length; ++i) + { + Lvls[i]->Write(oWriterANum); + } + oWriterANum.WriteString(L""); + } + } + + docNum::docNum() + { + bAId = false; + bId = false; + } + docNum::~docNum() + { + for(size_t i = 0; i < LvlOverrides.size(); ++i){ + RELEASEOBJECT(LvlOverrides[i]); + } + } + void docNum::Write(NSStringUtils::CStringBuilder& oWriterNumList) + { + if(bAId && bId) + { + oWriterNumList.WriteString(L""); + for(size_t i = 0; i < LvlOverrides.size(); ++i){ + LvlOverrides[i]->Write(oWriterNumList); + } + oWriterNumList.WriteString(L""); + } + } + + rowPrAfterBefore::rowPrAfterBefore(std::wstring name) + { + sName = name; + bGridAfter = false; + } + void rowPrAfterBefore::Write(NSStringUtils::CStringBuilder& writer) + { + if(bGridAfter && nGridAfter > 0) + { + writer.WriteString(L""); + } + if(oAfterWidth.bW) + oAfterWidth.Write(writer, _T("w:w") + sName); + } + + WriteHyperlink* WriteHyperlink::Parse(std::wstring fld) + { + WriteHyperlink* res = NULL; + if(-1 != fld.find(L"HYPERLINK")) + { + std::wstring sLink; + std::wstring sTooltip; + bool bNextLink = false; + bool bNextTooltip = false; + //разбиваем по пробелам, но с учетом кавычек + std::vector aItems; + std::wstring sCurItem; + bool bDQuot = false; + + for(int i = 0, length = (int)fld.length(); i < length; ++i) + { + wchar_t sCurLetter = fld[i]; + if('\"' == sCurLetter) + bDQuot = !bDQuot; + else if('\\' == sCurLetter && true == bDQuot && i + 1 < length && '\"' == fld[i + 1]) + { + i++; + sCurItem += fld[i]; + } + else if(' ' == sCurLetter && false == bDQuot) + { + if(sCurItem.length() > 0) + { + aItems.push_back(sCurItem); + sCurItem = _T(""); + } + } + else + sCurItem += sCurLetter; + } + if(sCurItem.length() > 0) + aItems.push_back(sCurItem); + + for(int i = 0, length = (int)aItems.size(); i < length; ++i) + { + std::wstring item = aItems[i]; + if(bNextLink) + { + bNextLink = false; + sLink = item; + } + if(bNextTooltip) + { + bNextTooltip = false; + sTooltip = item; + } + + if(L"HYPERLINK" == item) + bNextLink = true; + else if(L"\\o" == item) + bNextTooltip = true; + } + if(false == sLink.empty()) + { + res = new WriteHyperlink(); + boost::algorithm::trim(sLink); + + int nAnchorIndex = (int)sLink.find(L"#"); + if(-1 != nAnchorIndex) + { + res->href = sLink.substr(0, nAnchorIndex); + res->anchor = sLink.substr(nAnchorIndex); + } + else + res->href = sLink; + if(false == sTooltip.empty()) + { + res->tooltip = boost::algorithm::trim_copy(sTooltip); + } + } + } + return res; + } + void WriteHyperlink::Write(NSStringUtils::CStringBuilder& wr) + { + if(false == rId.empty()) + { + std::wstring sCorrect_rId = XmlUtils::EncodeXmlString(rId); + std::wstring sCorrect_tooltip = XmlUtils::EncodeXmlString(tooltip); + std::wstring sCorrect_anchor = XmlUtils::EncodeXmlString(anchor); + std::wstring sStart = L""; + wr.WriteString(sStart); + wr.Write(writer); + wr.WriteString(L""); + } + } + + IdCounter::IdCounter(int nStart) + { + m_nId = nStart; + } + int IdCounter::getNextId(int nCount) + { + int nRes = m_nId; + m_nId += nCount; + return nRes; + } + int IdCounter::getCurrentId() + { + return m_nId; + } + + CComment::CComment(IdCounter& oParaIdCounter, IdCounter& oFormatIdCounter) : m_oParaIdCounter(oParaIdCounter),m_oFormatIdCounter(oFormatIdCounter) + { + bIdOpen = false; + bIdFormat = false; + bSolved = false; + bDurableId = false; + } + CComment::~CComment() + { + for(size_t i = 0; i bIdFormat = true; + pComment->IdFormat = (int)(IdFormatStart + i + 1); + } + } + std::wstring CComment::writeRef(const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter) + { + std::wstring sRes; + sRes += (writeRef(this, sBefore, sRef, sAfter)); + + for(size_t i = 0; i< replies.size(); ++i) + { + sRes += (writeRef(replies[i], sBefore, sRef, sAfter)); + } + return sRes; + } + std::wstring CComment::writeRef(CComment* pComment, const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter) + { + std::wstring sRes; + if(!pComment->bIdFormat) + { + pComment->bIdFormat = true; + pComment->IdFormat = pComment->m_oFormatIdCounter.getNextId(); + } + sRes += (sBefore); + sRes += L"<" + sRef + L" w:id=\"" + std::to_wstring(pComment->IdFormat) + L"\"/>"; + sRes += (sAfter); + return sRes; + } + void CComment::writeContentWritePart(CComment* pComment, std::wstring& sText, int nPrevIndex, int nCurIndex, std::wstring& sRes) + { + std::wstring sPart; + if(nPrevIndex < nCurIndex) + sPart = XmlUtils::EncodeXmlString(sText.substr(nPrevIndex, nCurIndex - nPrevIndex)); + + int nId = pComment->m_oParaIdCounter.getNextId(); + + pComment->sParaId = XmlUtils::ToString(nId, L"%08X"); + sRes += L"sParaId + L"\" w14:textId=\"" + pComment->sParaId + L"\">"; + sRes += L""; + sRes += sPart; + sRes += L""; + } + std::wstring CComment::writeContent(CComment* pComment) + { + std::wstring sRes; + if(!pComment->bIdFormat) + { + pComment->bIdFormat = true; + pComment->IdFormat = pComment->m_oFormatIdCounter.getNextId(); + } + sRes += L"IdFormat) + L"\""; + if(false == pComment->UserName.empty()) + { + std::wstring sUserName = XmlUtils::EncodeXmlString(pComment->UserName); + sRes += L" w:author=\""; + sRes += (sUserName); + sRes += L"\""; + } + if(false == pComment->Date.empty()) + { + std::wstring sDate = XmlUtils::EncodeXmlString(pComment->Date); + sRes += L" w:date=\""; + sRes += sDate; + sRes += L"\""; + } + if(false == pComment->Initials.empty()) + { + sRes += L" w:initials=\""; + sRes += XmlUtils::EncodeXmlString(pComment->Initials); + sRes += L"\""; + } + sRes += L">"; + + if (false == pComment->sContent.empty()) + { + sRes += pComment->sContent; + } + else + { + //old comments + std::wstring sText = pComment->Text; + + XmlUtils::replace_all(sText, L"\r", L""); + + int nPrevIndex = 0; + for (int i = 0; i < (int)sText.length(); i++) + { + wchar_t cToken = sText[i]; + if('\n' == cToken) + { + writeContentWritePart(pComment, sText, nPrevIndex, i, sRes); + nPrevIndex = i + 1; + } + } + writeContentWritePart(pComment, sText, nPrevIndex, (int)sText.length(), sRes); + } + sRes += L""; + return sRes; + } + std::wstring CComment::writeContentExt(CComment* pComment) + { + std::wstring sRes; + if(false == pComment->sParaId.empty()) + { + std::wstring sDone(L"0"); + if(pComment->bSolved && pComment->Solved) + sDone = _T("1"); + if(!pComment->sParaIdParent.empty()) + sRes += L"sParaId + L"\" \ +w15:paraIdParent=\"" + pComment->sParaIdParent + L"\" w15:done=\"" + sDone + L"\"/>"; + else + sRes += L"sParaId + L"\" w15:done=\"" + sDone + L"\"/>"; + //расставляем paraIdParent + for(size_t i = 0; i < pComment->replies.size(); i++) + pComment->replies[i]->sParaIdParent = pComment->sParaId; + } + return sRes; + } + std::wstring CComment::writeContentExtensible(CComment* pComment) + { + std::wstring sRes; + if(pComment->bDurableId && !pComment->DateUtc.empty()) + { + sRes += L"DurableId, L"%08X") + L"\" w16cex:dateUtc=\"" + pComment->DateUtc + L"\"/>"; + } + return sRes; + } + std::wstring CComment::writeContentUserData(CComment* pComment) + { + std::wstring sRes; + if(pComment->bDurableId && !pComment->UserData.empty()) + { + sRes += L"DurableId, L"%08X") + L"\">"; + sRes += L"UserData); + sRes += L"\" providerId=\"AD\"/>"; + } + return sRes; + } + std::wstring CComment::writeContentsIds(CComment* pComment) + { + std::wstring sRes; + if(!pComment->sParaId.empty() && pComment->bDurableId) + { + sRes += L"sParaId + L"\" w16cid:durableId=\"" + XmlUtils::ToString(pComment->DurableId, L"%08X") + L"\"/>"; + } + return sRes; + } + std::wstring CComment::writePeople(CComment* pComment) + { + std::wstring sRes; + if(false == pComment->UserName.empty()) + { + sRes += L"UserName); + sRes += L"\">"; + if(!pComment->ProviderId.empty() && !pComment->UserId.empty()) + { + sRes += L"ProviderId); + sRes += L"\" w15:userId=\""; + sRes += XmlUtils::EncodeXmlString(pComment->UserId); + sRes += L"\"/>"; + } + sRes += L""; + } + return sRes; + } + + CComments::CComments() : m_oParaIdCounter(1) + { + } + CComments::~CComments() + { + for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + delete it->second; + } + m_mapComments.clear(); + } + void CComments::add(CComment* pComment) + { + if(pComment->bIdOpen) + { + m_mapComments[pComment->IdOpen] = pComment; + addAuthor(pComment); + for(size_t i = 0; i < pComment->replies.size(); i++) + addAuthor(pComment->replies[i]); + } + } + void CComments::addAuthor(CComment* pComment) + { + if(false == pComment->UserName.empty() && false == pComment->UserId.empty()) + m_mapAuthors[pComment->UserName] = pComment; + } + CComment* CComments::get(int nInd) + { + CComment* pRes = NULL; + boost::unordered_map::const_iterator pair = m_mapComments.find(nInd); + if(m_mapComments.end() != pair) + pRes = pair->second; + return pRes; + } + int CComments::getNextId(int nCount) + { + return m_oFormatIdCounter.getNextId(nCount); + } + std::wstring CComments::writeContent() + { + std::wstring sRes; + for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sRes += CComment::writeContent(it->second); + for(size_t i = 0; i < it->second->replies.size(); ++i) + sRes += CComment::writeContent(it->second->replies[i]); + } + return sRes; + } + std::wstring CComments::writeContentExt() + { + std::wstring sRes; + for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sRes += CComment::writeContentExt(it->second); + for(size_t i = 0; i < it->second->replies.size(); ++i) + sRes += CComment::writeContentExt(it->second->replies[i]); + } + return sRes; + } + std::wstring CComments::writeContentExtensible() + { + std::wstring sRes; + for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sRes += CComment::writeContentExtensible(it->second); + for(size_t i = 0; i < it->second->replies.size(); ++i) + sRes += CComment::writeContentExtensible(it->second->replies[i]); + } + return sRes; + } + std::wstring CComments::writeContentUserData() + { + std::wstring sRes; + for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sRes += CComment::writeContentUserData(it->second); + for(size_t i = 0; i < it->second->replies.size(); ++i) + sRes += CComment::writeContentUserData(it->second->replies[i]); + } + return sRes; + } + std::wstring CComments::writeContentsIds() + { + std::wstring sRes; + for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sRes += CComment::writeContentsIds(it->second); + for(size_t i = 0; i < it->second->replies.size(); ++i) + sRes += CComment::writeContentsIds(it->second->replies[i]); + } + return sRes; + } + std::wstring CComments::writePeople() + { + std::wstring sRes; + for (boost::unordered_map::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it) + { + sRes += (it->second->writePeople(it->second)); + } + return sRes; + } + + CDrawingPropertyWrapPoint::CDrawingPropertyWrapPoint() + { + bX = false; + bY = false; + } + + CDrawingPropertyWrap::CDrawingPropertyWrap() + { + bWrappingType = false; + bEdited = false; + bStart = false; + } + CDrawingPropertyWrap::~CDrawingPropertyWrap() + { + for(size_t i = 0; i < Points.size(); ++i) + delete Points[i]; + Points.clear(); + } + + CDrawingProperty::CDrawingProperty(int nDocPr) + { + m_nDocPr = nDocPr; + + bObject = false; + nObjectType = 0; + nObjectId = 0; + bDataPos = false; + bDataLength = false; + bType = false; + bBehindDoc = false; + bDistL = false; + bDistT = false; + bDistR = false; + bDistB = false; + bLayoutInCell = false; + bRelativeHeight = false; + bBSimplePos = false; + bEffectExtentL = false; + bEffectExtentT = false; + bEffectExtentR = false; + bEffectExtentB = false; + bWidth = false; + bHeight = false; + bPositionHRelativeFrom = false; + bPositionHAlign = false; + bPositionHPosOffset = false; + bPositionHPctOffset = false; + bPositionVRelativeFrom = false; + bPositionVAlign = false; + bPositionVPosOffset = false; + bPositionVPctOffset = false; + bSimplePosX = false; + bSimplePosY = false; + bDrawingPropertyWrap = false; + } + bool CDrawingProperty::IsGraphicFrameContent() + { + return false == sGraphicFrameContent.empty(); + } + std::wstring CDrawingProperty::Write() + { + if(!bType) return L""; + + std::wstring sXml; + + bool bGraphicFrameContent = IsGraphicFrameContent(); + + if(c_oAscWrapStyle::Inline == Type) + { + if(bWidth && bHeight) + { + if (bGraphicFrameContent) + { + sXml += L"\ +"; + } + else + { + sXml += L""; + } + + if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) + { + sXml += L""; + } + + if(!sDocPr.empty()) + { + sXml += sDocPr; + } + else + { + sXml += L""; + } + if (!sGraphicFramePr.empty()) + { + sXml += sGraphicFramePr; + } + else + { + sXml += L""; + } + if (bGraphicFrameContent) + { + sXml += sGraphicFrameContent + L""; + } + else + { + sXml += L""; + } + } + } + else + { + if(bWidth && bHeight && ((bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset) + && bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset)) + || (bBSimplePos && bSimplePosX && bSimplePosY))) + { + __int64 emuDistL = 0; + __int64 emuDistT = 0; + __int64 emuDistR = 0; + __int64 emuDistB = 0; + + if(bDistL) + emuDistL = DistL; + if(bDistT) + emuDistT = DistT; + if(bDistR) + emuDistR = DistR; + if(bDistB) + emuDistB = DistB; + int nSimplePos = 0; + if(bBSimplePos && BSimplePos) + nSimplePos = 1; + unsigned long nRelativeHeight = 0; + if(bRelativeHeight) + nRelativeHeight = RelativeHeight; + int nBehindDoc = 0; + if(bBehindDoc && BehindDoc) + nBehindDoc = 1; + int nLayoutInCell = 1; + if(bLayoutInCell && false == LayoutInCell) + nLayoutInCell = 0; + + if (bGraphicFrameContent) + { + sXml += L""; + } + sXml += L""; + + __int64 emuX = 0; + if(bSimplePosX) + emuX = SimplePosX; + __int64 emuY = 0; + if(bSimplePosY) + emuY = SimplePosY; + sXml += L""; + + if (bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset)) + { + std::wstring sRelativeFrom; + switch(PositionHRelativeFrom) + { + case 0: sRelativeFrom = _T("character");break; + case 1: sRelativeFrom = _T("column");break; + case 2: sRelativeFrom = _T("insideMargin");break; + case 3: sRelativeFrom = _T("leftMargin");break; + case 4: sRelativeFrom = _T("margin");break; + case 5: sRelativeFrom = _T("outsideMargin");break; + case 6: sRelativeFrom = _T("page");break; + case 7: sRelativeFrom = _T("rightMargin");break; + } + std::wstring sContent; + if(bPositionHAlign) + { + switch(PositionHAlign) + { + case 0: sContent = _T("center"); break; + case 1: sContent = _T("inside"); break; + case 2: sContent = _T("left"); break; + case 3: sContent = _T("outside"); break; + case 4: sContent = _T("right"); break; + } + } + else if(bPositionHPosOffset) + { + sContent = L"" + std::to_wstring(PositionHPosOffset) + L""; + } + else if(bPositionHPctOffset) + { + long pctOffset = (long)(1000 * PositionHPctOffset); + sContent = L"" + std::to_wstring(pctOffset) + L""; + } + sXml += L"" + sContent + L""; + } + if (bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset)) + { + std::wstring sRelativeFrom; + switch(PositionVRelativeFrom) + { + case 0: sRelativeFrom = _T("bottomMargin");break; + case 1: sRelativeFrom = _T("insideMargin");break; + case 2: sRelativeFrom = _T("line");break; + case 3: sRelativeFrom = _T("margin");break; + case 4: sRelativeFrom = _T("outsideMargin");break; + case 5: sRelativeFrom = _T("page");break; + case 6: sRelativeFrom = _T("paragraph");break; + case 7: sRelativeFrom = _T("topMargin");break; + } + std::wstring sContent; + if (bPositionVAlign) + { + switch(PositionVAlign) + { + case 0: sContent = _T("bottom");break; + case 1: sContent = _T("center");break; + case 2: sContent = _T("inside");break; + case 3: sContent = _T("outside");break; + case 4: sContent = _T("top");break; + } + } + else if(bPositionVPosOffset) + { + sContent = L"" + std::to_wstring(PositionVPosOffset) + L""; + } + else if(bPositionVPctOffset) + { + long pctOffset = (long)(1000 * PositionVPctOffset); + sContent = L"" + std::to_wstring(pctOffset) + L""; + } + sXml += L"" + sContent + L""; + } + sXml += L""; + + if (bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) + { + sXml += L""; + } + if (bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType) + { + std::wstring sTagName; + switch(DrawingPropertyWrap.WrappingType) + { + case c_oSerImageType2::WrapNone:sTagName = _T("wrapNone"); break; + case c_oSerImageType2::WrapSquare:sTagName = _T("wrapSquare"); break; + case c_oSerImageType2::WrapThrough:sTagName = _T("wrapThrough"); break; + case c_oSerImageType2::WrapTight:sTagName = _T("wrapTight"); break; + case c_oSerImageType2::WrapTopAndBottom:sTagName = _T("wrapTopAndBottom"); break; + } + if(DrawingPropertyWrap.bStart || DrawingPropertyWrap.Points.size() > 0) + { + if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType || + c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType || + c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType) + { + sXml += L""; + } + else + sXml += L""; + + int nEdited = 0; + if(DrawingPropertyWrap.bEdited && DrawingPropertyWrap.Edited) + nEdited = 1; + sXml += L""; + + if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY) + { + sXml += L""; + } + + for(size_t i = 0; i < DrawingPropertyWrap.Points.size(); ++i) + { + CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i]; + if(pWrapPoint->bX && pWrapPoint->bY) + { + sXml += L"X) + L"\" y=\"" + std::to_wstring(pWrapPoint->Y) + L"\"/>"; + } + } + sXml += L""; + sXml += L""; + } + else + { + //для wrapThrough и wrapTight wrapPolygon обязательное поле, если его нет - меняем тип. + if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType || + c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType || + c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType) + { + sXml += L""; + } + else + sXml += L""; + } + } + else + sXml += L""; + + if(!sDocPr.empty()) + { + sXml += sDocPr; + } + else + { + sXml += L""; + } + if(!sGraphicFramePr.empty()) + { + sXml += sGraphicFramePr; + } + else + { + sXml += L""; + } + if (bGraphicFrameContent) + { + sXml += sGraphicFrameContent; + } + + if(!sSizeRelH.empty()) + { + sXml += sSizeRelH; + } + if(!sSizeRelV.empty()) + { + sXml += sSizeRelV; + } + + sXml += L""; + + if (bGraphicFrameContent) + sXml += L""; + } + } + return sXml; + } + + bool CWiterTblPr::IsEmpty() + { + return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty(); + } + std::wstring CWiterTblPr::Write() + { + std::wstring sRes; + sRes += L""; + if(false == Style.empty()) + sRes += (Style); + if(false == tblpPr.empty()) + sRes += (tblpPr); + if(!RowBandSize.empty()) + sRes += (RowBandSize); + if(!ColBandSize.empty()) + sRes += (ColBandSize); + if (!Overlap.empty()) + sRes += (Overlap); + if(false == TableW.empty()) + sRes += (TableW); + if(false == Jc.empty()) + sRes += (Jc); + if(false == TableCellSpacing.empty()) + sRes += (TableCellSpacing); + if(false == TableInd.empty()) + sRes += (TableInd); + if(false == TableBorders.empty()) + sRes += (TableBorders); + if(false == Shd.empty()) + sRes += (Shd); + if(false == Layout.empty()) + sRes += (Layout); + if(false == TableCellMar.empty()) + sRes += (TableCellMar); + if(false == Look.empty()) + sRes += (Look); + if(!Caption.empty()) + { + sRes += L""; + } + if(!Description.empty()) + { + sRes += L""; + } + if(!tblPrChange.empty()) + sRes += (tblPrChange); + sRes += L""; + return sRes; + } + + CFramePr::CFramePr() + { + bDropCap = false; + bH = false; + bHAnchor = false; + bHRule = false; + bHSpace = false; + bLines = false; + bVAnchor = false; + bVSpace = false; + bW = false; + bWrap = false; + bX = false; + bXAlign = false; + bY = false; + bYAlign = false; + } + bool CFramePr::IsEmpty() + { + return !(bDropCap || bH || bHAnchor || bHRule || bHSpace || bLines || bVAnchor || bVSpace || bW || bWrap || bX || bXAlign || bY || bYAlign); + } + void CFramePr::Write(NSStringUtils::CStringBuilder& oStringWriter) + { + oStringWriter.WriteString(L""); + } + + CHyperlink::CHyperlink() + { + bHistory = false; + } + void CHyperlink::Write(NSStringUtils::CStringBuilder& wr) + { + wr.WriteString(L""); + wr.Write(writer); + wr.WriteString(L""); + } + + CFldSimple::CFldSimple() + { + } + void CFldSimple::Write(NSStringUtils::CStringBuilder& wr) + { + if(false == sInstr.empty()) + { + std::wstring sCorrect_Instr = XmlUtils::EncodeXmlString(sInstr); + std::wstring sStart(L""; + wr.WriteString(sStart); + wr.Write(writer); + wr.WriteString(L""); + } + } + TrackRevision::TrackRevision() { Id = NULL; @@ -158,5 +2163,14 @@ namespace BinDocxRW { } } } - + bool TrackRevision::IsNoEmpty() + { + return !Author.empty() || !Date.empty() || NULL != Id; + } + std::wstring TrackRevision::ToString(std::wstring sName) + { + NSStringUtils::CStringBuilder writer; + Write(&writer, sName); + return writer.GetData(); + } } diff --git a/OOXML/Binary/Document/BinReader/ReaderClasses.h b/OOXML/Binary/Document/BinReader/ReaderClasses.h index 5e2b1a84e3..ec31c36a17 100644 --- a/OOXML/Binary/Document/BinReader/ReaderClasses.h +++ b/OOXML/Binary/Document/BinReader/ReaderClasses.h @@ -83,116 +83,9 @@ public: bool bPageNumStart; bool bRtlGutter; bool bGutter; - SectPr() - { - sHeaderFooterReference = _T(""); - cols = _T(""); - bW = false; - bH = false; - bOrientation = false; - bLeft = false; - bTop = false; - bRight = false; - bBottom = false; - bHeader = false; - bFooter = false; - bTitlePg = false; - bEvenAndOddHeaders = false; - bSectionType = false; - bPageNumStart = false; - bRtlGutter = false; - bGutter = false; - } - std::wstring Write() - { - std::wstring sRes = _T(""); - - if(!sHeaderFooterReference.empty()) - sRes += sHeaderFooterReference; - if(!footnotePr.empty()) - sRes += footnotePr; - if(!endnotePr.empty()) - sRes += endnotePr; - if(bSectionType) - { - std::wstring sType; - switch(SectionType) - { - case 0: sType = _T("continuous");break; - case 1: sType = _T("evenPage");break; - case 2: sType = _T("nextColumn");break; - case 3: sType = _T("nextPage");break; - case 4: sType = _T("oddPage");break; - default: sType = _T("nextPage");break; - } - sRes += L""; - } - if((bW && bH) || bOrientation) - { - sRes += L""; - } - - if(bLeft || bTop || bRight || bBottom || bHeader || bFooter) - { - sRes += L""; - } - if(!pgBorders.empty()) - sRes += pgBorders; - - if(!lineNum.empty()) - sRes += lineNum; - - if(bPageNumStart) - sRes += L""; - - if(bRtlGutter) - { - if(RtlGutter) - sRes += L""; - else - sRes += L""; - } - - if(!cols.empty()) - sRes += cols; - sRes += L""; - - if(bTitlePg && TitlePg) - sRes += L""; - - if(!sectPrChange.empty()) - sRes += sectPrChange; - return sRes; - } + SectPr(); + std::wstring Write(); }; class docRGB { @@ -200,16 +93,9 @@ public: BYTE R; BYTE G; BYTE B; - docRGB() - { - R = 255; - G = 255; - B = 255; - } - std::wstring ToString() - { - return XmlUtils::ToString(R, L"%02X") + XmlUtils::ToString(G, L"%02X") + XmlUtils::ToString(B, L"%02X"); - } + + docRGB(); + std::wstring ToString(); }; class CThemeColor{ public: @@ -221,94 +107,19 @@ public: bool bShade; bool bTint; bool bColor; - CThemeColor(){ - Reset(); - } - void Reset() - { - bShade = false; - bTint = false; - bColor = false; - Auto = false; - } - bool IsNoEmpty() - { - return bShade || bTint || bColor || Auto; - } - std::wstring ToStringColor() - { - std::wstring sRes; - if(bColor) - { - switch(Color) - { - case 0: sRes = _T("accent1");break; - case 1: sRes = _T("accent2");break; - case 2: sRes = _T("accent3");break; - case 3: sRes = _T("accent4");break; - case 4: sRes = _T("accent5");break; - case 5: sRes = _T("accent6");break; - case 6: sRes = _T("background1");break; - case 7: sRes = _T("background2");break; - case 8: sRes = _T("dark1");break; - case 9: sRes = _T("dark2");break; - case 10: sRes = _T("followedHyperlink");break; - case 11: sRes = _T("hyperlink");break; - case 12: sRes = _T("light1");break; - case 13: sRes = _T("light2");break; - case 14: sRes = _T("none");break; - case 15: sRes = _T("text1");break; - case 16: sRes = _T("text2");break; - default : sRes = _T("none");break; - } - } - return sRes; - } - std::wstring ToStringTint() - { - std::wstring sRes; - if(bTint) - { - sRes = XmlUtils::ToString(Tint, L"%02X"); - } - return sRes; - } - std::wstring ToStringShade() - { - std::wstring sRes; - if(bShade) - { - sRes = XmlUtils::ToString(Shade, L"%02X"); - } - return sRes; - } + + CThemeColor(); + + void Reset(); + bool IsNoEmpty(); + + std::wstring ToStringColor(); + std::wstring ToStringTint(); + std::wstring ToStringShade(); void ToCThemeColor( nullable& oColor, nullable& oThemeColor, nullable& oThemeTint, - nullable& oThemeShade) - { - if (Auto) - { - if(!oColor.IsInit()) - oColor.Init(); - oColor->SetValue(SimpleTypes::hexcolorAuto); - } - if (bColor) - { - oThemeColor.Init(); - oThemeColor->SetValue((SimpleTypes::EThemeColor)Color); - } - if (bTint) - { - oThemeTint.Init(); - oThemeTint->SetValue(Tint); - } - if (bShade) - { - oThemeShade.Init(); - oThemeShade->SetValue(Shade); - } - } + nullable& oThemeShade); }; class Spacing { @@ -328,16 +139,8 @@ public: long Before; bool AfterAuto; bool BeforeAuto; - Spacing() - { - bLineRule = false; - bLine = false; - bLineTwips = false; - bAfter = false; - bBefore = false; - bAfterAuto = false; - bBeforeAuto = false; - } + + Spacing(); }; class Background { @@ -350,38 +153,9 @@ public: bool bColor; bool bThemeColor; - Background() : bColor (false), bThemeColor(false) {} + Background(); - std::wstring Write() - { - std::wstring sBackground = L""; - - sBackground += sObject; - - sBackground += L""; - return sBackground; - } + std::wstring Write(); }; class Tab @@ -391,11 +165,8 @@ public: long Pos; BYTE Leader; bool bLeader; - Tab() - { - Pos = 0; - bLeader = false; - } + + Tab(); }; class Tabs { @@ -446,177 +217,9 @@ public: bool bpersonalReply; public: - docStyle() - { - byteType = styletype_Paragraph; - bDefault = false; - bCustom = false; + docStyle(); - bqFormat = false; - buiPriority = false; - bhidden = false; - bsemiHidden = false; - bunhideWhenUsed = false; - bautoRedefine = false; - blocked = false; - bpersonal = false; - bpersonalCompose = false; - bpersonalReply = false; - } - void Write(NSStringUtils::CStringBuilder* pCStringWriter) - { - std::wstring sType; - switch(byteType) - { - case styletype_Character: sType = _T("character");break; - case styletype_Numbering: sType = _T("numbering");break; - case styletype_Table: sType = _T("table");break; - default: sType = _T("paragraph");break; - } - if(!Id.empty()) - { - std::wstring sStyle = L""; - pCStringWriter->WriteString(sStyle); - - if(!Name.empty()) - { - pCStringWriter->WriteString(L""); - } - if (!Aliases.empty()) - { - pCStringWriter->WriteString(L"WriteEncodeXmlString(Aliases); - pCStringWriter->WriteString(L"\"/>"); - } - if (!BasedOn.empty()) - { - pCStringWriter->WriteString(L""); - } - if (!NextId.empty()) - { - pCStringWriter->WriteString(L""); - } - if (!Link.empty()) - { - pCStringWriter->WriteString(L"WriteEncodeXmlString(Link); - pCStringWriter->WriteString(L"\"/>"); - } - if(bautoRedefine) - { - if(autoRedefine) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if (bhidden) - { - if (hidden) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if (buiPriority) - { - pCStringWriter->WriteString(L""); - } - if (bsemiHidden) - { - if (semiHidden) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if (bunhideWhenUsed) - { - if (unhideWhenUsed) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if (bqFormat) - { - if (qFormat) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if (blocked) - { - if (locked) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if(bpersonal) - { - if(personal) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if(bpersonalCompose) - { - if(personalCompose) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if(bpersonalReply) - { - if(personalReply) - pCStringWriter->WriteString(L""); - else - pCStringWriter->WriteString(L""); - } - if(!ParaPr.empty()) - { - pCStringWriter->WriteString(L""); - pCStringWriter->WriteString(ParaPr); - pCStringWriter->WriteString(L""); - } - if(!TextPr.empty()) - { - pCStringWriter->WriteString(TextPr); - } - - if(!TablePr.empty()) - pCStringWriter->WriteString(TablePr); - if(!RowPr.empty()) - { - pCStringWriter->WriteString(L""); - pCStringWriter->WriteString(RowPr); - pCStringWriter->WriteString(L""); - } - if(!CellPr.empty()) - { - pCStringWriter->WriteString(L""); - pCStringWriter->WriteString(CellPr); - pCStringWriter->WriteString(L""); - } - for(int i = 0, length = (int)TblStylePr.size(); i < length; ++i) - { - pCStringWriter->WriteString(TblStylePr[i]); - } - pCStringWriter->WriteString(L""); - } - } + void Write(NSStringUtils::CStringBuilder* pCStringWriter); }; class tblStylePr { @@ -624,11 +227,9 @@ public: NSStringUtils::CStringBuilder Writer; BYTE Type; bool bType; + public: - tblStylePr() - { - bType = false; - } + tblStylePr(); }; class PaddingsToWrite { @@ -642,13 +243,9 @@ public: bool bTop; bool bRight; bool bBottom; -public: PaddingsToWrite() - { - bLeft = false; - bTop = false; - bRight = false; - bBottom = false; - } + +public: + PaddingsToWrite(); }; class PaddingsToWriteMM { @@ -662,13 +259,9 @@ public: bool bTop; bool bRight; bool bBottom; -public: PaddingsToWriteMM() - { - bLeft = false; - bTop = false; - bRight = false; - bBottom = false; - } + +public: + PaddingsToWriteMM(); }; class docImg { @@ -690,82 +283,11 @@ public: bool bHeight; bool bPaddings; std::wstring srId; - docImg(int nDocPr) - { - m_nDocPr = nDocPr; - bMediaId = false; - bType = false; - bX = false; - bY = false; - bWidth = false; - bHeight = false; - bPaddings = false; - } - void Write(NSStringUtils::CStringBuilder* pCStringWriter) - { - if(bType) - { - if(c_oAscWrapStyle::Inline == Type) - { - if(bWidth && bHeight) - { - __int64 nWidth = (__int64)(g_dKoef_mm_to_emu * Width); - __int64 nHeight = (__int64)(g_dKoef_mm_to_emu * Height); - std::wstring sDrawing = L""; - pCStringWriter->WriteString(sDrawing); - } - } - else if(c_oAscWrapStyle::Flow == Type) - { - if(bX && bY && bWidth && bHeight) - { - __int64 nX = (__int64)(g_dKoef_mm_to_emu * X); - __int64 nY = (__int64)(g_dKoef_mm_to_emu * Y); - __int64 nWidth = (__int64)(g_dKoef_mm_to_emu * Width); - __int64 nHeight = (__int64)(g_dKoef_mm_to_emu * Height); - unsigned long nPaddingLeft = 0; - unsigned long nPaddingTop = 0; - unsigned long nPaddingRight = 0; - unsigned long nPaddingBottom = 0; - if(bPaddings) - { - if(Paddings.bLeft) nPaddingLeft = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Left); - if(Paddings.bTop) nPaddingTop = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Top); - if(Paddings.bRight) nPaddingRight = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Right); - if(Paddings.bBottom) nPaddingBottom = (unsigned long)(g_dKoef_mm_to_emu * Paddings.Bottom); - } - std::wstring sDrawing = L"" - + std::to_wstring(nX) + L"" - + std::to_wstring(nY) + L"\ -\ -"; + docImg(int nDocPr); - pCStringWriter->WriteString(sDrawing); - } - } - } - } + void Write(NSStringUtils::CStringBuilder* pCStringWriter); }; -//class tblPr -//{ -//public: -// tblPr() -// { -// } -// void Write(NSStringUtils::CStringBuilder* pCStringWriter) -// { -// } -//}; class docW { public: @@ -776,43 +298,11 @@ public: bool bType; bool bW; bool bWDocx; - docW() - { - bType = false; - bW = false; - bWDocx = false; - } - void Write(NSStringUtils::CStringBuilder& pCStringWriter, const std::wstring& sName) - { - pCStringWriter.WriteString(Write(sName)); - } - std::wstring Write(const std::wstring& sName) - { - std::wstring sXml; - if(bW || (bType && bWDocx)) - { - std::wstring sType; - int nVal; - if(bW) - { - sType = _T("dxa"); - nVal = SerializeCommon::Round( g_dKoef_mm_to_twips * W); - } - else - { - switch(Type) - { - case 0: sType = _T("auto"); break; - case 1: sType = _T("dxa"); break; - case 2: sType = _T("nil"); break; - case 3: sType = _T("pct"); break; - } - nVal = WDocx; - } - sXml = L"<" + sName + L" w:w=\"" + std::to_wstring(nVal) + L"\" w:type=\"" + sType + L"\"/>"; - } - return sXml; - } + + docW(); + + void Write(NSStringUtils::CStringBuilder& pCStringWriter, const std::wstring& sName); + std::wstring Write(const std::wstring& sName); }; class docBorder { @@ -828,69 +318,10 @@ public: bool bSize; bool bValue; bool bThemeColor; - docBorder() - { - bColor = false; - bSpace = false; - bSize = false; - bValue = false; - bThemeColor = false; - } - void Write(std::wstring sName, NSStringUtils::CStringBuilder* pCStringWriter, bool bCell) - { - if(bValue) - { - pCStringWriter->WriteString(L"<"); - pCStringWriter->WriteString(sName); - if(border_Single == Value) - pCStringWriter->WriteString(L" w:val=\"single\""); - else - pCStringWriter->WriteString(L" w:val=\"none\""); - if(bColor) - { - pCStringWriter->WriteString(L" w:color=\"" + Color.ToString() + L"\""); - } - if(bThemeColor && ThemeColor.IsNoEmpty()) - { - if(ThemeColor.Auto && !bColor) - { - std::wstring sAuto(L" w:color=\"auto\""); - pCStringWriter->WriteString(sAuto); - } - if(ThemeColor.bColor) - { - pCStringWriter->WriteString(L" w:themeColor=\"" + ThemeColor.ToStringColor() + L"\""); - } - if(ThemeColor.bTint) - { - pCStringWriter->WriteString(L" w:themeTint=\"" + ThemeColor.ToStringTint() + L"\""); - } - if(ThemeColor.bShade) - { - pCStringWriter->WriteString(L" w:themeShade=\"" + ThemeColor.ToStringShade() + L"\""); - } - } - if(bSize) - { - pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(Size) + L"\""); - } - if(bSpace) - { - pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(Space) + L"\""); - } - pCStringWriter->WriteString(L"/>"); - } - else - { - pCStringWriter->WriteString(L"<"); - pCStringWriter->WriteString(sName); - if(false != bCell) - pCStringWriter->WriteString(L" w:val=\"nil\""); - else - pCStringWriter->WriteString(L" w:val=\"none\" w:sz=\"0\" w:space=\"0\" w:color=\"auto\""); - pCStringWriter->WriteString(L"/>"); - } - } + + docBorder(); + + void Write(std::wstring sName, NSStringUtils::CStringBuilder* pCStringWriter, bool bCell); }; class docBorders { @@ -910,38 +341,12 @@ public: bool bInsideV; bool bInsideH; bool bBetween; + public: - docBorders() - { - bLeft = false; - bTop = false; - bRight = false; - bBottom = false; - bInsideV = false; - bInsideH = false; - bBetween = false; - } - bool IsEmpty() - { - return !(bLeft || bTop || bRight || bBottom || bInsideV || bInsideH || bBetween); - } - void Write(NSStringUtils::CStringBuilder* pCStringWriter, bool bCell) - { - if(bTop) - oTop.Write(L"w:top", pCStringWriter, bCell); - if(bLeft) - oLeft.Write(L"w:left", pCStringWriter, bCell); - if(bBottom) - oBottom.Write(L"w:bottom", pCStringWriter, bCell); - if(bRight) - oRight.Write(L"w:right", pCStringWriter, bCell); - if(bInsideH) - oInsideH.Write(L"w:insideH", pCStringWriter, bCell); - if(bInsideV) - oInsideV.Write(L"w:insideV", pCStringWriter, bCell); - if(bBetween) - oBetween.Write(L"w:between", pCStringWriter, bCell); - } + docBorders(); + + bool IsEmpty(); + void Write(NSStringUtils::CStringBuilder* pCStringWriter, bool bCell); }; class docLvlText { @@ -951,11 +356,8 @@ public: bool bText; bool bNumber; - docLvlText() - { - bText = false; - bNumber = false; - } + + docLvlText(); }; class docLvl { @@ -997,199 +399,10 @@ public: bool bLegacyIndent; bool bLegacySpace; - docLvl() - { - bILvl = false; - bFormat = false; - bJc = false; - bText = false; - bRestart = false; - bStart = false; - bSuff = false; - bParaPr = false; - bTextPr = false; - bPStyle = false; - bTentative = false; - bTplc = false; - bIsLgl = false; - bLvlLegacy = false; - bLegacy = false; - bLegacyIndent = false; - bLegacySpace = false; - } - ~docLvl() - { - for(int i = 0,length = (int)Text.size(); i < length; i++) - { - delete Text[i]; - } - } - void Write(NSStringUtils::CStringBuilder& oWriter) - { - oWriter.WriteString(L""); - if(bStart) - { - oWriter.WriteString(L""); - } - if(!sFormat.empty()) - { - oWriter.WriteString(sFormat); - } - else if(bFormat) - { - std::wstring sFormat; - switch(Format) - { - case numbering_numfmt_None: sFormat = L"none"; break; - case numbering_numfmt_Bullet: sFormat = L"bullet"; break; - case numbering_numfmt_Decimal: sFormat = L"decimal"; break; - case numbering_numfmt_LowerRoman: sFormat = L"lowerRoman"; break; - case numbering_numfmt_UpperRoman: sFormat = L"upperRoman"; break; - case numbering_numfmt_LowerLetter: sFormat = L"lowerLetter"; break; - case numbering_numfmt_UpperLetter: sFormat = L"upperLetter"; break; - case numbering_numfmt_DecimalZero: sFormat = L"decimalZero"; break; - default: - { - Format -= 0x2008; - if (Format >= 0) - { - SimpleTypes::CNumberFormat numFormat; - numFormat.SetValue((SimpleTypes::ENumberFormat)Format); + docLvl(); + ~docLvl(); - sFormat = numFormat.ToString(); - } - }break; - } - if(!sFormat.empty()) - { - oWriter.WriteString(L""); - } - } - if(bRestart) - { - oWriter.WriteString(L""); - } - if(bPStyle) - { - std::wstring sStyleName = XmlUtils::EncodeXmlString(PStyle); - oWriter.WriteString(L""); - } - if(bIsLgl) - { - if(IsLgl) - oWriter.WriteString(L""); - else - oWriter.WriteString(L""); - } - if(bSuff) - { - std::wstring sSuff; - switch(Suff) - { - case numbering_suff_Nothing: sSuff = _T("nothing");break; - case numbering_suff_Space: sSuff = _T("space");break; - default: sSuff = _T("tab");break; - } - oWriter.WriteString(L""); - } - if(bText) - { - std::wstring sText; - for(int i = 0, length = (int)Text.size(); i < length; ++i) - { - docLvlText* item = Text[i]; - if(item->bText) - { - sText += (item->Text); - } - else if(item->bNumber) - { - sText += L"%" + std::to_wstring(item->Number+1); - } - } - sText = XmlUtils::EncodeXmlString(sText); - - //std::wstring sTextXml;sTextXml.Format(L"", sText); - - std::wstring sTextXml(L""); - - oWriter.WriteString(sTextXml); - } - if(bLvlLegacy) - { - oWriter.WriteString(L""); - } - if(!sJc.empty()) - { - oWriter.WriteString(sJc); - } - else if(bJc) - { - std::wstring sJcType; - switch(Jc) - { - case align_Right:sJcType = _T("right");break; - case align_Left:sJcType = _T("left");break; - case align_Center:sJcType = _T("center");break; - case align_Justify:sJcType = _T("distribute");break; - } - if(!sJcType.empty()) - { - oWriter.WriteString(L""); - } - } - if(bParaPr) - { - oWriter.Write(ParaPr); - } - if(bTextPr) - { - oWriter.Write(TextPr); - } - oWriter.WriteString(L""); - } + void Write(NSStringUtils::CStringBuilder& oWriter); }; class docLvlOverride { @@ -1200,38 +413,11 @@ public: bool bILvl; bool bStartOverride; - docLvlOverride() - { - bILvl = false; - bStartOverride = false; - Lvl = NULL; - } - ~docLvlOverride() - { - RELEASEOBJECT(Lvl); - } - void Write(NSStringUtils::CStringBuilder& oWriter) - { - oWriter.WriteString(L""); - if (bStartOverride) - { - oWriter.WriteString(L""); - } - if(NULL != Lvl) - { - Lvl->Write(oWriter); - } - oWriter.WriteString(L""); - } + + docLvlOverride(); + ~docLvlOverride(); + + void Write(NSStringUtils::CStringBuilder& oWriter); }; class docANum { @@ -1240,41 +426,12 @@ public: std::wstring NumStyleLink; std::wstring StyleLink; std::vector Lvls; - bool bId; - docANum() - { - bId = false; - } - ~docANum() - { - for(int i = 0, length = (int)Lvls.size(); i < length; i++) - { - delete Lvls[i]; - } - } - void Write(NSStringUtils::CStringBuilder& oWriterANum) - { - if(bId) - { - oWriterANum.WriteString(L""); - if(!StyleLink.empty()) - { - std::wstring sCorrectStyleLink = XmlUtils::EncodeXmlString(StyleLink); - oWriterANum.WriteString(L""); - } - if(!NumStyleLink.empty()) - { - std::wstring sCorrectNumStyleLink = XmlUtils::EncodeXmlString(NumStyleLink); - oWriterANum.WriteString(L""); - } - for(int i = 0, length = (int)Lvls.size(); i < length; ++i) - { - Lvls[i]->Write(oWriterANum); - } - oWriterANum.WriteString(L""); - } - } + + docANum(); + ~docANum(); + + void Write(NSStringUtils::CStringBuilder& oWriterANum); }; class docNum { @@ -1285,28 +442,11 @@ public: bool bAId; bool bId; - docNum() - { - bAId = false; - bId = false; - } - ~docNum() - { - for(size_t i = 0; i < LvlOverrides.size(); ++i){ - RELEASEOBJECT(LvlOverrides[i]); - } - } - void Write(NSStringUtils::CStringBuilder& oWriterNumList) - { - if(bAId && bId) - { - oWriterNumList.WriteString(L""); - for(size_t i = 0; i < LvlOverrides.size(); ++i){ - LvlOverrides[i]->Write(oWriterNumList); - } - oWriterNumList.WriteString(L""); - } - } + + docNum(); + ~docNum(); + + void Write(NSStringUtils::CStringBuilder& oWriterNumList); }; class rowPrAfterBefore { @@ -1315,20 +455,9 @@ public: long nGridAfter; docW oAfterWidth; bool bGridAfter; - rowPrAfterBefore(std::wstring name) - { - sName = name; - bGridAfter = false; - } - void Write(NSStringUtils::CStringBuilder& writer) - { - if(bGridAfter && nGridAfter > 0) - { - writer.WriteString(L""); - } - if(oAfterWidth.bW) - oAfterWidth.Write(writer, _T("w:w") + sName); - } + + rowPrAfterBefore(std::wstring name); + void Write(NSStringUtils::CStringBuilder& writer); }; class WriteHyperlink { @@ -1338,137 +467,27 @@ public: std::wstring anchor; std::wstring tooltip; NSStringUtils::CStringBuilder writer; - static WriteHyperlink* Parse(std::wstring fld) - { - WriteHyperlink* res = NULL; - if(-1 != fld.find(L"HYPERLINK")) - { - std::wstring sLink; - std::wstring sTooltip; - bool bNextLink = false; - bool bNextTooltip = false; - //разбиваем по пробелам, но с учетом кавычек - std::vector aItems; - std::wstring sCurItem; - bool bDQuot = false; - - for(int i = 0, length = (int)fld.length(); i < length; ++i) - { - wchar_t sCurLetter = fld[i]; - if('\"' == sCurLetter) - bDQuot = !bDQuot; - else if('\\' == sCurLetter && true == bDQuot && i + 1 < length && '\"' == fld[i + 1]) - { - i++; - sCurItem += fld[i]; - } - else if(' ' == sCurLetter && false == bDQuot) - { - if(sCurItem.length() > 0) - { - aItems.push_back(sCurItem); - sCurItem = _T(""); - } - } - else - sCurItem += sCurLetter; - } - if(sCurItem.length() > 0) - aItems.push_back(sCurItem); - - for(int i = 0, length = (int)aItems.size(); i < length; ++i) - { - std::wstring item = aItems[i]; - if(bNextLink) - { - bNextLink = false; - sLink = item; - } - if(bNextTooltip) - { - bNextTooltip = false; - sTooltip = item; - } - if(L"HYPERLINK" == item) - bNextLink = true; - else if(L"\\o" == item) - bNextTooltip = true; - } - if(false == sLink.empty()) - { - res = new WriteHyperlink(); - boost::algorithm::trim(sLink); - - int nAnchorIndex = (int)sLink.find(L"#"); - if(-1 != nAnchorIndex) - { - res->href = sLink.substr(0, nAnchorIndex); - res->anchor = sLink.substr(nAnchorIndex); - } - else - res->href = sLink; - if(false == sTooltip.empty()) - { - res->tooltip = boost::algorithm::trim_copy(sTooltip); - } - } - } - return res; - } - void Write(NSStringUtils::CStringBuilder& wr) - { - if(false == rId.empty()) - { - std::wstring sCorrect_rId = XmlUtils::EncodeXmlString(rId); - std::wstring sCorrect_tooltip = XmlUtils::EncodeXmlString(tooltip); - std::wstring sCorrect_anchor = XmlUtils::EncodeXmlString(anchor); - std::wstring sStart = L""; - wr.WriteString(sStart); - wr.Write(writer); - wr.WriteString(L""); - } - } + static WriteHyperlink* Parse(std::wstring fld); + void Write(NSStringUtils::CStringBuilder& wr); }; class IdCounter { private: int m_nId; + public: - IdCounter(int nStart = 0) - { - m_nId = nStart; - } - int getNextId(int nCount = 1) - { - int nRes = m_nId; - m_nId += nCount; - return nRes; - } - int getCurrentId() - { - return m_nId; - } + IdCounter(int nStart = 0); + + int getNextId(int nCount = 1); + int getCurrentId(); }; class CComment { private: IdCounter& m_oParaIdCounter; IdCounter& m_oFormatIdCounter; + public: void *pBinary_DocumentTableReader; @@ -1495,313 +514,50 @@ public: bool bIdFormat; bool bSolved; bool bDurableId; + public: - CComment(IdCounter& oParaIdCounter, IdCounter& oFormatIdCounter):m_oParaIdCounter(oParaIdCounter),m_oFormatIdCounter(oFormatIdCounter) - { - bIdOpen = false; - bIdFormat = false; - bSolved = false; - bDurableId = false; - } - ~CComment() - { - for(size_t i = 0; i bIdFormat = true; - pComment->IdFormat = (int)(IdFormatStart + i + 1); - } - } - std::wstring writeRef(const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter) - { - std::wstring sRes; - sRes += (writeRef(this, sBefore, sRef, sAfter)); - - for(size_t i = 0; i< replies.size(); ++i) - { - sRes += (writeRef(replies[i], sBefore, sRef, sAfter)); - } - return sRes; - } - static std::wstring writeRef(CComment* pComment, const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter) - { - std::wstring sRes; - if(!pComment->bIdFormat) - { - pComment->bIdFormat = true; - pComment->IdFormat = pComment->m_oFormatIdCounter.getNextId(); - } - sRes += (sBefore); - sRes += L"<" + sRef + L" w:id=\"" + std::to_wstring(pComment->IdFormat) + L"\"/>"; - sRes += (sAfter); - return sRes; - } - static void writeContentWritePart(CComment* pComment, std::wstring& sText, int nPrevIndex, int nCurIndex, std::wstring& sRes) - { - std::wstring sPart; - if(nPrevIndex < nCurIndex) - sPart = XmlUtils::EncodeXmlString(sText.substr(nPrevIndex, nCurIndex - nPrevIndex)); + CComment(IdCounter& oParaIdCounter, IdCounter& oFormatIdCounter); + ~CComment(); - int nId = pComment->m_oParaIdCounter.getNextId(); + int getCount(); - pComment->sParaId = XmlUtils::ToString(nId, L"%08X"); - sRes += L"sParaId + L"\" w14:textId=\"" + pComment->sParaId + L"\">"; - sRes += L""; - sRes += sPart; - sRes += L""; - } - static std::wstring writeContent(CComment* pComment) - { - std::wstring sRes; - if(!pComment->bIdFormat) - { - pComment->bIdFormat = true; - pComment->IdFormat = pComment->m_oFormatIdCounter.getNextId(); - } - sRes += L"IdFormat) + L"\""; - if(false == pComment->UserName.empty()) - { - std::wstring sUserName = XmlUtils::EncodeXmlString(pComment->UserName); - sRes += L" w:author=\""; - sRes += (sUserName); - sRes += L"\""; - } - if(false == pComment->Date.empty()) - { - std::wstring sDate = XmlUtils::EncodeXmlString(pComment->Date); - sRes += L" w:date=\""; - sRes += sDate; - sRes += L"\""; - } - if(false == pComment->Initials.empty()) - { - sRes += L" w:initials=\""; - sRes += XmlUtils::EncodeXmlString(pComment->Initials); - sRes += L"\""; - } - sRes += L">"; + void setFormatStart(int IdFormatStart); - if (false == pComment->sContent.empty()) - { - sRes += pComment->sContent; - } - else - { - //old comments - std::wstring sText = pComment->Text; + std::wstring writeRef(const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter); + static std::wstring writeRef(CComment* pComment, const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter); - XmlUtils::replace_all(sText, L"\r", L""); - - int nPrevIndex = 0; - for (int i = 0; i < (int)sText.length(); i++) - { - wchar_t cToken = sText[i]; - if('\n' == cToken) - { - writeContentWritePart(pComment, sText, nPrevIndex, i, sRes); - nPrevIndex = i + 1; - } - } - writeContentWritePart(pComment, sText, nPrevIndex, (int)sText.length(), sRes); - } - sRes += L""; - return sRes; - } - static std::wstring writeContentExt(CComment* pComment) - { - std::wstring sRes; - if(false == pComment->sParaId.empty()) - { - std::wstring sDone(L"0"); - if(pComment->bSolved && pComment->Solved) - sDone = _T("1"); - if(!pComment->sParaIdParent.empty()) - sRes += L"sParaId + L"\" \ -w15:paraIdParent=\"" + pComment->sParaIdParent + L"\" w15:done=\"" + sDone + L"\"/>"; - else - sRes += L"sParaId + L"\" w15:done=\"" + sDone + L"\"/>"; - //расставляем paraIdParent - for(size_t i = 0; i < pComment->replies.size(); i++) - pComment->replies[i]->sParaIdParent = pComment->sParaId; - } - return sRes; - } - static std::wstring writeContentExtensible(CComment* pComment) - { - std::wstring sRes; - if(pComment->bDurableId && !pComment->DateUtc.empty()) - { - sRes += L"DurableId, L"%08X") + L"\" w16cex:dateUtc=\"" + pComment->DateUtc + L"\"/>"; - } - return sRes; - } - static std::wstring writeContentUserData(CComment* pComment) - { - std::wstring sRes; - if(pComment->bDurableId && !pComment->UserData.empty()) - { - sRes += L"DurableId, L"%08X") + L"\">"; - sRes += L"UserData); - sRes += L"\" providerId=\"AD\"/>"; - } - return sRes; - } - static std::wstring writeContentsIds(CComment* pComment) - { - std::wstring sRes; - if(!pComment->sParaId.empty() && pComment->bDurableId) - { - sRes += L"sParaId + L"\" w16cid:durableId=\"" + XmlUtils::ToString(pComment->DurableId, L"%08X") + L"\"/>"; - } - return sRes; - } - static std::wstring writePeople(CComment* pComment) - { - std::wstring sRes; - if(false == pComment->UserName.empty()) - { - sRes += L"UserName); - sRes += L"\">"; - if(!pComment->ProviderId.empty() && !pComment->UserId.empty()) - { - sRes += L"ProviderId); - sRes += L"\" w15:userId=\""; - sRes += XmlUtils::EncodeXmlString(pComment->UserId); - sRes += L"\"/>"; - } - sRes += L""; - } - return sRes; - } + static void writeContentWritePart(CComment* pComment, std::wstring& sText, int nPrevIndex, int nCurIndex, std::wstring& sRes); + static std::wstring writeContent(CComment* pComment); + static std::wstring writeContentExt(CComment* pComment); + static std::wstring writeContentExtensible(CComment* pComment); + static std::wstring writeContentUserData(CComment* pComment); + static std::wstring writeContentsIds(CComment* pComment); + static std::wstring writePeople(CComment* pComment); }; class CComments { boost::unordered_map m_mapComments; boost::unordered_map m_mapAuthors; + public: IdCounter m_oFormatIdCounter; IdCounter m_oParaIdCounter; - CComments() : m_oParaIdCounter(1) - { - } - ~CComments() - { - for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - delete it->second; - } - m_mapComments.clear(); - } - void add(CComment* pComment) - { - if(pComment->bIdOpen) - { - m_mapComments[pComment->IdOpen] = pComment; - addAuthor(pComment); - for(size_t i = 0; i < pComment->replies.size(); i++) - addAuthor(pComment->replies[i]); - } - } - void addAuthor(CComment* pComment) - { - if(false == pComment->UserName.empty() && false == pComment->UserId.empty()) - m_mapAuthors[pComment->UserName] = pComment; - } - CComment* get(int nInd) - { - CComment* pRes = NULL; - boost::unordered_map::const_iterator pair = m_mapComments.find(nInd); - if(m_mapComments.end() != pair) - pRes = pair->second; - return pRes; - } - int getNextId(int nCount = 1) - { - return m_oFormatIdCounter.getNextId(nCount); - } - std::wstring writeContent() - { - std::wstring sRes; - for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - sRes += CComment::writeContent(it->second); - for(size_t i = 0; i < it->second->replies.size(); ++i) - sRes += CComment::writeContent(it->second->replies[i]); - } - return sRes; - } - std::wstring writeContentExt() - { - std::wstring sRes; - for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - sRes += CComment::writeContentExt(it->second); - for(size_t i = 0; i < it->second->replies.size(); ++i) - sRes += CComment::writeContentExt(it->second->replies[i]); - } - return sRes; - } - std::wstring writeContentExtensible() - { - std::wstring sRes; - for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - sRes += CComment::writeContentExtensible(it->second); - for(size_t i = 0; i < it->second->replies.size(); ++i) - sRes += CComment::writeContentExtensible(it->second->replies[i]); - } - return sRes; - } - std::wstring writeContentUserData() - { - std::wstring sRes; - for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - sRes += CComment::writeContentUserData(it->second); - for(size_t i = 0; i < it->second->replies.size(); ++i) - sRes += CComment::writeContentUserData(it->second->replies[i]); - } - return sRes; - } - std::wstring writeContentsIds() - { - std::wstring sRes; - for (boost::unordered_map::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - sRes += CComment::writeContentsIds(it->second); - for(size_t i = 0; i < it->second->replies.size(); ++i) - sRes += CComment::writeContentsIds(it->second->replies[i]); - } - return sRes; - } - std::wstring writePeople() - { - std::wstring sRes; - for (boost::unordered_map::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it) - { - sRes += (it->second->writePeople(it->second)); - } - return sRes; - } + CComments(); + ~CComments(); + + void add(CComment* pComment); + void addAuthor(CComment* pComment); + + CComment* get(int nInd); + int getNextId(int nCount = 1); + + std::wstring writeContent(); + std::wstring writeContentExt(); + std::wstring writeContentExtensible(); + std::wstring writeContentUserData(); + std::wstring writeContentsIds(); + std::wstring writePeople(); }; class CDrawingPropertyWrapPoint @@ -1812,11 +568,8 @@ public: bool bX; bool bY; - CDrawingPropertyWrapPoint() - { - bX = false; - bY = false; - } + + CDrawingPropertyWrapPoint(); }; class CDrawingPropertyWrap { @@ -1830,18 +583,8 @@ public: bool bEdited; bool bStart; - CDrawingPropertyWrap() - { - bWrappingType = false; - bEdited = false; - bStart = false; - } - ~CDrawingPropertyWrap() - { - for(size_t i = 0; i < Points.size(); ++i) - delete Points[i]; - Points.clear(); - } + CDrawingPropertyWrap(); + ~CDrawingPropertyWrap(); }; class CDrawingProperty { @@ -1917,339 +660,10 @@ public: bool bSimplePosY; bool bDrawingPropertyWrap; - CDrawingProperty(int nDocPr) - { - m_nDocPr = nDocPr; + CDrawingProperty(int nDocPr); - bObject = false; - nObjectType = 0; - nObjectId = 0; - bDataPos = false; - bDataLength = false; - bType = false; - bBehindDoc = false; - bDistL = false; - bDistT = false; - bDistR = false; - bDistB = false; - bLayoutInCell = false; - bRelativeHeight = false; - bBSimplePos = false; - bEffectExtentL = false; - bEffectExtentT = false; - bEffectExtentR = false; - bEffectExtentB = false; - bWidth = false; - bHeight = false; - bPositionHRelativeFrom = false; - bPositionHAlign = false; - bPositionHPosOffset = false; - bPositionHPctOffset = false; - bPositionVRelativeFrom = false; - bPositionVAlign = false; - bPositionVPosOffset = false; - bPositionVPctOffset = false; - bSimplePosX = false; - bSimplePosY = false; - bDrawingPropertyWrap = false; - } - bool IsGraphicFrameContent() - { - return false == sGraphicFrameContent.empty(); - } - std::wstring Write() - { - if(!bType) return L""; - - std::wstring sXml; - - bool bGraphicFrameContent = IsGraphicFrameContent(); - - if(c_oAscWrapStyle::Inline == Type) - { - if(bWidth && bHeight) - { - if (bGraphicFrameContent) - { - sXml += L"\ -"; - } - else - { - sXml += L""; - } - - if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) - { - sXml += L""; - } - - if(!sDocPr.empty()) - { - sXml += sDocPr; - } - else - { - sXml += L""; - } - if (!sGraphicFramePr.empty()) - { - sXml += sGraphicFramePr; - } - else - { - sXml += L""; - } - if (bGraphicFrameContent) - { - sXml += sGraphicFrameContent + L""; - } - else - { - sXml += L""; - } - } - } - else - { - if(bWidth && bHeight && ((bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset) - && bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset)) - || (bBSimplePos && bSimplePosX && bSimplePosY))) - { - __int64 emuDistL = 0; - __int64 emuDistT = 0; - __int64 emuDistR = 0; - __int64 emuDistB = 0; - - if(bDistL) - emuDistL = DistL; - if(bDistT) - emuDistT = DistT; - if(bDistR) - emuDistR = DistR; - if(bDistB) - emuDistB = DistB; - int nSimplePos = 0; - if(bBSimplePos && BSimplePos) - nSimplePos = 1; - unsigned long nRelativeHeight = 0; - if(bRelativeHeight) - nRelativeHeight = RelativeHeight; - int nBehindDoc = 0; - if(bBehindDoc && BehindDoc) - nBehindDoc = 1; - int nLayoutInCell = 1; - if(bLayoutInCell && false == LayoutInCell) - nLayoutInCell = 0; - - if (bGraphicFrameContent) - { - sXml += L""; - } - sXml += L""; - - __int64 emuX = 0; - if(bSimplePosX) - emuX = SimplePosX; - __int64 emuY = 0; - if(bSimplePosY) - emuY = SimplePosY; - sXml += L""; - - if (bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset)) - { - std::wstring sRelativeFrom; - switch(PositionHRelativeFrom) - { - case 0: sRelativeFrom = _T("character");break; - case 1: sRelativeFrom = _T("column");break; - case 2: sRelativeFrom = _T("insideMargin");break; - case 3: sRelativeFrom = _T("leftMargin");break; - case 4: sRelativeFrom = _T("margin");break; - case 5: sRelativeFrom = _T("outsideMargin");break; - case 6: sRelativeFrom = _T("page");break; - case 7: sRelativeFrom = _T("rightMargin");break; - } - std::wstring sContent; - if(bPositionHAlign) - { - switch(PositionHAlign) - { - case 0: sContent = _T("center"); break; - case 1: sContent = _T("inside"); break; - case 2: sContent = _T("left"); break; - case 3: sContent = _T("outside"); break; - case 4: sContent = _T("right"); break; - } - } - else if(bPositionHPosOffset) - { - sContent = L"" + std::to_wstring(PositionHPosOffset) + L""; - } - else if(bPositionHPctOffset) - { - long pctOffset = (long)(1000 * PositionHPctOffset); - sContent = L"" + std::to_wstring(pctOffset) + L""; - } - sXml += L"" + sContent + L""; - } - if (bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset)) - { - std::wstring sRelativeFrom; - switch(PositionVRelativeFrom) - { - case 0: sRelativeFrom = _T("bottomMargin");break; - case 1: sRelativeFrom = _T("insideMargin");break; - case 2: sRelativeFrom = _T("line");break; - case 3: sRelativeFrom = _T("margin");break; - case 4: sRelativeFrom = _T("outsideMargin");break; - case 5: sRelativeFrom = _T("page");break; - case 6: sRelativeFrom = _T("paragraph");break; - case 7: sRelativeFrom = _T("topMargin");break; - } - std::wstring sContent; - if (bPositionVAlign) - { - switch(PositionVAlign) - { - case 0: sContent = _T("bottom");break; - case 1: sContent = _T("center");break; - case 2: sContent = _T("inside");break; - case 3: sContent = _T("outside");break; - case 4: sContent = _T("top");break; - } - } - else if(bPositionVPosOffset) - { - sContent = L"" + std::to_wstring(PositionVPosOffset) + L""; - } - else if(bPositionVPctOffset) - { - long pctOffset = (long)(1000 * PositionVPctOffset); - sContent = L"" + std::to_wstring(pctOffset) + L""; - } - sXml += L"" + sContent + L""; - } - sXml += L""; - - if (bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) - { - sXml += L""; - } - if (bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType) - { - std::wstring sTagName; - switch(DrawingPropertyWrap.WrappingType) - { - case c_oSerImageType2::WrapNone:sTagName = _T("wrapNone"); break; - case c_oSerImageType2::WrapSquare:sTagName = _T("wrapSquare"); break; - case c_oSerImageType2::WrapThrough:sTagName = _T("wrapThrough"); break; - case c_oSerImageType2::WrapTight:sTagName = _T("wrapTight"); break; - case c_oSerImageType2::WrapTopAndBottom:sTagName = _T("wrapTopAndBottom"); break; - } - if(DrawingPropertyWrap.bStart || DrawingPropertyWrap.Points.size() > 0) - { - if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType || - c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType || - c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType) - { - sXml += L""; - } - else - sXml += L""; - - int nEdited = 0; - if(DrawingPropertyWrap.bEdited && DrawingPropertyWrap.Edited) - nEdited = 1; - sXml += L""; - - if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY) - { - sXml += L""; - } - - for(size_t i = 0; i < DrawingPropertyWrap.Points.size(); ++i) - { - CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i]; - if(pWrapPoint->bX && pWrapPoint->bY) - { - sXml += L"X) + L"\" y=\"" + std::to_wstring(pWrapPoint->Y) + L"\"/>"; - } - } - sXml += L""; - sXml += L""; - } - else - { - //для wrapThrough и wrapTight wrapPolygon обязательное поле, если его нет - меняем тип. - if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType || - c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType || - c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType) - { - sXml += L""; - } - else - sXml += L""; - } - } - else - sXml += L""; - - if(!sDocPr.empty()) - { - sXml += sDocPr; - } - else - { - sXml += L""; - } - if(!sGraphicFramePr.empty()) - { - sXml += sGraphicFramePr; - } - else - { - sXml += L""; - } - if (bGraphicFrameContent) - { - sXml += sGraphicFrameContent; - } - - if(!sSizeRelH.empty()) - { - sXml += sSizeRelH; - } - if(!sSizeRelV.empty()) - { - sXml += sSizeRelV; - } - - sXml += L""; - - if (bGraphicFrameContent) - sXml += L""; - } - } - return sXml; - } + bool IsGraphicFrameContent(); + std::wstring Write(); }; class CWiterTblPr { @@ -2271,59 +685,9 @@ public: std::wstring Caption; std::wstring Description; std::wstring Overlap; - bool IsEmpty() - { - return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty(); - } - std::wstring Write() - { - std::wstring sRes; - sRes += L""; - if(false == Style.empty()) - sRes += (Style); - if(false == tblpPr.empty()) - sRes += (tblpPr); - if(!RowBandSize.empty()) - sRes += (RowBandSize); - if(!ColBandSize.empty()) - sRes += (ColBandSize); - if (!Overlap.empty()) - sRes += (Overlap); - if(false == TableW.empty()) - sRes += (TableW); - if(false == Jc.empty()) - sRes += (Jc); - if(false == TableCellSpacing.empty()) - sRes += (TableCellSpacing); - if(false == TableInd.empty()) - sRes += (TableInd); - if(false == TableBorders.empty()) - sRes += (TableBorders); - if(false == Shd.empty()) - sRes += (Shd); - if(false == Layout.empty()) - sRes += (Layout); - if(false == TableCellMar.empty()) - sRes += (TableCellMar); - if(false == Look.empty()) - sRes += (Look); - if(!Caption.empty()) - { - sRes += L""; - } - if(!Description.empty()) - { - sRes += L""; - } - if(!tblPrChange.empty()) - sRes += (tblPrChange); - sRes += L""; - return sRes; - } + + bool IsEmpty(); + std::wstring Write(); }; class CFramePr { @@ -2357,154 +721,12 @@ public: BYTE XAlign; long Y; BYTE YAlign; -public: CFramePr() - { - bDropCap = false; - bH = false; - bHAnchor = false; - bHRule = false; - bHSpace = false; - bLines = false; - bVAnchor = false; - bVSpace = false; - bW = false; - bWrap = false; - bX = false; - bXAlign = false; - bY = false; - bYAlign = false; - } - bool IsEmpty() - { - return !(bDropCap || bH || bHAnchor || bHRule || bHSpace || bLines || bVAnchor || bVSpace || bW || bWrap || bX || bXAlign || bY || bYAlign); - } - void Write(NSStringUtils::CStringBuilder& oStringWriter) - { - oStringWriter.WriteString(L""); - } + +public: + CFramePr(); + + bool IsEmpty(); + void Write(NSStringUtils::CStringBuilder& oStringWriter); }; class CHyperlink{ public: @@ -2519,81 +741,21 @@ public: NSStringUtils::CStringBuilder writer; bool bHistory; + public: - CHyperlink() - { - bHistory = false; - } - void Write(NSStringUtils::CStringBuilder& wr) - { - wr.WriteString(L""); - wr.Write(writer); - wr.WriteString(L""); - } + CHyperlink(); + + void Write(NSStringUtils::CStringBuilder& wr); }; class CFldSimple{ public: std::wstring sInstr; NSStringUtils::CStringBuilder writer; + public: - CFldSimple() - { - } - void Write(NSStringUtils::CStringBuilder& wr) - { - if(false == sInstr.empty()) - { - std::wstring sCorrect_Instr = XmlUtils::EncodeXmlString(sInstr); - std::wstring sStart(L""; - wr.WriteString(sStart); - wr.Write(writer); - wr.WriteString(L""); - } - } + CFldSimple(); + + void Write(NSStringUtils::CStringBuilder& wr); }; class TrackRevision @@ -2616,18 +778,12 @@ public: NSStringUtils::CStringBuilder* tcPr; NSStringUtils::CStringBuilder* content; NSStringUtils::CStringBuilder* contentRun; + TrackRevision(); ~TrackRevision(); - bool IsNoEmpty() - { - return !Author.empty() || !Date.empty() || NULL != Id; - } - std::wstring ToString(std::wstring sName) - { - NSStringUtils::CStringBuilder writer; - Write(&writer, sName); - return writer.GetData(); - } + + bool IsNoEmpty(); + std::wstring ToString(std::wstring sName); void Write(NSStringUtils::CStringBuilder* pCStringWriter, std::wstring sName); }; } diff --git a/OOXML/Binary/Document/BinReader/Readers.h b/OOXML/Binary/Document/BinReader/Readers.h index a4406cee87..dc2d2ae276 100644 --- a/OOXML/Binary/Document/BinReader/Readers.h +++ b/OOXML/Binary/Document/BinReader/Readers.h @@ -507,8 +507,8 @@ private: bool m_bMacro = false; bool m_bMacroRead = false; public: - BinaryFileReader(std::wstring& sFileInDir, NSBinPptxRW::CBinaryFileReader& oBufferedStream, Writers::FileWriter& oFileWriter, bool bMacro = false); - int ReadFile(); - int ReadMainTable(); + BinaryFileReader(std::wstring& sFileInDir, NSBinPptxRW::CBinaryFileReader& oBufferedStream, Writers::FileWriter& oFileWriter, bool bMacro = false); + int ReadFile(); + int ReadMainTable(); }; } diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.cpp b/OOXML/Binary/Document/BinWriter/BinWriters.cpp index 5bdb1104f2..ca00117515 100644 --- a/OOXML/Binary/Document/BinWriter/BinWriters.cpp +++ b/OOXML/Binary/Document/BinWriter/BinWriters.cpp @@ -64,6 +64,25 @@ namespace BinDocxRW { +ParamsWriter::ParamsWriter(NSBinPptxRW::CBinaryFileWriter* pCBufferedStream, DocWrapper::FontProcessor* pFontProcessor, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager) + : + m_pCBufferedStream(pCBufferedStream), + m_pFontProcessor(pFontProcessor), + m_pOfficeDrawingConverter(pOfficeDrawingConverter), + m_pEmbeddedFontsManager(pEmbeddedFontsManager) +{ + m_pMain = NULL; + m_pSettings = NULL; + m_pTheme = NULL; + m_pCurRels = NULL; + m_pStyles = NULL; + m_pNumbering = NULL; + + m_pEmbeddedStyles = NULL; + m_pEmbeddedNumbering = NULL; + + m_bLocalStyles = m_bLocalNumbering = false; +} std::wstring ParamsWriter::AddEmbeddedStyle(const std::wstring & sStyleId) { if (!m_pEmbeddedStyles) return L""; @@ -92,6 +111,7 @@ std::wstring ParamsWriter::AddEmbeddedStyle(const std::wstring & sStyleId) } return sNewStyleId; } + BinaryCommonWriter::BinaryCommonWriter(ParamsWriter& oParamsWriter) : m_oStream(*oParamsWriter.m_pCBufferedStream), m_pEmbeddedFontsManager(oParamsWriter.m_pEmbeddedFontsManager) { diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.h b/OOXML/Binary/Document/BinWriter/BinWriters.h index 4eb0fd3f75..67eeac858d 100644 --- a/OOXML/Binary/Document/BinWriter/BinWriters.h +++ b/OOXML/Binary/Document/BinWriter/BinWriters.h @@ -99,25 +99,11 @@ namespace BinDocxRW OOX::IFileContainer* m_pCurRels; std::map m_mapIgnoreComments; - ParamsWriter(NSBinPptxRW::CBinaryFileWriter* pCBufferedStream, DocWrapper::FontProcessor* pFontProcessor, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager) - : - m_pCBufferedStream(pCBufferedStream), - m_pFontProcessor(pFontProcessor), - m_pOfficeDrawingConverter(pOfficeDrawingConverter), - m_pEmbeddedFontsManager(pEmbeddedFontsManager) - { - m_pMain = NULL; - m_pSettings = NULL; - m_pTheme = NULL; - m_pCurRels = NULL; - m_pStyles = NULL; - m_pNumbering = NULL; + ParamsWriter(NSBinPptxRW::CBinaryFileWriter* pCBufferedStream, + DocWrapper::FontProcessor* pFontProcessor, + NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, + NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager); - m_pEmbeddedStyles = NULL; - m_pEmbeddedNumbering = NULL; - - m_bLocalStyles = m_bLocalNumbering = false; - } std::wstring AddEmbeddedStyle(const std::wstring & styleId); }; class ParamsDocumentWriter diff --git a/OOXML/Binary/Sheets/Common/Common.cpp b/OOXML/Binary/Sheets/Common/Common.cpp index 94fea119a9..fc76e10a96 100644 --- a/OOXML/Binary/Sheets/Common/Common.cpp +++ b/OOXML/Binary/Sheets/Common/Common.cpp @@ -160,4 +160,16 @@ namespace SerializeCommon return; } + + CommentData::CommentData() + { + bSolved = false; + bDocument = false; + } + CommentData::~CommentData() + { + for(size_t i = 0, length = aReplies.size(); i < length; ++i) + delete aReplies[i]; + aReplies.clear(); + } } diff --git a/OOXML/Binary/Sheets/Common/Common.h b/OOXML/Binary/Sheets/Common/Common.h index b62a132bd5..2ac585e242 100644 --- a/OOXML/Binary/Sheets/Common/Common.h +++ b/OOXML/Binary/Sheets/Common/Common.h @@ -47,6 +47,7 @@ namespace SerializeCommon VOID convertBase64ToImage (NSFile::CFileBinary& oFile, std::wstring &pBase64); long Round(double val); std::wstring changeExtention(const std::wstring& sSourcePath, const std::wstring& sTargetExt); + class CommentData { public : @@ -64,18 +65,11 @@ namespace SerializeCommon bool bSolved; bool bDocument; std::vector aReplies; - CommentData() - { - bSolved = false; - bDocument = false; - } - ~CommentData() - { - for(size_t i = 0, length = aReplies.size(); i < length; ++i) - delete aReplies[i]; - aReplies.clear(); - } + + CommentData(); + ~CommentData(); }; + void ReadFileType(const std::wstring& sXMLOptions, BYTE& result, UINT& nCodePage, std::wstring& wcDelimiter, BYTE& saveFileType); }