mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
docx cpp
+Math, +Media, +Settings
This commit is contained in:
@ -43,85 +43,26 @@ namespace OOX
|
||||
class CMathArgNodes : public WritingElementWithChilds<>
|
||||
{
|
||||
public:
|
||||
CMathArgNodes(OOX::Document *pMain = NULL) : WritingElementWithChilds<>(pMain)
|
||||
{
|
||||
m_eType = et_Unknown;
|
||||
}
|
||||
CMathArgNodes(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
fromXML( oNode );
|
||||
}
|
||||
CMathArgNodes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
fromXML( oReader );
|
||||
}
|
||||
CMathArgNodes(OOX::Document *pMain = NULL);
|
||||
CMathArgNodes(XmlUtils::CXmlNode &oNode);
|
||||
CMathArgNodes(XmlUtils::CXmlLiteReader& oReader);
|
||||
virtual ~CMathArgNodes();
|
||||
|
||||
const CMathArgNodes &operator =(const XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
ClearItems();
|
||||
fromXML( (XmlUtils::CXmlNode&)oNode );
|
||||
return *this;
|
||||
}
|
||||
const CMathArgNodes &operator =(const XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ClearItems();
|
||||
fromXML( (XmlUtils::CXmlLiteReader&)oReader );
|
||||
return *this;
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode);
|
||||
const CMathArgNodes &operator =(const XmlUtils::CXmlNode& oNode);
|
||||
const CMathArgNodes &operator =(const XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode);
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
std::wstring sNodeName = m_sNodeName;
|
||||
if (sNodeName.empty())
|
||||
sNodeName = GetMathNodeName(getType());
|
||||
|
||||
if (sNodeName.empty()) return L"";
|
||||
|
||||
std::wstring sResult = _T("<") + sNodeName + _T(">");
|
||||
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
if ( m_arrItems[i] )
|
||||
{
|
||||
sResult += m_arrItems[i]->toXML();
|
||||
}
|
||||
}
|
||||
|
||||
sResult += _T("</") + sNodeName + _T(">");
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
virtual std::wstring toXML() const;
|
||||
virtual EElementType getType() const;
|
||||
|
||||
EElementType m_eType;
|
||||
std::wstring m_sNodeName;
|
||||
|
||||
private:
|
||||
std::wstring GetMathNodeName(const EElementType & enumType) const
|
||||
{//todooo вытащить в одно место - пересекается с MathBottomNodes
|
||||
switch(enumType)
|
||||
{
|
||||
case OOX::et_m_deg: return L"m:deg";
|
||||
case OOX::et_m_den: return L"m:den";
|
||||
case OOX::et_m_e: return L"m:e";
|
||||
case OOX::et_m_fName: return L"m:fName";
|
||||
case OOX::et_m_lim: return L"m:lim";
|
||||
case OOX::et_m_num: return L"m:num";
|
||||
case OOX::et_m_oMath: return L"m:oMath";
|
||||
case OOX::et_m_sub: return L"m:sub";
|
||||
case OOX::et_m_sup: return L"m:sup";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
};
|
||||
std::wstring GetMathNodeName(const EElementType & enumType) const;
|
||||
};
|
||||
|
||||
}//namespace Logic
|
||||
}//namespace OOX
|
||||
|
||||
@ -38,10 +38,34 @@
|
||||
namespace OOX
|
||||
{
|
||||
namespace Logic
|
||||
{
|
||||
{
|
||||
CMathArgNodes::CMathArgNodes(OOX::Document *pMain) : WritingElementWithChilds<>(pMain)
|
||||
{
|
||||
m_eType = et_Unknown;
|
||||
}
|
||||
CMathArgNodes::CMathArgNodes(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
fromXML( oNode );
|
||||
}
|
||||
CMathArgNodes::CMathArgNodes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
fromXML( oReader );
|
||||
}
|
||||
CMathArgNodes::~CMathArgNodes()
|
||||
{
|
||||
}
|
||||
const CMathArgNodes& CMathArgNodes::operator =(const XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
ClearItems();
|
||||
fromXML( (XmlUtils::CXmlNode&)oNode );
|
||||
return *this;
|
||||
}
|
||||
const CMathArgNodes& CMathArgNodes::operator =(const XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ClearItems();
|
||||
fromXML( (XmlUtils::CXmlLiteReader&)oReader );
|
||||
return *this;
|
||||
}
|
||||
void CMathArgNodes::fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
m_sNodeName = oNode.GetName();
|
||||
@ -311,5 +335,50 @@ namespace OOX
|
||||
m_arrItems.push_back( pItem );
|
||||
}
|
||||
}
|
||||
std::wstring CMathArgNodes::toXML() const
|
||||
{
|
||||
std::wstring sNodeName = m_sNodeName;
|
||||
if (sNodeName.empty())
|
||||
sNodeName = GetMathNodeName(getType());
|
||||
|
||||
if (sNodeName.empty()) return L"";
|
||||
|
||||
std::wstring sResult = _T("<") + sNodeName + _T(">");
|
||||
|
||||
for ( size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
if ( m_arrItems[i] )
|
||||
{
|
||||
sResult += m_arrItems[i]->toXML();
|
||||
}
|
||||
}
|
||||
|
||||
sResult += _T("</") + sNodeName + _T(">");
|
||||
|
||||
return sResult;
|
||||
}
|
||||
EElementType CMathArgNodes::getType() const
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
std::wstring CMathArgNodes::GetMathNodeName(const EElementType & enumType) const
|
||||
{//todooo вытащить в одно место - пересекается с MathBottomNodes
|
||||
switch(enumType)
|
||||
{
|
||||
case OOX::et_m_deg: return L"m:deg";
|
||||
case OOX::et_m_den: return L"m:den";
|
||||
case OOX::et_m_e: return L"m:e";
|
||||
case OOX::et_m_fName: return L"m:fName";
|
||||
case OOX::et_m_lim: return L"m:lim";
|
||||
case OOX::et_m_num: return L"m:num";
|
||||
case OOX::et_m_oMath: return L"m:oMath";
|
||||
case OOX::et_m_sub: return L"m:sub";
|
||||
case OOX::et_m_sup: return L"m:sup";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
}//namespace Logic
|
||||
}//namespace OOX
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,9 @@ namespace OOX
|
||||
{
|
||||
namespace Logic
|
||||
{
|
||||
COMathPara::COMathPara(OOX::Document *pMain) : WritingElementWithChilds<WritingElement>(pMain)
|
||||
{
|
||||
}
|
||||
COMathPara::~COMathPara()
|
||||
{
|
||||
}
|
||||
@ -53,5 +56,58 @@ namespace OOX
|
||||
|
||||
return sResult;
|
||||
}
|
||||
void COMathPara::fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
XmlUtils::CXmlNodes oChilds;
|
||||
if ( oNode.GetNodes( _T("*"), oChilds ) )
|
||||
{
|
||||
XmlUtils::CXmlNode oItem;
|
||||
for ( int nIndex = 0; nIndex < oChilds.GetCount(); nIndex++ )
|
||||
{
|
||||
if ( oChilds.GetAt( nIndex, oItem ) )
|
||||
{
|
||||
std::wstring sName = oItem.GetName();
|
||||
WritingElement *pItem = NULL;
|
||||
|
||||
if ( _T("w:r") == sName )
|
||||
pItem = new CRun( oItem );
|
||||
else if ( _T("m:oMath") == sName )
|
||||
pItem = new COMath( oItem );
|
||||
else if ( _T("m:oMathParaPr") == sName )
|
||||
pItem = new COMathParaPr( oItem );
|
||||
|
||||
if ( pItem )
|
||||
m_arrItems.push_back( pItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void COMathPara::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
WritingElement *pItem = NULL;
|
||||
|
||||
if ( _T("m:oMath") == sName )
|
||||
pItem = new COMath( oReader );
|
||||
else if ( _T("m:oMathParaPr") == sName )
|
||||
pItem = new COMathParaPr( oReader );
|
||||
else if ( _T("w:r") == sName )
|
||||
pItem = new CRun( oReader );
|
||||
|
||||
if ( pItem )
|
||||
m_arrItems.push_back( pItem );
|
||||
|
||||
}
|
||||
}
|
||||
EElementType COMathPara::getType() const
|
||||
{
|
||||
return et_m_oMathPara;
|
||||
}
|
||||
}//namespace Logic
|
||||
}//namespace OOX
|
||||
|
||||
@ -46,67 +46,16 @@ namespace OOX
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(COMathPara)
|
||||
COMathPara(OOX::Document *pMain = NULL) : WritingElementWithChilds<WritingElement>(pMain)
|
||||
{
|
||||
}
|
||||
|
||||
COMathPara(OOX::Document *pMain = NULL);
|
||||
virtual ~COMathPara();
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
XmlUtils::CXmlNodes oChilds;
|
||||
if ( oNode.GetNodes( _T("*"), oChilds ) )
|
||||
{
|
||||
XmlUtils::CXmlNode oItem;
|
||||
for ( int nIndex = 0; nIndex < oChilds.GetCount(); nIndex++ )
|
||||
{
|
||||
if ( oChilds.GetAt( nIndex, oItem ) )
|
||||
{
|
||||
std::wstring sName = oItem.GetName();
|
||||
WritingElement *pItem = NULL;
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode);
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
if ( _T("w:r") == sName )
|
||||
pItem = new CRun( oItem );
|
||||
else if ( _T("m:oMath") == sName )
|
||||
pItem = new COMath( oItem );
|
||||
else if ( _T("m:oMathParaPr") == sName )
|
||||
pItem = new COMathParaPr( oItem );
|
||||
|
||||
if ( pItem )
|
||||
m_arrItems.push_back( pItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
WritingElement *pItem = NULL;
|
||||
|
||||
if ( _T("m:oMath") == sName )
|
||||
pItem = new COMath( oReader );
|
||||
else if ( _T("m:oMathParaPr") == sName )
|
||||
pItem = new COMathParaPr( oReader );
|
||||
else if ( _T("w:r") == sName )
|
||||
pItem = new CRun( oReader );
|
||||
|
||||
if ( pItem )
|
||||
m_arrItems.push_back( pItem );
|
||||
|
||||
}
|
||||
}
|
||||
virtual std::wstring toXML() const;
|
||||
|
||||
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_m_oMathPara;
|
||||
}
|
||||
virtual EElementType getType() const;
|
||||
};
|
||||
|
||||
}//namespace Logic
|
||||
}//namespace OOX
|
||||
}//namespace OOX
|
||||
|
||||
60
OOXML/DocxFormat/Media/Audio.cpp
Normal file
60
OOXML/DocxFormat/Media/Audio.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* (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 "Audio.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
Audio::Audio(OOX::Document* pMain, bool bDocument) : Media (pMain, bDocument)
|
||||
{
|
||||
}
|
||||
Audio::Audio(OOX::Document* pMain, const CPath& filename, bool bExternal) : Media(pMain, filename, bExternal)
|
||||
{
|
||||
}
|
||||
Audio::~Audio()
|
||||
{
|
||||
}
|
||||
const FileType Audio::type() const
|
||||
{
|
||||
return FileTypes::Audio;
|
||||
}
|
||||
const CPath Audio::DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
const CPath Audio::DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
|
||||
} // namespace OOX
|
||||
@ -40,29 +40,15 @@ namespace OOX
|
||||
class Audio : public Media
|
||||
{
|
||||
public:
|
||||
Audio(OOX::Document* pMain, bool bDocument = true) : Media (pMain, bDocument)
|
||||
{
|
||||
}
|
||||
Audio(OOX::Document* pMain, const CPath& filename, bool bExternal = false) : Media(pMain, filename, bExternal)
|
||||
{
|
||||
}
|
||||
virtual ~Audio()
|
||||
{
|
||||
}
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return FileTypes::Audio;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
Audio(OOX::Document* pMain, bool bDocument = true);
|
||||
Audio(OOX::Document* pMain, const CPath& filename, bool bExternal = false);
|
||||
virtual ~Audio();
|
||||
|
||||
virtual const FileType type() const;
|
||||
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
};
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_AUDIO_INCLUDE_H_
|
||||
#endif // OOX_AUDIO_INCLUDE_H_
|
||||
|
||||
59
OOXML/DocxFormat/Media/Image.cpp
Normal file
59
OOXML/DocxFormat/Media/Image.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* (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 "Image.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
Image::Image(OOX::Document* pMain, bool bDocument) : Media (pMain, bDocument)
|
||||
{
|
||||
}
|
||||
Image::Image(OOX::Document* pMain, const CPath& filename, bool bExternal) : Media(pMain, filename, bExternal)
|
||||
{
|
||||
}
|
||||
Image::~Image()
|
||||
{
|
||||
}
|
||||
const FileType Image::type() const
|
||||
{
|
||||
return FileTypes::Image;
|
||||
}
|
||||
const CPath Image::DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
const CPath Image::DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
} // namespace OOX
|
||||
@ -30,6 +30,7 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Media.h"
|
||||
|
||||
namespace OOX
|
||||
@ -37,27 +38,13 @@ namespace OOX
|
||||
class Image : public Media
|
||||
{
|
||||
public:
|
||||
Image(OOX::Document* pMain, bool bDocument = true) : Media (pMain, bDocument)
|
||||
{
|
||||
}
|
||||
Image(OOX::Document* pMain, const CPath& filename, bool bExternal = false) : Media(pMain, filename, bExternal)
|
||||
{
|
||||
}
|
||||
virtual ~Image()
|
||||
{
|
||||
}
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return FileTypes::Image;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
Image(OOX::Document* pMain, bool bDocument = true);
|
||||
Image(OOX::Document* pMain, const CPath& filename, bool bExternal = false);
|
||||
virtual ~Image();
|
||||
|
||||
virtual const FileType type() const;
|
||||
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
};
|
||||
} // namespace OOX
|
||||
|
||||
@ -78,6 +78,22 @@ namespace OOX
|
||||
read(filename);
|
||||
}
|
||||
|
||||
JsaProject::~JsaProject()
|
||||
{
|
||||
}
|
||||
const FileType JsaProject::type() const
|
||||
{
|
||||
return FileTypes::JsaProject;
|
||||
}
|
||||
const CPath JsaProject::DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
const CPath JsaProject::DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
|
||||
void JsaProject::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
|
||||
@ -44,21 +44,13 @@ namespace OOX
|
||||
public:
|
||||
JsaProject( OOX::Document *pMain );
|
||||
JsaProject(OOX::Document *pMain, const CPath& filename);
|
||||
virtual ~JsaProject()
|
||||
{
|
||||
}
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return FileTypes::JsaProject;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
virtual ~JsaProject();
|
||||
|
||||
virtual const FileType type() const;
|
||||
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
};
|
||||
|
||||
@ -49,6 +49,34 @@ namespace OOX
|
||||
|
||||
read(filename);
|
||||
}
|
||||
Media::~Media()
|
||||
{
|
||||
}
|
||||
const FileType Media::type() const
|
||||
{
|
||||
return FileTypes::Media;
|
||||
}
|
||||
bool Media::IsExist()
|
||||
{
|
||||
return m_bExist;
|
||||
}
|
||||
bool Media::IsExternal()
|
||||
{
|
||||
return m_bExternal;
|
||||
}
|
||||
CPath Media::filename()
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
const CPath Media::DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
const CPath Media::DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
void Media::read(const CPath& filename)
|
||||
{
|
||||
m_filename = filename;
|
||||
|
||||
@ -43,42 +43,26 @@ namespace OOX
|
||||
public:
|
||||
Media(OOX::Document *pMain, bool bDocument = true);
|
||||
Media(OOX::Document *pMain, const CPath& filename, bool bExternal = false);
|
||||
virtual ~Media()
|
||||
{
|
||||
}
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return FileTypes::Media;
|
||||
}
|
||||
virtual ~Media();
|
||||
|
||||
virtual const FileType type() const;
|
||||
|
||||
virtual void read(const CPath& filename);
|
||||
virtual void write(const CPath& filename, const CPath& directory, CContentTypes& content) const;
|
||||
|
||||
void set_filename(const std::wstring & file_path, bool bExternal);
|
||||
void set_filename(CPath & file_path, bool bExternal, bool bDefault = false);
|
||||
|
||||
bool IsExist()
|
||||
{
|
||||
return m_bExist;
|
||||
}
|
||||
bool IsExternal()
|
||||
{
|
||||
return m_bExternal;
|
||||
}
|
||||
CPath filename()
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
bool IsExist();
|
||||
bool IsExternal();
|
||||
CPath filename();
|
||||
|
||||
virtual void copy_to(const CPath& path) const;
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
|
||||
std::vector<BYTE> m_Data;
|
||||
|
||||
protected:
|
||||
CPath m_filename;
|
||||
bool m_bExist;
|
||||
|
||||
81
OOXML/DocxFormat/Media/OleObject.cpp
Normal file
81
OOXML/DocxFormat/Media/OleObject.cpp
Normal file
@ -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 "OleObject.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
OleObject::OleObject(OOX::Document *pMain, bool bMsPackage, bool bDocument) : Media (pMain, bDocument)
|
||||
{
|
||||
m_bMsPackage = bMsPackage;
|
||||
}
|
||||
OleObject::OleObject(OOX::Document *pMain, const OOX::CPath& filename, bool bMsPackage) : Media (pMain)
|
||||
{
|
||||
m_bMsPackage = bMsPackage;
|
||||
read(filename);
|
||||
}
|
||||
const FileType OleObject::type() const
|
||||
{
|
||||
if (m_bMsPackage) return OOX::FileTypes::MicrosoftOfficeUnknown;
|
||||
else return OOX::FileTypes::OleObject;
|
||||
}
|
||||
const CPath OleObject::DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
const CPath OleObject::DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
void OleObject::set_filename_cache(const std::wstring & file_path)
|
||||
{
|
||||
m_filenameCache = file_path;
|
||||
}
|
||||
void OleObject::set_filename_cache(CPath & file_path)
|
||||
{
|
||||
m_filenameCache = file_path;
|
||||
}
|
||||
void OleObject::set_MsPackage(bool val)
|
||||
{
|
||||
m_bMsPackage = val;
|
||||
}
|
||||
CPath OleObject::filename_cache()
|
||||
{
|
||||
return m_filenameCache;
|
||||
}
|
||||
bool OleObject::isMsPackage()
|
||||
{
|
||||
return m_bMsPackage;
|
||||
}
|
||||
|
||||
} // namespace OOX
|
||||
@ -41,46 +41,21 @@ namespace OOX
|
||||
class OleObject : public Media
|
||||
{
|
||||
public:
|
||||
OleObject(OOX::Document *pMain, bool bMsPackage = false, bool bDocument = true) : Media (pMain, bDocument)
|
||||
{
|
||||
m_bMsPackage = bMsPackage;
|
||||
}
|
||||
OleObject(OOX::Document *pMain, const OOX::CPath& filename, bool bMsPackage = false) : Media (pMain)
|
||||
{
|
||||
m_bMsPackage = bMsPackage;
|
||||
read(filename);
|
||||
}
|
||||
virtual const FileType type() const
|
||||
{
|
||||
if (m_bMsPackage) return OOX::FileTypes::MicrosoftOfficeUnknown;
|
||||
else return OOX::FileTypes::OleObject;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
void set_filename_cache(const std::wstring & file_path)
|
||||
{
|
||||
m_filenameCache = file_path;
|
||||
}
|
||||
void set_filename_cache(CPath & file_path)
|
||||
{
|
||||
m_filenameCache = file_path;
|
||||
}
|
||||
void set_MsPackage(bool val)
|
||||
{
|
||||
m_bMsPackage = val;
|
||||
}
|
||||
CPath filename_cache()
|
||||
{
|
||||
return m_filenameCache;
|
||||
}
|
||||
bool isMsPackage() {return m_bMsPackage;}
|
||||
OleObject(OOX::Document *pMain, bool bMsPackage = false, bool bDocument = true);
|
||||
OleObject(OOX::Document *pMain, const OOX::CPath& filename, bool bMsPackage = false);
|
||||
|
||||
virtual const FileType type() const;
|
||||
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
|
||||
void set_filename_cache(const std::wstring & file_path);
|
||||
void set_filename_cache(CPath & file_path);
|
||||
void set_MsPackage(bool val);
|
||||
|
||||
CPath filename_cache();
|
||||
bool isMsPackage();
|
||||
|
||||
protected:
|
||||
CPath m_filenameCache; //image
|
||||
bool m_bMsPackage;
|
||||
|
||||
59
OOXML/DocxFormat/Media/Video.cpp
Normal file
59
OOXML/DocxFormat/Media/Video.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* (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 "Video.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
Video::Video(OOX::Document* pMain, bool bDocument) : Media (pMain, bDocument)
|
||||
{
|
||||
}
|
||||
Video::Video(OOX::Document* pMain, const CPath& filename, bool bExternal) : Media(pMain, filename, bExternal)
|
||||
{
|
||||
}
|
||||
Video::~Video()
|
||||
{
|
||||
}
|
||||
const FileType Video::type() const
|
||||
{
|
||||
return FileTypes::Video;
|
||||
}
|
||||
const CPath Video::DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
const CPath Video::DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
} // namespace OOX
|
||||
@ -41,29 +41,15 @@ namespace OOX
|
||||
class Video : public Media
|
||||
{
|
||||
public:
|
||||
Video(OOX::Document* pMain, bool bDocument = true) : Media (pMain, bDocument)
|
||||
{
|
||||
}
|
||||
Video(OOX::Document* pMain, const CPath& filename, bool bExternal = false) : Media(pMain, filename, bExternal)
|
||||
{
|
||||
}
|
||||
virtual ~Video()
|
||||
{
|
||||
}
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return FileTypes::Video;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
if (m_bDocument) return type().DefaultDirectory();
|
||||
else return L"../" + type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return m_filename.GetFilename();
|
||||
}
|
||||
Video(OOX::Document* pMain, bool bDocument = true);
|
||||
Video(OOX::Document* pMain, const CPath& filename, bool bExternal = false);
|
||||
virtual ~Video();
|
||||
|
||||
virtual const FileType type() const;
|
||||
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
};
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_VIDEO_INCLUDE_H_
|
||||
#endif // OOX_VIDEO_INCLUDE_H_
|
||||
|
||||
@ -63,6 +63,7 @@ namespace OOX
|
||||
}
|
||||
private:
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
public:
|
||||
nullable_string m_sAppName;
|
||||
nullable_bool m_oCheckSyle;
|
||||
@ -71,6 +72,7 @@ namespace OOX
|
||||
nullable_bool m_oNlCheck;
|
||||
nullable_string m_sVendorID;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// CAutoCaption 17.15.1.7 (Part 1)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
154
OOXML/DocxFormat/Settings/WebSettings.cpp
Normal file
154
OOXML/DocxFormat/Settings/WebSettings.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* (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 "WebSettings.h"
|
||||
|
||||
namespace ComplexTypes
|
||||
{
|
||||
namespace Word
|
||||
{
|
||||
//--------------------------------------------------------------------------------
|
||||
// OptimizeForBrowser 17.15.2.34 (Part 1)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
COptimizeForBrowser::COptimizeForBrowser()
|
||||
{
|
||||
}
|
||||
COptimizeForBrowser::~COptimizeForBrowser()
|
||||
{
|
||||
}
|
||||
void COptimizeForBrowser::FromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
XmlMacroReadAttributeBase( oNode, _T("w:val"), m_oVal );
|
||||
XmlMacroReadAttributeBase( oNode, _T("w:target"), m_oTarget );
|
||||
}
|
||||
void COptimizeForBrowser::FromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
// Читаем атрибуты
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, _T("w:val"), m_oVal )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:target"), m_oTarget )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
std::wstring COptimizeForBrowser::ToString() const
|
||||
{
|
||||
std::wstring sResult;
|
||||
|
||||
ComplexTypes_WriteAttribute( _T("w:val=\""), m_oVal );
|
||||
ComplexTypes_WriteAttribute( _T("w:target=\""), m_oTarget );
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
} // Word
|
||||
} // ComplexTypes
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
// TO DO: Доделать данный класс
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// CWebSettings 17.11.15
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
CWebSettings::CWebSettings(OOX::Document *pMain) : OOX::File(pMain)
|
||||
{
|
||||
}
|
||||
CWebSettings::CWebSettings(OOX::Document *pMain, const CPath& oPath) : OOX::File(pMain)
|
||||
{
|
||||
read( oPath );
|
||||
}
|
||||
CWebSettings::~CWebSettings()
|
||||
{
|
||||
}
|
||||
void CWebSettings::read(const CPath& oFilePath)
|
||||
{
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
|
||||
if ( !oReader.FromFile( oFilePath.GetPath() ) )
|
||||
return;
|
||||
|
||||
if ( !oReader.ReadNextNode() )
|
||||
return;
|
||||
|
||||
std::wstring sName = oReader.GetName();
|
||||
if ( _T("w:webSettings") == sName && !oReader.IsEmptyNode() )
|
||||
{
|
||||
int nStylesDepth = oReader.GetDepth();
|
||||
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
|
||||
{
|
||||
sName = oReader.GetName();
|
||||
if ( _T("w:allowPNG") == sName )
|
||||
m_oAllowPNG = oReader;
|
||||
else if ( _T("w:optimizeForBrowser") == sName )
|
||||
m_oOptimizeForBrowser = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CWebSettings::write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
std::wstring sXml;
|
||||
sXml = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:webSettings xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" mc:Ignorable=\"w14 w15\">");
|
||||
|
||||
if ( m_oAllowPNG.IsInit() )
|
||||
{
|
||||
sXml += _T("<w:allowPNG ");
|
||||
sXml += m_oAllowPNG->ToString();
|
||||
sXml += _T("/>");
|
||||
}
|
||||
|
||||
if ( m_oOptimizeForBrowser.IsInit() )
|
||||
{
|
||||
sXml += _T("<w:optimizeForBrowser ");
|
||||
sXml += m_oOptimizeForBrowser->ToString();
|
||||
sXml += _T("/>");
|
||||
}
|
||||
|
||||
sXml += _T("</w:webSettings>");
|
||||
CDirectory::SaveToFile( oFilePath.GetPath(), sXml );
|
||||
|
||||
oContent.Registration( type().OverrideType(), oDirectory, oFilePath );
|
||||
}
|
||||
const OOX::FileType CWebSettings::type() const
|
||||
{
|
||||
return FileTypes::WebSetting;
|
||||
}
|
||||
const CPath CWebSettings::DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
const CPath CWebSettings::DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
|
||||
} // namespace OOX
|
||||
@ -44,42 +44,20 @@ namespace ComplexTypes
|
||||
//--------------------------------------------------------------------------------
|
||||
// OptimizeForBrowser 17.15.2.34 (Part 1)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class COptimizeForBrowser : public ComplexType
|
||||
{
|
||||
public:
|
||||
ComplexTypes_AdditionConstructors(COptimizeForBrowser)
|
||||
COptimizeForBrowser()
|
||||
{
|
||||
}
|
||||
virtual ~COptimizeForBrowser()
|
||||
{
|
||||
}
|
||||
COptimizeForBrowser();
|
||||
virtual ~COptimizeForBrowser();
|
||||
|
||||
virtual void FromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
XmlMacroReadAttributeBase( oNode, _T("w:val"), m_oVal );
|
||||
XmlMacroReadAttributeBase( oNode, _T("w:target"), m_oTarget );
|
||||
}
|
||||
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
// Читаем атрибуты
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, _T("w:val"), m_oVal )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("w:target"), m_oTarget )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
virtual std::wstring ToString() const
|
||||
{
|
||||
std::wstring sResult;
|
||||
virtual void FromXML(XmlUtils::CXmlNode& oNode);
|
||||
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
ComplexTypes_WriteAttribute( _T("w:val=\""), m_oVal );
|
||||
ComplexTypes_WriteAttribute( _T("w:target=\""), m_oTarget );
|
||||
|
||||
return sResult;
|
||||
}
|
||||
virtual std::wstring ToString() const;
|
||||
|
||||
public:
|
||||
|
||||
nullable<SimpleTypes::COptimizeForBrowserTarget> m_oTarget;
|
||||
nullable<SimpleTypes::COnOff > m_oVal;
|
||||
};
|
||||
@ -94,90 +72,29 @@ namespace OOX
|
||||
//--------------------------------------------------------------------------------
|
||||
// CWebSettings 17.11.15
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class CWebSettings : public OOX::File
|
||||
{
|
||||
public:
|
||||
CWebSettings(OOX::Document *pMain) : OOX::File(pMain)
|
||||
{
|
||||
}
|
||||
CWebSettings(OOX::Document *pMain, const CPath& oPath) : OOX::File(pMain)
|
||||
{
|
||||
read( oPath );
|
||||
}
|
||||
virtual ~CWebSettings()
|
||||
{
|
||||
}
|
||||
CWebSettings(OOX::Document *pMain);
|
||||
CWebSettings(OOX::Document *pMain, const CPath& oPath);
|
||||
virtual ~CWebSettings();
|
||||
|
||||
public:
|
||||
virtual void read(const CPath& oFilePath)
|
||||
{
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
|
||||
if ( !oReader.FromFile( oFilePath.GetPath() ) )
|
||||
return;
|
||||
|
||||
if ( !oReader.ReadNextNode() )
|
||||
return;
|
||||
|
||||
std::wstring sName = oReader.GetName();
|
||||
if ( _T("w:webSettings") == sName && !oReader.IsEmptyNode() )
|
||||
{
|
||||
int nStylesDepth = oReader.GetDepth();
|
||||
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
|
||||
{
|
||||
sName = oReader.GetName();
|
||||
if ( _T("w:allowPNG") == sName )
|
||||
m_oAllowPNG = oReader;
|
||||
else if ( _T("w:optimizeForBrowser") == sName )
|
||||
m_oOptimizeForBrowser = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
std::wstring sXml;
|
||||
sXml = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:webSettings xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" mc:Ignorable=\"w14 w15\">");
|
||||
|
||||
if ( m_oAllowPNG.IsInit() )
|
||||
{
|
||||
sXml += _T("<w:allowPNG ");
|
||||
sXml += m_oAllowPNG->ToString();
|
||||
sXml += _T("/>");
|
||||
}
|
||||
|
||||
if ( m_oOptimizeForBrowser.IsInit() )
|
||||
{
|
||||
sXml += _T("<w:optimizeForBrowser ");
|
||||
sXml += m_oOptimizeForBrowser->ToString();
|
||||
sXml += _T("/>");
|
||||
}
|
||||
|
||||
sXml += _T("</w:webSettings>");
|
||||
CDirectory::SaveToFile( oFilePath.GetPath(), sXml );
|
||||
|
||||
oContent.Registration( type().OverrideType(), oDirectory, oFilePath );
|
||||
}
|
||||
virtual void read(const CPath& oFilePath);
|
||||
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const;
|
||||
|
||||
public:
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return FileTypes::WebSetting;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
virtual const OOX::FileType type() const;
|
||||
virtual const CPath DefaultDirectory() const;
|
||||
virtual const CPath DefaultFileName() const;
|
||||
|
||||
public:
|
||||
|
||||
// Childs
|
||||
nullable<ComplexTypes::Word::COnOff2 > m_oAllowPNG;
|
||||
nullable<ComplexTypes::Word::COptimizeForBrowser > m_oOptimizeForBrowser;
|
||||
};
|
||||
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_WEBSETTING_INCLDUE_H_
|
||||
|
||||
Reference in New Issue
Block a user