Commit 2e8c83a6 authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormat, TxtFormat - chage convert from ooxml drawing

parent e8574965
...@@ -196,6 +196,8 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes() ...@@ -196,6 +196,8 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xml\" ContentType=\"application/xml\" />\ <Default Extension=\"xml\" ContentType=\"application/xml\" />\
<Default Extension=\"gif\" ContentType=\"image/gif\"/>\ <Default Extension=\"gif\" ContentType=\"image/gif\"/>\
<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\ <Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\
<Default Extension=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\
<Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\ <Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
<Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>"); <Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>");
...@@ -767,6 +769,7 @@ void NSPresentationEditor::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRe ...@@ -767,6 +769,7 @@ void NSPresentationEditor::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRe
void NSPresentationEditor::CPPTXWriter::WriteLayout(CLayout& oLayout, int nIndexLayout, int nStartLayout, int nIndexTheme) void NSPresentationEditor::CPPTXWriter::WriteLayout(CLayout& oLayout, int nIndexLayout, int nStartLayout, int nIndexTheme)
{ {
CStringWriter oWriter; CStringWriter oWriter;
CRelsGenerator oRels(&m_oManager); CRelsGenerator oRels(&m_oManager);
oRels.StartLayout(nIndexTheme); oRels.StartLayout(nIndexTheme);
......
...@@ -388,10 +388,6 @@ ...@@ -388,10 +388,6 @@
RelativePath="..\source\Reader\OOXPictureAnchorReader.h" RelativePath="..\source\Reader\OOXPictureAnchorReader.h"
> >
</File> </File>
<File
RelativePath="..\source\Reader\OOXPictureGraphicReader.h"
>
</File>
<File <File
RelativePath="..\source\Reader\OOXPictureInlineReader.h" RelativePath="..\source\Reader\OOXPictureInlineReader.h"
> >
......
...@@ -34,56 +34,52 @@ ...@@ -34,56 +34,52 @@
#include "OOXReader.h" #include "OOXReader.h"
#include "OOXReaderBasic.h" #include "OOXReaderBasic.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Drawing/DrawingStyles.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h"
class OOXColorReader class OOXColorReader
{ {
private:
PPTX::nsTheme::ClrScheme * m_ooxColorScheme;
public: public:
OOXColorReader() OOXColorReader()
{ {
m_ooxColorScheme = NULL;
} }
bool Parse( ReaderParameter oParam, OOX::Drawing::CStyleColor & ooxColor, RtfColor & oOutputColor ) OOXColorReader(PPTX::nsTheme::ClrScheme * ooxColorScheme)
{ {
if (ooxColor.getType() == OOX::Drawing::colorHsl) m_ooxColorScheme = ooxColorScheme;
{
double dHue, dSat, dLum;
ooxColor.m_oHslClr.GetHSL(dHue,dSat,dLum);
oOutputColor.SetHSL( dHue, dSat, dLum );
return true;
} }
else if(ooxColor.getType() == OOX::Drawing::colorPrst) bool Parse( ReaderParameter oParam, const std::wstring &name, RtfColor & oOutputColor )
{ {
oOutputColor = RtfColor(ooxColor.m_oPrstClr.m_oVal.Get_R(), ooxColor.m_oPrstClr.m_oVal.Get_G(), ooxColor.m_oPrstClr.m_oVal.Get_B()); if (!m_ooxColorScheme) return false;
return true;
} std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = m_ooxColorScheme->Scheme.find(name);
else if(ooxColor.getType() == OOX::Drawing::colorSheme)
if (pFind == m_ooxColorScheme->Scheme.end()) return false;
PPTX::Logic::UniColor & color = pFind->second;
switch(color.getType ())
{ {
RtfColor::_ThemeColor oTheme; case OOX::et_a_schemeClr:
if( true == RtfColor::GetThemeByOOX( ooxColor.m_oShemeClr.m_oVal.GetValue(), oTheme ))
return oParam.oRtf->m_oColorTable.GetColor( oTheme, oOutputColor );
return false;
}
else if( ooxColor.getType() == OOX::Drawing::colorSRgb)
{ {
oOutputColor = RtfColor(ooxColor.m_oSrgbClr.m_oVal.Get_R(), ooxColor.m_oSrgbClr.m_oVal.Get_G(), ooxColor.m_oSrgbClr.m_oVal.Get_B()); NSCommon::smart_ptr<PPTX::Logic::SchemeClr> schemeColor = color.Color.smart_dynamic_cast<PPTX::Logic::SchemeClr>();
return true; if (schemeColor.IsInit())
}
else if( ooxColor.getType() == OOX::Drawing::colorScRgb)
{ {
unsigned char r, g, b, a; RtfColor::_ThemeColor oTheme;
ooxColor.m_oScrgbClr.GetRGBA( r, g, b, a); if( true == RtfColor::GetThemeByOOX( (SimpleTypes::EShemeColorVal)schemeColor->val.GetBYTECode(), oTheme ))
oOutputColor = RtfColor(r, g, b); return oParam.oRtf->m_oColorTable.GetColor( oTheme, oOutputColor );
return true;
} }
else if( ooxColor.getType() == OOX::Drawing::colorSys) }break;
case OOX::et_a_prstClr:
case OOX::et_a_scrgbClr:
case OOX::et_a_srgbClr:
case OOX::et_a_sysClr:
default:
{ {
//if (ooxColor.m_oSysClr.m_oLastClr) DWORD rgba = color.GetRGBA();
//{ oOutputColor.SetRGB(rgba >> 8);
//}
unsigned char r, g, b, a;
ooxColor.m_oSysClr.GetRGBA( r, g, b, a);
oOutputColor = RtfColor(r, g, b);
return true; return true;
}break;
} }
return false; return false;
} }
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
class OOXColorSchemeReader class OOXColorSchemeReader
{ {
private: private:
OOX::Drawing::CColorScheme * m_ooxColorScheme; PPTX::nsTheme::ClrScheme * m_ooxColorScheme;
public: public:
OOXColorSchemeReader(OOX::Drawing::CColorScheme * ooxColorScheme) OOXColorSchemeReader(PPTX::nsTheme::ClrScheme * ooxColorScheme)
{ {
m_ooxColorScheme = ooxColorScheme; m_ooxColorScheme = ooxColorScheme;
} }
...@@ -48,53 +48,53 @@ public: ...@@ -48,53 +48,53 @@ public:
if (m_ooxColorScheme == NULL) return false; if (m_ooxColorScheme == NULL) return false;
RtfColor oNewColor; RtfColor oNewColor;
OOXColorReader oColorReader; OOXColorReader oColorReader(m_ooxColorScheme);
oColorReader.Parse( oParam, m_ooxColorScheme->m_oAccent1, oNewColor); oColorReader.Parse( oParam, L"accent1", oNewColor);
oNewColor.m_eTheme = RtfColor::caccentone; oNewColor.m_eTheme = RtfColor::caccentone;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oAccent2, oNewColor); oColorReader.Parse( oParam, L"accent2", oNewColor);
oNewColor.m_eTheme = RtfColor::caccenttwo; oNewColor.m_eTheme = RtfColor::caccenttwo;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oAccent3, oNewColor); oColorReader.Parse( oParam, L"accent3", oNewColor);
oNewColor.m_eTheme = RtfColor::caccentthree; oNewColor.m_eTheme = RtfColor::caccentthree;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oAccent4, oNewColor); oColorReader.Parse( oParam, L"accent4", oNewColor);
oNewColor.m_eTheme = RtfColor::caccentfour; oNewColor.m_eTheme = RtfColor::caccentfour;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oAccent5, oNewColor); oColorReader.Parse( oParam, L"accent5", oNewColor);
oNewColor.m_eTheme = RtfColor::caccentfive; oNewColor.m_eTheme = RtfColor::caccentfive;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oAccent6, oNewColor); oColorReader.Parse( oParam, L"accent6", oNewColor);
oNewColor.m_eTheme = RtfColor::caccentsix; oNewColor.m_eTheme = RtfColor::caccentsix;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oDk1, oNewColor); oColorReader.Parse( oParam, L"dk1", oNewColor);
oNewColor.m_eTheme = RtfColor::cmaindarkone; oNewColor.m_eTheme = RtfColor::cmaindarkone;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oDk2, oNewColor); oColorReader.Parse( oParam, L"dk2", oNewColor);
oNewColor.m_eTheme = RtfColor::cmaindarktwo; oNewColor.m_eTheme = RtfColor::cmaindarktwo;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oLt1, oNewColor); oColorReader.Parse( oParam, L"lt1", oNewColor);
oNewColor.m_eTheme = RtfColor::cmainlightone; oNewColor.m_eTheme = RtfColor::cmainlightone;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oLt2, oNewColor); oColorReader.Parse( oParam, L"lt2", oNewColor);
oNewColor.m_eTheme = RtfColor::cmainlighttwo; oNewColor.m_eTheme = RtfColor::cmainlighttwo;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oHlink, oNewColor); oColorReader.Parse( oParam, L"hlink", oNewColor);
oNewColor.m_eTheme = RtfColor::chyperlink; oNewColor.m_eTheme = RtfColor::chyperlink;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
oColorReader.Parse( oParam, m_ooxColorScheme->m_oFolHlink, oNewColor); oColorReader.Parse( oParam, L"folHlink", oNewColor);
oNewColor.m_eTheme = RtfColor::cfollowedhyperlink; oNewColor.m_eTheme = RtfColor::cfollowedhyperlink;
oParam.oRtf->m_oColorTable.AddItem( oNewColor ); oParam.oRtf->m_oColorTable.AddItem( oNewColor );
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
* *
*/ */
#include "OOXPictureGraphicReader.h"
#include "OOXDrawingGraphicReader.h" #include "OOXDrawingGraphicReader.h"
#include "OOXShapeReader.h" #include "OOXShapeReader.h"
...@@ -41,114 +40,39 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput) ...@@ -41,114 +40,39 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
{ {
if (m_ooxGraphic == NULL) return 0; if (m_ooxGraphic == NULL) return 0;
bool bTryPicture = false; if (m_ooxGraphic->element.IsInit())
switch(m_ooxGraphic->m_eGraphicType)
{ {
case OOX::Drawing::graphictypeShape: if (m_ooxGraphic->element->getType() == OOX::et_p_ShapeTree)
{ {
for (size_t i = 0; i < m_ooxGraphic->m_arrItems.size(); i++) OOXShapeReader shapeReader(m_ooxGraphic->element->GetElem().operator->());
{
if (m_ooxGraphic->m_arrItems[i] == NULL) continue;
if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_w_Shape)
{
OOXShapeReader shapeReader(dynamic_cast<OOX::Logic::CShape*>(m_ooxGraphic->m_arrItems[i]));
return (shapeReader.Parse(oParam, pOutput) ? 1 : 0); return (shapeReader.Parse(oParam, pOutput) ? 1 : 0);
} }
} else
}break;
case OOX::Drawing::graphictypeGroupShape:
{
for (size_t i = 0; i < m_ooxGraphic->m_arrItems.size(); i++)
{ {
if (m_ooxGraphic->m_arrItems[i] == NULL) continue; OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->element->GetElem().operator->()));
if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_w_GroupShape)
{
OOXShapeGroupReader groupReader(dynamic_cast<OOX::Logic::CGroupShape*>(m_ooxGraphic->m_arrItems[i]));
return (groupReader.Parse(oParam, pOutput) ? 1 : 0); return (groupReader.Parse(oParam, pOutput) ? 1 : 0);
} }
} }
}break; if (m_ooxGraphic->olePic.IsInit())
case OOX::Drawing::graphictypePicture:
case OOX::Drawing::graphictypeLockedCanvas:
case OOX::Drawing::graphictypeChart:
case OOX::Drawing::graphictypeDiagram:
{//find picture or replacement picture
for (size_t i = 0; i < m_ooxGraphic->m_arrItems.size(); i++)
{
if (m_ooxGraphic->m_arrItems[i] == NULL) continue;
if (m_ooxGraphic->m_arrItems[i]->getType() == OOX::et_pic_pic)
{ {
pOutput->m_nShapeType = 75; pOutput->m_nShapeType = 75;
OOX::Drawing::CPicture *picture = dynamic_cast<OOX::Drawing::CPicture *>(m_ooxGraphic->m_arrItems[i]); OOXShapeReader::Parse(oParam, pOutput, &m_ooxGraphic->olePic->blipFill); // тут если false приходит - картинка-потеряшка
OOXShapeReader::Parse(oParam, pOutput, &picture->m_oBlipFill); // тут если false приходит - картинка-потеряшка
return 1; return 1;
} }
} if (m_ooxGraphic->smartArt.IsInit())
}break;
}
return 2;
}
//OOX::Logic::CPicture*
OOX::Logic::CDrawing* OOXDrawingGraphicConverter::Convert( ReaderParameter oParam , RtfShapePtr pOutput)
{
NSBinPptxRW::CDrawingConverter drawingConverter;
OOX::CTheme *pTheme = oParam.oDocx->GetTheme();
if (pTheme)
{
NSCommon::smart_ptr<PPTX::Theme> theme(new PPTX::Theme());
PPTX::FileMap map;
theme->read(pTheme->m_oReadPath, map);
(*drawingConverter.m_pTheme) = theme.smart_dynamic_cast<PPTX::WrapperFile>();
}
drawingConverter.SetRelsPath(oParam.oDocx->m_pDocument->m_oReadPath.GetPath());
std::wstring sXml;
sXml = drawingConverter.ObjectToDrawingML(m_sXml, XMLWRITER_DOC_TYPE_DOCX);
// sXml = drawingConverter.ObjectToVML(m_sXml);
if (sXml.empty())return NULL;
OOX::CPath pathDrawingRels(drawingConverter.m_strCurrentRelsPath);
if (m_ooxGraphicRels)
{
m_ooxGraphicRels->Read(pathDrawingRels, pathDrawingRels);
}
std::wstring sBegin (L"<main xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:p=\"urn:schemas-microsoft-com:office:powerpoint\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/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\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\">");
std::wstring sEnd (L"</main>");
std::wstring strXml = sBegin + sXml + sEnd;
XmlUtils::CXmlLiteReader oSubReader;
if (oSubReader.FromString(strXml) == false) return NULL;
oSubReader.ReadNextNode();
int nStylesDepth1 = oSubReader.GetDepth();
while ( oSubReader.ReadNextSiblingNode( nStylesDepth1 ) )
{ {
std::wstring sName = oSubReader.GetName(); m_ooxGraphic->smartArt->LoadDrawing();
//if (sName == L"w:pict") if (m_ooxGraphic->smartArt->m_diag.IsInit())
//{
// return new OOX::Logic::CPicture(oSubReader);
//}
if (sName == L"w:drawing")
{ {
return new OOX::Logic::CDrawing(oSubReader); OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->smartArt->m_diag.GetPointer()));
return (groupReader.Parse(oParam, pOutput) ? 1 : 0);
} }
} }
//nullable_string spid;
return NULL; //nullable<Table> table;
//return pPict; //nullable<ChartRec> chartRec;
return 0;
} }
...@@ -40,25 +40,16 @@ ...@@ -40,25 +40,16 @@
#define PICTURE_BUFFER_SIZE 1024 #define PICTURE_BUFFER_SIZE 1024
class OOXDrawingGraphicConverter class OOXGraphicReader
{ {
private: private:
std::wstring m_sXml; PPTX::Logic::GraphicFrame *m_ooxGraphic;
public: public:
OOX::IFileContainer *m_ooxGraphicRels;
OOXDrawingGraphicConverter(std::wstring sXml) OOXGraphicReader(PPTX::Logic::GraphicFrame*ooxGraphic)
{
m_sXml = sXml;
m_ooxGraphicRels = new OOX::IFileContainer();
}
virtual ~OOXDrawingGraphicConverter()
{ {
if (m_ooxGraphicRels) m_ooxGraphic = ooxGraphic;
delete m_ooxGraphicRels;
m_ooxGraphicRels = NULL;
} }
//OOX::Logic::CPicture* Parse( ReaderParameter oParam , RtfShapePtr pOutput);
OOX::Logic::CDrawing* Convert( ReaderParameter oParam, RtfShapePtr pOutput); int Parse( ReaderParameter oParam, RtfShapePtr & pOutput);
}; };
...@@ -175,12 +175,12 @@ private: ...@@ -175,12 +175,12 @@ private:
class OOXFontReader3 class OOXFontReader3
{ {
private: private:
OOX::Drawing::CTextFont *m_asciiFont; PPTX::Logic::TextFont *m_asciiFont;
OOX::Drawing::CTextFont *m_csFont; PPTX::Logic::TextFont *m_csFont;
OOX::Drawing::CTextFont *m_asianFont; PPTX::Logic::TextFont *m_asianFont;
public: public:
OOXFontReader3(OOX::Drawing::CTextFont * asciiFont, OOX::Drawing::CTextFont * asianFont, OOX::Drawing::CTextFont * csFont) OOXFontReader3(PPTX::Logic::TextFont * asciiFont, PPTX::Logic::TextFont * asianFont, PPTX::Logic::TextFont * csFont)
{ {
m_asciiFont = asciiFont; m_asciiFont = asciiFont;
m_asianFont = asianFont; m_asianFont = asianFont;
...@@ -192,9 +192,9 @@ public: ...@@ -192,9 +192,9 @@ public:
std::wstring sAscii, sCs, sEastAsia; std::wstring sAscii, sCs, sEastAsia;
if ((m_asciiFont) && (m_asciiFont->m_oTypeFace.IsInit())) sAscii = m_asciiFont->m_oTypeFace->GetValue(); if (m_asciiFont) sAscii = m_asciiFont->typeface;
if ((m_csFont) && (m_csFont->m_oTypeFace.IsInit())) sCs = m_csFont->m_oTypeFace->GetValue(); if (m_csFont) sCs = m_csFont->typeface;
if ((m_asianFont) && (m_asianFont->m_oTypeFace.IsInit())) sEastAsia = m_asianFont->m_oTypeFace->GetValue(); if (m_asianFont) sEastAsia = m_asianFont->typeface;
std::wstring sFont; std::wstring sFont;
std::wstring sTempFont; std::wstring sTempFont;
...@@ -215,27 +215,28 @@ public: ...@@ -215,27 +215,28 @@ public:
oCurFont.m_nID = nFont; oCurFont.m_nID = nFont;
oCurFont.m_sName = sFont; oCurFont.m_sName = sFont;
if( !sAscii.empty() ) //if( !sAscii.empty() )
{ //{
if (m_asciiFont->m_oPanose.IsInit()) // if (m_asciiFont->m_oPanose.IsInit())
oCurFont.m_sPanose = m_asciiFont->m_oPanose->GetValue(); // oCurFont.m_sPanose = m_asciiFont->m_oPanose->GetValue();
oCurFont.m_nCharset = m_asciiFont->m_oCharset.GetValue(); // if (m_asciiFont->charset.IsInit())
oCurFont.m_nPitch = m_asciiFont->m_oPitchFamily.GetValue(); // oCurFont.m_nCharset = m_asciiFont->charset.get();
} // oCurFont.m_nPitch = m_asciiFont->m_oPitchFamily.GetValue();
else if( !sCs.empty() ) //}
{ //else if( !sCs.empty() )
if (m_csFont->m_oPanose.IsInit()) //{
oCurFont.m_sPanose = m_csFont->m_oPanose->GetValue(); // if (m_csFont->m_oPanose.IsInit())
oCurFont.m_nCharset = m_csFont->m_oCharset.GetValue(); // oCurFont.m_sPanose = m_csFont->m_oPanose->GetValue();
oCurFont.m_nPitch = m_csFont->m_oPitchFamily.GetValue(); // oCurFont.m_nCharset = m_csFont->m_oCharset.GetValue();
} // oCurFont.m_nPitch = m_csFont->m_oPitchFamily.GetValue();
else if( !sEastAsia.empty() ) //}
{ //else if( !sEastAsia.empty() )
if (m_asianFont->m_oPanose.IsInit()) //{
oCurFont.m_sPanose = m_asianFont->m_oPanose->GetValue(); // if (m_asianFont->m_oPanose.IsInit())
oCurFont.m_nCharset = m_asianFont->m_oCharset.GetValue(); // oCurFont.m_sPanose = m_asianFont->m_oPanose->GetValue();
oCurFont.m_nPitch = m_asianFont->m_oPitchFamily.GetValue(); // oCurFont.m_nCharset = m_asianFont->m_oCharset.GetValue();
} // oCurFont.m_nPitch = m_asianFont->m_oPitchFamily.GetValue();
//}
oParam.oRtf->m_oFontTable.AddItem( oCurFont ); oParam.oRtf->m_oFontTable.AddItem( oCurFont );
} }
} }
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
class OOXFontSchemeReader class OOXFontSchemeReader
{ {
private: private:
OOX::Drawing::CFontScheme * m_ooxFontScheme; PPTX::nsTheme::FontScheme * m_ooxFontScheme;
public: public:
OOXFontSchemeReader(OOX::Drawing::CFontScheme * ooxFontScheme) OOXFontSchemeReader(PPTX::nsTheme::FontScheme * ooxFontScheme)
{ {
m_ooxFontScheme = ooxFontScheme; m_ooxFontScheme = ooxFontScheme;
} }
...@@ -47,36 +47,17 @@ public: ...@@ -47,36 +47,17 @@ public:
{ {
if (m_ooxFontScheme == NULL) return false; if (m_ooxFontScheme == NULL) return false;
if (m_ooxFontScheme->m_oMajorFont.m_oLatin.m_oTypeFace.IsInit()) oParam.oReader->m_smajorAscii = m_ooxFontScheme->majorFont.latin.typeface;
{ oParam.oReader->m_smajorHAnsi = m_ooxFontScheme->majorFont.latin.typeface;
oParam.oReader->m_smajorAscii = m_ooxFontScheme->m_oMajorFont.m_oLatin.m_oTypeFace->GetValue();
oParam.oReader->m_smajorHAnsi = m_ooxFontScheme->m_oMajorFont.m_oLatin.m_oTypeFace->GetValue();
}
if (m_ooxFontScheme->m_oMajorFont.m_oEa.m_oTypeFace.IsInit())
{
oParam.oReader->m_smajorEastAsia = m_ooxFontScheme->m_oMajorFont.m_oEa.m_oTypeFace->GetValue();
}
if (m_ooxFontScheme->m_oMajorFont.m_oCs.m_oTypeFace.IsInit())
{
oParam.oReader->m_smajorBidi = m_ooxFontScheme->m_oMajorFont.m_oCs.m_oTypeFace->GetValue();
}
//for (long i=0 ; i < m_ooxFontScheme->m_oMajorFont.m_arrFont.size(); i++)
//{
//}
if (m_ooxFontScheme->m_oMinorFont.m_oLatin.m_oTypeFace.IsInit()) oParam.oReader->m_smajorEastAsia = m_ooxFontScheme->majorFont.ea.typeface;
{ oParam.oReader->m_smajorBidi = m_ooxFontScheme->majorFont.cs.typeface;
oParam.oReader->m_sminorAscii = m_ooxFontScheme->m_oMinorFont.m_oLatin.m_oTypeFace->GetValue();
oParam.oReader->m_sminorHAnsi = m_ooxFontScheme->m_oMinorFont.m_oLatin.m_oTypeFace->GetValue(); oParam.oReader->m_sminorAscii = m_ooxFontScheme->minorFont.latin.typeface;
} oParam.oReader->m_sminorHAnsi = m_ooxFontScheme->minorFont.latin.typeface;
if (m_ooxFontScheme->m_oMinorFont.m_oEa.m_oTypeFace.IsInit())
{ oParam.oReader->m_sminorEastAsia = m_ooxFontScheme->minorFont.ea.typeface;
oParam.oReader->m_sminorEastAsia = m_ooxFontScheme->m_oMinorFont.m_oEa.m_oTypeFace->GetValue(); oParam.oReader->m_sminorBidi = m_ooxFontScheme->minorFont.cs.typeface;
}
if (m_ooxFontScheme->m_oMinorFont.m_oCs.m_oTypeFace.IsInit())
{
oParam.oReader->m_sminorBidi = m_ooxFontScheme->m_oMinorFont.m_oCs.m_oTypeFace->GetValue();
}
//for (long i=0 ; i < m_ooxFontScheme->m_oMinorFont.m_arrFont.size(); i++) //for (long i=0 ; i < m_ooxFontScheme->m_oMinorFont.m_arrFont.size(); i++)
//{ //{
//} //}
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
class OOXParagraphReader class OOXParagraphReader
{ {
private: private:
OOX::Drawing::CParagraph *m_drawingParagraph; PPTX::Logic::Paragraph *m_drawingParagraph;
OOX::Logic::CParagraph *m_ooxParagraph; OOX::Logic::CParagraph *m_ooxParagraph;
OOX::WritingElementWithChilds<OOX::WritingElement> *m_ooxElement; OOX::WritingElementWithChilds<OOX::WritingElement> *m_ooxElement;
public: public:
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
m_oCharProperty.SetDefault(); m_oCharProperty.SetDefault();
} }
OOXParagraphReader (OOX::Drawing::CParagraph *ooxParagraph) OOXParagraphReader (PPTX::Logic::Paragraph *ooxParagraph)
{ {
m_ooxElement = NULL; m_ooxElement = NULL;
m_ooxParagraph = NULL; m_ooxParagraph = NULL;
...@@ -70,4 +70,5 @@ public: ...@@ -70,4 +70,5 @@ public:
} }
bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle); bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle);
bool Parse2( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, RtfStylePtr poStyle); bool Parse2( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, RtfStylePtr poStyle);
bool Parse3( ReaderParameter oParam , RtfParagraph& oOutputParagraph, CcnfStyle oConditionalTableStyle, RtfStylePtr poStyle, OOX::WritingElement* m_ooxElement);
}; };
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
*/ */
#pragma once #pragma once
#include "OOXDrawingGraphicReader.h" #include "OOXDrawingGraphicReader.h"
#include "OOXPictureGraphicReader.h"
#include "OOXReaderBasic.h" #include "OOXReaderBasic.h"
class OOXDrawingAnchorReader class OOXDrawingAnchorReader
...@@ -297,13 +296,9 @@ public: ...@@ -297,13 +296,9 @@ public:
if(m_ooxAnchor->m_oWrapTopAndBottom.IsInit()) if(m_ooxAnchor->m_oWrapTopAndBottom.IsInit())
pOutput->m_nWrapType = 1; pOutput->m_nWrapType = 1;
int result = 0; OOXGraphicReader oGraphicReader(&m_ooxAnchor->m_oGraphic);
if( m_ooxAnchor->m_oGraphic.IsInit() )
{
OOXGraphicReader oGraphicReader(m_ooxAnchor->m_oGraphic.GetPointer());
result = oGraphicReader.Parse( oParam, pOutput); int result = oGraphicReader.Parse( oParam, pOutput);
}
if( PROP_DEF == pOutput->m_nBottom && pOutput->m_nTop !=PROP_DEF ) if( PROP_DEF == pOutput->m_nBottom && pOutput->m_nTop !=PROP_DEF )
{ {
pOutput->m_nBottom = pOutput->m_nTop + nHeight; pOutput->m_nBottom = pOutput->m_nTop + nHeight;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
*/ */
#pragma once #pragma once
#include "OOXPictureGraphicReader.h" #include "OOXDrawingGraphicReader.h"
class OOXDrawingInlineReader class OOXDrawingInlineReader
{ {
...@@ -78,13 +78,9 @@ public: ...@@ -78,13 +78,9 @@ public:
} }
} }
int result = 0; OOXGraphicReader oGraphicReader(&m_ooxInline->m_oGraphic);
if(m_ooxInline->m_oGraphic.IsInit())
{
OOXGraphicReader oGraphicReader(m_ooxInline->m_oGraphic.GetPointer());
result = oGraphicReader.Parse( oParam, pOutput); int result = oGraphicReader.Parse( oParam, pOutput);
}
return result; return result;
} }
}; };
...@@ -73,7 +73,7 @@ bool OOXReader::Parse() ...@@ -73,7 +73,7 @@ bool OOXReader::Parse()
oFontTableReader.Parse( oReaderParameter ); oFontTableReader.Parse( oReaderParameter );
} }
OOX::CTheme* theme = inputDocxFile.GetTheme(); PPTX::Theme* theme = inputDocxFile.GetTheme();
if (theme) if (theme)
{ {
OOXThemeReader oThemeReader( theme ); OOXThemeReader oThemeReader( theme );
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
class OOXRunReader class OOXRunReader
{ {
private: private:
OOX::Drawing::CRun* m_drawingRun; PPTX::Logic::Run* m_drawingRun;
OOX::Logic::CRun* m_ooxRun; OOX::Logic::CRun* m_ooxRun;
public: public:
RtfCharProperty m_oCharProperty; RtfCharProperty m_oCharProperty;
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
m_ooxRun = ooxRun; m_ooxRun = ooxRun;
m_oCharProperty.SetDefault(); m_oCharProperty.SetDefault();
} }
OOXRunReader(OOX::Drawing::CRun *ooxRun) OOXRunReader(PPTX::Logic::Run *ooxRun)
{ {
m_drawingRun = ooxRun; m_drawingRun = ooxRun;
m_ooxRun = NULL; m_ooxRun = NULL;
......
...@@ -30,14 +30,12 @@ ...@@ -30,14 +30,12 @@
* *
*/ */
#pragma once #pragma once
#include "OOXPictureGraphicReader.h"
#include "OOXReaderBasic.h" #include "OOXReaderBasic.h"
#include "../RtfDocument.h" #include "../RtfDocument.h"
#include "../RtfShape.h" #include "../RtfShape.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h" #include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Logic/Shape.h"
bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop); bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);
...@@ -52,7 +50,7 @@ public: ...@@ -52,7 +50,7 @@ public:
m_arrElement = vmlElem; m_arrElement = vmlElem;
} }
OOXShapeReader(OOX::WritingElementWithChilds<OOX::WritingElement> * elem); OOXShapeReader(OOX::WritingElementWithChilds<OOX::WritingElement> * elem);
OOXShapeReader(OOX::Logic::CShape * ooxShape) OOXShapeReader(OOX::WritingElement* ooxShape)
{ {
m_ooxShape = ooxShape; m_ooxShape = ooxShape;
m_vmlElement = NULL; m_vmlElement = NULL;
...@@ -67,26 +65,24 @@ public: ...@@ -67,26 +65,24 @@ public:
void ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment); void ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment);
static bool Parse(ReaderParameter oParam, RtfShapePtr& pOutput, OOX::Drawing::CBlipFillProperties *oox_bitmap_fill); static bool Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::BlipFill *oox_bitmap_fill);
private: private:
void Parse(ReaderParameter oParam, PPTX::Logic::ColorBase *oox_color, unsigned int & nColor, _CP_OPT(double) &opacity);
void Parse(ReaderParameter oParam, PPTX::Logic::SolidFill *oox_solid_fill, unsigned int & nColor, _CP_OPT(double) &opacity);
bool Parse(ReaderParameter oParam, int indexSchemeColor, BYTE& ucA, BYTE& ucG, BYTE& ucB, BYTE& ucR); void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::StyleRef *style_ref, int type);
void Parse(ReaderParameter oParam, OOX::Drawing::CColor *oox_color, unsigned int & nColor, _CP_OPT(double) &opacity); void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::Ln *oox_line_prop, std::wstring *change_sheme_color = NULL);
void Parse(ReaderParameter oParam, OOX::Drawing::CSchemeColor *oox_ShemeClr, unsigned int & nColor, _CP_OPT(double) &opacity);
void Parse(ReaderParameter oParam, OOX::Drawing::Colors::CColorTransform *oox_ScrgbClr, unsigned int & nColor, _CP_OPT(double) &opacity);
void Parse(ReaderParameter oParam, OOX::Drawing::CSolidColorFillProperties *oox_solid_fill, unsigned int & nColor, _CP_OPT(double) &opacity);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, OOX::Drawing::CStyleMatrixReference *style_matrix_ref); void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::UniFill *oox_fill, std::wstring *change_sheme_color = NULL);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, OOX::Drawing::CLineProperties *oox_line_prop, std::wstring *change_sheme_color = NULL);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, OOX::Drawing::CGradientFillProperties *oox_grad_fill, std::wstring *change_sheme_color = NULL); void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::GradFill *oox_grad_fill, std::wstring *change_sheme_color = NULL);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, OOX::Drawing::CPatternFillProperties *oox_pattern_fill, std::wstring *change_sheme_color = NULL); void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::PattFill *oox_pattern_fill, std::wstring *change_sheme_color = NULL);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, OOX::Drawing::CSolidColorFillProperties *oox_solid_fill, std::wstring *change_sheme_color = NULL); void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::SolidFill *oox_solid_fill, std::wstring *change_sheme_color = NULL);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
OOX::Vml::CVmlCommonElements *m_vmlElement; OOX::Vml::CVmlCommonElements *m_vmlElement;
OOX::WritingElementWithChilds<OOX::WritingElement> *m_arrElement; OOX::WritingElementWithChilds<OOX::WritingElement> *m_arrElement;
OOX::Logic::CShape *m_ooxShape; OOX::WritingElement *m_ooxShape;
void ParseVmlPath (RtfShapePtr& pShape, const std::wstring &custom_path); void ParseVmlPath (RtfShapePtr& pShape, const std::wstring &custom_path);
bool ParseVmlStyles (RtfShapePtr& pShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props) bool ParseVmlStyles (RtfShapePtr& pShape, std::vector<SimpleTypes::Vml::CCssPropertyPtr> & props)
...@@ -104,14 +100,14 @@ class OOXShapeGroupReader ...@@ -104,14 +100,14 @@ class OOXShapeGroupReader
{ {
private: private:
OOX::Vml::CGroup *m_vmlGroup; OOX::Vml::CGroup *m_vmlGroup;
OOX::Logic::CGroupShape *m_ooxGroup; PPTX::Logic::SpTree *m_ooxGroup;
public: public:
OOXShapeGroupReader(OOX::Vml::CGroup *vmlGroup) OOXShapeGroupReader(OOX::Vml::CGroup *vmlGroup)
{ {
m_ooxGroup = NULL; m_ooxGroup = NULL;
m_vmlGroup = vmlGroup; m_vmlGroup = vmlGroup;
} }
OOXShapeGroupReader(OOX::Logic::CGroupShape *ooxGroup) OOXShapeGroupReader(PPTX::Logic::SpTree *ooxGroup)
{ {
m_vmlGroup = NULL; m_vmlGroup = NULL;
m_ooxGroup = ooxGroup; m_ooxGroup = ooxGroup;
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
{ {
case OOX::et_a_p: case OOX::et_a_p:
{ {
OOX::Drawing::CParagraph * pParagraph = dynamic_cast<OOX::Drawing::CParagraph*>(ooxElement); PPTX::Logic::Paragraph * pParagraph = dynamic_cast<PPTX::Logic::Paragraph*>(ooxElement);
OOXParagraphReader m_oParagraphReader(pParagraph); OOXParagraphReader m_oParagraphReader(pParagraph);
RtfParagraphPtr oNewParagraph ( new RtfParagraph() ); RtfParagraphPtr oNewParagraph ( new RtfParagraph() );
......
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
class OOXThemeReader class OOXThemeReader
{ {
private: private:
OOX::CTheme* m_ooxTheme; PPTX::Theme* m_ooxTheme;
public: public:
OOXThemeReader( OOX::CTheme* ooxTheme) OOXThemeReader( PPTX::Theme* ooxTheme)
{ {
m_ooxTheme = ooxTheme; m_ooxTheme = ooxTheme;
} }
...@@ -49,11 +49,11 @@ public: ...@@ -49,11 +49,11 @@ public:
if (m_ooxTheme == NULL) return false; if (m_ooxTheme == NULL) return false;
{ {
OOXColorSchemeReader oColorSchemeReader (&m_ooxTheme->m_oThemeElements.m_oClrScheme); OOXColorSchemeReader oColorSchemeReader (&m_ooxTheme->themeElements.clrScheme);
oColorSchemeReader.Parse( oParam ); oColorSchemeReader.Parse( oParam );
} }
{ {
OOXFontSchemeReader oFontSchemeReader (&m_ooxTheme->m_oThemeElements.m_oFontScheme ); OOXFontSchemeReader oFontSchemeReader (&m_ooxTheme->themeElements.fontScheme );
oFontSchemeReader.Parse( oParam ); oFontSchemeReader.Parse( oParam );
} }
return true; return true;
......
...@@ -46,7 +46,7 @@ class OOXpPrReader ...@@ -46,7 +46,7 @@ class OOXpPrReader
private: private:
bool ParseDrawing( ReaderParameter oParam, RtfParagraphProperty& oOutputProperty); bool ParseDrawing( ReaderParameter oParam, RtfParagraphProperty& oOutputProperty);
OOX::Drawing::CParagraphProperty * m_drawingParaProps; PPTX::Logic::TextParagraphPr * m_drawingParaProps;
OOX::Logic::CParagraphProperty * m_ooxParaProps; OOX::Logic::CParagraphProperty * m_ooxParaProps;
public: public:
bool m_bDefStyle; bool m_bDefStyle;
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
m_ooxParaProps = ooxParaProps; m_ooxParaProps = ooxParaProps;
m_drawingParaProps = NULL; m_drawingParaProps = NULL;
} }
OOXpPrReader(OOX::Drawing::CParagraphProperty *ooxParaProps) OOXpPrReader(PPTX::Logic::TextParagraphPr *ooxParaProps)
{ {
m_bDefStyle = true; m_bDefStyle = true;
m_ooxParaProps = NULL; m_ooxParaProps = NULL;
......
...@@ -45,7 +45,7 @@ class OOXrPrReader ...@@ -45,7 +45,7 @@ class OOXrPrReader
private: private:
bool ParseDrawing( ReaderParameter oParam, RtfCharProperty& oOutputProperty); bool ParseDrawing( ReaderParameter oParam, RtfCharProperty& oOutputProperty);
OOX::Drawing::CRunProperty * m_drawingRunProps; PPTX::Logic::RunProperties * m_drawingRunProps;
OOX::Logic::CRunProperty * m_ooxRunProps; OOX::Logic::CRunProperty * m_ooxRunProps;
public: public:
bool m_bDefStyle; bool m_bDefStyle;
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
m_ooxRunProps = ooxRunProps; m_ooxRunProps = ooxRunProps;
m_drawingRunProps = NULL; m_drawingRunProps = NULL;
} }
OOXrPrReader(OOX::Drawing::CRunProperty *ooxRunProps) OOXrPrReader(PPTX::Logic::RunProperties *ooxRunProps)
{ {
m_bDefStyle = true; m_bDefStyle = true;
m_ooxRunProps = NULL; m_ooxRunProps = NULL;
......
...@@ -146,7 +146,7 @@ bool OOXWriter::SaveByItemEnd() ...@@ -146,7 +146,7 @@ bool OOXWriter::SaveByItemEnd()
if (m_poDocPropsApp) if (m_poDocPropsApp)
{ {
((OOX::CApp*)m_poDocPropsApp)->SetApplication ( L"OnlyOffice" ); ((OOX::CApp*)m_poDocPropsApp)->SetApplication ( L"OnlyOffice" );
((OOX::CApp*)m_poDocPropsApp)->SetAppVersion ( L"3.0000" ); ((OOX::CApp*)m_poDocPropsApp)->SetAppVersion ( L"4.3" );
((OOX::CApp*)m_poDocPropsApp)->write(pathDocProps + FILE_SEPARATOR_STR + L"app.xml", pathDocProps.GetDirectory(), oContentTypes); ((OOX::CApp*)m_poDocPropsApp)->write(pathDocProps + FILE_SEPARATOR_STR + L"app.xml", pathDocProps.GetDirectory(), oContentTypes);
......
...@@ -49,16 +49,16 @@ const int TxtFile::getLinesCount() ...@@ -49,16 +49,16 @@ const int TxtFile::getLinesCount()
const std::list<std::string> TxtFile::readAnsiOrCodePage() // == readUtf8withoutPref также const std::list<std::string> TxtFile::readAnsiOrCodePage() // == readUtf8withoutPref также
{ {
std::list<std::string> result; std::list<std::string> result;
CFile file_binary; NSFile::CFileBinary file_binary;
if (file_binary.OpenFile(m_path) != S_OK) return result; if (file_binary.OpenFile(m_path) != S_OK) return result;
long file_size = file_binary.GetFileSize(); DWORD file_size = file_binary.GetFileSize();
char *file_data = new char[file_size]; char *file_data = new char[file_size];
if (file_data == NULL) return result; if (file_data == NULL) return result;
file_binary.ReadFile((BYTE*)file_data, file_size); file_binary.ReadFile((BYTE*)file_data, file_size, file_size);
long start_pos = 0; long start_pos = 0;
...@@ -116,16 +116,16 @@ const std::list<std::wstring> TxtFile::readUnicodeFromBytes(char *file_data, lon ...@@ -116,16 +116,16 @@ const std::list<std::wstring> TxtFile::readUnicodeFromBytes(char *file_data, lon
const std::list<std::wstring> TxtFile::readUnicode() const std::list<std::wstring> TxtFile::readUnicode()
{ {
std::list<std::wstring> result; std::list<std::wstring> result;
CFile file_binary; NSFile::CFileBinary file_binary;
if (file_binary.OpenFile(m_path) != S_OK) return result; if (file_binary.OpenFile(m_path) != S_OK) return result;
long file_size = file_binary.GetFileSize(); DWORD file_size = file_binary.GetFileSize();
char *file_data = new char[file_size]; char *file_data = new char[file_size];
if (file_data == NULL) return result; if (file_data == NULL) return result;
file_binary.ReadFile((BYTE*)file_data, file_size); file_binary.ReadFile((BYTE*)file_data, file_size, file_size);
return readUnicodeFromBytes(file_data, file_size); return readUnicodeFromBytes(file_data, file_size);
} }
...@@ -133,16 +133,16 @@ const std::list<std::wstring> TxtFile::readUnicode() ...@@ -133,16 +133,16 @@ const std::list<std::wstring> TxtFile::readUnicode()
const std::list<std::wstring> TxtFile::readBigEndian() const std::list<std::wstring> TxtFile::readBigEndian()
{ {
std::list<std::wstring> result; std::list<std::wstring> result;
CFile file_binary; NSFile::CFileBinary file_binary;
if (file_binary.OpenFile(m_path) != S_OK) return result; if (file_binary.OpenFile(m_path) != S_OK) return result;
long file_size = file_binary.GetFileSize(); DWORD file_size = file_binary.GetFileSize();
char *file_data = new char[file_size]; char *file_data = new char[file_size];
if (file_data == NULL) return result; if (file_data == NULL) return result;
file_binary.ReadFile((BYTE*)file_data, file_size); file_binary.ReadFile((BYTE*)file_data, file_size, file_size);
//swap bytes //swap bytes
for (long i = 0; i < file_size; i+=2) for (long i = 0; i < file_size; i+=2)
...@@ -158,16 +158,16 @@ const std::list<std::wstring> TxtFile::readBigEndian() ...@@ -158,16 +158,16 @@ const std::list<std::wstring> TxtFile::readBigEndian()
const std::list<std::string> TxtFile::readUtf8() const std::list<std::string> TxtFile::readUtf8()
{ {
std::list<std::string> result; std::list<std::string> result;
CFile file_binary; NSFile::CFileBinary file_binary;
if (file_binary.OpenFile(m_path) != S_OK) return result; if (file_binary.OpenFile(m_path) != S_OK) return result;
long file_size = file_binary.GetFileSize(); DWORD file_size = file_binary.GetFileSize();
char *file_data = new char[file_size]; char *file_data = new char[file_size];
if (file_data == NULL) return result; if (file_data == NULL) return result;
file_binary.ReadFile((BYTE*)file_data, file_size); file_binary.ReadFile((BYTE*)file_data, file_size, file_size);
long start_pos = 3; //skip header long start_pos = 3; //skip header
...@@ -197,13 +197,13 @@ const std::list<std::string> TxtFile::readUtf8() ...@@ -197,13 +197,13 @@ const std::list<std::string> TxtFile::readUtf8()
void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // === writeUtf8withoutPref также void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // === writeUtf8withoutPref также
{ {
CFile file; NSFile::CFileBinary file;
if (file.CreateFile(m_path) == S_OK) if (file.CreateFileW(m_path) == S_OK)
{ {
BYTE endLine[2] = {0x0d, 0x0a}; BYTE endLine[2] = {0x0d, 0x0a};
for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter) for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
{ {
file.WriteFile((void*)(*iter).c_str(), (*iter).length()); file.WriteFile((BYTE*)(*iter).c_str(), (*iter).length());
file.WriteFile(endLine, 2); file.WriteFile(endLine, 2);
m_linesCount++; m_linesCount++;
...@@ -213,8 +213,8 @@ void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // === ...@@ -213,8 +213,8 @@ void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // ===
void TxtFile::writeUnicode(const std::list<std::wstring>& content) void TxtFile::writeUnicode(const std::list<std::wstring>& content)
{ {
CFile file; NSFile::CFileBinary file;
if (file.CreateFile(m_path) == S_OK) if (file.CreateFileW(m_path) == S_OK)
{ {
BYTE Header[2] = {0xff, 0xfe}; BYTE Header[2] = {0xff, 0xfe};
BYTE EndLine[4] = {0x0d, 0x00, 0x0a, 0x00}; BYTE EndLine[4] = {0x0d, 0x00, 0x0a, 0x00};
...@@ -228,7 +228,7 @@ void TxtFile::writeUnicode(const std::list<std::wstring>& content) ...@@ -228,7 +228,7 @@ void TxtFile::writeUnicode(const std::list<std::wstring>& content)
if(sizeof(wchar_t) == 2) if(sizeof(wchar_t) == 2)
{ {
file.WriteFile((void*)data, size << 1); file.WriteFile((BYTE*)data, size << 1);
} }
else else
{ {
...@@ -243,8 +243,8 @@ void TxtFile::writeUnicode(const std::list<std::wstring>& content) ...@@ -243,8 +243,8 @@ void TxtFile::writeUnicode(const std::list<std::wstring>& content)
void TxtFile::writeBigEndian(const std::list<std::wstring>& content) void TxtFile::writeBigEndian(const std::list<std::wstring>& content)
{ {
CFile file; NSFile::CFileBinary file;
if (file.CreateFile(m_path) == S_OK) if (file.CreateFileW(m_path) == S_OK)
{ {
BYTE Header[2] = {0xfe, 0xff}; BYTE Header[2] = {0xfe, 0xff};
BYTE EndLine[4] = {0x00, 0x0d, 0x00, 0x0a}; BYTE EndLine[4] = {0x00, 0x0d, 0x00, 0x0a};
...@@ -264,7 +264,7 @@ void TxtFile::writeBigEndian(const std::list<std::wstring>& content) ...@@ -264,7 +264,7 @@ void TxtFile::writeBigEndian(const std::list<std::wstring>& content)
data[i] = data[i+1]; data[i] = data[i+1];
data[i+1] = v; data[i+1] = v;
} }
file.WriteFile((void*)(*iter).c_str(), size << 1); file.WriteFile((BYTE*)(*iter).c_str(), size << 1);
} }
else else
{ {
...@@ -279,8 +279,8 @@ void TxtFile::writeBigEndian(const std::list<std::wstring>& content) ...@@ -279,8 +279,8 @@ void TxtFile::writeBigEndian(const std::list<std::wstring>& content)
void TxtFile::writeUtf8(const std::list<std::string>& content) void TxtFile::writeUtf8(const std::list<std::string>& content)
{ {
CFile file; NSFile::CFileBinary file;
if (file.CreateFile(m_path) == S_OK) if (file.CreateFileW(m_path) == S_OK)
{ {
BYTE Header[3] = {0xef ,0xbb , 0xbf}; BYTE Header[3] = {0xef ,0xbb , 0xbf};
BYTE EndLine[2] = {0x0d ,0x0a}; BYTE EndLine[2] = {0x0d ,0x0a};
...@@ -289,8 +289,8 @@ void TxtFile::writeUtf8(const std::list<std::string>& content) ...@@ -289,8 +289,8 @@ void TxtFile::writeUtf8(const std::list<std::string>& content)
for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter) for (std::list<std::string>::const_iterator iter = content.begin(); iter != content.end(); ++iter)
{ {
file.WriteFile((void*)(*iter).c_str(), (*iter).length()); file.WriteFile((BYTE*)(*iter).c_str(), (*iter).length());
file.WriteFile((void*)EndLine, 2); file.WriteFile((BYTE*)EndLine, 2);
m_linesCount++; m_linesCount++;
} }
...@@ -299,12 +299,14 @@ void TxtFile::writeUtf8(const std::list<std::string>& content) ...@@ -299,12 +299,14 @@ void TxtFile::writeUtf8(const std::list<std::string>& content)
const bool TxtFile::isUnicode() const bool TxtFile::isUnicode()
{ {
CFile file; NSFile::CFileBinary file;
if (file.OpenFile(m_path) != S_OK) return false; if (file.OpenFile(m_path) != S_OK) return false;
DWORD dwRead;
BYTE data [2]; BYTE data [2];
file.ReadFile(data,2);
file.ReadFile(data, 2, dwRead);
file.CloseFile(); file.CloseFile();
if ((data [0] == 0xff) && (data [1] == 0xfe))return true; if ((data [0] == 0xff) && (data [1] == 0xfe))return true;
...@@ -314,12 +316,14 @@ const bool TxtFile::isUnicode() ...@@ -314,12 +316,14 @@ const bool TxtFile::isUnicode()
const bool TxtFile::isBigEndian() const bool TxtFile::isBigEndian()
{ {
CFile file; NSFile::CFileBinary file;
if (file.OpenFile(m_path) != S_OK) return false; if (file.OpenFile(m_path) != S_OK) return false;
DWORD dwRead;
BYTE data [2]; BYTE data [2];
file.ReadFile(data,2);
file.ReadFile(data, 2, dwRead);
file.CloseFile(); file.CloseFile();
if ((data [0] == 0xfe) && (data [1] == 0xff))return true; if ((data [0] == 0xfe) && (data [1] == 0xff))return true;
...@@ -329,12 +333,14 @@ const bool TxtFile::isBigEndian() ...@@ -329,12 +333,14 @@ const bool TxtFile::isBigEndian()
const bool TxtFile::isUtf8() const bool TxtFile::isUtf8()
{ {
CFile file; NSFile::CFileBinary file;
if (file.OpenFile(m_path) != S_OK) return false; if (file.OpenFile(m_path) != S_OK) return false;
DWORD dwRead;
BYTE data [3]; BYTE data [3];
file.ReadFile(data,3);
file.ReadFile(data, 3, dwRead);
file.CloseFile(); file.CloseFile();
if ((data [0] == 0xef) && (data [1] == 0xbb) && (data [2] == 0xbf))return true; if ((data [0] == 0xef) && (data [1] == 0xbb) && (data [2] == 0xbf))return true;
......
...@@ -50,7 +50,6 @@ namespace NSBinPptxRW ...@@ -50,7 +50,6 @@ namespace NSBinPptxRW
#include "../../../Common/DocxFormat/Source/SystemUtility/File.h" #include "../../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "../../../DesktopEditor/common/Path.h"
#include "../../../ASCOfficeDocxFile2/DocWrapper/FontProcessor.h" #include "../../../ASCOfficeDocxFile2/DocWrapper/FontProcessor.h"
#include "../../../ASCOfficeDocxFile2/BinReader/FileWriter.h" #include "../../../ASCOfficeDocxFile2/BinReader/FileWriter.h"
...@@ -211,7 +210,7 @@ void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::F ...@@ -211,7 +210,7 @@ void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::F
//default files //default files
pDocxWriter->m_oDefaultTheme.Write(pathTheme.GetPath()); pDocxWriter->m_oTheme.Write(pathTheme.GetPath());
OOX::CContentTypes oContentTypes; OOX::CContentTypes oContentTypes;
//docProps //docProps
...@@ -224,7 +223,7 @@ void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::F ...@@ -224,7 +223,7 @@ void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::F
if (pApp) if (pApp)
{ {
pApp->SetApplication(_T("OnlyOffice")); pApp->SetApplication(_T("OnlyOffice"));
pApp->SetAppVersion(_T("3.0000")); pApp->SetAppVersion(_T("4.3000"));
pApp->SetDocSecurity(0); pApp->SetDocSecurity(0);
pApp->SetScaleCrop(false); pApp->SetScaleCrop(false);
pApp->SetLinksUpToDate(false); pApp->SetLinksUpToDate(false);
...@@ -243,20 +242,24 @@ void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::F ...@@ -243,20 +242,24 @@ void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::F
delete pCore; delete pCore;
} }
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
pDocxWriter->m_oTheme.Write(strDirectory);
pDocxWriter->m_oCommentsWriter.Write();
pDocxWriter->m_oChartWriter.Write();
pDocxWriter->m_oStylesWriter.Write(); pDocxWriter->m_oStylesWriter.Write();
pDocxWriter->m_oNumberingWriter.Write();
pDocxWriter->m_oFontTableWriter.Write(); pDocxWriter->m_oFontTableWriter.Write();
pDocxWriter->m_oHeaderFooterWriter.Write();
//Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
pDocxWriter->m_oSettingWriter.Write(); pDocxWriter->m_oSettingWriter.Write();
pDocxWriter->m_oWebSettingsWriter.Write(); pDocxWriter->m_oWebSettingsWriter.Write();
//Document пишем после HeaderFooter, чтобы заполнить sectPr
pDocxWriter->m_oDocumentWriter.Write(); pDocxWriter->m_oDocumentWriter.Write();
//Rels и ContentTypes пишем в конце
pDocxWriter->m_oDocumentRelsWriter.Write(); pDocxWriter->m_oDocumentRelsWriter.Write();
pDocxWriter->m_oContentTypesWriter.Write();
oContentTypes.Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", OOX::CPath(L"/word"), OOX::CPath(L"document.xml"));
oContentTypes.Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", OOX::CPath(L"/word"), OOX::CPath(L"styles.xml"));
oContentTypes.Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", OOX::CPath(L"/word"), OOX::CPath(L"settings.xml"));
oContentTypes.Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml", OOX::CPath(L"/word"), OOX::CPath(L"webSettings.xml"));
oContentTypes.Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml", OOX::CPath(L"/word"), OOX::CPath(L"fontTable.xml"));
oContentTypes.Registration(L"application/vnd.openxmlformats-officedocument.theme+xml", OOX::CPath(L"/word/theme"), OOX::CPath(L"theme1.xml"));
oContentTypes.Write(strDirectory);
} }
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