Commit 8cdf4911 authored by ElenaSubbotina's avatar ElenaSubbotina

DocxBin - add background document

parent c5c64cb6
......@@ -53,13 +53,22 @@ namespace Writers
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
oFile.WriteStringUTF8(CString(_T("</w:body><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">")));
oFile.WriteStringUTF8(m_oBackground.GetData());
oFile.WriteStringUTF8(CString(_T("<w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body>")));
oFile.WriteStringUTF8(CString(_T("</w:document>")));
oFile.CloseFile();
}
CString WriteSectPrHdrFtr()
......
......@@ -39,7 +39,8 @@ namespace Writers
class ContentWriter
{
public:
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oBackground;
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oSecPr;
};
class HdrFtrItem
......
......@@ -265,19 +265,64 @@ public:
bBeforeAuto = false;
}
};
class Background
{
public:
docRGB Color;
CThemeColor ThemeColor;
CString sObject;
bool bColor;
bool bThemeColor;
Background() : bColor (false), bThemeColor(false) {}
CString Write()
{
CString sBackground = L"<w:background";
if(bColor)
{
sBackground += L" w:color=\"" + Color.ToString() + L"\"";
}
if(bThemeColor && ThemeColor.IsNoEmpty())
{
if(ThemeColor.bColor)
sBackground += L" w:themeColor=\"" + ThemeColor.ToStringColor() + L"\"";
if(ThemeColor.bTint)
sBackground += L" w:themeColorTint=\"" + ThemeColor.ToStringTint() + L"\"";
if(ThemeColor.bShade)
sBackground += L" w:themeColorShade=\"" + ThemeColor.ToStringShade() + L"\"";
}
if (!bColor && !bThemeColor)
{
sBackground += L" w:color=\"ffffff\"";
}
sBackground += L">";
sBackground += sObject;
sBackground += L"</w:background>";
return sBackground;
}
};
class Shd
{
public:
BYTE Value;
docRGB Color;
BYTE Value;
docRGB Color;
CThemeColor ThemeColor;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bColor = false;
Value = shd_Nil;
bColor = false;
bThemeColor = false;
}
CString ToString()
......
This diff is collapsed.
......@@ -152,7 +152,8 @@ extern int g_nCurFormatVersion;
Comments = 8,
Settings = 9,
Footnotes = 10,
Endnotes = 11
Endnotes = 11,
Background
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
......@@ -446,20 +447,21 @@ extern int g_nCurFormatVersion;
};}
namespace c_oSerParType{enum c_oSerParType
{
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9,
Hyperlink = 10,
FldSimple = 11,
Del = 12,
Ins = 13
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9,
Hyperlink = 10,
FldSimple = 11,
Del = 12,
Ins = 13,
Background = 14
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
......@@ -506,6 +508,12 @@ extern int g_nCurFormatVersion;
endnoteReference = 27,
arPr = 28
};}
namespace c_oSerBackgroundType{enum c_oSerBackgroundType
{
Color = 0,
ColorTheme = 1,
pptxDrawing = 2
};}
namespace c_oSerImageType{enum c_oSerImageType
{
MediaId = 0,
......
This diff is collapsed.
......@@ -47,6 +47,12 @@
#include "../source/Oox2OdfConverter/Oox2OdfConverter.h"
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
std::wstring DetectTypeDocument(const std::wstring & pathOOX)
{
std::wstring sRes;
......
......@@ -373,6 +373,18 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
......
......@@ -75,14 +75,14 @@ namespace OOX
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("w:color"), m_oColor );
oNode.ReadAttributeBase( _T("w:themeColor"), m_oThemeColor );
oNode.ReadAttributeBase( _T("w:themeShade"), m_oThemeShade );
oNode.ReadAttributeBase( _T("w:themeTint"), m_oThemeTint );
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
......@@ -96,9 +96,11 @@ namespace OOX
if ( _T("w:drawing") == sName )
m_oDrawing = oReader;
else if ( _T("v:background") == sName )
m_oBackground = oReader;
}
}
virtual CString toXML() const
virtual CString toXML() const
{
CString sResult = _T("<w:background ");
......@@ -136,6 +138,11 @@ namespace OOX
sResult += m_oDrawing->toXML();
sResult += _T("</w:background>");
}
else if (m_oBackground.IsInit())
{//наличие атрибута Color обязательно
sResult += m_oBackground->toXML();
sResult += _T("</w:background>");
}
else
sResult += _T("/>");
......@@ -165,13 +172,14 @@ namespace OOX
public:
// Attributes
nullable<SimpleTypes::CHexColor<> > m_oColor;
nullable<SimpleTypes::CThemeColor<> > m_oThemeColor;
nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeShade;
nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeTint;
nullable<SimpleTypes::CHexColor<> > m_oColor;
nullable<SimpleTypes::CThemeColor<> > m_oThemeColor;
nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeShade;
nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeTint;
// Childs
nullable<OOX::Logic::CDrawing > m_oDrawing;
nullable<OOX::Logic::CDrawing > m_oDrawing;
nullable<OOX::Vml::CBackground> m_oBackground;
};
}
}
......
......@@ -103,8 +103,8 @@ namespace OOX
std::wstring wsName = oReader.GetName();
while( !wsName.empty() )
{
if ( _T("w:element") == wsName ) m_sElement = oReader.GetText();
else if ( _T("w:uri") == wsName ) m_sUri = oReader.GetText();
if ( _T("w:element") == wsName ) m_sElement = oReader.GetText();
else if ( _T("w:uri") == wsName ) m_sUri = oReader.GetText();
if ( !oReader.MoveToNextAttribute() )
break;
......
......@@ -1327,7 +1327,7 @@ namespace BinXlsxRW {
{
OOX::Spreadsheet::CRun* pRun = static_cast<OOX::Spreadsheet::CRun*>(we);
nCurPos = m_oBcw.WriteItemStart(c_oSerSharedStringTypes::Run);
WriteRun(*pRun, pIndexedColors, pTheme, oFontProcessor);
WriteRun(*pRun, pIndexedColors, pTheme, oFontProcessor);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
else if(OOX::Spreadsheet::et_t == we->getType())
......@@ -1344,7 +1344,7 @@ namespace BinXlsxRW {
void WriteRun(OOX::Spreadsheet::CRun& run, OOX::Spreadsheet::CIndexedColors* pIndexedColors, OOX::CTheme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos;
//rPr
//rPr
if(run.m_oRPr.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerSharedStringTypes::RPr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment