Compare commits

...

4 Commits

5 changed files with 90 additions and 37 deletions

View File

@ -155,7 +155,8 @@ extern int g_nCurFormatVersion;
Footnotes = 10,
Endnotes = 11,
Background = 12,
VbaProject = 13
VbaProject = 13,
App = 14
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
@ -1021,6 +1022,11 @@ extern int g_nCurFormatVersion;
PrEndPos = 10,
PrRef = 11
};}
namespace c_oSerApp{enum c_oSerApp
{
Application = 0,
AppVersion = 1
};}
namespace c_oSerDocPr{enum c_oSerDocPr
{
Id = 0,

View File

@ -60,6 +60,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/HeaderFooter.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
namespace BinDocxRW
{
@ -7762,6 +7763,38 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
};
class BinaryAppTableWriter
{
BinaryCommonWriter m_oBcw;
ParamsWriter& m_oParamsWriter;
public:
BinaryAppTableWriter(ParamsWriter& oParamsWriter):
m_oBcw(oParamsWriter),m_oParamsWriter(oParamsWriter)
{
}
void Write(OOX::CApp& oApp)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteProperties(oApp);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteProperties(OOX::CApp& oApp)
{
int nCurPos = 0;
if (oApp.m_sApplication.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::Application);
m_oBcw.m_oStream.WriteStringW3(oApp.m_sApplication.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oApp.m_sAppVersion.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::AppVersion);
m_oBcw.m_oStream.WriteStringW3(oApp.m_sAppVersion.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
class BinaryFileWriter
{
BinaryCommonWriter m_oBcw;
@ -7907,6 +7940,15 @@ namespace BinDocxRW
this->WriteTableEnd(nCurPos);
}
//Write App
if(NULL != oDocx.m_pApp)
{
BinDocxRW::BinaryAppTableWriter oBinaryAppWriter(m_oParamsWriter);
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::App);
oBinaryAppWriter.Write(*oDocx.m_pApp);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, oDocx.m_pDocument, &m_oParamsWriter.m_mapIgnoreComments);
//Write DocumentTable

View File

@ -80,19 +80,19 @@ public:
if( m_ooxAnchor->m_oSimplePos.IsInit())
{
pOutput->m_nLeft = (int)m_ooxAnchor->m_oSimplePos->m_oX.ToTwips() ;
pOutput->m_nTop = (int)m_ooxAnchor->m_oSimplePos->m_oY.ToTwips();
nLeft = (int)m_ooxAnchor->m_oSimplePos->m_oX.ToTwips() ;
nTop = (int)m_ooxAnchor->m_oSimplePos->m_oY.ToTwips();
}
if( m_ooxAnchor->m_oExtent.IsInit() )
{
pOutput->m_nWidth = (int)m_ooxAnchor->m_oExtent->m_oCx.ToTwips();
pOutput->m_nHeight = (int)m_ooxAnchor->m_oExtent->m_oCy.ToTwips();
nWidth = (int)m_ooxAnchor->m_oExtent->m_oCx.ToTwips();
nHeight = (int)m_ooxAnchor->m_oExtent->m_oCy.ToTwips();
if( PROP_DEF != pOutput->m_nLeft && PROP_DEF != pOutput->m_nTop )//всегда !!
{
pOutput->m_nRight = pOutput->m_nLeft + pOutput->m_nWidth;
pOutput->m_nBottom = pOutput->m_nTop + pOutput->m_nHeight;
pOutput->m_nRight = pOutput->m_nLeft + nWidth;
pOutput->m_nBottom = pOutput->m_nTop + nHeight;
}
}
if( m_ooxAnchor->m_oPositionH.IsInit() )

View File

@ -292,15 +292,15 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
{
if (m_arrElement == NULL) return false;
for (std::vector<OOX::WritingElement*>::iterator it = m_arrElement->m_arrItems.begin(); it != m_arrElement->m_arrItems.end(); ++it)
for (size_t i = 0; i < m_arrElement->m_arrItems.size(); i++ )
{
if ((*it) == NULL) continue;
if (m_arrElement->m_arrItems[i] == NULL) continue;
switch((*it)->getType())
switch(m_arrElement->m_arrItems[i]->getType())
{
case OOX::et_v_fill:
{
OOX::Vml::CFill* fill = dynamic_cast<OOX::Vml::CFill*>(*it);
OOX::Vml::CFill* fill = dynamic_cast<OOX::Vml::CFill*>(m_arrElement->m_arrItems[i]);
if (!fill) break;
std::wstring srId = fill->m_sId.IsInit() ? fill->m_sId.get2() : L"" ;
@ -376,7 +376,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
}break;
case OOX::et_v_stroke:
{
OOX::Vml::CStroke* stroke = dynamic_cast<OOX::Vml::CStroke*>(*it);
OOX::Vml::CStroke* stroke = dynamic_cast<OOX::Vml::CStroke*>(m_arrElement->m_arrItems[i]);
if (!stroke) break;
pOutput->m_nLineDashing = stroke->m_oDahsStyle.GetValue(); //совпадают значения
@ -385,7 +385,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
}break;
case OOX::et_v_imagedata:
{
OOX::Vml::CImageData* image_data = dynamic_cast<OOX::Vml::CImageData*>(*it);
OOX::Vml::CImageData* image_data = dynamic_cast<OOX::Vml::CImageData*>(m_arrElement->m_arrItems[i]);
if (!image_data) break;
std::wstring srId = image_data->m_oId.IsInit() ? image_data->m_oId.get2() : L"" ;
@ -464,7 +464,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
}break;
case OOX::et_wd_wrap:
{
OOX::VmlWord::CWrap *wrap = dynamic_cast<OOX::VmlWord::CWrap*>(*it);
OOX::VmlWord::CWrap *wrap = dynamic_cast<OOX::VmlWord::CWrap*>(m_arrElement->m_arrItems[i]);
if (wrap->m_oType.IsInit() && pOutput->m_nZOrderRelative == PROP_DEF)
{
@ -490,16 +490,15 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
}break;
case OOX::et_v_textbox:
{
OOX::Vml::CTextbox *text_box= dynamic_cast<OOX::Vml::CTextbox*>(*it);
OOX::Vml::CTextbox *text_box= dynamic_cast<OOX::Vml::CTextbox*>(m_arrElement->m_arrItems[i]);
if ((text_box) && (text_box->m_oTxtbxContent.IsInit()))
{
OOXTextItemReader oTextItemReader;
for (std::vector<OOX::WritingElement*>::iterator it = text_box->m_oTxtbxContent->m_arrItems.begin();
it != text_box->m_oTxtbxContent->m_arrItems.end(); ++it)
for (size_t i = 0; i < text_box->m_oTxtbxContent->m_arrItems.size(); i++)
{
oTextItemReader.Parse( *it, oParam );
oTextItemReader.Parse( text_box->m_oTxtbxContent->m_arrItems[i], oParam );
}
if( oTextItemReader.m_oTextItems->GetCount() > 0 )
@ -508,7 +507,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
}break;
case OOX::et_v_textpath:
{
OOX::Vml::CTextPath *text_path= dynamic_cast<OOX::Vml::CTextPath*>(*it);
OOX::Vml::CTextPath *text_path= dynamic_cast<OOX::Vml::CTextPath*>(m_arrElement->m_arrItems[i]);
if (text_path)
{
pOutput->m_bGtext = 1;
@ -534,7 +533,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
}break;
case OOX::et_o_signatureline:
{
OOX::VmlOffice::CSignatureLine *signature = dynamic_cast<OOX::VmlOffice::CSignatureLine*>(*it);
OOX::VmlOffice::CSignatureLine *signature = dynamic_cast<OOX::VmlOffice::CSignatureLine*>(m_arrElement->m_arrItems[i]);
if ( signature )
{
if (signature->m_oIsSignatureLine.IsInit() && signature->m_oIsSignatureLine->ToBool())
@ -1414,12 +1413,21 @@ bool OOXShapeReader::ParsePic( ReaderParameter oParam, RtfShapePtr& pOutput)
sOlePath= pOleFile->filename().GetPath();
}
}
if (pOutput->m_pOleObject->m_nWidth == PROP_DEF)
{
if (pOutput->m_nWidth == PROP_DEF)
{
pOutput->m_nWidth = pOutput->m_nRight - pOutput->m_nLeft;
}
pOutput->m_pOleObject->m_nWidth = pOutput->m_nWidth;
}
if (pOutput->m_pOleObject->m_nHeight == PROP_DEF)
{
if (pOutput->m_nHeight == PROP_DEF)
{
pOutput->m_nHeight = pOutput->m_nBottom - pOutput->m_nTop;
}
pOutput->m_pOleObject->m_nHeight = pOutput->m_nHeight;
}
if (!sOlePath.empty())

View File

@ -465,20 +465,6 @@ namespace NSCommon
if (pManager->m_pFont)
{
bIsSymbol = (-1 != (pManager->m_pFont->m_nSymbolic)) ? TRUE : FALSE;
if (!bIsSymbol)
{
TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pManager->m_pFont->m_pFace, ft_sfnt_os2);
int y = 0;
++y;
if (NULL != pOS2)
{
if (0 == (pOS2->ulCodePageRange1 & 0xF0000000))
bIsSymbol = TRUE;
}
}
}
std::wstring sFontName = pPair->second.m_sName;
@ -499,9 +485,20 @@ namespace NSCommon
{
CFontFile* pFontCheck = pManager->m_pFont;
int nCMapIndex = 0;
int unGID = pFontCheck->SetCMapForCharCode(sFontName.at(0), &nCMapIndex);
if (unGID <= 0)
int nFontNameLen = (int)sFontName.length();
bool bIsPresentAll = true;
for (int nC = 0; nC < nFontNameLen; nC++)
{
int nCMapIndex = 0;
if (0 >= pFontCheck->SetCMapForCharCode(sFontName.at(nC), &nCMapIndex))
{
bIsPresentAll = false;
break;
}
}
if (!bIsPresentAll)
{
CFontSelectFormat oSelectFormat;
oSelectFormat.wsName = new std::wstring(L"Arial");