mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-02 19:31:54 +08:00
Compare commits
18 Commits
core-linux
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| bc67fc8e55 | |||
| 4aae1b21e9 | |||
| ae69f892f1 | |||
| bdd4b68f43 | |||
| a9a674c895 | |||
| ed575b3b68 | |||
| 016d46d030 | |||
| 486685e4b4 | |||
| 26a6a77b8d | |||
| 90aa7973ed | |||
| b2363c02c0 | |||
| 32b59120aa | |||
| 7186b56b64 | |||
| 6247490047 | |||
| f30e14c421 | |||
| e340a2af22 | |||
| 6a5cddf0ce | |||
| 312728fe9a |
@ -171,7 +171,7 @@ namespace DocFileFormat
|
||||
if ( (*iter)->tapx != NULL )
|
||||
{
|
||||
std::vector<short> tableGrid;
|
||||
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, false);
|
||||
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, NULL, false);
|
||||
(*iter)->tapx->Convert( tpMapping );
|
||||
RELEASEOBJECT( tpMapping );
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -99,6 +99,9 @@ namespace PPTX
|
||||
SpTreeElem element;
|
||||
|
||||
std::wstring GetVmlXmlBySpid(smart_ptr<OOX::IFileContainer> & rels) const;
|
||||
|
||||
void ChartToOlePackageInStorage(OOX::IFileContainer* pRels, const std::wstring &sTempDirectory, const std::wstring &sOleFileName);
|
||||
std::wstring ChartToXlsx(OOX::IFileContainer* pRels, const std::wstring &sTempDirectory);
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds();
|
||||
};
|
||||
|
||||
@ -38,77 +38,105 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
HRESULT ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name)
|
||||
void ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name)
|
||||
{
|
||||
HRESULT hr = S_FALSE;
|
||||
|
||||
Ole1FormatReader ole1Reader(pData, nSize);
|
||||
Ole1FormatReaderWriter ole1Reader(pData, nSize);
|
||||
|
||||
bool bResult = false;
|
||||
if (ole1Reader.NativeDataSize > 0)
|
||||
{
|
||||
POLE::Storage * storageOut = new POLE::Storage(sOle2Name.c_str());
|
||||
if ( (storageOut) && (storageOut->open(true, true)))
|
||||
NSFile::CFileBinary file;
|
||||
|
||||
file.CreateFileW(sOle2Name);
|
||||
file.WriteFile(ole1Reader.NativeData, ole1Reader.NativeDataSize);
|
||||
file.CloseFile();
|
||||
|
||||
POLE::Storage * storageIn = new POLE::Storage(sOle2Name.c_str());
|
||||
if ( (storageIn) && (storageIn->open(false, false))) //storage in storage
|
||||
{
|
||||
_UINT32 tmp = 0;
|
||||
std::string name = ole1Reader.Header.ClassName.val;
|
||||
_UINT32 name_size = name.length() + 1;
|
||||
//Ole
|
||||
BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||
POLE::Stream oStream3(storageOut, L"\001Ole", true, 20);
|
||||
oStream3.write(dataOleInfo, 20);
|
||||
oStream3.flush();
|
||||
//CompObj
|
||||
BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x0a,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
|
||||
POLE::Stream oStream1(storageOut, L"\001CompObj", true, 28 + (name_size + 5) + 2 * (ole1Reader.Header.ClassName.size + 4) + 4 * 4);
|
||||
oStream1.write(dataCompObjHeader, 28);
|
||||
//test package stream??? xls ole -> xlsx ole
|
||||
bResult = true;
|
||||
storageIn->close();
|
||||
}
|
||||
delete storageIn;
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
POLE::Storage * storageOut = new POLE::Storage(sOle2Name.c_str());
|
||||
if ( (storageOut) && (storageOut->open(true, true)))
|
||||
{
|
||||
_UINT32 tmp = 0;
|
||||
std::string name = ole1Reader.Header.ClassName.val;
|
||||
_UINT32 name_size = name.length() + 1;
|
||||
//Ole
|
||||
BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||
POLE::Stream oStream3(storageOut, L"\001Ole", true, 20);
|
||||
oStream3.write(dataOleInfo, 20);
|
||||
oStream3.flush();
|
||||
//CompObj
|
||||
BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x0a,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
|
||||
POLE::Stream oStream1(storageOut, L"\001CompObj", true, 28 + (name_size + 5) + 2 * (ole1Reader.Header.ClassName.size + 4) + 4 * 4);
|
||||
oStream1.write(dataCompObjHeader, 28);
|
||||
|
||||
oStream1.write((BYTE*)&name_size, 4);
|
||||
oStream1.write((BYTE*)name.c_str(), name_size);
|
||||
oStream1.write((BYTE*)&name_size, 4);
|
||||
oStream1.write((BYTE*)name.c_str(), name_size);
|
||||
|
||||
//oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
|
||||
//oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
|
||||
//oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
|
||||
//oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
|
||||
|
||||
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
|
||||
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
|
||||
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
|
||||
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
|
||||
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
|
||||
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
|
||||
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
|
||||
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
|
||||
|
||||
tmp = 0x71B239F4;
|
||||
oStream1.write((BYTE*)&tmp, 4); // UnicodeMarker
|
||||
tmp = 0x71B239F4;
|
||||
oStream1.write((BYTE*)&tmp, 4); // UnicodeMarker
|
||||
|
||||
tmp = 0;
|
||||
oStream1.write((BYTE*)&tmp, 4); // UnicodeUserType
|
||||
oStream1.write((BYTE*)&tmp, 4); // UnicodeClipboardFormat
|
||||
oStream1.write((BYTE*)&tmp, 4); //
|
||||
oStream1.flush();
|
||||
tmp = 0;
|
||||
oStream1.write((BYTE*)&tmp, 4); // UnicodeUserType
|
||||
oStream1.write((BYTE*)&tmp, 4); // UnicodeClipboardFormat
|
||||
oStream1.write((BYTE*)&tmp, 4); //
|
||||
oStream1.flush();
|
||||
|
||||
//ObjInfo
|
||||
BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x04,0x00};
|
||||
POLE::Stream oStream2(storageOut, L"\003ObjInfo", true, 6);
|
||||
oStream2.write(dataObjInfo, 6);
|
||||
oStream2.flush();
|
||||
//Ole10Native
|
||||
POLE::Stream streamData(storageOut, L"\001Ole10Native", true, ole1Reader.NativeDataSize + 4);
|
||||
streamData.write((BYTE*)&ole1Reader.NativeDataSize, 4);
|
||||
streamData.write(ole1Reader.NativeData, ole1Reader.NativeDataSize);
|
||||
streamData.flush();
|
||||
//ObjInfo
|
||||
BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x04,0x00};
|
||||
POLE::Stream oStream2(storageOut, L"\003ObjInfo", true, 6);
|
||||
oStream2.write(dataObjInfo, 6);
|
||||
oStream2.flush();
|
||||
//Ole10Native
|
||||
POLE::Stream streamData(storageOut, L"\001Ole10Native", true, ole1Reader.NativeDataSize + 4);
|
||||
streamData.write((BYTE*)&ole1Reader.NativeDataSize, 4);
|
||||
|
||||
storageOut->close();
|
||||
delete storageOut;
|
||||
_UINT32 sz_write = 0;
|
||||
_UINT32 sz = 4096;
|
||||
while (sz_write < ole1Reader.NativeDataSize)
|
||||
{
|
||||
if (sz_write + sz > ole1Reader.NativeDataSize)
|
||||
sz = ole1Reader.NativeDataSize - sz_write;
|
||||
streamData.write(ole1Reader.NativeData + sz_write, sz);
|
||||
sz_write += sz;
|
||||
}
|
||||
streamData.flush();
|
||||
|
||||
storageOut->close();
|
||||
delete storageOut;
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //conv_NI38P7GBIpw1aD84H3k.rtf
|
||||
if (!bResult) //conv_NI38P7GBIpw1aD84H3k.rtf
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
|
||||
file.CreateFileW(sOle2Name);
|
||||
file.WriteFile(pData, nSize);
|
||||
file.CloseFile();
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
return S_FALSE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
||||
bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
|
||||
{
|
||||
if ( "ansi" == sCommand ) oDocument.m_oProperty.m_eCodePage = RtfDocumentProperty::cp_ansi;
|
||||
@ -1259,61 +1287,22 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
|
||||
COMMAND_RTF_INT ( "trqr", rowProps->m_eJust, sCommand, true, RtfRowProperty::rj_trqr )
|
||||
COMMAND_RTF_INT ( "trqc", rowProps->m_eJust, sCommand, true, RtfRowProperty::rj_trqc )
|
||||
|
||||
COMMAND_RTF_INT ( "trrh", rowProps->m_nHeight, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trrh", rowProps->m_nHeight, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "trftsWidth", rowProps->m_eWidthUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trwWidth", rowProps->m_nWidth, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "trftsWidthB", rowProps->m_eWidthStartInvCellUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trwWidthB", rowProps->m_nWidthStartInvCell, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "trftsWidthA", rowProps->m_eWidthEndInvCellUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trwWidthA", rowProps->m_nWidthEndInvCell, sCommand, hasParameter, parameter )
|
||||
|
||||
else if ( "trftsWidth" == sCommand )
|
||||
{
|
||||
if ( hasParameter )
|
||||
{
|
||||
switch( parameter )
|
||||
{
|
||||
case 0: rowProps->m_eWidthUnit = mu_none; break;
|
||||
case 1: rowProps->m_eWidthUnit = mu_Auto; break;
|
||||
case 2: rowProps->m_eWidthUnit = mu_Percent; break;
|
||||
case 3: rowProps->m_eWidthUnit = mu_Twips; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
COMMAND_RTF_INT ( "trwWidth", rowProps->m_nWidth, sCommand, hasParameter, parameter )
|
||||
else if ( "trftsWidthB" == sCommand )
|
||||
{
|
||||
if ( hasParameter )
|
||||
{
|
||||
switch( parameter )
|
||||
{
|
||||
case 0: rowProps->m_eMUStartInvCell = mu_none; break;
|
||||
case 1: rowProps->m_eMUStartInvCell = mu_Auto; break;
|
||||
case 2: rowProps->m_eMUStartInvCell = mu_Percent; break;
|
||||
case 3: rowProps->m_eMUStartInvCell = mu_Twips; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
COMMAND_RTF_INT ( "trwWidthB", rowProps->m_nWidthStartInvCell, sCommand, hasParameter, parameter )
|
||||
else if ( "trftsWidthA" == sCommand )
|
||||
{
|
||||
if ( hasParameter )
|
||||
{
|
||||
switch( parameter )
|
||||
{
|
||||
case 0: rowProps->m_eMUEndInvCell = mu_none; break;
|
||||
case 1: rowProps->m_eMUEndInvCell = mu_Auto; break;
|
||||
case 2: rowProps->m_eMUEndInvCell = mu_Percent; break;
|
||||
case 3: rowProps->m_eMUEndInvCell = mu_Twips; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
COMMAND_RTF_INT ( "trwWidthA", rowProps->m_nWidthEndInvCell, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_BOOL( "taprtl", rowProps->m_bBidi, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trautofit", rowProps->m_nAutoFit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trgaph", rowProps->m_nGraph, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "tblind", rowProps->nTableIndent, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "tblindtype", rowProps->nTableIndentUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "tblindtype", rowProps->eTableIndentUnit, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "tdfrmtxtLeft", rowProps->m_nWrapLeft, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "tdfrmtxtRight", rowProps->m_nWrapRight, sCommand, hasParameter, parameter )
|
||||
@ -1352,7 +1341,9 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
|
||||
if ( PROP_DEF == rowProps->nTableIndent )
|
||||
{
|
||||
rowProps->nTableIndent = parameter;
|
||||
rowProps->nTableIndentUnits = 3;
|
||||
|
||||
if ( PROP_DEF == rowProps->eTableIndentUnit )
|
||||
rowProps->eTableIndentUnit = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1376,20 +1367,21 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
|
||||
COMMAND_RTF_INT ( "trpaddl", rowProps->m_nDefCellMarLeft, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddr", rowProps->m_nDefCellMarRight, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddt", rowProps->m_nDefCellMarTop, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddfb", rowProps->m_nDefCellMarBottomUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddfl", rowProps->m_nDefCellMarLeftUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddfr", rowProps->m_nDefCellMarRightUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddft", rowProps->m_nDefCellMarTopUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddfb", rowProps->m_eDefCellMarBottomUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddfl", rowProps->m_eDefCellMarLeftUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddfr", rowProps->m_eDefCellMarRightUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trpaddft", rowProps->m_eDefCellMarTopUnit, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "trspdb", rowProps->m_nDefCellSpBottom, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdl", rowProps->m_nDefCellSpLeft, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdr", rowProps->m_nDefCellSpRight, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdt", rowProps->m_nDefCellSpTop, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdfb", rowProps->m_nDefCellSpBottomUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdfl", rowProps->m_nDefCellSpLeftUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdfr", rowProps->m_nDefCellSpRightUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdft", rowProps->m_nDefCellSpTopUnits, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdfb", rowProps->m_eDefCellSpBottomUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdfl", rowProps->m_eDefCellSpLeftUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdfr", rowProps->m_eDefCellSpRightUnit, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "trspdft", rowProps->m_eDefCellSpTopUnit, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "ts", rowProps->m_nStyle, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "ts", rowProps->m_nStyle, sCommand, hasParameter, parameter )
|
||||
|
||||
COMMAND_RTF_INT ( "tbllkhdrrows", rowProps->m_bAutoFirstRow, sCommand, hasParameter, parameter )
|
||||
COMMAND_RTF_INT ( "tbllklastrow", rowProps->m_bAutoLastRow, sCommand, hasParameter, parameter )
|
||||
@ -1807,48 +1799,15 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
|
||||
|
||||
if ( 0 != nSize && pData)
|
||||
{
|
||||
HRESULT hRes = S_FALSE;
|
||||
boost::shared_array<BYTE> buffer(pData);
|
||||
m_oOle.m_oOle1Data = std::make_pair(buffer, nSize);
|
||||
|
||||
//конвертация Ole1 в Ole2
|
||||
#if 0//defined(_WIN32) || defined(_WIN64)
|
||||
RtfOle1ToOle2Stream oStream;
|
||||
|
||||
oStream.lpstbl = new OLESTREAMVTBL();
|
||||
oStream.lpstbl->Get = &OleGet1;
|
||||
oStream.lpstbl->Put = &OlePut1;
|
||||
|
||||
oStream.pBuffer = pData;
|
||||
oStream.nBufferSize = nSize;
|
||||
oStream.nCurPos = 0;
|
||||
|
||||
std::wstring sOleStorageName = Utils::CreateTempFile( oReader.m_sTempFolder );
|
||||
|
||||
IStorage* piMSStorage = NULL;
|
||||
if ( SUCCEEDED( StgCreateDocfile( sOleStorageName.c_str(), STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED/* | STGM_DELETEONRELEASE*/, NULL, &piMSStorage) ) )
|
||||
{
|
||||
hRes = OleConvertOLESTREAMToIStorage( &oStream, piMSStorage, NULL );
|
||||
piMSStorage->Commit( STGC_DEFAULT );
|
||||
RELEASEINTERFACE( piMSStorage );
|
||||
}
|
||||
delete oStream.lpstbl;
|
||||
#else
|
||||
std::wstring sOleStorageName = NSDirectory::CreateTempFileWithUniqueName(oReader.m_sTempFolder, L"img");
|
||||
|
||||
hRes = ConvertOle1ToOle2(pData, nSize, sOleStorageName);
|
||||
|
||||
#endif
|
||||
delete[] pData;
|
||||
|
||||
POLE::Storage * piRootStorage = new POLE::Storage(sOleStorageName.c_str());
|
||||
if ( piRootStorage)
|
||||
{
|
||||
m_oOle.SetFilename( sOleStorageName.c_str() );
|
||||
m_oOle.SetOle( piRootStorage );
|
||||
hRes = S_OK;
|
||||
}
|
||||
|
||||
if ( hRes != S_OK )
|
||||
Utils::RemoveDirOrFile( sOleStorageName.c_str() );
|
||||
//конвертация Ole1 в Ole2
|
||||
ConvertOle1ToOle2(pData, nSize, sOleStorageName);
|
||||
|
||||
m_oOle.SetFilename( sOleStorageName.c_str() );
|
||||
}
|
||||
}
|
||||
else if ( "result" == sCommand )
|
||||
@ -1858,7 +1817,7 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
|
||||
RtfAllPictReader oAllPictReader( *oNewShape );
|
||||
StartSubReader( oAllPictReader, oDocument, oReader );
|
||||
|
||||
m_oOle.m_oResultPic = oNewShape;
|
||||
m_oOle.m_oResultShape = oNewShape;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@ -2053,6 +2012,7 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt
|
||||
else if ( L"txdir" == m_sPropName ) m_oShape.m_nTxdir = nValue;
|
||||
else if ( L"fFitShapeToText"== m_sPropName ) m_oShape.m_bFitShapeToText = nValue;
|
||||
else if ( L"fFitTextToShape"== m_sPropName ) m_oShape.m_bFitTextToShape = nValue;
|
||||
else if ( L"fRotateText" == m_sPropName ) m_oShape.m_fRotateText = nValue;
|
||||
|
||||
//Geometry
|
||||
else if ( L"adjustValue" == m_sPropName ) m_oShape.m_nAdjustValue[0] = nValue;
|
||||
@ -2173,8 +2133,8 @@ bool RtfTrackerChangesReader::ExecuteCommand(RtfDocument& oDocument, RtfReader&
|
||||
else if ( "clbrdrr" == sCommand ) m_eInternalState = is_borderCellRight;
|
||||
else if ( "clbrdrb" == sCommand ) m_eInternalState = is_borderCellBottom;
|
||||
|
||||
else if ( "tsbrdrdgl" == sCommand ) m_eInternalState = is_borderCellLR;
|
||||
else if ( "tsbrdrdgr" == sCommand ) m_eInternalState = is_borderCellRL;
|
||||
else if ( "tsbrdrdgl" == sCommand ) m_eInternalState = is_borderCellLR;
|
||||
else if ( "tsbrdrdgr" == sCommand ) m_eInternalState = is_borderCellRL;
|
||||
|
||||
else if ( "trbrdrl" == sCommand ) m_eInternalState = is_borderRowLeft;
|
||||
else if ( "trbrdrr" == sCommand ) m_eInternalState = is_borderRowRight;
|
||||
@ -2182,7 +2142,8 @@ bool RtfTrackerChangesReader::ExecuteCommand(RtfDocument& oDocument, RtfReader&
|
||||
else if ( "trbrdrb" == sCommand ) m_eInternalState = is_borderRowBottom;
|
||||
else if ( "trbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
|
||||
else if ( "trbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
|
||||
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
|
||||
|
||||
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
|
||||
else if ( "tsbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
|
||||
else if ( "tsbrdrl" == sCommand ) m_eInternalState = is_borderRowLeft;
|
||||
else if ( "tsbrdrt" == sCommand ) m_eInternalState = is_borderRowTop;
|
||||
@ -2957,9 +2918,9 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
|
||||
else if ( "brdrb" == sCommand ) m_eInternalState = is_borderBottom;
|
||||
else if ( "brdrl" == sCommand ) m_eInternalState = is_borderLeft;
|
||||
else if ( "brdrr" == sCommand ) m_eInternalState = is_borderRight;
|
||||
//else if ( "brdrbtw" == sCommand ) m_eInternalState = is_borderRight;
|
||||
//else if ( "brdrbtw" == sCommand ) m_eInternalState = is_borderRight;
|
||||
else if ( "brdrbar" == sCommand ) m_eInternalState = is_borderBar;
|
||||
else if ( "box" == sCommand ) m_eInternalState = is_borderBox;
|
||||
else if ( "box" == sCommand ) m_eInternalState = is_borderBox;
|
||||
|
||||
else if ( "cldglu" == sCommand ) m_eInternalState = is_borderCellLR;
|
||||
else if ( "cldgll" == sCommand ) m_eInternalState = is_borderCellRL;
|
||||
@ -2977,7 +2938,8 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
|
||||
else if ( "trbrdrb" == sCommand ) m_eInternalState = is_borderRowBottom;
|
||||
else if ( "trbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
|
||||
else if ( "trbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
|
||||
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
|
||||
|
||||
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
|
||||
else if ( "tsbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
|
||||
else if ( "tsbrdrl" == sCommand ) m_eInternalState = is_borderRowLeft;
|
||||
else if ( "tsbrdrt" == sCommand ) m_eInternalState = is_borderRowTop;
|
||||
|
||||
@ -1148,12 +1148,16 @@ public:
|
||||
RtfShapeReader oShapeReader(m_oShape);
|
||||
StartSubReader( oShapeReader, oDocument, oReader );
|
||||
}
|
||||
if( "shppict" == sCommand )
|
||||
else if( "shppict" == sCommand )
|
||||
{
|
||||
RtfShppictReader oShppictReader(m_oShape);
|
||||
StartSubReader( oShppictReader, oDocument, oReader );
|
||||
}
|
||||
else if( "pict" == sCommand )
|
||||
else if( "nonshppict" == sCommand )
|
||||
{
|
||||
Skip( oDocument, oReader );
|
||||
}
|
||||
else if( "pict" == sCommand )
|
||||
{
|
||||
m_oShape.m_eAnchorTypeShape = RtfShape::st_inline;
|
||||
m_oShape.m_nShapeType = NSOfficeDrawing::sptPictureFrame;
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
return pCur;
|
||||
}
|
||||
|
||||
unsigned char ReadUChar()
|
||||
unsigned char ReadUChar()
|
||||
{
|
||||
if (pCur + 1 >= pEnd)
|
||||
return 0;
|
||||
@ -67,6 +67,14 @@ public:
|
||||
pCur++;
|
||||
return unResult;
|
||||
};
|
||||
void WriteUChar(unsigned char val)
|
||||
{
|
||||
if (pCur + 1 >= pEnd)
|
||||
return;
|
||||
|
||||
pCur[0] = val;
|
||||
pCur++;
|
||||
};
|
||||
unsigned short ReadUShort()
|
||||
{
|
||||
if (pCur + 2 >= pEnd)
|
||||
@ -76,15 +84,31 @@ public:
|
||||
pCur += 2;
|
||||
return ushResult;
|
||||
};
|
||||
unsigned int ReadULong()
|
||||
void WriteUShort(unsigned short val)
|
||||
{
|
||||
if (pCur + 2 >= pEnd)
|
||||
return;
|
||||
|
||||
((unsigned short*) pCur)[0] = val;
|
||||
pCur += 2;
|
||||
};
|
||||
_UINT32 ReadULong()
|
||||
{
|
||||
if (pCur + 4 >= pEnd)
|
||||
return 0;
|
||||
|
||||
unsigned int unResult = (unsigned int)((pCur[0] << 0) | ((pCur[1]) << 8) | ((pCur[2]) << 16) | ((pCur[3]) << 24));
|
||||
_UINT32 unResult = (_UINT32)((pCur[0] << 0) | ((pCur[1]) << 8) | ((pCur[2]) << 16) | ((pCur[3]) << 24));
|
||||
pCur += 4;
|
||||
return unResult;
|
||||
};
|
||||
void WriteULong(_UINT32 val)
|
||||
{
|
||||
if (pCur + 4 >= pEnd)
|
||||
return;
|
||||
|
||||
((_UINT32*)pCur)[0] = val;
|
||||
pCur += 4;
|
||||
};
|
||||
double ReadDouble()
|
||||
{
|
||||
if (pCur + 4 >= pEnd)
|
||||
@ -110,13 +134,25 @@ public:
|
||||
{
|
||||
return (char)ReadUChar();
|
||||
};
|
||||
short ReadShort()
|
||||
void WriteChar(char val)
|
||||
{
|
||||
WriteUChar((unsigned char)val);
|
||||
};
|
||||
short ReadShort()
|
||||
{
|
||||
return (short)ReadUShort();
|
||||
};
|
||||
int ReadLong()
|
||||
void WriteShort(short val)
|
||||
{
|
||||
return (int)ReadULong();
|
||||
WriteUShort((unsigned short) val);
|
||||
};
|
||||
_INT32 ReadLong()
|
||||
{
|
||||
return (_INT32)ReadULong();
|
||||
};
|
||||
void WriteLong(_INT32 val)
|
||||
{
|
||||
WriteULong((_UINT32)val);
|
||||
};
|
||||
void ReadBytes(char* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
@ -128,6 +164,16 @@ public:
|
||||
pBuffer[ulIndex] = ReadChar();
|
||||
}
|
||||
};
|
||||
void WriteBytes(char* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
size_t ulRemainSize = (pEnd - pCur);
|
||||
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
|
||||
|
||||
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
|
||||
{
|
||||
WriteChar(pBuffer[ulIndex]);
|
||||
}
|
||||
};
|
||||
void ReadBytes(unsigned char* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
size_t ulRemainSize = (pEnd - pCur);
|
||||
@ -135,7 +181,17 @@ public:
|
||||
|
||||
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
|
||||
{
|
||||
pBuffer[ulIndex] = ReadChar();
|
||||
pBuffer[ulIndex] = ReadUChar();
|
||||
}
|
||||
};
|
||||
void WriteBytes(unsigned char* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
size_t ulRemainSize = (pEnd - pCur);
|
||||
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
|
||||
|
||||
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
|
||||
{
|
||||
WriteUChar(pBuffer[ulIndex]);
|
||||
}
|
||||
};
|
||||
void ReadBytes(unsigned short* pBuffer, unsigned int ulSize)
|
||||
@ -158,7 +214,7 @@ public:
|
||||
pBuffer[ulIndex] = ReadShort();
|
||||
}
|
||||
}
|
||||
void ReadBytes(unsigned int* pBuffer, unsigned int ulSize)
|
||||
void ReadBytes(_UINT32* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
size_t ulRemainSize = (pEnd - pCur) / 4;
|
||||
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
|
||||
@ -173,22 +229,32 @@ public:
|
||||
nValue = ReadUChar();
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator<<(unsigned char nValue)
|
||||
{
|
||||
WriteUChar(nValue);
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(unsigned short& nValue)
|
||||
{
|
||||
nValue = ReadUShort();
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(unsigned int& nValue)
|
||||
CDataStream& operator<<(unsigned short nValue)
|
||||
{
|
||||
WriteUShort(nValue);
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(_UINT32& nValue)
|
||||
{
|
||||
nValue = ReadULong();
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(unsigned long& nValue)
|
||||
CDataStream& operator<<(_UINT32 nValue)
|
||||
{
|
||||
nValue = ReadULong();
|
||||
WriteULong(nValue);
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(double& dValue)
|
||||
CDataStream& operator>>(double& dValue)
|
||||
{
|
||||
dValue = ReadDouble();
|
||||
return *this;
|
||||
@ -198,6 +264,11 @@ public:
|
||||
nValue = ReadChar();
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator<<(char nValue)
|
||||
{
|
||||
WriteChar(nValue);
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(bool& nValue)
|
||||
{
|
||||
nValue = !!ReadChar();
|
||||
@ -208,17 +279,23 @@ public:
|
||||
nValue = ReadShort();
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(int& nValue)
|
||||
CDataStream& operator<<(short nValue)
|
||||
{
|
||||
WriteShort(nValue);
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(_INT32& nValue)
|
||||
{
|
||||
nValue = ReadLong();
|
||||
return *this;
|
||||
}
|
||||
CDataStream& operator>>(long& nValue)
|
||||
CDataStream& operator<<(_INT32 nValue)
|
||||
{
|
||||
nValue = ReadLong();
|
||||
WriteLong(nValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
if (NULL == pBuffer)
|
||||
@ -255,7 +332,7 @@ public:
|
||||
pCur = pBuffer;
|
||||
}
|
||||
|
||||
unsigned int CanRead()
|
||||
unsigned int CanReadWrite()
|
||||
{
|
||||
return (unsigned int)(pEnd - pCur);
|
||||
}
|
||||
@ -269,36 +346,55 @@ private:
|
||||
};
|
||||
struct LengthPrefixedAnsiString
|
||||
{
|
||||
_UINT32 size;
|
||||
_UINT32 size = 0;
|
||||
std::string val;
|
||||
};
|
||||
CDataStream & operator >> (CDataStream & strm, LengthPrefixedAnsiString & str)
|
||||
static CDataStream & operator >> (CDataStream & strm, LengthPrefixedAnsiString & str)
|
||||
{
|
||||
strm >> str.size;
|
||||
char *s = new char[str.size];
|
||||
strm.ReadBytes(s, str.size);
|
||||
str.val = std::string(s,str.size);
|
||||
str.val = std::string(s, str.size);
|
||||
delete []s;
|
||||
return strm;
|
||||
}
|
||||
static CDataStream & operator << (CDataStream & strm, LengthPrefixedAnsiString str)
|
||||
{
|
||||
strm << str.size;
|
||||
|
||||
strm.WriteBytes((char*)str.val.c_str(), str.size - 1);
|
||||
strm.WriteUChar(0);
|
||||
return strm;
|
||||
}
|
||||
struct ObjectHeader
|
||||
{
|
||||
_UINT32 OLEVersion;
|
||||
_UINT32 FormatID;
|
||||
_UINT32 OLEVersion = 1281;
|
||||
_UINT32 FormatID = 2;
|
||||
|
||||
LengthPrefixedAnsiString ClassName;
|
||||
|
||||
_UINT32 Width;
|
||||
_UINT32 Height;
|
||||
_UINT32 Width = 0;
|
||||
_UINT32 Height = 0;
|
||||
|
||||
};
|
||||
|
||||
class Ole1FormatReader
|
||||
class Ole1FormatReaderWriter
|
||||
{
|
||||
public:
|
||||
|
||||
Ole1FormatReader(BYTE *pData, int Size)
|
||||
Ole1FormatReaderWriter() : NativeData(NULL), NativeDataSize(0), OtherData(NULL), OtherDataSize(0)
|
||||
{
|
||||
}
|
||||
Ole1FormatReaderWriter(BYTE *pData, int Size) : NativeData(NULL), NativeDataSize(0), OtherData(NULL), OtherDataSize(0)
|
||||
{
|
||||
Read(pData, Size);
|
||||
}
|
||||
virtual ~Ole1FormatReaderWriter()
|
||||
{
|
||||
if (OtherData)
|
||||
delete []OtherData;
|
||||
OtherData = NULL;
|
||||
}
|
||||
void Read(BYTE *pData, int Size)
|
||||
{
|
||||
NativeDataSize = 0;
|
||||
if (!pData || Size < 8) return;
|
||||
@ -320,15 +416,57 @@ public:
|
||||
NativeData = stream.GetCurPtr();
|
||||
stream.Skip(NativeDataSize);
|
||||
|
||||
int sz = stream.CanRead();
|
||||
if (stream.IsEof())
|
||||
return;
|
||||
// далее графическое представление
|
||||
OtherDataSize = stream.CanReadWrite();
|
||||
|
||||
/// далее графическое представление
|
||||
OtherData = new BYTE[OtherDataSize];
|
||||
stream.ReadBytes(OtherData, OtherDataSize);
|
||||
}
|
||||
|
||||
}
|
||||
void Write(BYTE *pData, int &Size)
|
||||
{
|
||||
Size = 0;
|
||||
if (!pData) return;
|
||||
if (NativeDataSize < 1) return;
|
||||
|
||||
CDataStream stream(pData, NativeDataSize + 2048);
|
||||
|
||||
stream << Header.OLEVersion << Header.FormatID;
|
||||
|
||||
stream << Header.ClassName;
|
||||
|
||||
stream << Header.Width << Header.Height;
|
||||
|
||||
stream << NativeDataSize;
|
||||
|
||||
stream.WriteBytes(NativeData, NativeDataSize);
|
||||
|
||||
/// далее графическое представление
|
||||
BYTE other[9] = {1, 5, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
Size = stream.Tell() - 1;
|
||||
stream.WriteBytes(other, 9);
|
||||
Size = stream.Tell() - 1;
|
||||
|
||||
//padding ???
|
||||
|
||||
char padding[8];
|
||||
memset(padding, 0, 8);
|
||||
|
||||
stream.WriteBytes(padding, (Size / 8 + 1 ) * 8 - Size);
|
||||
Size = stream.Tell() - 1;
|
||||
}
|
||||
ObjectHeader Header;
|
||||
|
||||
_UINT32 NativeDataSize;
|
||||
BYTE *NativeData;
|
||||
|
||||
_UINT32 OtherDataSize;
|
||||
BYTE *OtherData;
|
||||
|
||||
//PresentationObjectHeader PresentationHeader;
|
||||
|
||||
};
|
||||
|
||||
@ -53,12 +53,16 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
|
||||
return (shapeReader.Parse(oParam, pOutput) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
if (m_ooxGraphic->chartRec.IsInit())
|
||||
{
|
||||
//сгенерим ole (olePic)
|
||||
std::wstring sOleFileName = L"oleObject" + std::to_wstring(++oParam.oReader->m_nCurOleChartId) + L".bin";
|
||||
m_ooxGraphic->ChartToOlePackageInStorage(oParam.oReader->m_currentContainer, oParam.oReader->m_sTempFolder, sOleFileName);
|
||||
}
|
||||
if (m_ooxGraphic->olePic.IsInit())
|
||||
{
|
||||
pOutput->m_nShapeType = 75;
|
||||
|
||||
OOXShapeReader::Parse(oParam, pOutput, &m_ooxGraphic->olePic->blipFill); // тут если false приходит - картинка-потеряшка
|
||||
return 1;
|
||||
OOXShapeReader shapeReader(m_ooxGraphic->olePic.GetPointer());
|
||||
return (shapeReader.Parse(oParam, pOutput) ? 1 : 0);
|
||||
}
|
||||
if (m_ooxGraphic->smartArt.IsInit())
|
||||
{
|
||||
@ -69,9 +73,10 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
|
||||
return (groupReader.Parse(oParam, pOutput) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//nullable_string spid;
|
||||
//nullable<Table> table;
|
||||
//nullable<ChartRec> chartRec;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -597,142 +597,40 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
|
||||
case OOX::et_w_object:
|
||||
{
|
||||
OOX::Logic::CObject * ooxObject = dynamic_cast<OOX::Logic::CObject*>(ooxItem);
|
||||
|
||||
RtfShapePtr pNewShape ( new RtfShape() );
|
||||
if (ooxObject)
|
||||
{
|
||||
long nOleWidth = PROP_DEF;
|
||||
long nOleHeight = PROP_DEF;
|
||||
|
||||
RtfShapePtr aPictShape;
|
||||
RtfOlePtr oCurOle;
|
||||
|
||||
if (ooxObject->m_oShape.IsInit())
|
||||
{//важна последовательность обработки
|
||||
OOXShapeReader oShapeReaderType(ooxObject->m_oShapeType.GetPointer());
|
||||
oShapeReaderType.Parse( oParam, pNewShape );
|
||||
|
||||
OOXShapeReader oShapeReaderShape(ooxObject->m_oShape.GetPointer());
|
||||
oShapeReaderShape.Parse( oParam, pNewShape );
|
||||
|
||||
for (size_t i = 0; i < ooxObject->m_arrItems.size(); ++i)
|
||||
{
|
||||
RtfShapePtr oNewShape ( new RtfShape() );
|
||||
|
||||
oNewShape->m_eAnchorTypeShape = RtfShape::st_inline;
|
||||
oNewShape->m_oCharProperty = oNewProperty;
|
||||
|
||||
OOXShapeReader oShapeReader(ooxObject->m_oShape.GetPointer());
|
||||
if( true == oShapeReader.Parse( oParam, oNewShape ) )
|
||||
aPictShape = oNewShape;
|
||||
}
|
||||
OOXShapeReader oShapeReader(ooxObject->m_arrItems[i]);
|
||||
oShapeReader.Parse( oParam, pNewShape );
|
||||
}
|
||||
|
||||
if (ooxObject->m_oOleObject.IsInit())
|
||||
{
|
||||
RtfOlePtr oNewOle ( new RtfOle() );
|
||||
|
||||
oNewOle->m_nWidth = nOleWidth; //?? todooo
|
||||
oNewOle->m_nHeight = nOleHeight;
|
||||
|
||||
int nShapeId = PROP_DEF;
|
||||
if (ooxObject->m_oOleObject->m_sShapeId.IsInit())
|
||||
nShapeId = oParam.oReader->m_oOOXIdGenerator.GetId(ooxObject->m_oOleObject->m_sShapeId.get2());
|
||||
|
||||
if( PROP_DEF != nShapeId )
|
||||
{
|
||||
oNewOle->m_nShapeId = nShapeId;
|
||||
//ставим соответствующий shape
|
||||
if( NULL != aPictShape && aPictShape->m_nID == nShapeId )
|
||||
aPictShape->m_bIsOle = true;
|
||||
}
|
||||
if( ooxObject->m_oOleObject->m_sProgId.IsInit() )
|
||||
oNewOle->m_sOleClass = ooxObject->m_oOleObject->m_sProgId.get2();
|
||||
|
||||
if(ooxObject->m_oOleObject->m_oType.IsInit())
|
||||
{
|
||||
switch( ooxObject->m_oOleObject->m_oType->GetValue())
|
||||
{
|
||||
case SimpleTypes::oletypeLink: oNewOle->m_eOleType = RtfOle::ot_link; break;
|
||||
case SimpleTypes::oletypeEmbed: oNewOle->m_eOleType = RtfOle::ot_emb; break;
|
||||
}
|
||||
}
|
||||
if(ooxObject->m_oOleObject->m_oId.IsInit())
|
||||
{
|
||||
std::wstring sRelativePath;
|
||||
|
||||
if (oParam.oReader->m_currentContainer)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(ooxObject->m_oOleObject->m_oId->GetValue());
|
||||
|
||||
if ((oFile.IsInit() && (OOX::FileTypes::OleObject == oFile->type())))
|
||||
{
|
||||
OOX::OleObject* pO = (OOX::OleObject*)oFile.operator->();
|
||||
sRelativePath = pO->filename().m_strFilename;
|
||||
}
|
||||
}
|
||||
//todooo проверить что тут за путь ..
|
||||
std::wstring sOlePath = sRelativePath;
|
||||
|
||||
POLE::Storage *storage = new POLE::Storage(sOlePath.c_str());
|
||||
if (storage)
|
||||
{
|
||||
//RtfOle2ToOle1Stream oStream;
|
||||
//oStream.lpstbl = new OLESTREAMVTBL();
|
||||
//oStream.lpstbl->Get = &OleGet2;
|
||||
//oStream.lpstbl->Put = &OlePut2;
|
||||
//todooo convert ole2 to ole1
|
||||
//if( SUCCEEDED( OleConvertIStorageToOLESTREAM( piStorage, &oStream ) ) )
|
||||
//{
|
||||
// //сохраняем в файл
|
||||
// std::wstring sOleStorageName = Utils::CreateTempFile( oParam.oReader->m_sTempFolder );
|
||||
// HANDLE hFile = CreateFile ( sOleStorageName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
// if( INVALID_HANDLE_VALUE != hFile )
|
||||
// {
|
||||
// DWORD dwByteWrite = 0;
|
||||
// WriteFile( hFile, oStream.aBuffer.GetData(), (DWORD)oStream.aBuffer.size(), &dwByteWrite, NULL );
|
||||
// CloseHandle( hFile );
|
||||
|
||||
// oNewOle->SetFilename( sOleStorageName );
|
||||
// //только сейчас запоминаем
|
||||
// oCurOle = oNewOle;
|
||||
// }
|
||||
// else
|
||||
// Utils::RemoveDirOrFile( sOleStorageName );
|
||||
//}
|
||||
delete( storage );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( NULL != aPictShape)
|
||||
{
|
||||
aPictShape->m_nShapeType = 75;//NSOfficeDrawing::sptPictureFrame;
|
||||
//надо пересчитать размеры картинки так чтобы scalex == 100 и scaley = 100
|
||||
//если scalex != 100, то после редактирование ole киртинка сжимается(растягивается)
|
||||
if( NULL != aPictShape->m_oPicture )
|
||||
{
|
||||
if( PROP_DEF != (int)aPictShape->m_oPicture->m_dScaleX && PROP_DEF != (int)aPictShape->m_oPicture->m_dScaleY &&
|
||||
PROP_DEF != aPictShape->m_oPicture->m_nWidthGoal && PROP_DEF != aPictShape->m_oPicture->m_nHeightGoal )
|
||||
{
|
||||
if( 100 != (int)aPictShape->m_oPicture->m_dScaleX )
|
||||
{
|
||||
aPictShape->m_oPicture->m_nWidthGoal = long (( aPictShape->m_oPicture->m_dScaleX / 100.0 ) * aPictShape->m_oPicture->m_nWidthGoal );
|
||||
aPictShape->m_oPicture->m_dScaleX = 100;
|
||||
}
|
||||
if( 100 != (int)aPictShape->m_oPicture->m_dScaleY )
|
||||
{
|
||||
aPictShape->m_oPicture->m_nHeightGoal = long (( aPictShape->m_oPicture->m_dScaleY / 100.0 ) * aPictShape->m_oPicture->m_nHeightGoal );
|
||||
aPictShape->m_oPicture->m_dScaleY = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( NULL != aPictShape && NULL != oCurOle )
|
||||
{
|
||||
TextItemContainerPtr oNewTextItemContainer ( new TextItemContainer() );
|
||||
RtfParagraphPtr pNewPar ( new RtfParagraph() );
|
||||
|
||||
pNewPar->AddItem( oCurOle );
|
||||
oNewTextItemContainer->AddItem( pNewPar );
|
||||
aPictShape->m_aTextItems = oNewTextItemContainer;
|
||||
|
||||
oCurOle->m_oResultPic = aPictShape;
|
||||
oOutputParagraph.AddItem( oCurOle );
|
||||
}
|
||||
else if (NULL != aPictShape)
|
||||
{
|
||||
oOutputParagraph.AddItem( aPictShape );
|
||||
}
|
||||
OOXShapeReader oShapeReaderControl(ooxObject->m_oControl.GetPointer());
|
||||
oShapeReaderControl.Parse( oParam, pNewShape );
|
||||
|
||||
OOXShapeReader oShapeReaderObject(ooxObject->m_oOleObject.GetPointer());
|
||||
oShapeReaderObject.Parse( oParam, pNewShape );
|
||||
}
|
||||
|
||||
if (pNewShape->m_bIsOle && pNewShape->m_pOleObject)
|
||||
{
|
||||
if (ooxObject->m_oDxaOrig.IsInit()) pNewShape->m_pOleObject->m_nWidth = *ooxObject->m_oDxaOrig;
|
||||
if (ooxObject->m_oDyaOrig.IsInit()) pNewShape->m_pOleObject->m_nHeight = *ooxObject->m_oDyaOrig;
|
||||
|
||||
pNewShape->m_pOleObject->m_oResultShape = pNewShape;
|
||||
|
||||
oOutputParagraph.AddItem( pNewShape->m_pOleObject );
|
||||
}
|
||||
else
|
||||
oOutputParagraph.AddItem( pNewShape );
|
||||
}break;
|
||||
case OOX::et_w_drawing:
|
||||
{
|
||||
@ -748,8 +646,15 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
oOutputParagraph.AddItem( pNewDrawing );
|
||||
bAddDrawing = true;
|
||||
if (pNewDrawing->m_bIsOle && pNewDrawing->m_pOleObject)
|
||||
{
|
||||
pNewDrawing->m_pOleObject->m_oResultShape = pNewDrawing;
|
||||
|
||||
oOutputParagraph.AddItem( pNewDrawing->m_pOleObject );
|
||||
}
|
||||
else
|
||||
oOutputParagraph.AddItem( pNewDrawing );
|
||||
bAddDrawing = true;
|
||||
}
|
||||
if (!bAddDrawing)
|
||||
{
|
||||
@ -1520,30 +1425,26 @@ bool OOXrPrReader::Parse( ReaderParameter oParam, RtfCharProperty& oOutputProper
|
||||
}
|
||||
if ( m_ooxRunProps->m_oTextOutline.IsInit())
|
||||
{
|
||||
if (m_ooxRunProps->m_oTextOutline->Fill.m_type == PPTX::Logic::UniFill::noFill )
|
||||
{
|
||||
oOutputProperty.m_nForeColor = 0xffffff; //white
|
||||
}
|
||||
else if (m_ooxRunProps->m_oTextOutline->Fill.m_type == PPTX::Logic::UniFill::solidFill )
|
||||
{
|
||||
NSCommon::smart_ptr<PPTX::Logic::SolidFill> fill = m_ooxRunProps->m_oTextOutline->Fill.Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
|
||||
|
||||
unsigned int nColor = 0; //black
|
||||
_CP_OPT(double) opacity;
|
||||
|
||||
OOXShapeReader::Parse(oParam, fill->Color.Color.operator ->(), nColor, opacity);
|
||||
oOutputProperty.m_nForeColor = nColor;
|
||||
}
|
||||
unsigned int nColor = 0; //black
|
||||
_CP_OPT(double) opacity;
|
||||
|
||||
OOXShapeReader::Parse(oParam, &m_ooxRunProps->m_oTextOutline->Fill, nColor, opacity);
|
||||
|
||||
RtfColor rtfColor;
|
||||
rtfColor.SetRGB(nColor);
|
||||
|
||||
if (oOutputProperty.m_nForeColor != PROP_DEF)
|
||||
{
|
||||
RtfColor rtfColor;
|
||||
rtfColor.SetRGB(oOutputProperty.m_nForeColor);
|
||||
|
||||
oOutputProperty.m_nForeColor = oParam.oRtf->m_oColorTable.AddItem(rtfColor);
|
||||
}
|
||||
}
|
||||
else if( m_ooxRunProps->m_oColor.IsInit() )
|
||||
if ( m_ooxRunProps->m_oTextFill.is_init())
|
||||
{
|
||||
unsigned int nColor = 0; //black
|
||||
_CP_OPT(double) opacity;
|
||||
|
||||
OOXShapeReader::Parse(oParam, &m_ooxRunProps->m_oTextFill, nColor, opacity);
|
||||
|
||||
RtfColor rtfColor;
|
||||
rtfColor.SetRGB(nColor);
|
||||
}
|
||||
if( m_ooxRunProps->m_oColor.IsInit() )
|
||||
{
|
||||
OOXColorReader oColorReader;
|
||||
RtfColor oColor;
|
||||
|
||||
@ -80,19 +80,19 @@ public:
|
||||
|
||||
if( m_ooxAnchor->m_oSimplePos.IsInit())
|
||||
{
|
||||
nLeft = (int)m_ooxAnchor->m_oSimplePos->m_oX.ToTwips() ;
|
||||
nTop = (int)m_ooxAnchor->m_oSimplePos->m_oY.ToTwips();
|
||||
pOutput->m_nLeft = (int)m_ooxAnchor->m_oSimplePos->m_oX.ToTwips() ;
|
||||
pOutput->m_nTop = (int)m_ooxAnchor->m_oSimplePos->m_oY.ToTwips();
|
||||
}
|
||||
|
||||
if( m_ooxAnchor->m_oExtent.IsInit() )
|
||||
{
|
||||
nWidth = (int)m_ooxAnchor->m_oExtent->m_oCx.ToTwips();
|
||||
nHeight = (int)m_ooxAnchor->m_oExtent->m_oCy.ToTwips();
|
||||
pOutput->m_nWidth = (int)m_ooxAnchor->m_oExtent->m_oCx.ToTwips();
|
||||
pOutput->m_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 + nWidth;
|
||||
pOutput->m_nBottom = pOutput->m_nTop + nHeight;
|
||||
pOutput->m_nRight = pOutput->m_nLeft + pOutput->m_nWidth;
|
||||
pOutput->m_nBottom = pOutput->m_nTop + pOutput->m_nHeight;
|
||||
}
|
||||
}
|
||||
if( m_ooxAnchor->m_oPositionH.IsInit() )
|
||||
|
||||
@ -44,6 +44,8 @@ OOXReader::OOXReader( RtfDocument& oDocument, std::wstring path ): m_oDocument(
|
||||
{
|
||||
m_sPath = path;
|
||||
m_nCurItap = 0;
|
||||
m_nCurOleChartId = 0;
|
||||
m_nCurFittextId = 0;
|
||||
|
||||
m_convertationManager = NULL;
|
||||
m_currentContainer = NULL;
|
||||
|
||||
@ -64,6 +64,7 @@ public:
|
||||
|
||||
int m_nCurItap; //для определение вложенности таблицы
|
||||
|
||||
int m_nCurOleChartId;
|
||||
int m_nCurFittextId;
|
||||
std::map<int, std::wstring> m_aBookmarks;
|
||||
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
*/
|
||||
#include "OOXShapeReader.h"
|
||||
#include "OOXTextItemReader.h"
|
||||
#include "../Ole1FormatReader.h"
|
||||
#include "../RtfOle.h"
|
||||
|
||||
#include "../../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/Shape.h"
|
||||
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.h"
|
||||
@ -44,7 +46,7 @@
|
||||
#define RGB(r,g,b) ((_UINT32)(((BYTE)(r)|((_UINT16)((BYTE)(g))<<8))|(((_UINT32)(BYTE)(b))<<16)))
|
||||
#endif
|
||||
|
||||
bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop)
|
||||
bool OOXShapeReader::ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop)
|
||||
{
|
||||
if (pShape == NULL) return false;
|
||||
if (prop == NULL) return false;
|
||||
@ -316,7 +318,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
|
||||
std::wstring sImagePath = pImage->filename().GetPath();
|
||||
|
||||
pOutput->m_oPicture = RtfPicturePtr( new RtfPicture() );
|
||||
WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sPath );
|
||||
WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sTempFolder );
|
||||
|
||||
pOutput->m_nFillType = 2;
|
||||
}
|
||||
@ -402,7 +404,7 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
std::wstring sImagePath = pImage->filename().GetPath();
|
||||
|
||||
WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sPath );
|
||||
WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sTempFolder );
|
||||
}
|
||||
}
|
||||
int nCropedWidthGoal = pOutput->m_oPicture->m_nWidthGoal;
|
||||
@ -738,7 +740,7 @@ bool OOXShapeReader::Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::L
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
|
||||
std::wstring sImagePath = pImage->filename().GetPath();
|
||||
result = WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sPath);
|
||||
result = WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sTempFolder);
|
||||
}
|
||||
}
|
||||
else if (oox_bitmap_fill->blip->link.IsInit())
|
||||
@ -1318,6 +1320,10 @@ void OOXShapeReader::Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::L
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (text_props->rot.IsInit())
|
||||
{
|
||||
pOutput->m_fRotateText = 1;
|
||||
}
|
||||
//nullable_int rot;
|
||||
//nullable_limit<Limit::TextWrap> wrap;
|
||||
|
||||
@ -1340,6 +1346,16 @@ bool OOXShapeReader::ParsePic( ReaderParameter oParam, RtfShapePtr& pOutput)
|
||||
|
||||
Parse(oParam, pOutput, &ooxPic->blipFill);
|
||||
|
||||
if (pOutput->m_oPicture->m_sPicFilename.empty() && !ooxPic->blipFill.blip->oleFilepathImage.empty())
|
||||
{
|
||||
pOutput->m_oPicture->eDataType = RtfPicture::dt_png;
|
||||
pOutput->m_oPicture->m_sPicFilename = ooxPic->blipFill.blip->oleFilepathImage;
|
||||
pOutput->m_oPicture->m_bIsCopy = false; //не удалять
|
||||
|
||||
pOutput->m_oPicture->m_nWidthGoal = pOutput->m_nWidth;
|
||||
pOutput->m_oPicture->m_nHeightGoal = pOutput->m_nHeight;
|
||||
}
|
||||
|
||||
if ((oox_sp_style) && (oox_sp_style->lnRef.idx.IsInit()))
|
||||
{
|
||||
Parse(oParam, pOutput, &oox_sp_style->lnRef, 2);
|
||||
@ -1360,6 +1376,63 @@ bool OOXShapeReader::ParsePic( ReaderParameter oParam, RtfShapePtr& pOutput)
|
||||
pOutput->m_oPicture->m_dScaleY = (pOutput->m_nBottom - pOutput->m_nTop)* 100. / pOutput->m_oPicture->m_nHeightGoal;
|
||||
}
|
||||
}
|
||||
|
||||
if (ooxPic->oleObject.IsInit())
|
||||
{
|
||||
pOutput->m_bIsOle = true;
|
||||
pOutput->m_pOleObject = RtfOlePtr(new RtfOle());
|
||||
|
||||
if (ooxPic->oleObject->m_oDxaOrig.IsInit())
|
||||
pOutput->m_pOleObject->m_nWidth = *ooxPic->oleObject->m_oDxaOrig;
|
||||
|
||||
if (ooxPic->oleObject->m_oDyaOrig.IsInit())
|
||||
pOutput->m_pOleObject->m_nHeight = *ooxPic->oleObject->m_oDyaOrig;
|
||||
|
||||
if (ooxPic->oleObject->m_sProgId.IsInit() )
|
||||
pOutput->m_pOleObject->m_sOleClass = *ooxPic->oleObject->m_sProgId;
|
||||
|
||||
if (ooxPic->oleObject->m_oType.IsInit())
|
||||
{
|
||||
switch( ooxPic->oleObject->m_oType->GetBYTECode())
|
||||
{
|
||||
case SimpleTypes::oletypeLink: pOutput->m_pOleObject->m_eOleType = RtfOle::ot_link; break;
|
||||
case SimpleTypes::oletypeEmbed: pOutput->m_pOleObject->m_eOleType = RtfOle::ot_emb; break;
|
||||
}
|
||||
}
|
||||
std::wstring sOlePath;
|
||||
if (ooxPic->oleObject->m_OleObjectFile.IsInit())
|
||||
{
|
||||
sOlePath = ooxPic->oleObject->m_OleObjectFile->filename().GetPath();
|
||||
}
|
||||
else if(ooxPic->oleObject->m_oId.IsInit() && oParam.oReader->m_currentContainer)
|
||||
{
|
||||
smart_ptr<OOX::File> pFile = oParam.oReader->m_currentContainer->Find(*ooxPic->oleObject->m_oId);
|
||||
smart_ptr<OOX::OleObject> pOleFile = pFile.smart_dynamic_cast<OOX::OleObject>();
|
||||
|
||||
if (pOleFile.IsInit())
|
||||
{
|
||||
sOlePath= pOleFile->filename().GetPath();
|
||||
}
|
||||
}
|
||||
if (pOutput->m_pOleObject->m_nWidth == PROP_DEF)
|
||||
{
|
||||
pOutput->m_pOleObject->m_nWidth = pOutput->m_nWidth;
|
||||
}
|
||||
if (pOutput->m_pOleObject->m_nHeight == PROP_DEF)
|
||||
{
|
||||
pOutput->m_pOleObject->m_nHeight = pOutput->m_nHeight;
|
||||
}
|
||||
if (!sOlePath.empty())
|
||||
{
|
||||
ConvertOle2ToOle1(sOlePath, pOutput->m_pOleObject);
|
||||
|
||||
std::wstring ole1FileName = Utils::CreateTempFile( oParam.oReader->m_sTempFolder );
|
||||
|
||||
RtfUtility::WriteDataToFileBinary( ole1FileName, pOutput->m_pOleObject->m_oOle1Data.first.get(), pOutput->m_pOleObject->m_oOle1Data.second );
|
||||
|
||||
pOutput->m_pOleObject->SetFilename(ole1FileName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput)
|
||||
@ -1373,16 +1446,75 @@ bool OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput)
|
||||
|
||||
if (m_vmlElement || m_arrElement) return ParseVml(oParam , pOutput);
|
||||
|
||||
PPTX::Logic::Shape * ooxShape = dynamic_cast<PPTX::Logic::Shape*> (m_ooxShape);
|
||||
// PPTX::Logic::CxnSp * cxnShape = dynamic_cast<PPTX::Logic::CxnSp*> (m_ooxShape);
|
||||
PPTX::Logic::Pic * ooxPic = dynamic_cast<PPTX::Logic::Pic*> (m_ooxShape);
|
||||
PPTX::Logic::Shape *ooxShape = dynamic_cast<PPTX::Logic::Shape*> (m_ooxShape);
|
||||
// PPTX::Logic::CxnSp *cxnShape = dynamic_cast<PPTX::Logic::CxnSp*> (m_ooxShape);
|
||||
PPTX::Logic::Pic *ooxPic = dynamic_cast<PPTX::Logic::Pic*> (m_ooxShape);
|
||||
|
||||
OOX::VmlOffice::COLEObject *vmlOLE = dynamic_cast<OOX::VmlOffice::COLEObject*> (m_ooxShape);
|
||||
|
||||
if (ooxShape) return ParseShape(oParam, pOutput);
|
||||
if (ooxPic) return ParsePic(oParam, pOutput);
|
||||
//if (cxnShape) return ParseConnector(oParam, pOutput);
|
||||
|
||||
if (vmlOLE) return ParseVmlObject(oParam, pOutput);
|
||||
|
||||
return false;
|
||||
}
|
||||
bool OOXShapeReader::ParseVmlObject ( ReaderParameter oParam , RtfShapePtr& pOutput)
|
||||
{
|
||||
OOX::VmlOffice::COLEObject *vmlOLE = dynamic_cast<OOX::VmlOffice::COLEObject*> (m_ooxShape);
|
||||
if (!vmlOLE) return false;
|
||||
|
||||
pOutput->m_bIsOle = true;
|
||||
pOutput->m_pOleObject = RtfOlePtr(new RtfOle());
|
||||
|
||||
if( vmlOLE->m_sProgId.IsInit() )
|
||||
pOutput->m_pOleObject->m_sOleClass = vmlOLE->m_sProgId.get2();
|
||||
|
||||
if(vmlOLE->m_oType.IsInit())
|
||||
{
|
||||
switch( vmlOLE->m_oType->GetValue())
|
||||
{
|
||||
case SimpleTypes::oletypeLink: pOutput->m_pOleObject->m_eOleType = RtfOle::ot_link; break;
|
||||
case SimpleTypes::oletypeEmbed: pOutput->m_pOleObject->m_eOleType = RtfOle::ot_emb; break;
|
||||
}
|
||||
}
|
||||
std::wstring sOlePath;
|
||||
if (vmlOLE->m_oId.IsInit() && oParam.oReader->m_currentContainer)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(vmlOLE->m_oId->GetValue());
|
||||
|
||||
if ((oFile.IsInit() && (OOX::FileTypes::OleObject == oFile->type())))
|
||||
{
|
||||
OOX::OleObject* pO = (OOX::OleObject*)oFile.operator->();
|
||||
sOlePath = pO->filename().m_strFilename;
|
||||
}
|
||||
}
|
||||
if (pOutput->m_nWidth == PROP_DEF && pOutput->m_nRight != PROP_DEF)
|
||||
{
|
||||
pOutput->m_nWidth = pOutput->m_nRight - (pOutput->m_nLeft == PROP_DEF ? 0 : pOutput->m_nLeft);
|
||||
}
|
||||
if (pOutput->m_nHeight == PROP_DEF && pOutput->m_nBottom != PROP_DEF)
|
||||
{
|
||||
pOutput->m_nHeight = pOutput->m_nBottom - (pOutput->m_nTop == PROP_DEF ? 0 : pOutput->m_nTop);
|
||||
}
|
||||
|
||||
if (pOutput->m_nWidth != PROP_DEF) pOutput->m_pOleObject->m_nWidth = pOutput->m_nWidth;
|
||||
if (pOutput->m_nHeight != PROP_DEF) pOutput->m_pOleObject->m_nHeight = pOutput->m_nHeight;
|
||||
|
||||
if (!sOlePath.empty())
|
||||
{
|
||||
ConvertOle2ToOle1(sOlePath, pOutput->m_pOleObject);
|
||||
|
||||
std::wstring ole1FileName = Utils::CreateTempFile( oParam.oReader->m_sTempFolder );
|
||||
|
||||
RtfUtility::WriteDataToFileBinary( ole1FileName, pOutput->m_pOleObject->m_oOle1Data.first.get(), pOutput->m_pOleObject->m_oOle1Data.second );
|
||||
|
||||
pOutput->m_pOleObject->SetFilename(ole1FileName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OOXShapeReader::Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::UniFill *oox_fill, std::wstring *change_sheme_color)
|
||||
{
|
||||
if (!oox_fill) return;
|
||||
@ -1902,6 +2034,7 @@ bool OOXBackgroundReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput, std::wstring sTempPath)
|
||||
{
|
||||
OOX::CPath ooxPath = sPath; //для target
|
||||
@ -2020,3 +2153,119 @@ bool OOXShapeReader::WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OOXShapeReader::Parse(ReaderParameter oParam, PPTX::Logic::UniFill *uni_fill, unsigned int & nColor, _CP_OPT(double) &opacity)
|
||||
{
|
||||
if (!uni_fill) return;
|
||||
|
||||
if (uni_fill->m_type == PPTX::Logic::UniFill::noFill )
|
||||
{
|
||||
nColor = 0xffffff; //white
|
||||
}
|
||||
else if (uni_fill->m_type == PPTX::Logic::UniFill::solidFill )
|
||||
{
|
||||
NSCommon::smart_ptr<PPTX::Logic::SolidFill> fill = uni_fill->Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
|
||||
|
||||
Parse(oParam, fill->Color.Color.operator ->(), nColor, opacity);
|
||||
}
|
||||
else if (uni_fill->m_type == PPTX::Logic::UniFill::gradFill )
|
||||
{
|
||||
NSCommon::smart_ptr<PPTX::Logic::GradFill> fill = uni_fill->Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
|
||||
|
||||
unsigned int nColor = 0; //black
|
||||
_CP_OPT(double) opacity;
|
||||
|
||||
if (!fill->GsLst.empty())
|
||||
{
|
||||
Parse(oParam, fill->GsLst[0].color.Color.operator ->(), nColor, opacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
void OOXShapeReader::ConvertOle2ToOle1(const std::wstring &oleFilePath, RtfOlePtr object)
|
||||
{
|
||||
if (!object) return;
|
||||
if (oleFilePath.empty()) return;
|
||||
|
||||
Ole1FormatReaderWriter ole1Writer;
|
||||
|
||||
ole1Writer.Header.ClassName.val = std::string(object->m_sOleClass.begin(), object->m_sOleClass.end());
|
||||
ole1Writer.Header.ClassName.size = ole1Writer.Header.ClassName.val.length() + 1;
|
||||
|
||||
//ole1Writer.Header.Width = object->m_nWidth;
|
||||
//ole1Writer.Header.Height = object->m_nHeight;
|
||||
|
||||
DWORD size = 0;
|
||||
if (false == NSFile::CFileBinary::ReadAllBytes(oleFilePath, &ole1Writer.NativeData, size))
|
||||
return;
|
||||
ole1Writer.NativeDataSize = size;
|
||||
|
||||
int ole1DataSize = ole1Writer.NativeDataSize + 2048;
|
||||
BYTE* ole1Data = new BYTE[ole1DataSize];
|
||||
|
||||
if (ole1Data)
|
||||
{
|
||||
ole1Writer.Write(ole1Data, ole1DataSize);
|
||||
|
||||
boost::shared_array<BYTE> buffer(ole1Data);
|
||||
object->m_oOle1Data = std::make_pair(buffer, ole1DataSize);
|
||||
}
|
||||
delete []ole1Writer.NativeData;
|
||||
}
|
||||
|
||||
void OOXShapeReader::ConvertOle2ToOle1(POLE::Storage *storage, RtfOlePtr object)
|
||||
{
|
||||
if (!object) return;
|
||||
if (!storage) return;
|
||||
|
||||
Ole1FormatReaderWriter ole1Writer;
|
||||
|
||||
ole1Writer.Header.ClassName.val = std::string(object->m_sOleClass.begin(), object->m_sOleClass.end());
|
||||
ole1Writer.Header.ClassName.size = ole1Writer.Header.ClassName.val.length();
|
||||
|
||||
//ole1Writer.Header.Width = object->m_nWidth;
|
||||
//ole1Writer.Header.Height = object->m_nHeight;
|
||||
|
||||
std::list<std::wstring> entries;
|
||||
entries = storage->entries( L"/" );
|
||||
|
||||
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
|
||||
{
|
||||
std::wstring name = XmlUtils::GetLower(*it);
|
||||
|
||||
if (std::wstring::npos != name.find(L"ole")) continue;
|
||||
if (std::wstring::npos != name.find(L"compobj")) continue;
|
||||
if (std::wstring::npos != name.find(L"objinfo")) continue;
|
||||
|
||||
if (std::wstring::npos != name.find(L"native") ||
|
||||
std::wstring::npos != name.find(L"content") ||
|
||||
std::wstring::npos != name.find(L"package"))
|
||||
{
|
||||
POLE::Stream *stream = new POLE::Stream(storage, *it);
|
||||
if (stream)
|
||||
{
|
||||
ole1Writer.NativeDataSize = stream->size();
|
||||
|
||||
ole1Writer.NativeData = new unsigned char[ole1Writer.NativeDataSize];
|
||||
stream->read(ole1Writer.NativeData, ole1Writer.NativeDataSize);
|
||||
delete stream;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ole1Writer.NativeData)
|
||||
{
|
||||
int ole1DataSize = ole1Writer.NativeDataSize + 2048;
|
||||
BYTE* ole1Data = new BYTE[ole1DataSize];
|
||||
|
||||
if (ole1Data)
|
||||
{
|
||||
ole1Writer.Write(ole1Data, ole1DataSize);
|
||||
|
||||
boost::shared_array<BYTE> buffer(ole1Data);
|
||||
object->m_oOle1Data = std::make_pair(buffer, ole1DataSize);
|
||||
}
|
||||
delete []ole1Writer.NativeData;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,10 +62,14 @@ public:
|
||||
bool Parse ( ReaderParameter oParam , RtfShapePtr& oOutput);
|
||||
bool ParseVmlChild ( ReaderParameter oParam , RtfShapePtr& oOutput);
|
||||
bool ParseVml ( ReaderParameter oParam , RtfShapePtr& oOutput);
|
||||
bool ParseVmlObject ( ReaderParameter oParam , RtfShapePtr& oOutput);
|
||||
|
||||
static bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);
|
||||
|
||||
void ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment);
|
||||
|
||||
static bool Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::BlipFill *oox_bitmap_fill);
|
||||
static void Parse(ReaderParameter oParam, PPTX::Logic::UniFill *fill, unsigned int & nColor, _CP_OPT(double) &opacity);
|
||||
static void Parse(ReaderParameter oParam, PPTX::Logic::ColorBase *oox_color, unsigned int & nColor, _CP_OPT(double) &opacity);
|
||||
private:
|
||||
|
||||
@ -101,6 +105,8 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConvertOle2ToOle1(POLE::Storage *storage, RtfOlePtr object);
|
||||
void ConvertOle2ToOle1(const std::wstring &oleFilePath, RtfOlePtr object);
|
||||
};
|
||||
|
||||
class OOXShapeGroupReader
|
||||
@ -123,7 +129,7 @@ public:
|
||||
{
|
||||
for (size_t i = 0; i < props.size(); i++)
|
||||
{
|
||||
ParseVmlStyle( pGroupShape, props[i].get());
|
||||
OOXShapeReader::ParseVmlStyle( pGroupShape, props[i].get());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -80,8 +80,8 @@ bool OOXtrPrReader::Parse( ReaderParameter oParam , RtfRowProperty& oOutputPrope
|
||||
oOutputProperty.m_nHeight = -oOutputProperty.m_nHeight;
|
||||
}
|
||||
|
||||
OOXtcPrReader::Parse(m_ooxTableRowProps->m_oWBefore.GetPointer(), oOutputProperty.m_eMUStartInvCell, oOutputProperty.m_nWidthStartInvCell);
|
||||
OOXtcPrReader::Parse(m_ooxTableRowProps->m_oWAfter.GetPointer(), oOutputProperty.m_eMUEndInvCell, oOutputProperty.m_nWidthEndInvCell);
|
||||
OOXtcPrReader::Parse(m_ooxTableRowProps->m_oWBefore.GetPointer(), oOutputProperty.m_eWidthStartInvCellUnit, oOutputProperty.m_nWidthStartInvCell);
|
||||
OOXtcPrReader::Parse(m_ooxTableRowProps->m_oWAfter.GetPointer(), oOutputProperty.m_eWidthEndInvCellUnit, oOutputProperty.m_nWidthEndInvCell);
|
||||
|
||||
if( m_ooxTableRowProps->m_oGridBefore.IsInit() && m_ooxTableRowProps->m_oGridBefore->m_oVal.IsInit())
|
||||
oOutputProperty.m_nGridBefore = m_ooxTableRowProps->m_oGridBefore->m_oVal->GetValue();
|
||||
|
||||
@ -277,15 +277,20 @@ private:
|
||||
if( nBoundLeft == nCurX )
|
||||
{
|
||||
oOutputProperty.m_oBorderLeft.Merge( oInputStyle->m_oTableProp.m_oBorderLeft );
|
||||
|
||||
if( nBoundRight == nCurX )
|
||||
oOutputProperty.m_oBorderRight.Merge( oInputStyle->m_oTableProp.m_oBorderRight );
|
||||
else if (oInputStyle->m_oTableProp.m_bAutoNoColBand != 1)
|
||||
else //if (oInputStyle->m_oTableProp.m_bAutoNoColBand != 1)
|
||||
oOutputProperty.m_oBorderRight.Merge( oInputStyle->m_oTableProp.m_oBorderVert );
|
||||
}
|
||||
else if( nBoundRight == nCurX )
|
||||
{
|
||||
oOutputProperty.m_oBorderLeft.Merge( oInputStyle->m_oTableProp.m_oBorderVert );
|
||||
oOutputProperty.m_oBorderRight.Merge( oInputStyle->m_oTableProp.m_oBorderRight );
|
||||
|
||||
if( nBoundLeft == nCurX )
|
||||
oOutputProperty.m_oBorderLeft.Merge( oInputStyle->m_oTableProp.m_oBorderLeft );
|
||||
else //if (oInputStyle->m_oTableProp.m_bAutoNoColBand != 1)
|
||||
oOutputProperty.m_oBorderLeft.Merge( oInputStyle->m_oTableProp.m_oBorderVert );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -298,13 +303,16 @@ private:
|
||||
oOutputProperty.m_oBorderTop.Merge( oInputStyle->m_oTableProp.m_oBorderTop );
|
||||
if( nBoundBottom == nCurY )
|
||||
oOutputProperty.m_oBorderBottom.Merge( oInputStyle->m_oTableProp.m_oBorderBottom );
|
||||
else if (oInputStyle->m_oTableProp.m_bAutoNoRowBand != 1)
|
||||
else// if (oInputStyle->m_oTableProp.m_bAutoNoRowBand != 1)
|
||||
oOutputProperty.m_oBorderBottom.Merge( oInputStyle->m_oTableProp.m_oBorderHor );
|
||||
}
|
||||
else if( nBoundBottom == nCurY )
|
||||
{
|
||||
oOutputProperty.m_oBorderTop.Merge( oInputStyle->m_oTableProp.m_oBorderHor );
|
||||
oOutputProperty.m_oBorderBottom.Merge( oInputStyle->m_oTableProp.m_oBorderBottom );
|
||||
if( nBoundTop == nCurX )
|
||||
oOutputProperty.m_oBorderTop.Merge( oInputStyle->m_oTableProp.m_oBorderTop );
|
||||
else //if (oInputStyle->m_oTableProp.m_bAutoNoRowBand != 1)
|
||||
oOutputProperty.m_oBorderTop.Merge( oInputStyle->m_oTableProp.m_oBorderHor );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -79,26 +79,9 @@ public:
|
||||
oOutputProperty.m_nStyle = oTableStyle->m_nID;
|
||||
}
|
||||
}
|
||||
if(m_ooxTableProps->m_oTblInd.IsInit() )
|
||||
{
|
||||
SimpleTypes::ETblWidth eType = m_ooxTableProps->m_oTblInd->m_oType.IsInit() ? m_ooxTableProps->m_oTblInd->m_oType->GetValue() : SimpleTypes::tblwidthNil;
|
||||
double dValue = m_ooxTableProps->m_oTblInd->m_oW.IsInit() ? m_ooxTableProps->m_oTblInd->m_oW->GetValue() : 0;
|
||||
|
||||
switch(eType)
|
||||
{
|
||||
case SimpleTypes::tblwidthDxa://сделаем не по документации, а как все остальные юниты !!!
|
||||
{
|
||||
oOutputProperty.nTableIndentUnits = 3;
|
||||
oOutputProperty.nTableIndent = (int)dValue;
|
||||
oOutputProperty.m_nLeft = (int)oOutputProperty.nTableIndent;
|
||||
}break;
|
||||
case SimpleTypes::tblwidthPct:
|
||||
{
|
||||
// oOutputProperty.nTableIndentUnits = 3;
|
||||
// oOutputProperty.nTableIndent = Strings::ToInteger( sValue );
|
||||
}break;
|
||||
}
|
||||
}
|
||||
OOXtcPrReader::Parse(m_ooxTableProps->m_oTblInd.GetPointer(), oOutputProperty.eTableIndentUnit, oOutputProperty.nTableIndent, false);
|
||||
oOutputProperty.m_nLeft = oOutputProperty.nTableIndent;
|
||||
|
||||
if( m_ooxTableProps->m_oTblLayout.IsInit() && m_ooxTableProps->m_oTblLayout->m_oType.IsInit())
|
||||
{
|
||||
if( m_ooxTableProps->m_oTblLayout->m_oType->GetValue() == SimpleTypes::tbllayouttypeAutofit) oOutputProperty.m_nAutoFit = 1;
|
||||
@ -165,66 +148,37 @@ public:
|
||||
}
|
||||
if( m_ooxTableProps->m_oTblCellMar.IsInit() )
|
||||
{
|
||||
_MetricUnits eMetric = mu_none;
|
||||
int nValue = PROP_DEF;
|
||||
//if( mu_Twips == eMetric && PROP_DEF != nValue )
|
||||
//todooo сделать вариант с процентми
|
||||
if( m_ooxTableProps->m_oTblCellMar->m_oBottom.IsInit() && m_ooxTableProps->m_oTblCellMar->m_oBottom->m_oW.IsInit())
|
||||
{
|
||||
oOutputProperty.m_nDefCellMarBottomUnits= 3;
|
||||
oOutputProperty.m_nDefCellMarBottom = (int)m_ooxTableProps->m_oTblCellMar->m_oBottom->m_oW->GetValue();
|
||||
}
|
||||
if(m_ooxTableProps->m_oTblCellMar->m_oStart.IsInit() && m_ooxTableProps->m_oTblCellMar->m_oStart->m_oW.IsInit())
|
||||
{
|
||||
oOutputProperty.m_nDefCellMarLeftUnits = 3;
|
||||
oOutputProperty.m_nDefCellMarLeft = (int)m_ooxTableProps->m_oTblCellMar->m_oStart->m_oW->GetValue();
|
||||
}
|
||||
if(m_ooxTableProps->m_oTblCellMar->m_oEnd.IsInit() && m_ooxTableProps->m_oTblCellMar->m_oEnd->m_oW.IsInit() )
|
||||
{
|
||||
oOutputProperty.m_nDefCellMarRightUnits = 3;
|
||||
oOutputProperty.m_nDefCellMarRight = (int)m_ooxTableProps->m_oTblCellMar->m_oEnd->m_oW->GetValue();
|
||||
}
|
||||
if(m_ooxTableProps->m_oTblCellMar->m_oTop.IsInit() && m_ooxTableProps->m_oTblCellMar->m_oTop->m_oW.IsInit())
|
||||
{
|
||||
oOutputProperty.m_nDefCellMarTopUnits = 3;
|
||||
oOutputProperty.m_nDefCellMarTop = (int)m_ooxTableProps->m_oTblCellMar->m_oTop->m_oW->GetValue();
|
||||
}
|
||||
OOXtcPrReader::Parse(m_ooxTableProps->m_oTblCellMar->m_oBottom.GetPointer(), oOutputProperty.m_eDefCellMarBottomUnit, oOutputProperty.m_nDefCellMarBottom, false);
|
||||
OOXtcPrReader::Parse(m_ooxTableProps->m_oTblCellMar->m_oStart.GetPointer(), oOutputProperty.m_eDefCellMarLeftUnit, oOutputProperty.m_nDefCellMarLeft, false);
|
||||
OOXtcPrReader::Parse(m_ooxTableProps->m_oTblCellMar->m_oEnd.GetPointer(), oOutputProperty.m_eDefCellMarRightUnit, oOutputProperty.m_nDefCellMarRight, false);
|
||||
OOXtcPrReader::Parse(m_ooxTableProps->m_oTblCellMar->m_oTop.GetPointer(), oOutputProperty.m_eDefCellMarTopUnit, oOutputProperty.m_nDefCellMarTop, false);
|
||||
|
||||
}
|
||||
if( m_ooxTableProps->m_oTblCellSpacing.IsInit() && m_ooxTableProps->m_oTblCellSpacing->m_oW.IsInit())
|
||||
|
||||
if( m_ooxTableProps->m_oTblCellSpacing.IsInit())
|
||||
{
|
||||
//todooo тут тоже не было изначально варианта с процентами
|
||||
//mu_Twips == eMetric && PROP_DEF != nValue )
|
||||
{
|
||||
double nValue = m_ooxTableProps->m_oTblCellSpacing->m_oW->GetValue();
|
||||
OOXtcPrReader::Parse(m_ooxTableProps->m_oTblCellSpacing.GetPointer(), oOutputProperty.m_eDefCellSpTopUnit, oOutputProperty.m_nDefCellSpTop, false);
|
||||
|
||||
oOutputProperty.m_eDefCellSpBottomUnit = oOutputProperty.m_eDefCellSpTopUnit;
|
||||
oOutputProperty.m_eDefCellSpLeftUnit = oOutputProperty.m_eDefCellSpTopUnit;
|
||||
oOutputProperty.m_eDefCellSpRightUnit = oOutputProperty.m_eDefCellSpTopUnit;
|
||||
|
||||
oOutputProperty.m_nDefCellSpTopUnits = 3;
|
||||
oOutputProperty.m_nDefCellSpBottomUnits = 3;
|
||||
oOutputProperty.m_nDefCellSpLeftUnits = 3;
|
||||
oOutputProperty.m_nDefCellSpRightUnits = 3;
|
||||
|
||||
oOutputProperty.m_nDefCellSpTop = (int)nValue;
|
||||
oOutputProperty.m_nDefCellSpBottom = (int)nValue;
|
||||
oOutputProperty.m_nDefCellSpLeft = (int)nValue;
|
||||
oOutputProperty.m_nDefCellSpRight = (int)nValue;
|
||||
}
|
||||
oOutputProperty.m_nDefCellSpBottom = oOutputProperty.m_nDefCellSpTop;
|
||||
oOutputProperty.m_nDefCellSpLeft = oOutputProperty.m_nDefCellSpTop;
|
||||
oOutputProperty.m_nDefCellSpRight = oOutputProperty.m_nDefCellSpTop;
|
||||
}
|
||||
if( m_ooxTableProps->m_oTblLook.IsInit())
|
||||
{
|
||||
OOXtblLookReader oLookReader(m_ooxTableProps->m_oTblLook.GetPointer());
|
||||
CtblLook oLook;
|
||||
oLookReader.Parse( oParam, oLook );
|
||||
if( true == oLook.bFirstRow )
|
||||
oOutputProperty.m_bAutoFirstRow = 1;
|
||||
if( true == oLook.bLastRow )
|
||||
oOutputProperty.m_bAutoLastRow = 1;
|
||||
if( true == oLook.bFirstCol )
|
||||
oOutputProperty.m_bAutoFirstCol = 1;
|
||||
if( true == oLook.bLastCol )
|
||||
oOutputProperty.m_bAutoLastCol = 1;
|
||||
if( true == oLook.bNoHBand )
|
||||
oOutputProperty.m_bAutoNoRowBand = 1;
|
||||
if( true == oLook.bNoVBand )
|
||||
oOutputProperty.m_bAutoNoColBand = 1;
|
||||
|
||||
if ( oLook.bFirstRow ) oOutputProperty.m_bAutoFirstRow = 1;
|
||||
if ( oLook.bLastRow ) oOutputProperty.m_bAutoLastRow = 1;
|
||||
if ( oLook.bFirstCol ) oOutputProperty.m_bAutoFirstCol = 1;
|
||||
if ( oLook.bLastCol ) oOutputProperty.m_bAutoLastCol = 1;
|
||||
if ( oLook.bNoHBand ) oOutputProperty.m_bAutoNoRowBand = 1;
|
||||
if ( oLook.bNoVBand ) oOutputProperty.m_bAutoNoColBand = 1;
|
||||
}
|
||||
if (m_ooxTableProps->m_oTblStyleRowBandSize.IsInit() && m_ooxTableProps->m_oTblStyleRowBandSize->m_oVal.IsInit())
|
||||
oOutputProperty.m_nRowBandSize = m_ooxTableProps->m_oTblStyleRowBandSize->m_oVal->GetValue();
|
||||
|
||||
@ -50,7 +50,7 @@ std::wstring RtfOle::RenderToOOX(RenderParameter oRenderParameter)
|
||||
}
|
||||
else
|
||||
{
|
||||
RtfCharProperty * pCharProps = m_oResultPic ? &m_oResultPic->m_oCharProperty : &m_oCharProperty;
|
||||
RtfCharProperty * pCharProps = &m_oCharProperty;
|
||||
//------------------------------------------
|
||||
// todooo общая часть с RtfChar
|
||||
bool bInsert = false;
|
||||
@ -94,12 +94,11 @@ std::wstring RtfOle::RenderToOOX(RenderParameter oRenderParameter)
|
||||
RenderParameter oNewRenderParameter = oRenderParameter;
|
||||
oNewRenderParameter.nType = RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2;
|
||||
|
||||
if (m_oResultPic)
|
||||
if (m_oResultShape)
|
||||
{
|
||||
m_oResultPic->m_bIsOle = true;
|
||||
sResult += m_oResultPic->RenderToOOX(oNewRenderParameter);
|
||||
sResult += m_oResultShape->RenderToOOX(oNewRenderParameter);
|
||||
|
||||
oNewRenderParameter.nValue = m_oResultPic->m_nID;
|
||||
oNewRenderParameter.nValue = m_oResultShape->m_nID;
|
||||
}
|
||||
sResult += RenderToOOXOnlyOle(oNewRenderParameter);
|
||||
|
||||
@ -171,6 +170,9 @@ std::wstring RtfOle::RenderToRtf(RenderParameter oRenderParameter)
|
||||
case ot_link: sResult += L"\\objlink"; break;
|
||||
}
|
||||
}
|
||||
//sResult += L"\\f13";
|
||||
sResult += L"\\objsetsize";
|
||||
|
||||
RENDER_RTF_INT( m_nWidth, sResult, L"objw" );
|
||||
RENDER_RTF_INT( m_nHeight, sResult, L"objh" );
|
||||
|
||||
@ -182,39 +184,17 @@ std::wstring RtfOle::RenderToRtf(RenderParameter oRenderParameter)
|
||||
std::wstring str = RtfUtility::RtfInternalEncoder::Encode( m_sOleFilename );
|
||||
sResult += L"{\\*\\objdata " + str + L"}";
|
||||
}
|
||||
if( NULL != m_oResultPic )
|
||||
//-------------------------------------
|
||||
if( NULL != m_oResultShape )
|
||||
{
|
||||
std::wstring str = m_oResultPic->RenderToRtf( oRenderParameter );
|
||||
sResult += L"{\\result \\pard\\plain" + str + L"}";
|
||||
std::wstring str = m_oResultShape->RenderToRtf( oRenderParameter );
|
||||
sResult += L"{\\result {\\pard\\plain" + str + L"}}";
|
||||
}
|
||||
//else if( NULL != m_oResultPicture )
|
||||
//{
|
||||
// std::wstring str = m_oResultPicture->RenderToRtf( oRenderParameter );
|
||||
// sResult += L"{\\result {\\*\\shppict" + str + L"}}";
|
||||
//}
|
||||
sResult += L"}";
|
||||
return sResult;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
DWORD CALLBACK OlePut1(LPOLESTREAM oStream, const void FAR* pTarget, DWORD dwRead)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
DWORD CALLBACK OleGet2(LPOLESTREAM oStream, void FAR* pTarget, DWORD dwRead)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
DWORD CALLBACK OleGet1(LPOLESTREAM oStream, void FAR* pTarget, DWORD dwRead)
|
||||
{
|
||||
RtfOle1ToOle2Stream* piStream = static_cast<RtfOle1ToOle2Stream*>(oStream);
|
||||
if( piStream->nCurPos + (int)dwRead > piStream->nBufferSize )
|
||||
return 0;
|
||||
memcpy( pTarget, (piStream->pBuffer + piStream->nCurPos) , dwRead );
|
||||
piStream->nCurPos += dwRead;
|
||||
return dwRead;
|
||||
}
|
||||
DWORD CALLBACK OlePut2(LPOLESTREAM oStream, const void FAR* pTarget, DWORD dwWrite)
|
||||
{
|
||||
RtfOle2ToOle1Stream* piStream = static_cast<RtfOle2ToOle1Stream*>(oStream);
|
||||
BYTE* pSource = (BYTE*)pTarget;
|
||||
for( DWORD i = 0; i < dwWrite; i++ )
|
||||
piStream->aBuffer.push_back( pSource[i] );
|
||||
return dwWrite;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
#include "RtfParagraph.h"
|
||||
#include "RtfShape.h"
|
||||
|
||||
#include <boost/smart_ptr/shared_array.hpp>
|
||||
|
||||
class RtfOle : public IDocumentElement
|
||||
{
|
||||
public:
|
||||
@ -42,13 +44,15 @@ public:
|
||||
int m_nShapeId;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
std::wstring m_sOleClass;
|
||||
RtfShapePtr m_oResultPic;
|
||||
std::wstring m_sOleClass;
|
||||
|
||||
RtfShapePtr m_oResultShape;
|
||||
|
||||
std::pair<boost::shared_array<unsigned char>, size_t> m_oOle1Data;
|
||||
|
||||
RtfCharProperty m_oCharProperty; // тут могут быть track changes ....
|
||||
RtfOle()
|
||||
{
|
||||
m_piStorage = NULL;
|
||||
SetDefault();
|
||||
}
|
||||
~RtfOle()
|
||||
@ -71,12 +75,6 @@ public:
|
||||
{
|
||||
m_sOleFilename = sFilename;
|
||||
}
|
||||
void SetOle( POLE::Storage* piOle )
|
||||
{
|
||||
if (piOle == NULL) return;
|
||||
|
||||
m_piStorage = piOle;
|
||||
}
|
||||
void SetDefault()
|
||||
{
|
||||
m_eOleType = ot_none;
|
||||
@ -84,48 +82,15 @@ public:
|
||||
m_nWidth = PROP_DEF;
|
||||
m_nHeight = PROP_DEF;
|
||||
|
||||
RELEASEOBJECT( m_piStorage );
|
||||
Utils::RemoveDirOrFile( m_sOleFilename );
|
||||
m_sOleFilename = L"";
|
||||
|
||||
m_oCharProperty.SetDefault();
|
||||
}
|
||||
private:
|
||||
POLE::Storage* m_piStorage;
|
||||
std::wstring m_sOleFilename;
|
||||
std::wstring m_sOleFilename;
|
||||
|
||||
std::wstring RenderToOOXOnlyOle(RenderParameter oRenderParameter);
|
||||
};
|
||||
typedef boost::shared_ptr<RtfOle> RtfOlePtr;
|
||||
|
||||
|
||||
#if defined (_WIN32) || defined (_WIN64)
|
||||
struct RtfOle1ToOle2Stream : OLESTREAM
|
||||
{
|
||||
BYTE* pBuffer;
|
||||
long nBufferSize;
|
||||
long nCurPos;
|
||||
};
|
||||
struct RtfOle2ToOle1Stream : OLESTREAM
|
||||
{
|
||||
std::vector<BYTE> aBuffer;
|
||||
};
|
||||
|
||||
DWORD CALLBACK OleGet1(LPOLESTREAM oStream, void FAR* pTarget, DWORD dwRead);;
|
||||
DWORD CALLBACK OlePut1(LPOLESTREAM, const void FAR*, DWORD);
|
||||
DWORD CALLBACK OleGet2(LPOLESTREAM oStream, void FAR* pTarget, DWORD dwRead);;
|
||||
DWORD CALLBACK OlePut2(LPOLESTREAM, const void FAR*, DWORD);
|
||||
|
||||
#else
|
||||
struct RtfOle1ToOle2Stream : POLE::Stream
|
||||
{
|
||||
BYTE* pBuffer;
|
||||
|
||||
long nBufferSize;
|
||||
long nCurPos;
|
||||
};
|
||||
struct RtfOle2ToOle1Stream : POLE::Stream
|
||||
{
|
||||
std::vector<BYTE> aBuffer;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "RtfWriter.h"
|
||||
#include "Utils.h"
|
||||
|
||||
std::wstring RtfPicture::GenerateWMF(RenderParameter oRenderParameter)
|
||||
std::wstring RtfPicture::GenerateWMF(RenderParameter oRenderParameter) //копия растра в векторе
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += L"{\\pict";
|
||||
@ -145,6 +145,10 @@ std::wstring RtfPicture::RenderToOOX(RenderParameter oRenderParameter)
|
||||
else
|
||||
m_bIsCopy = false;
|
||||
|
||||
if( true == m_bIsCopy && !m_sPicFilename.empty() )
|
||||
{
|
||||
Utils::RemoveDirOrFile( m_sPicFilename );
|
||||
}
|
||||
poOOXWriter->m_oContentTypes.AddExtension( sMime, sExtension);
|
||||
|
||||
std::wstring srId = poRelsWriter->AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", sFilenameRels);
|
||||
|
||||
@ -32,13 +32,11 @@
|
||||
#pragma once
|
||||
#include "RtfProperty.h"
|
||||
#include "Utils.h"
|
||||
//#include "../Common/MediaFormatDefine.h"
|
||||
|
||||
class RtfPicture : public IDocumentElement
|
||||
{
|
||||
public:
|
||||
typedef enum {dt_none, dt_png, dt_jpg, dt_emf, dt_wmf, dt_apm, dt_macpict}DataType;
|
||||
// RtfShape m_oShapeProp;
|
||||
|
||||
DataType eDataType;
|
||||
|
||||
@ -108,10 +106,6 @@ public:
|
||||
DEFAULT_PROPERTY( m_nCropR )
|
||||
DEFAULT_PROPERTY( m_nCropB )
|
||||
|
||||
if( true == m_bIsCopy && !m_sPicFilename.empty() )
|
||||
{
|
||||
Utils::RemoveDirOrFile( m_sPicFilename );
|
||||
}
|
||||
m_sPicFilename = L"";
|
||||
}
|
||||
std::wstring RenderToRtf(RenderParameter oRenderParameter);
|
||||
|
||||
@ -2364,13 +2364,13 @@ std::wstring RtfCellProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
|
||||
std::wstring sMargin;
|
||||
if( 3 == m_ePaddingLeftUnit && PROP_DEF != m_nPaddingLeft)
|
||||
sResult += L"<w:left w:w=\"" + std::to_wstring(m_nPaddingLeft) + L"\" w:type=\"dxa\"/>";
|
||||
sMargin += L"<w:left w:w=\"" + std::to_wstring(m_nPaddingLeft) + L"\" w:type=\"dxa\"/>";
|
||||
if( 3 == m_ePaddingRightUnit && PROP_DEF != m_nPaddingRight)
|
||||
sResult += L"<w:right w:w=\"" + std::to_wstring(m_nPaddingRight) + L"\" w:type=\"dxa\"/>";
|
||||
sMargin += L"<w:right w:w=\"" + std::to_wstring(m_nPaddingRight) + L"\" w:type=\"dxa\"/>";
|
||||
if( 3 == m_ePaddingTopUnit && PROP_DEF != m_nPaddingTop)
|
||||
sResult += L"<w:top w:w=\"" + std::to_wstring(m_nPaddingTop) + L"\" w:type=\"dxa\"/>";
|
||||
sMargin += L"<w:top w:w=\"" + std::to_wstring(m_nPaddingTop) + L"\" w:type=\"dxa\"/>";
|
||||
if( 3 == m_ePaddingBottomUnit && PROP_DEF != m_nPaddingBottom)
|
||||
sResult += L"<w:bottom w:w=\"" + std::to_wstring(m_nPaddingBottom) + L"\" w:type=\"dxa\"/>";
|
||||
sMargin += L"<w:bottom w:w=\"" + std::to_wstring(m_nPaddingBottom) + L"\" w:type=\"dxa\"/>";
|
||||
|
||||
if( !sMargin.empty() )
|
||||
{
|
||||
@ -2531,7 +2531,7 @@ std::wstring RtfTableProperty::RenderToRtf(RenderParameter oRenderParameter)
|
||||
RENDER_RTF_INT( m_nAutoFit, sResult, L"trautofit" )
|
||||
RENDER_RTF_INT( m_nGraph, sResult, L"trgaph" )
|
||||
RENDER_RTF_INT( nTableIndent, sResult, L"tblind" )
|
||||
RENDER_RTF_INT( nTableIndentUnits, sResult, L"tblindtype" )
|
||||
RENDER_RTF_INT( eTableIndentUnit, sResult, L"tblindtype" )
|
||||
|
||||
RENDER_RTF_INT( m_nWrapLeft, sResult, L"tdfrmtxtLeft" )
|
||||
RENDER_RTF_INT( m_nWrapRight, sResult, L"tdfrmtxtRight" )
|
||||
@ -2589,49 +2589,51 @@ std::wstring RtfTableProperty::RenderToRtf(RenderParameter oRenderParameter)
|
||||
RENDER_RTF_INT( m_nDefCellMarRight, sResult, L"trpaddr" );
|
||||
RENDER_RTF_INT( m_nDefCellMarTop, sResult, L"trpaddt" );
|
||||
RENDER_RTF_INT( m_nDefCellMarBottom, sResult, L"trpaddb" );
|
||||
RENDER_RTF_INT( m_nDefCellMarLeftUnits, sResult, L"trpaddfl" );
|
||||
RENDER_RTF_INT( m_nDefCellMarRightUnits, sResult, L"trpaddfr" );
|
||||
RENDER_RTF_INT( m_nDefCellMarTopUnits, sResult, L"trpaddft" );
|
||||
RENDER_RTF_INT( m_nDefCellMarBottomUnits, sResult, L"trpaddfb" );
|
||||
RENDER_RTF_INT( m_eDefCellMarLeftUnit, sResult, L"trpaddfl" );
|
||||
RENDER_RTF_INT( m_eDefCellMarRightUnit, sResult, L"trpaddfr" );
|
||||
RENDER_RTF_INT( m_eDefCellMarTopUnit, sResult, L"trpaddft" );
|
||||
RENDER_RTF_INT( m_eDefCellMarBottomUnit, sResult, L"trpaddfb" );
|
||||
|
||||
RENDER_RTF_INT( m_nDefCellSpBottom, sResult, L"trspdb" );
|
||||
RENDER_RTF_INT( m_nDefCellSpLeft, sResult, L"trspdl" );
|
||||
RENDER_RTF_INT( m_nDefCellSpRight, sResult, L"trspdr" );
|
||||
RENDER_RTF_INT( m_nDefCellSpTop, sResult, L"trspdt" );
|
||||
RENDER_RTF_INT( m_nDefCellSpBottomUnits, sResult, L"trspdfb" );
|
||||
RENDER_RTF_INT( m_nDefCellSpLeftUnits, sResult, L"trspdfl" );
|
||||
RENDER_RTF_INT( m_nDefCellSpRightUnits, sResult, L"trspdfr" );
|
||||
RENDER_RTF_INT( m_nDefCellSpTopUnits, sResult, L"trspdft" );
|
||||
RENDER_RTF_INT( m_eDefCellSpBottomUnit, sResult, L"trspdfb" );
|
||||
RENDER_RTF_INT( m_eDefCellSpLeftUnit, sResult, L"trspdfl" );
|
||||
RENDER_RTF_INT( m_eDefCellSpRightUnit, sResult, L"trspdfr" );
|
||||
RENDER_RTF_INT( m_eDefCellSpTopUnit, sResult, L"trspdft" );
|
||||
|
||||
if( m_oBorderLeft.IsValid() == true )
|
||||
{
|
||||
sResult += L"\\trbrdrl";
|
||||
sResult += m_oBorderLeft.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderRight.IsValid() == true )
|
||||
{
|
||||
sResult += L"\\trbrdrr";
|
||||
sResult += m_oBorderRight.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderTop.IsValid() == true )
|
||||
{
|
||||
sResult += L"\\trbrdrt";
|
||||
sResult += m_oBorderTop.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderLeft.IsValid() == true )
|
||||
{
|
||||
sResult += L"\\trbrdrl";
|
||||
sResult += m_oBorderLeft.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderBottom.IsValid() == true )
|
||||
{
|
||||
sResult += L"\\trbrdrb";
|
||||
sResult += m_oBorderBottom.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderRight.IsValid() == true )
|
||||
{
|
||||
sResult += L"\\trbrdrr";
|
||||
sResult += m_oBorderRight.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderVert.IsValid() == true && m_bAutoNoColBand != 1)
|
||||
if( m_oBorderHor.IsValid() == true/* && m_bAutoNoRowBand != 1*/)
|
||||
{
|
||||
sResult += L"\\trbrdrh";
|
||||
sResult += m_oBorderHor.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderVert.IsValid() == true/* && m_bAutoNoColBand != 1*/)
|
||||
{
|
||||
sResult += L"\\trbrdrv";
|
||||
sResult += m_oBorderVert.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
if( m_oBorderHor.IsValid() == true && m_bAutoNoRowBand != 1)
|
||||
{
|
||||
sResult += L"\\trbrdrh";
|
||||
sResult += m_oBorderHor.RenderToRtf( oRenderParameter );
|
||||
}
|
||||
|
||||
if( m_oShading.IsValid() == true )
|
||||
sResult += m_oShading.RenderToRtf( oRenderParameter );
|
||||
|
||||
@ -2671,17 +2673,9 @@ std::wstring RtfTableProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
sResult += L"<w:tblLayout w:type=\"autofit\"/>";
|
||||
|
||||
//сделаем не по документации, а как все остальные юниты !!!
|
||||
if( PROP_DEF != nTableIndent && 1 != nTableIndentUnits )
|
||||
if( PROP_DEF != nTableIndent && 3 == eTableIndentUnit )
|
||||
{
|
||||
switch(nTableIndentUnits)
|
||||
{
|
||||
//case 0: sResult += L"<w:tblInd w:w=\"0\" w:type=\"dxa\"/>" );break;
|
||||
//case 2: sResult += L"<w:tblInd w:w=\"" + std::to_wstring(nTableIndent) + L"%%\" w:type=\"pct\"/>", );break;
|
||||
case 3: sResult += L"<w:tblInd w:w=\"" + std::to_wstring(nTableIndent) + L"\" w:type=\"dxa\"/>"; break;
|
||||
//default: sResult += L"<w:tblInd w:w=\"" + std::to_wstring(nTableIndent) + L"\" w:type=\"dxa\"/>", nTableIndent );break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sResult += L"<w:tblInd w:w=\"" + std::to_wstring(nTableIndent) + L"\" w:type=\"dxa\"/>";
|
||||
}
|
||||
|
||||
if( 1 == m_bOverlap )
|
||||
@ -2761,19 +2755,19 @@ std::wstring RtfTableProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
sResult += L"<w:tblW w:w=\"0\" w:type=\"auto\"/>";
|
||||
|
||||
std::wstring sDefCellMargins;
|
||||
if( PROP_DEF != m_nDefCellMarBottom && 3 == m_nDefCellMarBottomUnits )
|
||||
if( PROP_DEF != m_nDefCellMarBottom && 3 == m_eDefCellMarBottomUnit )
|
||||
sDefCellMargins += L"<w:bottom w:w=\"" + std::to_wstring(m_nDefCellMarBottom) + L"\" w:type=\"dxa\"/>";
|
||||
if( PROP_DEF != m_nDefCellMarLeft && 3 == m_nDefCellMarLeftUnits )
|
||||
if( PROP_DEF != m_nDefCellMarLeft && 3 == m_eDefCellMarLeftUnit )
|
||||
sDefCellMargins += L"<w:left w:w=\"" + std::to_wstring(m_nDefCellMarLeft) + L"\" w:type=\"dxa\"/>";
|
||||
if( PROP_DEF != m_nDefCellMarRight && 3 == m_nDefCellMarRightUnits )
|
||||
if( PROP_DEF != m_nDefCellMarRight && 3 == m_eDefCellMarRightUnit )
|
||||
sDefCellMargins += L"<w:right w:w=\"" + std::to_wstring(m_nDefCellMarRight) + L"\" w:type=\"dxa\"/>";
|
||||
if( PROP_DEF != m_nDefCellMarTop && 3 == m_nDefCellMarTopUnits )
|
||||
if( PROP_DEF != m_nDefCellMarTop && 3 == m_eDefCellMarTopUnit )
|
||||
sDefCellMargins += L"<w:top w:w=\"" + std::to_wstring(m_nDefCellMarTop) + L"\" w:type=\"dxa\"/>";
|
||||
|
||||
if( !sDefCellMargins.empty() )
|
||||
sResult += L"<w:tblCellMar>" + sDefCellMargins + L"</w:tblCellMar>";
|
||||
|
||||
if( PROP_DEF != m_nDefCellSpBottom && 3 == m_nDefCellSpBottomUnits )
|
||||
if( PROP_DEF != m_nDefCellSpBottom && 3 == m_eDefCellSpBottomUnit )
|
||||
sResult += L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_nDefCellSpBottom) + L"\" w:type=\"dxa\"/>";
|
||||
|
||||
//if( PROP_DEF != m_nLeft )
|
||||
@ -2853,7 +2847,7 @@ std::wstring RtfRowProperty::RenderToRtf(RenderParameter oRenderParameter)
|
||||
break;
|
||||
}
|
||||
RENDER_RTF_INT( m_nWidth, sResult, L"trwWidth" );
|
||||
switch( m_eMUStartInvCell )
|
||||
switch( m_eWidthStartInvCellUnit )
|
||||
{
|
||||
case mu_Auto: sResult += L"\\trftsWidthB1"; break;
|
||||
case mu_Percent: sResult += L"\\trftsWidthB2"; break;
|
||||
@ -2862,7 +2856,7 @@ std::wstring RtfRowProperty::RenderToRtf(RenderParameter oRenderParameter)
|
||||
break;
|
||||
}
|
||||
RENDER_RTF_INT( m_nWidthStartInvCell, sResult, L"trwWidthB" );
|
||||
switch( m_eMUEndInvCell )
|
||||
switch( m_eWidthEndInvCellUnit )
|
||||
{
|
||||
case mu_Auto: sResult += L"\\trftsWidthA1"; break;
|
||||
case mu_Percent: sResult += L"\\trftsWidthA2"; break;
|
||||
@ -2913,7 +2907,7 @@ std::wstring RtfRowProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
|
||||
if( PROP_DEF != m_nWidthStartInvCell )
|
||||
{
|
||||
switch( m_eMUStartInvCell )
|
||||
switch( m_eWidthStartInvCellUnit )
|
||||
{
|
||||
case mu_Percent: sResult += L"<w:wBefore w:type=\"pct\" w:w=\"" + std::to_wstring(m_nWidthStartInvCell) + L"%\"/>"; break;
|
||||
case mu_Twips: sResult += L"<w:wBefore w:type=\"dxa\" w:w=\"" + std::to_wstring(m_nWidthStartInvCell) + L"\"/>"; break;
|
||||
@ -2923,7 +2917,7 @@ std::wstring RtfRowProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
}
|
||||
if( PROP_DEF != m_nWidthEndInvCell )
|
||||
{
|
||||
switch( m_eMUEndInvCell )
|
||||
switch( m_eWidthEndInvCellUnit )
|
||||
{
|
||||
case mu_Percent: sResult += L"<w:wAfter w:type=\"pct\" w:w=\"" + std::to_wstring(m_nWidthEndInvCell) + L"%\"/>"; break;
|
||||
case mu_Twips: sResult += L"<w:wAfter w:type=\"dxa\" w:w=\"" + std::to_wstring(m_nWidthEndInvCell) + L"\"/>"; break;
|
||||
|
||||
@ -1779,7 +1779,7 @@ public:
|
||||
int m_nGraph; //trgaphN Half the space between the cells of a table row in twips.
|
||||
|
||||
int nTableIndent; //tblindN
|
||||
int nTableIndentUnits; // tblindtypeN
|
||||
int eTableIndentUnit; // tblindtypeN
|
||||
|
||||
enum _RowJust
|
||||
{
|
||||
@ -1812,20 +1812,20 @@ public:
|
||||
int m_nDefCellMarRight; //trpaddrN Default right cell margin or padding for the row.
|
||||
int m_nDefCellMarTop; //trpaddtN Default top cell margin or padding for the row.
|
||||
|
||||
int m_nDefCellMarBottomUnits; //Units for \trpaddbN: 0 Null. Ignore \trpaddbN in favor of \trgaphN (Word 97 style padding). 3 Twips.
|
||||
int m_nDefCellMarLeftUnits;
|
||||
int m_nDefCellMarRightUnits;
|
||||
int m_nDefCellMarTopUnits;
|
||||
int m_eDefCellMarBottomUnit; //Units for \trpaddbN: 0 Null. Ignore \trpaddbN in favor of \trgaphN (Word 97 style padding). 3 Twips.
|
||||
int m_eDefCellMarLeftUnit;
|
||||
int m_eDefCellMarRightUnit;
|
||||
int m_eDefCellMarTopUnit;
|
||||
|
||||
int m_nDefCellSpBottom; //trspdbN Default bottom cell spacing for the row. The total vertical spacing between adjacent cells is equal to the sum of \trspdtN from the bottom cell and \trspdbN from the top cell, both of which will have the same value when written by Word.
|
||||
int m_nDefCellSpLeft; //trspdlN
|
||||
int m_nDefCellSpRight; //trspdrN
|
||||
int m_nDefCellSpTop; //trspdtN
|
||||
|
||||
int m_nDefCellSpBottomUnits; //trspdfbN Units for \trspdbN: 0 Null. Ignore \trspdbN. 3 Twips.
|
||||
int m_nDefCellSpLeftUnits;
|
||||
int m_nDefCellSpRightUnits;
|
||||
int m_nDefCellSpTopUnits;
|
||||
int m_eDefCellSpBottomUnit; //trspdfbN Units for \trspdbN: 0 Null. Ignore \trspdbN. 3 Twips.
|
||||
int m_eDefCellSpLeftUnit;
|
||||
int m_eDefCellSpRightUnit;
|
||||
int m_eDefCellSpTopUnit;
|
||||
|
||||
RtfBorder m_oBorderLeft;
|
||||
RtfBorder m_oBorderRight;
|
||||
@ -1869,7 +1869,7 @@ public:
|
||||
DEFAULT_PROPERTY( m_nGraph )
|
||||
|
||||
DEFAULT_PROPERTY( nTableIndent )
|
||||
DEFAULT_PROPERTY( nTableIndentUnits )
|
||||
DEFAULT_PROPERTY( eTableIndentUnit )
|
||||
|
||||
m_eJust = rj_none;
|
||||
|
||||
@ -1900,24 +1900,24 @@ public:
|
||||
DEFAULT_PROPERTY( m_nDefCellMarLeft )
|
||||
DEFAULT_PROPERTY( m_nDefCellMarTop )
|
||||
|
||||
m_nDefCellMarBottomUnits = 3;
|
||||
m_nDefCellMarRightUnits = 3;
|
||||
m_nDefCellMarLeftUnits = 3;
|
||||
m_nDefCellMarTopUnits = 3;
|
||||
//DEFAULT_PROPERTY( m_nDefCellMarBottomUnits )
|
||||
//DEFAULT_PROPERTY( m_nDefCellMarRightUnits )
|
||||
//DEFAULT_PROPERTY( m_nDefCellMarLeftUnits )
|
||||
//DEFAULT_PROPERTY( m_nDefCellMarTopUnits )
|
||||
//m_eDefCellMarBottomUnit = 3;
|
||||
//m_eDefCellMarRightUnit = 3;
|
||||
//m_eDefCellMarLeftUnit = 3;
|
||||
//m_eDefCellMarTopUnit = 3;
|
||||
DEFAULT_PROPERTY( m_eDefCellMarBottomUnit )
|
||||
DEFAULT_PROPERTY( m_eDefCellMarRightUnit )
|
||||
DEFAULT_PROPERTY( m_eDefCellMarLeftUnit )
|
||||
DEFAULT_PROPERTY( m_eDefCellMarTopUnit )
|
||||
|
||||
DEFAULT_PROPERTY( m_nDefCellSpBottom )
|
||||
DEFAULT_PROPERTY( m_nDefCellSpLeft )
|
||||
DEFAULT_PROPERTY( m_nDefCellSpRight )
|
||||
DEFAULT_PROPERTY( m_nDefCellSpTop )
|
||||
|
||||
DEFAULT_PROPERTY( m_nDefCellSpBottomUnits )
|
||||
DEFAULT_PROPERTY( m_nDefCellSpLeftUnits )
|
||||
DEFAULT_PROPERTY( m_nDefCellSpRightUnits )
|
||||
DEFAULT_PROPERTY( m_nDefCellSpTopUnits )
|
||||
DEFAULT_PROPERTY( m_eDefCellSpBottomUnit )
|
||||
DEFAULT_PROPERTY( m_eDefCellSpLeftUnit )
|
||||
DEFAULT_PROPERTY( m_eDefCellSpRightUnit )
|
||||
DEFAULT_PROPERTY( m_eDefCellSpTopUnit )
|
||||
|
||||
m_oBorderLeft.SetEmpty();
|
||||
m_oBorderRight.SetEmpty();
|
||||
@ -1950,7 +1950,7 @@ public:
|
||||
MERGE_PROPERTY( m_nAutoFit, oTablePr )
|
||||
MERGE_PROPERTY( m_nGraph, oTablePr )
|
||||
MERGE_PROPERTY( nTableIndent, oTablePr )
|
||||
MERGE_PROPERTY( nTableIndentUnits, oTablePr )
|
||||
MERGE_PROPERTY( eTableIndentUnit, oTablePr )
|
||||
|
||||
MERGE_PROPERTY_DEF( m_eJust, oTablePr, rj_none )
|
||||
|
||||
@ -1976,19 +1976,19 @@ public:
|
||||
MERGE_PROPERTY( m_nDefCellMarRight, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellMarLeft, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellMarTop, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellMarBottomUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellMarRightUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellMarLeftUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellMarTopUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellMarBottomUnit, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellMarRightUnit, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellMarLeftUnit, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellMarTopUnit, oTablePr )
|
||||
|
||||
MERGE_PROPERTY( m_nDefCellSpBottom, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpLeft, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpRight, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpTop, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpBottomUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpLeftUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpRightUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_nDefCellSpTopUnits, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellSpBottomUnit, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellSpLeftUnit, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellSpRightUnit, oTablePr )
|
||||
MERGE_PROPERTY( m_eDefCellSpTopUnit, oTablePr )
|
||||
|
||||
m_oBorderLeft.Merge ( oTablePr.m_oBorderLeft );
|
||||
m_oBorderRight.Merge( oTablePr.m_oBorderRight );
|
||||
@ -2423,11 +2423,11 @@ public:
|
||||
|
||||
int m_nHeight; //trrhN Height of a table row in twips. When 0, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line.
|
||||
|
||||
int m_nWidthStartInvCell; //trwWidthBN Width of invisible cell at the beginning of the row. Used only in cases where rows have different widths.
|
||||
int m_eMUStartInvCell; //trftsWidthBN Units for \trwWidthBN:
|
||||
int m_nWidthStartInvCell; //trwWidthBN Width of invisible cell at the beginning of the row. Used only in cases where rows have different widths.
|
||||
int m_eWidthStartInvCellUnit; //trftsWidthBN Units for \trwWidthBN:
|
||||
|
||||
int m_nWidthEndInvCell; //trwWidthAN Width of invisible cell at the end of the row. Used only when rows have different widths.
|
||||
int m_eMUEndInvCell; //trftsWidthAN Units for \trwWidthAN:
|
||||
int m_nWidthEndInvCell; //trwWidthAN Width of invisible cell at the end of the row. Used only when rows have different widths.
|
||||
int m_eWidthEndInvCellUnit; //trftsWidthAN Units for \trwWidthAN:
|
||||
|
||||
int m_nGridBefore; //для oox
|
||||
int m_nGridAfter; //для oox
|
||||
@ -2483,9 +2483,11 @@ public:
|
||||
DEFAULT_PROPERTY( m_nHeight )
|
||||
|
||||
DEFAULT_PROPERTY( m_nWidthStartInvCell )
|
||||
m_eMUStartInvCell = mu_none;
|
||||
DEFAULT_PROPERTY( m_nWidthEndInvCell )
|
||||
m_eMUEndInvCell = mu_none;
|
||||
|
||||
m_eWidthStartInvCellUnit = mu_none;
|
||||
m_eWidthEndInvCellUnit = mu_none;
|
||||
|
||||
DEFAULT_PROPERTY( m_nGridBefore )
|
||||
DEFAULT_PROPERTY( m_nGridAfter )
|
||||
m_aArray.clear();
|
||||
@ -2526,10 +2528,10 @@ public:
|
||||
|
||||
MERGE_PROPERTY( m_nHeight, oRowPr )
|
||||
|
||||
MERGE_PROPERTY ( m_nWidthStartInvCell, oRowPr )
|
||||
MERGE_PROPERTY_DEF ( m_eMUStartInvCell, oRowPr, mu_none )
|
||||
MERGE_PROPERTY ( m_nWidthEndInvCell, oRowPr )
|
||||
MERGE_PROPERTY_DEF ( m_eMUEndInvCell, oRowPr, mu_none )
|
||||
MERGE_PROPERTY ( m_nWidthStartInvCell, oRowPr )
|
||||
MERGE_PROPERTY_DEF ( m_eWidthStartInvCellUnit, oRowPr, mu_none )
|
||||
MERGE_PROPERTY ( m_nWidthEndInvCell, oRowPr )
|
||||
MERGE_PROPERTY_DEF ( m_eWidthEndInvCellUnit, oRowPr, mu_none )
|
||||
|
||||
MERGE_PROPERTY_DEF ( m_nGridBefore, oRowPr, mu_none )
|
||||
MERGE_PROPERTY_DEF ( m_nGridAfter, oRowPr, mu_none )
|
||||
|
||||
@ -42,10 +42,14 @@ void RtfShape::SetDefault()
|
||||
m_eAnchorTypeShape = st_none;
|
||||
|
||||
//Common
|
||||
DEFAULT_PROPERTY( m_nWidth )
|
||||
DEFAULT_PROPERTY( m_nHeight )
|
||||
|
||||
DEFAULT_PROPERTY( m_nLeft )
|
||||
DEFAULT_PROPERTY( m_nTop )
|
||||
DEFAULT_PROPERTY( m_nBottom )
|
||||
DEFAULT_PROPERTY( m_nRight )
|
||||
|
||||
DEFAULT_PROPERTY( m_nID )
|
||||
DEFAULT_PROPERTY( m_nZOrder )
|
||||
DEFAULT_PROPERTY( m_nHeader )
|
||||
@ -187,9 +191,9 @@ void RtfShape::SetDefault()
|
||||
m_aTextItems = TextItemContainerPtr();
|
||||
m_oPicture = RtfPicturePtr();
|
||||
m_bBackground = false;
|
||||
m_bIsOle = false;
|
||||
m_bInGroup = false;
|
||||
m_bIsGroup = false;
|
||||
m_bIsOle = false;
|
||||
|
||||
m_oCharProperty.SetDefault();
|
||||
}
|
||||
@ -224,7 +228,12 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
|
||||
|
||||
sResult += m_oCharProperty.RenderToRtf( oRenderParameter );
|
||||
|
||||
if( st_inline == m_eAnchorTypeShape || st_none == m_eAnchorTypeShape)
|
||||
if (m_bIsOle)
|
||||
{
|
||||
m_oPicture->dump_shape_properties = RenderToRtfShapeProperty( oRenderParameter );
|
||||
sResult += m_oPicture->RenderToRtf( oRenderParameter );
|
||||
}
|
||||
else if (( st_inline == m_eAnchorTypeShape || st_none == m_eAnchorTypeShape) && !m_bIsOle)
|
||||
{
|
||||
if( NULL != m_oPicture && m_nShapeType == NSOfficeDrawing::sptPictureFrame)
|
||||
{
|
||||
@ -329,7 +338,7 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
|
||||
sResult += L"}";
|
||||
}
|
||||
}
|
||||
else // anchor
|
||||
else // anchor or ole
|
||||
{
|
||||
sResult += L"{\\shp";
|
||||
sResult += L"{\\*\\shpinst";
|
||||
@ -453,12 +462,12 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
|
||||
if (m_sName.empty() == false)
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzName}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText( m_sName, oRenderParameter.poDocument, -1 ) + L"}}";
|
||||
sResult += RtfChar::renderRtfText( m_sName, oRenderParameter.poDocument, 48 ) + L"}}"; //utf-16
|
||||
}
|
||||
if (m_sDescription.empty() == false)
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzDescription}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText(m_sDescription, oRenderParameter.poDocument, -1 ) + L"}}";
|
||||
sResult += RtfChar::renderRtfText(m_sDescription, oRenderParameter.poDocument, 48 ) + L"}}"; //utf-16
|
||||
}
|
||||
//Rehydration
|
||||
//RENDER_RTF_SHAPE_PROP(L"metroBlob", sResult, m_sMetroBlob);
|
||||
@ -494,6 +503,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
|
||||
RENDER_RTF_SHAPE_PROP(L"txdir", sResult, m_nTxdir);
|
||||
RENDER_RTF_SHAPE_PROP(L"WrapText", sResult, m_nWrapText);
|
||||
RENDER_RTF_SHAPE_PROP(L"txflTextFlow", sResult, m_nTxflTextFlow);
|
||||
RENDER_RTF_SHAPE_PROP(L"fRotateText", sResult, m_fRotateText);
|
||||
//Geometry
|
||||
RENDER_RTF_SHAPE_PROP(L"adjustValue", sResult, m_nAdjustValue[0] );
|
||||
RENDER_RTF_SHAPE_PROP(L"adjust2Value", sResult, m_nAdjustValue[1] );
|
||||
@ -607,7 +617,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
|
||||
{
|
||||
RENDER_RTF_SHAPE_PROP(L"fGtext", sResult, m_bGtext );
|
||||
|
||||
int nCodePage = -1;
|
||||
int nCodePage = 48; //utf-16
|
||||
|
||||
if( m_sGtextFont.empty() == false)
|
||||
{
|
||||
@ -647,31 +657,31 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
|
||||
if( !m_sSigSetupId.empty() )
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzSigSetupId}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupId, oRenderParameter.poDocument, 0);
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupId, oRenderParameter.poDocument, 48); //utf-16
|
||||
sResult += L"}}";
|
||||
}
|
||||
if( !m_sSigSetupProvId.empty() )
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzSigSetupProvId}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupProvId, oRenderParameter.poDocument, 0);
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupProvId, oRenderParameter.poDocument, 48); //utf-16
|
||||
sResult += L"}}";
|
||||
}
|
||||
if( !m_sSigSetupSuggSigner.empty() )
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzSigSetupSuggSigner}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSigner, oRenderParameter.poDocument, 0);
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSigner, oRenderParameter.poDocument, 48); //utf-16
|
||||
sResult += L"}}";
|
||||
}
|
||||
if( !m_sSigSetupSuggSigner2.empty() )
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzSigSetupSuggSigner2}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSigner2, oRenderParameter.poDocument, 0);
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSigner2, oRenderParameter.poDocument, 48); //utf-16
|
||||
sResult += L"}}";
|
||||
}
|
||||
if( !m_sSigSetupSuggSignerEmail.empty() )
|
||||
{
|
||||
sResult += L"{\\sp{\\sn wzSigSetupSuggSignerEmail}{\\sv ";
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSignerEmail, oRenderParameter.poDocument, 0);
|
||||
sResult += RtfChar::renderRtfText(m_sSigSetupSuggSignerEmail, oRenderParameter.poDocument, 48); //utf-16
|
||||
sResult += L"}}";
|
||||
}
|
||||
}
|
||||
@ -687,69 +697,62 @@ std::wstring RtfShape::RenderToOOX(RenderParameter oRenderParameter)
|
||||
std::wstring sResult;
|
||||
RtfDocument* poDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
|
||||
|
||||
TextItemContainerPtr aTempTextItems;
|
||||
|
||||
if( NSOfficeDrawing::sptPictureFrame == m_nShapeType && 0 != m_aTextItems )
|
||||
{//Значит это Ole обьект с anchor, для него все также только TextBox надо делать по-другому
|
||||
aTempTextItems = m_aTextItems;
|
||||
m_aTextItems = TextItemContainerPtr();
|
||||
m_bIsOle = true;
|
||||
{//test for ole
|
||||
TextItemContainerPtr aTempTextItems = m_aTextItems;
|
||||
|
||||
m_aTextItems = TextItemContainerPtr();
|
||||
|
||||
if( 0 != aTempTextItems )
|
||||
{//пишем только Ole обьект
|
||||
int nTempTextItemsCount = aTempTextItems->GetCount();
|
||||
for (size_t i = 0; i < nTempTextItemsCount; i++ )
|
||||
{
|
||||
ITextItemPtr piCurTextItem;
|
||||
aTempTextItems->GetItem( piCurTextItem, i );
|
||||
if( NULL != piCurTextItem && TYPE_RTF_PARAGRAPH == piCurTextItem->GetType() )
|
||||
{
|
||||
RtfParagraphPtr poCurParagraph = boost::static_pointer_cast< RtfParagraph, ITextItem >( piCurTextItem );
|
||||
if( NULL != poCurParagraph )
|
||||
{
|
||||
for (size_t j = 0; j < poCurParagraph->GetCount(); j++ )
|
||||
{
|
||||
IDocumentElementPtr piCurIDocumentElement;
|
||||
poCurParagraph->GetItem( piCurIDocumentElement, j );
|
||||
if( NULL != piCurIDocumentElement && TYPE_RTF_OLE == piCurIDocumentElement->GetType() )
|
||||
{
|
||||
//рендерим только Ole часть
|
||||
RenderParameter oNewParam = oRenderParameter;
|
||||
oNewParam.nType = RENDER_TO_OOX_PARAM_OLE_ONLY;
|
||||
oNewParam.nValue = m_nID;
|
||||
|
||||
RtfOlePtr poCurOle = boost::static_pointer_cast< RtfOle, IDocumentElement >( piCurIDocumentElement );
|
||||
if( NULL != poCurOle )
|
||||
{
|
||||
m_sOle += poCurOle->RenderToOOX( oNewParam );
|
||||
if (!m_sOle.empty())
|
||||
{
|
||||
m_pOleObject = poCurOle;
|
||||
m_bIsOle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( true == m_bIsOle )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//возвращаем text box на место
|
||||
m_aTextItems = aTempTextItems;
|
||||
}
|
||||
}
|
||||
|
||||
sResult = RenderToOOXBegin(oRenderParameter);
|
||||
|
||||
if( !sResult.empty() )
|
||||
sResult += RenderToOOXEnd(oRenderParameter);
|
||||
|
||||
std::wstring sOle;
|
||||
if( 0 != aTempTextItems )
|
||||
{//пишем только Ole обьект
|
||||
//ищем первый ole обьект
|
||||
RtfOlePtr poFirstOle;
|
||||
int nTempTextItemsCount = aTempTextItems->GetCount();
|
||||
for (size_t i = 0; i < nTempTextItemsCount; i++ )
|
||||
{
|
||||
ITextItemPtr piCurTextItem;
|
||||
aTempTextItems->GetItem( piCurTextItem, i );
|
||||
if( NULL != piCurTextItem && TYPE_RTF_PARAGRAPH == piCurTextItem->GetType() )
|
||||
{
|
||||
RtfParagraphPtr poCurParagraph = boost::static_pointer_cast< RtfParagraph, ITextItem >( piCurTextItem );
|
||||
if( NULL != poCurParagraph )
|
||||
{
|
||||
bool bBreak = false;
|
||||
for (size_t j = 0; j < poCurParagraph->GetCount(); j++ )
|
||||
{
|
||||
IDocumentElementPtr piCurIDocumentElement;
|
||||
poCurParagraph->GetItem( piCurIDocumentElement, j );
|
||||
if( NULL != piCurIDocumentElement && TYPE_RTF_OLE == piCurIDocumentElement->GetType() )
|
||||
{
|
||||
//рендерим только Ole часть
|
||||
RenderParameter oNewParam = oRenderParameter;
|
||||
oNewParam.nType = RENDER_TO_OOX_PARAM_OLE_ONLY;
|
||||
oNewParam.nValue = m_nID;
|
||||
|
||||
RtfOlePtr poCurOle = boost::static_pointer_cast< RtfOle, IDocumentElement >( piCurIDocumentElement );
|
||||
if( NULL != poCurOle )
|
||||
{
|
||||
sOle += poCurOle->RenderToOOX( oNewParam );
|
||||
bBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( true == bBreak )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//возвращаем text box на место
|
||||
m_aTextItems = aTempTextItems;
|
||||
}
|
||||
|
||||
if( !sOle.empty() && !sResult.empty())
|
||||
{
|
||||
XmlUtils::replace_all(sResult, L"</w:pict>", sOle + L"</w:pict>" );//todooo переписать
|
||||
}
|
||||
|
||||
return sResult;
|
||||
}
|
||||
@ -784,7 +787,14 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
;//child shape
|
||||
else if( RENDER_TO_OOX_PARAM_SHAPE_WSHAPE == oRenderParameter.nType )
|
||||
{//pic bullets
|
||||
sResult += L"<w:pict>";
|
||||
if (m_bIsOle)
|
||||
{
|
||||
sResult += L"<w:object w:dxaOrig=\"0\" w:dyaOrig=\"0\">";
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += L"<w:pict>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{//работает по умолчанию
|
||||
@ -816,7 +826,14 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
sResult += sCharProp;
|
||||
sResult += L"</w:rPr>";
|
||||
}
|
||||
sResult += L"<w:pict>";
|
||||
if (m_bIsOle)
|
||||
{
|
||||
sResult += L"<w:object w:dxaOrig=\"0\" w:dyaOrig=\"0\">";
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += L"<w:pict>";
|
||||
}
|
||||
}
|
||||
|
||||
if (oRenderParameter.sValue.empty())
|
||||
@ -826,12 +843,13 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
|
||||
sResult += L"<" + oRenderParameter.sValue;
|
||||
|
||||
if (m_sName.empty())
|
||||
RtfDocument* poDocument = static_cast<RtfDocument*>( oRenderParameter.poDocument );
|
||||
sResult += L" id=\"_x0000_s" + std::to_wstring(poDocument->GetShapeId( m_nID )) + L"\"";
|
||||
|
||||
if (!m_sName.empty())
|
||||
{
|
||||
RtfDocument* poDocument = static_cast<RtfDocument*>( oRenderParameter.poDocument );
|
||||
m_sName += L"_x0000_s" + std::to_wstring(poDocument->GetShapeId( m_nID )) + L"";
|
||||
sResult += L" title=\"" + m_sName + L"\"";
|
||||
}
|
||||
sResult += L" id=\"" + m_sName + L"\"";
|
||||
|
||||
if( PROP_DEF != m_nShapeType && 0 != m_nShapeType)
|
||||
{
|
||||
@ -1084,7 +1102,7 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
sResult += L" style=\"" + sStyle + L"\"";
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
if( true == m_bIsOle ) sResult += L" o:ole=\"\"";
|
||||
if( false == m_sOle.empty() ) sResult += L" o:ole=\"\"";
|
||||
|
||||
if( PROP_DEF != m_nGroupLeft && PROP_DEF != m_nGroupTop )
|
||||
sResult += L" coordorigin=\"" + std::to_wstring(m_nGroupLeft) + L"," + std::to_wstring(m_nGroupTop) + L"\"";
|
||||
@ -1261,7 +1279,7 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
}
|
||||
}
|
||||
|
||||
if( 0 != m_aTextItems )
|
||||
if( 0 != m_aTextItems && !m_bIsOle)
|
||||
{
|
||||
RenderParameter oNewParam = oRenderParameter;
|
||||
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
|
||||
@ -1317,16 +1335,19 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
|
||||
sResult += L"<v:imagedata r:id=\"" + sPicture + L"\"";
|
||||
|
||||
if( PROP_DEF != nCropLeft )
|
||||
sResult += L" cropleft=\"" + std::to_wstring(nCropLeft) + L"f\"";
|
||||
if( PROP_DEF != nCropTop )
|
||||
sResult += L" croptop=\"" + std::to_wstring(nCropTop) + L"f\"";
|
||||
if( PROP_DEF != nCropRight )
|
||||
sResult += L" cropright=\"" + std::to_wstring(nCropRight) + L"f\"";
|
||||
if( PROP_DEF != nCropBottom )
|
||||
sResult += L" cropbottom=\"" + std::to_wstring(nCropBottom) + L"f\"";
|
||||
if (!m_bIsOle)
|
||||
{
|
||||
if( PROP_DEF != nCropLeft )
|
||||
sResult += L" cropleft=\"" + std::to_wstring(nCropLeft) + L"f\"";
|
||||
if( PROP_DEF != nCropTop )
|
||||
sResult += L" croptop=\"" + std::to_wstring(nCropTop) + L"f\"";
|
||||
if( PROP_DEF != nCropRight )
|
||||
sResult += L" cropright=\"" + std::to_wstring(nCropRight) + L"f\"";
|
||||
if( PROP_DEF != nCropBottom )
|
||||
sResult += L" cropbottom=\"" + std::to_wstring(nCropBottom) + L"f\"";
|
||||
}
|
||||
|
||||
sResult += L" o:title=\"\"/>";
|
||||
sResult += L" o:title=\"" + m_sName + L"\"/>";
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -1452,10 +1473,20 @@ std::wstring RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter)
|
||||
if( RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2 == oRenderParameter.nType )
|
||||
;
|
||||
else if( RENDER_TO_OOX_PARAM_SHAPE_WSHAPE == oRenderParameter.nType )
|
||||
sResult += L"</w:pict>";
|
||||
{
|
||||
if (!m_sOle.empty()) sResult += m_sOle + L"</w:object>";
|
||||
else sResult += L"</w:pict>";
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += L"</w:pict></w:r>";//работает по умолчанию
|
||||
if (!m_sOle.empty())
|
||||
{
|
||||
sResult += m_sOle + L"</w:object></w:r>";//работает по умолчанию
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += L"</w:pict></w:r>";//работает по умолчанию
|
||||
}
|
||||
|
||||
if (m_bDelete) sResult += L"</w:del>";
|
||||
if (m_bInsert) sResult += L"</w:ins>";
|
||||
|
||||
@ -35,6 +35,9 @@
|
||||
class RtfShape;
|
||||
typedef boost::shared_ptr<RtfShape> RtfShapePtr;
|
||||
|
||||
class RtfOle;
|
||||
typedef boost::shared_ptr<RtfOle> RtfOlePtr;
|
||||
|
||||
class RtfShape: public IRenderableProperty, public ItemContainer<RtfShapePtr>
|
||||
{
|
||||
private:
|
||||
@ -44,9 +47,11 @@ private:
|
||||
public:
|
||||
bool m_bBackground;
|
||||
bool m_bIsGroup;
|
||||
bool m_bIsOle;
|
||||
bool m_bInGroup; //local anchor
|
||||
|
||||
std::wstring m_sOle;
|
||||
bool m_bIsOle;
|
||||
RtfOlePtr m_pOleObject;
|
||||
//-----------------------------
|
||||
enum _AnchorTypeShape { st_none, st_inline, st_anchor };
|
||||
enum _AnchorX
|
||||
@ -72,10 +77,14 @@ public:
|
||||
std::wstring m_sName;
|
||||
std::wstring m_sDescription;
|
||||
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
|
||||
int m_nLeft; //shpleftN Specifies position of shape from the left of the anchor. The value N is in twips.
|
||||
int m_nTop; //shptopN Specifies position of shape from the top of the anchor. The value N is in twips.
|
||||
int m_nBottom; //shpbottomN Specifies position of shape from the bottom of the anchor. The value N is in twips.
|
||||
int m_nRight; //shprightN Specifies position of shape from the right of the anchor. The value N is in twips.
|
||||
|
||||
int m_nID; //shplidN A number that is unique to each shape. This keyword is primarily used for linked text boxes. The value N is a long integer.
|
||||
int m_nZOrder; //shpzN Describes the z-order of the shape. It starts at 0 for the shape that is furthest from the top, and proceeds to the top most shape (N). The shapes that appear inside the header document will have a separate z-order, compared to the z-order of the shapes in the main document. For instance, both the back-most shape in the header and the back-most main-document shape will have a z-order of 0.
|
||||
int m_nHeader; //shpfhdrN Set to 0 if the shape is in the main document. Set to 1 if the shape is in the header document.
|
||||
|
||||
@ -104,9 +104,10 @@ public:
|
||||
|
||||
int nWidthBefore = 0;
|
||||
int nWidthAfter = 0;
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eMUStartInvCell)
|
||||
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
|
||||
nWidthBefore = oCurRow->m_oProperty.m_nWidthStartInvCell;
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eMUEndInvCell)
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthEndInvCellUnit)
|
||||
nWidthAfter = oCurRow->m_oProperty.m_nWidthEndInvCell;
|
||||
|
||||
int nDelta = 0;// поправка на margin и indent и spacing
|
||||
@ -114,13 +115,13 @@ public:
|
||||
nDelta = -oCurRow->m_oProperty.m_nLeft;
|
||||
else
|
||||
{
|
||||
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.nTableIndentUnits )
|
||||
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit )
|
||||
nDelta -= m_oProperty.nTableIndent;
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_nDefCellMarLeftUnits )
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit )
|
||||
nDelta += m_oProperty.m_nDefCellMarLeft;
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_nDefCellSpLeftUnits )
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit )
|
||||
nDelta += 2 * m_oProperty.m_nDefCellSpLeft;
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eMUStartInvCell)
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
|
||||
nDelta -= oCurRow->m_oProperty.m_nWidthStartInvCell;
|
||||
}
|
||||
|
||||
@ -155,9 +156,9 @@ public:
|
||||
|
||||
int nWidthBefore = 0;
|
||||
int nWidthAfter = 0;
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eMUStartInvCell)
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
|
||||
nWidthBefore = oCurRow->m_oProperty.m_nWidthStartInvCell;
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eMUEndInvCell)
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthEndInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthEndInvCellUnit)
|
||||
nWidthAfter = oCurRow->m_oProperty.m_nWidthEndInvCell;
|
||||
|
||||
int nDelta = 0;// поправка на margin и indent и spacing и border
|
||||
@ -165,13 +166,13 @@ public:
|
||||
nDelta = -oCurRow->m_oProperty.m_nLeft;
|
||||
else
|
||||
{
|
||||
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.nTableIndentUnits )
|
||||
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit )
|
||||
nDelta -= m_oProperty.nTableIndent;
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_nDefCellMarLeftUnits )
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit )
|
||||
nDelta += m_oProperty.m_nDefCellMarLeft;
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_nDefCellSpLeftUnits )
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit )
|
||||
nDelta += 2 * m_oProperty.m_nDefCellSpLeft;
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eMUStartInvCell)
|
||||
if( PROP_DEF != oCurRow->m_oProperty.m_nWidthStartInvCell && mu_Twips == oCurRow->m_oProperty.m_eWidthStartInvCellUnit)
|
||||
nDelta -= oCurRow->m_oProperty.m_nWidthStartInvCell;
|
||||
}
|
||||
|
||||
@ -282,11 +283,11 @@ public:
|
||||
RtfTableRowPtr oCurRow= m_aArray[ i ];
|
||||
|
||||
int nLeft = 0;
|
||||
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.nTableIndentUnits )
|
||||
if( PROP_DEF != m_oProperty.nTableIndent && 3 == m_oProperty.eTableIndentUnit )
|
||||
nLeft += m_oProperty.nTableIndent;
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_nDefCellMarLeftUnits )
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellMarLeft && 3 == m_oProperty.m_eDefCellMarLeftUnit )
|
||||
nLeft -= m_oProperty.m_nDefCellMarLeft;
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_nDefCellSpLeftUnits )
|
||||
if( PROP_DEF != m_oProperty.m_nDefCellSpLeft && 3 == m_oProperty.m_eDefCellSpLeftUnit )
|
||||
nLeft += 2 * m_oProperty.m_nDefCellSpLeft;
|
||||
int nDelta = nLeft;//в left учитывается GrindBefore
|
||||
|
||||
|
||||
@ -695,14 +695,21 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sCodePage.empty())
|
||||
if (sCodePage.empty() && nCodepage > 0)
|
||||
sCodePage = "CP" + std::to_string(nCodepage);
|
||||
|
||||
unsigned int insize = (unsigned int)(end - start);
|
||||
const char* inptr = (const char*)start.operator ->();
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
return oConverter.toUnicode(inptr, insize, sCodePage.c_str());
|
||||
if (sCodePage.empty())
|
||||
{
|
||||
return std::wstring(start, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int insize = (unsigned int)(end - start);
|
||||
const char* inptr = (const char*)start.operator ->();
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
return oConverter.toUnicode(inptr, insize, sCodePage.c_str());
|
||||
}
|
||||
}
|
||||
static std::string convert_string(std::wstring::const_iterator start, std::wstring::const_iterator end, int nCodepage = 0)
|
||||
{
|
||||
|
||||
@ -40,17 +40,14 @@
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
HRESULT convert_single(std::wstring srcFileName)
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
std::wstring srcFileName = argv[1];
|
||||
int n1 = srcFileName.rfind(_T('.'));
|
||||
std::wstring ext_1 = n1 >= 0 ? srcFileName.substr(n1+1, srcFileName.length() - n1) : _T("");
|
||||
std::wstring ext_1 = n1 >= 0 ? srcFileName.substr(n1 + 1, srcFileName.length() - n1) : _T("");
|
||||
|
||||
std::transform(ext_1.begin(), ext_1.end(), ext_1.begin(), ::tolower);
|
||||
|
||||
std::wstring dstFileName = argc > 2 ? argv[2] : srcFileName + L"_my." + (ext_1 == L"rtf" ? L"docx" : L"rtf");
|
||||
std::wstring dstFileName = srcFileName + L"_my." + (ext_1 == L"rtf" ? L"docx" : L"rtf");
|
||||
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(dstFileName);
|
||||
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
@ -84,3 +81,33 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HRESULT convert_directory(std::wstring pathName)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
|
||||
|
||||
for (size_t i = 0; i < arFiles.size(); i++)
|
||||
{
|
||||
convert_single(arFiles[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = -1;
|
||||
if (NSFile::CFileBinary::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_single(argv[1]);
|
||||
}
|
||||
else if (NSDirectory::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_directory(argv[1]);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "Compat12.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "CompressPictures.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "CrtLayout12.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
|
||||
#include "CrtLayout12A.h"
|
||||
|
||||
#include <simple_xml_writer.h>
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -39,12 +41,10 @@ CrtLayout12A::CrtLayout12A()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CrtLayout12A::~CrtLayout12A()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BaseObjectPtr CrtLayout12A::clone()
|
||||
{
|
||||
return BaseObjectPtr(new CrtLayout12A(*this));
|
||||
@ -52,10 +52,88 @@ BaseObjectPtr CrtLayout12A::clone()
|
||||
|
||||
void CrtLayout12A::readFields(CFRecord& record)
|
||||
{
|
||||
#pragma message("####################### CrtLayout12A record is not implemented")
|
||||
Log::error("CrtLayout12A record is not implemented.");
|
||||
unsigned short flags, reserved;
|
||||
record >> frtheader >> dwCheckSum >> flags;
|
||||
|
||||
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
|
||||
fLayoutTargetInner = GETBIT(flags, 0);
|
||||
|
||||
record >> xTL >> yTL >> xBR >> yBR;
|
||||
|
||||
record >> wXMode >> wYMode >> wWidthMode >> wHeightMode;
|
||||
|
||||
record >> x >> y >> dx >> dy >> reserved;
|
||||
}
|
||||
|
||||
int CrtLayout12A::serialize (std::wostream & _stream)
|
||||
{
|
||||
CP_XML_WRITER(_stream)
|
||||
{
|
||||
CP_XML_NODE(L"c:layout")
|
||||
{
|
||||
if (wXMode == 0 && wYMode == 0 && wWidthMode == 0 && wHeightMode == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_NODE(L"c:manualLayout")
|
||||
{
|
||||
CP_XML_NODE(L"c:layoutTarget"){CP_XML_ATTR(L"val", fLayoutTargetInner ? L"inner" : L"outer");}
|
||||
|
||||
if (wXMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:xMode")
|
||||
{
|
||||
if (wXMode == 1) CP_XML_ATTR(L"val", L"factor");
|
||||
else CP_XML_ATTR(L"val", L"edge");
|
||||
}
|
||||
}
|
||||
if (wYMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:yMode")
|
||||
{
|
||||
if (wYMode == 1) CP_XML_ATTR(L"val", L"factor");
|
||||
else CP_XML_ATTR(L"val", L"edge");
|
||||
}
|
||||
}
|
||||
|
||||
if (wXMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:x") {CP_XML_ATTR(L"val", x.data.value);}
|
||||
}
|
||||
if (wYMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:y") {CP_XML_ATTR(L"val", y.data.value);}
|
||||
}
|
||||
|
||||
if (wWidthMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:wMode")
|
||||
{
|
||||
if (wWidthMode == 1)CP_XML_ATTR(L"val", L"factor");
|
||||
else CP_XML_ATTR(L"val", L"edge");
|
||||
}
|
||||
}
|
||||
if (wHeightMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:hMode")
|
||||
{
|
||||
if (wHeightMode == 1)CP_XML_ATTR(L"val", L"factor");
|
||||
else CP_XML_ATTR(L"val", L"edge");
|
||||
}
|
||||
}
|
||||
if (wWidthMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:w") {CP_XML_ATTR(L"val", dx.data.value);}
|
||||
}
|
||||
if (wHeightMode > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:h") {CP_XML_ATTR(L"val", dy.data.value);}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
@ -32,12 +32,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "BiffRecord.h"
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
#include "../Biff_structures/Xnum.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
|
||||
// Logical representation of CrtLayout12A record in BIFF8
|
||||
class CrtLayout12A: public BiffRecord
|
||||
{
|
||||
BIFF_RECORD_DEFINE_TYPE_INFO(CrtLayout12A)
|
||||
@ -47,12 +46,32 @@ public:
|
||||
~CrtLayout12A();
|
||||
|
||||
BaseObjectPtr clone();
|
||||
|
||||
|
||||
void readFields(CFRecord& record);
|
||||
void readFields (CFRecord& record);
|
||||
int serialize (std::wostream & _stream);
|
||||
|
||||
static const ElementType type = typeCrtLayout12A;
|
||||
static const ElementType type = typeCrtLayout12A;
|
||||
|
||||
FrtHeader frtheader;
|
||||
_UINT32 dwCheckSum;
|
||||
|
||||
bool fLayoutTargetInner;
|
||||
|
||||
short xTL;
|
||||
short yTL;
|
||||
short xBR;
|
||||
short yBR;
|
||||
|
||||
CrtLayout12Mode wXMode;
|
||||
CrtLayout12Mode wYMode;
|
||||
|
||||
CrtLayout12Mode wWidthMode;
|
||||
CrtLayout12Mode wHeightMode;
|
||||
|
||||
Xnum x;
|
||||
Xnum y;
|
||||
Xnum dx;
|
||||
Xnum dy;
|
||||
};
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "DataLabExt.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "DataLabExtContents.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "DropDownObjIds.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "FeatHdr.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "HFPicture.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "HeaderFooter.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
//#include <Exception/AttributeDataWrong.h>
|
||||
|
||||
namespace XLS
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "NameCmt.h"
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Logic/Biff_structures/FrtHeader.h>
|
||||
#include "BiffRecord.h"
|
||||
#include "../Biff_structures/FrtHeader.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -79,17 +79,18 @@ bool AI::empty()
|
||||
|
||||
BRAI* brai = dynamic_cast<BRAI*>(m_BRAI.get());
|
||||
|
||||
bool bEmpty = true;
|
||||
if (brai)
|
||||
{
|
||||
std::wstring forumla = brai->formula.getAssembledFormula();
|
||||
return forumla.empty();
|
||||
bEmpty = forumla.empty();
|
||||
}
|
||||
SeriesText * text = dynamic_cast<SeriesText *>(m_SeriesText.get());
|
||||
if (text)
|
||||
if (text && bEmpty)
|
||||
{
|
||||
return text->stText.value().empty();
|
||||
bEmpty = text->stText.value().empty();
|
||||
}
|
||||
return false;
|
||||
return bEmpty;
|
||||
}
|
||||
|
||||
int AI::serialize(std::wostream & _stream)
|
||||
|
||||
@ -237,6 +237,10 @@ const bool CHARTFORMATS::loadContent(BinProcessor& proc)
|
||||
elements_.pop_back();
|
||||
count--;
|
||||
}
|
||||
if (!m_CrtLayout12A && proc.optional<CrtLayout12A>()) // RP_2064.xls
|
||||
{
|
||||
m_CrtLayout12A = elements_.back(); elements_.pop_back();
|
||||
}
|
||||
if (proc.optional<CRTMLFRT>())
|
||||
{
|
||||
elements_.pop_back();
|
||||
|
||||
@ -791,34 +791,42 @@ int ChartSheetSubstream::serialize_plot_area (std::wostream & _stream)
|
||||
}
|
||||
}
|
||||
|
||||
ShtProps *sht_props = dynamic_cast<ShtProps*>(chart_formats->m_ShtProps.get());
|
||||
ShtProps *sht_props = dynamic_cast<ShtProps*>(chart_formats->m_ShtProps.get());
|
||||
|
||||
std::wstringstream stream_legend_entries;
|
||||
|
||||
CP_XML_WRITER(_stream)
|
||||
{
|
||||
CP_XML_NODE(L"c:plotArea")
|
||||
{
|
||||
for (size_t i = 0; i < chart_formats->m_arAXISPARENT.size(); i++)
|
||||
{
|
||||
AXISPARENT* parent = dynamic_cast<AXISPARENT*> (chart_formats->m_arAXISPARENT[i].get());
|
||||
ax_parent = dynamic_cast<AxisParent*> (parent->m_AxisParent.get());
|
||||
axes = dynamic_cast<AXES*> (parent->m_AXES.get());
|
||||
//for (size_t i = 0; i < chart_formats->m_arAXISPARENT.size(); i++)
|
||||
//{
|
||||
// AXISPARENT* parent = dynamic_cast<AXISPARENT*> (chart_formats->m_arAXISPARENT[i].get());
|
||||
// ax_parent = dynamic_cast<AxisParent*> (parent->m_AxisParent.get());
|
||||
// axes = dynamic_cast<AXES*> (parent->m_AXES.get());
|
||||
|
||||
//if (((bool)ax_parent->iax == false) && axes) //primary axes
|
||||
//{
|
||||
// PlotAreaFRAME = dynamic_cast<FRAME*> (axes->m_PlotArea_FRAME.get());
|
||||
// PlotAreaPos = dynamic_cast<Pos*> (parent->m_Pos.get());
|
||||
//
|
||||
// if (PlotAreaFRAME && PlotAreaPos)
|
||||
// {
|
||||
// PlotAreaPos->m_Frame = PlotAreaFRAME->m_Frame;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
// if (((bool)ax_parent->iax == false) && axes) //primary axes
|
||||
// {
|
||||
// PlotAreaFRAME = dynamic_cast<FRAME*> (axes->m_PlotArea_FRAME.get());
|
||||
// PlotAreaPos = dynamic_cast<Pos*> (parent->m_Pos.get());
|
||||
//
|
||||
// //if (PlotAreaFRAME && PlotAreaPos)
|
||||
// //{
|
||||
// // PlotAreaPos->m_Frame = PlotAreaFRAME->m_Frame;
|
||||
// //}
|
||||
// }
|
||||
//}
|
||||
|
||||
if (PlotAreaPos && (sht_props) && (sht_props->fAlwaysAutoPlotArea != false))
|
||||
if ((sht_props) && (sht_props->fAlwaysAutoPlotArea != false))
|
||||
{
|
||||
PlotAreaPos->serialize(CP_XML_STREAM());
|
||||
if (chart_formats->m_CrtLayout12A)
|
||||
{
|
||||
chart_formats->m_CrtLayout12A->serialize(CP_XML_STREAM());
|
||||
}
|
||||
else if (PlotAreaPos && (sht_props) && (sht_props->fAlwaysAutoPlotArea != false))
|
||||
{
|
||||
PlotAreaPos->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
|
||||
int series_order = 0;
|
||||
|
||||
@ -349,7 +349,7 @@ namespace oox
|
||||
//case msosptLeftRightArrowCallout : return L"leftRightArrowCallout";
|
||||
//case msosptUpDownArrowCallout : return L"upDownArrowCallout";
|
||||
//case msosptQuadArrowCallout : return L"quadArrowCallout";
|
||||
//case msosptBevel : return L"bevel";
|
||||
case msosptBevel : return L"bevel";
|
||||
//case msosptLeftBracket : return L"leftBracket";
|
||||
//case msosptRightBracket : return L"rightBracket";
|
||||
//case msosptLeftBrace : return L"leftBrace";
|
||||
|
||||
@ -71,6 +71,6 @@ cd ./icu/source/
|
||||
./runConfigureICU MacOSX
|
||||
make
|
||||
cd ../../
|
||||
cp "./icu/source/lib/libicudata.55.1.dylib" "build/llibicudata.55.1.dylib"
|
||||
cp "./icu/source/lib/libicudata.55.1.dylib" "build/libicudata.55.1.dylib"
|
||||
cp "./icu/source/lib/libicuuc.55.1.dylib" "build/libicuuc.55.1.dylib"
|
||||
fi
|
||||
|
||||
@ -50,9 +50,9 @@ fi
|
||||
|
||||
if [[ "$platform" == *"mac"* ]]
|
||||
then
|
||||
CFLAGS="-fPIC" CXXFLAGS="-fPIC -stdlib=libc++" LDFLAGS="-stdlib=libc++" make native
|
||||
CFLAGS="-fPIC" CXXFLAGS="-fPIC -stdlib=libc++" LDFLAGS="-stdlib=libc++" make native -j $(sysctl -n hw.ncpu)
|
||||
|
||||
ccp "./out/native/obj.target/tools/gyp/libv8_base.a" "./../$platform$arch/"
|
||||
cp "./out/native/obj.target/tools/gyp/libv8_base.a" "./../$platform$arch/"
|
||||
cp "./out/native/obj.target/tools/gyp/libv8_libbase.a" "./../$platform$arch/"
|
||||
cp "./out/native/obj.target/tools/gyp/libv8_libplatform.a" "./../$platform$arch/"
|
||||
cp "./out/native/obj.target/tools/gyp/libv8_nosnapshot.a" "./../$platform$arch/"
|
||||
|
||||
@ -449,12 +449,10 @@ namespace OOX
|
||||
virtual ~CObject()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
@ -473,6 +471,8 @@ namespace OOX
|
||||
oSubReader.ReadNextNode();//root
|
||||
oSubReader.ReadNextNode();//pict
|
||||
|
||||
ReadAttributes(oSubReader);
|
||||
|
||||
int nCurDepth = oSubReader.GetDepth();
|
||||
while ( oSubReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
@ -634,26 +634,37 @@ namespace OOX
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
return _T("<w:object />");
|
||||
return _T("<w:object/>");
|
||||
}
|
||||
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_w_object;
|
||||
}
|
||||
nullable<std::wstring> m_sXml;
|
||||
|
||||
// Childs
|
||||
nullable<std::wstring> m_sXml;
|
||||
//-----------------------------------------------------------------------
|
||||
nullable_int m_oDxaOrig;
|
||||
nullable_int m_oDyaOrig;
|
||||
|
||||
nullable<OOX::Logic::CControl> m_oControl;
|
||||
//top childs
|
||||
nullable<OOX::Vml::CShapeType> m_oShapeType;//?? нужен ли отдельно тута???
|
||||
|
||||
nullable<OOX::Vml::CShapeType> m_oShapeType;
|
||||
nullable<OOX::VmlOffice::COLEObject> m_oOleObject;
|
||||
|
||||
nullable<OOX::Vml::CShape> m_oShape;
|
||||
//minor childs
|
||||
|
||||
private:
|
||||
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, _T("w:dxaOrig"), m_oDxaOrig )
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("w:dxyOrig"), m_oDyaOrig )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -241,3 +241,4 @@
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_DRM (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005a)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_PASSWORD (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005b)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_ICU (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005c)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_LIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005d)
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include "../fontengine/ApplicationFonts.h"
|
||||
#include "../graphics/GraphicsRenderer.h"
|
||||
#include "../common/File.h"
|
||||
#include "../common/Directory.h"
|
||||
#include "../graphics/Timer.h"
|
||||
#include "../common/StringBuilder.h"
|
||||
|
||||
@ -44,6 +45,8 @@
|
||||
#include "../freetype_names/FontMaps/FontDictionary.h"
|
||||
#endif
|
||||
|
||||
//#define RANGES_LOG
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace NSCommon
|
||||
@ -270,7 +273,7 @@ namespace NSCommon
|
||||
}
|
||||
};
|
||||
|
||||
void SaveAllFontsJS(CApplicationFonts& applicationFonts, std::wstring strFile, std::wstring strFolderThumbnails, std::wstring strFontSelectionBin)
|
||||
void SaveAllFontsJS(CApplicationFonts& applicationFonts, std::wstring strFile, std::wstring strFile2, std::wstring strFolderThumbnails, std::wstring strFontSelectionBin, std::wstring strOutputDir)
|
||||
{
|
||||
CArray<CFontInfo*>* pList = applicationFonts.GetList()->GetFonts();
|
||||
int nCount = pList->GetCount();
|
||||
@ -478,6 +481,8 @@ namespace NSCommon
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring sFontName = pPair->second.m_sName;
|
||||
|
||||
if (bIsSymbol)
|
||||
{
|
||||
CFontSelectFormat oSelectFormat;
|
||||
@ -488,7 +493,26 @@ namespace NSCommon
|
||||
{
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
oRenderer.put_FontPath(pInfoCur->m_wsFontPath);
|
||||
oRenderer.put_FontPath(pInfoCur->m_wsFontPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
CFontFile* pFontCheck = pManager->m_pFont;
|
||||
|
||||
int nCMapIndex = 0;
|
||||
int unGID = pFontCheck->SetCMapForCharCode(sFontName.at(0), &nCMapIndex);
|
||||
if (unGID <= 0)
|
||||
{
|
||||
CFontSelectFormat oSelectFormat;
|
||||
oSelectFormat.wsName = new std::wstring(L"Arial");
|
||||
CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
oRenderer.put_FontPath(pInfoCur->m_wsFontPath);
|
||||
}
|
||||
}
|
||||
|
||||
oRenderer.put_FontStringGID(FALSE);
|
||||
@ -514,43 +538,101 @@ namespace NSCommon
|
||||
// все объекты, которые позволят не знать о существующих фонтах
|
||||
if (0 != strFile.length())
|
||||
{
|
||||
bool bIsDumpAllFontWeb = (strFile2.empty() || strOutputDir.empty()) ? false : true;
|
||||
|
||||
BYTE correct16[16] = {0xA0, 0x66, 0xD6, 0x20, 0x14, 0x96, 0x47, 0xfa, 0x95, 0x69, 0xB8, 0x50, 0xB0, 0x41, 0x49, 0x48};
|
||||
int nCountIdSymbols = (nCountFonts >= 1000) ? 4 : 3;
|
||||
BYTE encode[32];
|
||||
|
||||
NSStringUtils::CStringBuilder oWriterJS;
|
||||
NSStringUtils::CStringBuilder oWriterJS2;
|
||||
|
||||
// сначала все файлы
|
||||
size_t nCountFiles = mapFontFiles.size();
|
||||
if (nCountFiles == 0)
|
||||
{
|
||||
oWriterJS += (L"window[\"__fonts_files\"] = []; \n\n");
|
||||
oWriterJS2 += (L"window[\"__fonts_files\"] = []; \n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring* pMassFiles = new std::wstring[nCountFiles];
|
||||
std::wstring* pMassFiles2 = new std::wstring[nCountFiles];
|
||||
|
||||
int nCurrentId = 0;
|
||||
for ( std::map<std::wstring, LONG>::iterator pos = mapFontFiles.begin(); pos != mapFontFiles.end(); ++pos)
|
||||
{
|
||||
std::wstring strFontId = pos->first;
|
||||
|
||||
NSStringUtils::string_replace(strFontId, L"\\\\", L"\\");
|
||||
NSStringUtils::string_replace(strFontId, L"/", L"\\");
|
||||
|
||||
int nStart = strFontId.find_last_of(wchar_t('\\'));
|
||||
strFontId = strFontId.substr(nStart + 1);
|
||||
NSStringUtils::string_replace(strFontId, L"\\", L"/");
|
||||
|
||||
pMassFiles[pos->second] = strFontId;
|
||||
|
||||
if (bIsDumpAllFontWeb)
|
||||
{
|
||||
std::wstring sId = std::to_wstring(nCurrentId++);
|
||||
int nLenId = (int)sId.length();
|
||||
while (nLenId < nCountIdSymbols)
|
||||
{
|
||||
sId = L"0" + sId;
|
||||
++nLenId;
|
||||
}
|
||||
|
||||
pMassFiles2[pos->second] = sId;
|
||||
NSFile::CFileBinary::Copy(strFontId, strOutputDir + L"/" + sId);
|
||||
|
||||
NSFile::CFileBinary oFileDst;
|
||||
if (oFileDst.OpenFile(strOutputDir + L"/" + sId, true))
|
||||
{
|
||||
DWORD dwRead = (DWORD)(oFileDst.GetFileSize());
|
||||
if (dwRead > 32)
|
||||
dwRead = 32;
|
||||
|
||||
DWORD dwWorked = 0;
|
||||
oFileDst.SeekFile(0);
|
||||
oFileDst.ReadFile(encode, dwRead, dwWorked);
|
||||
|
||||
for (DWORD k = 0; k < dwRead; ++k)
|
||||
encode[k] ^= correct16[k & 0x0F];
|
||||
|
||||
oFileDst.SeekFile(0);
|
||||
oFileDst.WriteFile(encode, dwRead);
|
||||
oFileDst.CloseFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oWriterJS += (L"window[\"__fonts_files\"] = [\n");
|
||||
oWriterJS2 += (L"window[\"__fonts_files\"] = [\n");
|
||||
for (size_t nIndex = 0; nIndex < nCountFiles; ++nIndex)
|
||||
{
|
||||
oWriterJS += (L"\"");
|
||||
oWriterJS2 += (L"\"");
|
||||
|
||||
oWriterJS += (pMassFiles[nIndex]);
|
||||
oWriterJS2 += (pMassFiles2[nIndex]);
|
||||
|
||||
if (nIndex != (nCountFiles - 1))
|
||||
{
|
||||
oWriterJS += (L"\",\n");
|
||||
oWriterJS2 += (L"\",\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
oWriterJS += (L"\"");
|
||||
oWriterJS2 += (L"\"");
|
||||
}
|
||||
}
|
||||
oWriterJS += (L"\n];\n\n");
|
||||
oWriterJS2 += (L"\n];\n\n");
|
||||
|
||||
delete [] pMassFiles;
|
||||
delete [] pMassFiles2;
|
||||
}
|
||||
|
||||
size_t nPosForWriter2 = oWriterJS.GetCurSize();
|
||||
|
||||
oWriterJS += L"window[\"__fonts_infos\"] = [\n";
|
||||
|
||||
std::map<std::wstring, int> mapFontIndexes;
|
||||
@ -824,6 +906,15 @@ namespace NSCommon
|
||||
oWriterJS.AddCharSafe(',');
|
||||
oWriterJS.AddInt(mapFontIndexes.find(arrFontsPriority[nFontPriority - 1].name)->second);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
|
||||
#ifdef RANGES_LOG
|
||||
FILE* f = fopen("D:\\fonts.log", "a+");
|
||||
fprintf(f, "[%d - %d]: ", nFontPriorityStart, i - 1);
|
||||
std::string sTmp = U_TO_UTF8(arrFontsPriority[nFontPriority - 1].name);
|
||||
fprintf(f, sTmp.c_str());
|
||||
fprintf(f, "\n");
|
||||
fclose(f);
|
||||
#endif
|
||||
}
|
||||
nFontPriority = nFontPriorityTest;
|
||||
nFontPriorityStart = i;
|
||||
@ -837,6 +928,15 @@ namespace NSCommon
|
||||
oWriterJS.AddCharSafe(',');
|
||||
oWriterJS.AddInt(mapFontIndexes.find(arrFontsPriority[nFontPriority - 1].name)->second);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
|
||||
#ifdef RANGES_LOG
|
||||
FILE* f = fopen("D:\\fonts.log", "a+");
|
||||
fprintf(f, "[%d - %d]: ", nFontPriorityStart, nMaxSymbol - 1);
|
||||
std::string sTmp = U_TO_UTF8(arrFontsPriority[nFontPriority - 1].name);
|
||||
fprintf(f, sTmp.c_str());
|
||||
fprintf(f, "\n");
|
||||
fclose(f);
|
||||
#endif
|
||||
}
|
||||
|
||||
oWriterJS.SetCurSize(oWriterJS.GetCurSize() - 1);
|
||||
@ -870,6 +970,16 @@ namespace NSCommon
|
||||
oFile.CreateFileW(strFile);
|
||||
oFile.WriteStringUTF8(oWriterJS.GetData(), true);
|
||||
oFile.CloseFile();
|
||||
|
||||
if (bIsDumpAllFontWeb)
|
||||
{
|
||||
oWriterJS2.Write(oWriterJS, nPosForWriter2);
|
||||
|
||||
NSFile::CFileBinary oFile2;
|
||||
oFile2.CreateFileW(strFile2);
|
||||
oFile2.WriteStringUTF8(oWriterJS2.GetData(), true);
|
||||
oFile2.CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != strFontSelectionBin.length())
|
||||
@ -1084,89 +1194,136 @@ namespace NSCommon
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring CorrectDir(const std::wstring& sDir)
|
||||
{
|
||||
if (sDir.empty())
|
||||
return L"";
|
||||
|
||||
const wchar_t* data = sDir.c_str();
|
||||
|
||||
std::wstring::size_type pos1 = (data[0] == '\"') ? 1 : 0;
|
||||
std::wstring::size_type pos2 = sDir.length();
|
||||
|
||||
if (data[pos2 - 1] == '\"')
|
||||
--pos2;
|
||||
|
||||
if (pos2 > 0 && ((data[pos2 - 1] == '\\') || (data[pos2 - 1] == '/')))
|
||||
--pos2;
|
||||
|
||||
return sDir.substr(pos1, pos2 - pos1);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t** argv)
|
||||
#else
|
||||
int main(int argc, char** argv)
|
||||
#endif
|
||||
{
|
||||
#if 0
|
||||
char buf[10];
|
||||
wcout << "[\n";
|
||||
wcout << itoa(argc, buf, 10) << "\n";
|
||||
std::vector<std::wstring> arFontsDirs;
|
||||
bool bIsUseSystemFonts = false;
|
||||
std::wstring strAllFontsWebPath = L"";
|
||||
std::wstring strAllFontsPath = L"";
|
||||
std::wstring strThumbnailsFolder = L"";
|
||||
std::wstring strFontsSelectionBin = L"";
|
||||
std::wstring strOutputDir = L"";
|
||||
|
||||
for (int i = 0; i < argc; ++i)
|
||||
wcout << argv[i] << "\n";
|
||||
|
||||
wcout << "]";
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring strFontsFolder = L"";
|
||||
if (1 < argc)
|
||||
strFontsFolder = std::wstring(argv[1]);
|
||||
std::wstring strAllFontsJSPath = L"";
|
||||
if (2 < argc)
|
||||
strAllFontsJSPath = std::wstring(argv[2]);
|
||||
std::wstring strThumbnailsFolder = L"";
|
||||
if (3 < argc)
|
||||
strThumbnailsFolder = std::wstring(argv[3]);
|
||||
std::wstring strFontsSelectionBin = L"";
|
||||
if (4 < argc)
|
||||
strFontsSelectionBin = std::wstring(argv[4]);
|
||||
std::wstring sParam(argv[i]);
|
||||
#else
|
||||
std::wstring strFontsFolder = L"";
|
||||
if (1 < argc)
|
||||
strFontsFolder = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)argv[1], (LONG)strlen(argv[1]));
|
||||
std::wstring strAllFontsJSPath = L"";
|
||||
if (2 < argc)
|
||||
strAllFontsJSPath = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)argv[2], (LONG)strlen(argv[2]));
|
||||
std::wstring strThumbnailsFolder = L"";
|
||||
if (3 < argc)
|
||||
strThumbnailsFolder = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)argv[3], (LONG)strlen(argv[3]));
|
||||
std::wstring strFontsSelectionBin = L"";
|
||||
if (4 < argc)
|
||||
strFontsSelectionBin = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)argv[4], (LONG)strlen(argv[4]));
|
||||
std::string sParamA(argv[i]);
|
||||
std::wstring sParam = UTF8_TO_U(sParamA);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
if (sParam.find(L"--") == 0)
|
||||
{
|
||||
std::wstring sKey = L"";
|
||||
std::wstring sValue = L"";
|
||||
|
||||
#if 0
|
||||
std::wstring::size_type _pos = sParam.find('=');
|
||||
if (std::wstring::npos == _pos)
|
||||
{
|
||||
sKey = sParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
sKey = sParam.substr(0, _pos);
|
||||
sValue = sParam.substr(_pos + 1);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
//std::wstring strFontsFolder = L"C:/Windows/Fonts";
|
||||
strFontsFolder = L"D:/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb/Fonts/native";
|
||||
strAllFontsJSPath = L"D:/AllFontsGenTest/AllFonts.js";
|
||||
strThumbnailsFolder = L"D:/AllFontsGenTest";
|
||||
strFontsSelectionBin = L"D:/AllFontsGenTest/font_selection.bin";
|
||||
#endif
|
||||
if (sKey == L"--use-system")
|
||||
{
|
||||
if (sValue == L"1" || sValue == L"true")
|
||||
bIsUseSystemFonts = true;
|
||||
}
|
||||
else if (sKey == L"--allfonts-web")
|
||||
{
|
||||
strAllFontsWebPath = CorrectDir(sValue);
|
||||
}
|
||||
else if (sKey == L"--allfonts")
|
||||
{
|
||||
strAllFontsPath = CorrectDir(sValue);
|
||||
}
|
||||
else if (sKey == L"--images")
|
||||
{
|
||||
strThumbnailsFolder = CorrectDir(sValue);
|
||||
}
|
||||
else if (sKey == L"--selection")
|
||||
{
|
||||
strFontsSelectionBin = CorrectDir(sValue);
|
||||
}
|
||||
else if (sKey == L"--input")
|
||||
{
|
||||
const wchar_t* src = sValue.c_str();
|
||||
const wchar_t* limit = src + sValue.length();
|
||||
|
||||
#if defined(_LINUX) && !defined(_MAC)
|
||||
strFontsFolder = L"";
|
||||
strAllFontsJSPath = L"/home/oleg/AllFontsGen/AllFonts.js";
|
||||
strThumbnailsFolder = L"/home/oleg/AllFontsGen/";
|
||||
strFontsSelectionBin = L"/home/oleg/AllFontsGen/font_selection.bin";
|
||||
#endif
|
||||
const wchar_t* srcPrev = src;
|
||||
while (src < limit)
|
||||
{
|
||||
if (*src == ';')
|
||||
{
|
||||
if (srcPrev != src)
|
||||
{
|
||||
arFontsDirs.push_back(std::wstring(srcPrev, src - srcPrev));
|
||||
}
|
||||
src++;
|
||||
srcPrev = src;
|
||||
}
|
||||
else
|
||||
src++;
|
||||
}
|
||||
|
||||
#ifdef _MAC
|
||||
strFontsFolder = L"";
|
||||
strAllFontsJSPath = L"/Users/Oleg/Desktop/activex/AllFonts.js";
|
||||
strThumbnailsFolder = L"/Users/Oleg/Desktop/activex/";
|
||||
strFontsSelectionBin = L"/Users/Oleg/Desktop/activex/font_selection.bin";
|
||||
#endif
|
||||
if (src > srcPrev)
|
||||
{
|
||||
arFontsDirs.push_back(std::wstring(srcPrev, src - srcPrev));
|
||||
}
|
||||
}
|
||||
else if (sKey == L"--output-web")
|
||||
{
|
||||
strOutputDir = CorrectDir(sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
--input="D:\OO_FONTS" --allfonts="D:\123\gen\AllFonts.js" --allfonts-web="D:\123\gen\AllFonts2.js" --images="D:\123\gen" --selection="D:\123\gen\font_selection.bin" --output-web="D:\123" --use-system="true"
|
||||
*/
|
||||
|
||||
CApplicationFonts oApplicationF;
|
||||
|
||||
if (strFontsFolder.length() != 0)
|
||||
oApplicationF.InitializeFromFolder(strFontsFolder, false);
|
||||
else
|
||||
oApplicationF.Initialize(false);
|
||||
std::vector<std::wstring> arFontFiles;
|
||||
if (bIsUseSystemFonts)
|
||||
arFontFiles = oApplicationF.GetSetupFontFiles();
|
||||
|
||||
NSCommon::SaveAllFontsJS(oApplicationF, strAllFontsJSPath, strThumbnailsFolder, strFontsSelectionBin);
|
||||
for (std::vector<std::wstring>::iterator i = arFontsDirs.begin(); i != arFontsDirs.end(); i++)
|
||||
{
|
||||
NSDirectory::GetFiles2(*i, arFontFiles, true);
|
||||
}
|
||||
|
||||
oApplicationF.InitializeFromArrayFiles(arFontFiles, 3);
|
||||
|
||||
NSCommon::SaveAllFontsJS(oApplicationF, strAllFontsPath, strAllFontsWebPath, strThumbnailsFolder, strFontsSelectionBin, strOutputDir);
|
||||
|
||||
#ifdef _GENERATE_FONT_MAP_
|
||||
|
||||
|
||||
@ -411,9 +411,9 @@ namespace NSStringUtils
|
||||
return m_lSize;
|
||||
}
|
||||
|
||||
inline void Write(CStringBuilder& oWriter)
|
||||
inline void Write(CStringBuilder& oWriter, const size_t& offset = 0)
|
||||
{
|
||||
WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
|
||||
WriteString(oWriter.m_pData + offset, oWriter.m_lSizeCur - offset);
|
||||
}
|
||||
|
||||
inline void Clear()
|
||||
|
||||
20
Makefile
20
Makefile
@ -38,6 +38,18 @@ else
|
||||
PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER)
|
||||
ARCH_REPO_DIR := linux
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
PLATFORM := mac
|
||||
SHARED_EXT := .dylib
|
||||
SHELL_EXT := .sh
|
||||
LIB_EXT := .a
|
||||
LIB_PREFIX := lib
|
||||
ARCH_EXT := .tar.gz
|
||||
MAKE := make -j $(shell sysctl -n hw.ncpu)
|
||||
AR := tar -zcvf
|
||||
PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER)
|
||||
ARCH_REPO_DIR := mac
|
||||
endif
|
||||
endif
|
||||
|
||||
TARGET := $(PLATFORM)_$(ARCHITECTURE)
|
||||
@ -256,6 +268,12 @@ ifeq ($(OS),Windows_NT)
|
||||
ARTIFACTS += Common/3dParty/v8/$(TARGET)/*/*.dll
|
||||
endif
|
||||
|
||||
EXT_TARGET += $(DOCBUILDER)
|
||||
|
||||
ifneq ($(PLATFORM),mac)
|
||||
EXT_TARGET += $(HTMLFILEINTERNAL)
|
||||
endif
|
||||
|
||||
#Template for next statment:
|
||||
#FOO_MAKE := $(basename $(FOO_PRO)).build/Makefile
|
||||
#$(FOO): $(FOO_MAKE)
|
||||
@ -276,7 +294,7 @@ bin: $(X2T) $(ALLFONTSGEN)
|
||||
|
||||
lib: $(PDFWRITER) $(DOCTRENDERER) $(HTMLRENDERER) $(PDFREADER) $(DJVUFILE) $(XPSFILE) $(HTMLFILE) $(UNICODECONVERTER)
|
||||
|
||||
ext: $(HTMLFILEINTERNAL) $(DOCBUILDER)
|
||||
ext: $(EXT_TARGET)
|
||||
|
||||
desktop: $(ASCDOCUMENTSCORE)
|
||||
|
||||
|
||||
@ -151,3 +151,15 @@ HRESULT COfficeUtils::CompressFilesFromMemory(const std::wstring& zipFile, const
|
||||
*result = ZLibZipUtils::CompressFiles(zipFile.c_str(), data_source, pParam, compression_level) ? true : false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::GetFilesSize(const std::wstring& zipFile, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed)
|
||||
{
|
||||
if (ZLibZipUtils::GetFilesSize(zipFile.c_str(), searchPattern, nCommpressed, nUncommpressed))
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ public:
|
||||
HRESULT LoadFileFromArchive (const std::wstring& zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize);
|
||||
HRESULT ExtractFilesToMemory (const std::wstring& zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result);
|
||||
HRESULT CompressFilesFromMemory (const std::wstring& zipFile, const RequestFileCallback& data_source, void* pParam, short compression_level, bool* result);
|
||||
HRESULT GetFilesSize (const std::wstring& zipFile, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -102,7 +102,9 @@ namespace ZLibZipUtils
|
||||
int nBufferSize = MultiByteToWideChar( CP_OEMCP, 0, sVal, -1, NULL, 0 );
|
||||
wchar_t* pBuffer = new wchar_t[nBufferSize];
|
||||
MultiByteToWideChar( CP_OEMCP, 0, sVal, -1, pBuffer, nBufferSize );
|
||||
std::wstring sRes(pBuffer, nBufferSize);
|
||||
//If this parameter is -1, the function processes the entire input string, including the terminating null character.
|
||||
//Therefore, the resulting Unicode string has a terminating null character, and the length returned by the function includes this character.
|
||||
std::wstring sRes(pBuffer, nBufferSize - 1);
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
return sRes;
|
||||
#else
|
||||
@ -953,6 +955,37 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetFilesSize(const WCHAR* zip_file_path, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed)
|
||||
{
|
||||
nCommpressed = 0;
|
||||
nUncommpressed = 0;
|
||||
unzFile unzip_file_handle = unzOpenHelp(zip_file_path);
|
||||
if (unzip_file_handle != NULL)
|
||||
{
|
||||
//todo implement true pattern
|
||||
std::wstring searchExt = searchPattern.substr(2);
|
||||
bool isEmptyPattern = 0 == searchExt.length();
|
||||
do
|
||||
{
|
||||
char filename_inzip[256];
|
||||
unz_file_info file_info;
|
||||
unzGetCurrentFileInfo(unzip_file_handle, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
|
||||
std::wstring filenameW = codepage_issue_fixFromOEM(filename_inzip);
|
||||
std::transform(filenameW.begin(), filenameW.end(), filenameW.begin(), ::tolower);
|
||||
if (isEmptyPattern || NSFile::GetFileExtention(filenameW) == searchExt)
|
||||
{
|
||||
nCommpressed += file_info.compressed_size;
|
||||
nUncommpressed += file_info.uncompressed_size;
|
||||
}
|
||||
// else just skip the erroneous file
|
||||
} while (UNZ_OK == unzGoToNextFile(unzip_file_handle));
|
||||
|
||||
unzClose (unzip_file_handle);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
static unsigned int get_files_count( const WCHAR* dirname )
|
||||
|
||||
@ -65,4 +65,5 @@ namespace ZLibZipUtils
|
||||
bool LoadFileFromArchive(const WCHAR* zipFile, const WCHAR* filePathInZip, BYTE** fileInBytes, ULONG& nFileSize);
|
||||
bool ExtractFiles(const WCHAR* zip_file_path, const ExtractedFileCallback& callback, void* pParam);
|
||||
bool CompressFiles(const WCHAR* zip_file_path, const RequestFileCallback& callback, void* pParam, int compression_level);
|
||||
bool GetFilesSize(const WCHAR* zip_file_path, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed);
|
||||
}
|
||||
|
||||
@ -3888,6 +3888,11 @@ namespace NExtractTools
|
||||
return AVS_FILEUTILS_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
if (!oInputParams.checkInputLimits())
|
||||
{
|
||||
return AVS_FILEUTILS_ERROR_CONVERT_LIMITS;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
switch(conversion)
|
||||
{
|
||||
|
||||
@ -471,4 +471,26 @@ namespace NExtractTools
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
bool InputParams::checkInputLimits()
|
||||
{
|
||||
std::wstring& sFrom = *this->m_sFileFrom;
|
||||
int nFormatFrom = *this->m_nFormatFrom;
|
||||
boost::unordered_map<int, InputLimit>::const_iterator itLimit = this->m_mapInputLimits.find(nFormatFrom);
|
||||
if(itLimit != this->m_mapInputLimits.end())
|
||||
{
|
||||
const InputLimit& oLimit = itLimit->second;
|
||||
if(oLimit.compressed > 0 || oLimit.uncompressed > 0)
|
||||
{
|
||||
ULONG nCompressed = 0;
|
||||
ULONG nUncompressed = 0;
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
oCOfficeUtils.GetFilesSize(sFrom, oLimit.pattern, nCompressed, nUncompressed);
|
||||
if((oLimit.compressed > 0 && nCompressed > oLimit.compressed) || (oLimit.uncompressed > 0 && nUncompressed > oLimit.uncompressed))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,9 @@
|
||||
#include "../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../DesktopEditor/common/Path.h"
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
@ -360,6 +363,19 @@ namespace NExtractTools
|
||||
}
|
||||
};
|
||||
|
||||
class InputLimit
|
||||
{
|
||||
public:
|
||||
UINT compressed;
|
||||
UINT uncompressed;
|
||||
std::wstring pattern;
|
||||
InputLimit()
|
||||
{
|
||||
compressed = 0;
|
||||
uncompressed = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class InputParams
|
||||
{
|
||||
public:
|
||||
@ -385,6 +401,7 @@ namespace NExtractTools
|
||||
std::wstring* m_sSavePassword;
|
||||
std::wstring* m_sTempDir;
|
||||
bool* m_bIsNoBase64;
|
||||
boost::unordered_map<int, InputLimit> m_mapInputLimits;
|
||||
//output params
|
||||
mutable bool m_bOutputConvertCorrupted;
|
||||
public:
|
||||
@ -488,6 +505,10 @@ namespace NExtractTools
|
||||
m_oThumbnail = new InputParamsThumbnail();
|
||||
m_oThumbnail->FromXmlNode(oXmlNode);
|
||||
}
|
||||
else if(_T("m_oInputLimits") == sName)
|
||||
{
|
||||
FromLimitsNode(oXmlNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sValue;
|
||||
@ -609,6 +630,41 @@ namespace NExtractTools
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FromLimitsNode(XmlUtils::CXmlNode& oXmlNode)
|
||||
{
|
||||
XmlUtils::CXmlNodes oLimitsNode;
|
||||
if (oXmlNode.GetNodes(L"m_oInputLimit", oLimitsNode))
|
||||
{
|
||||
for(int i = 0; i < oLimitsNode.GetCount(); ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oLimitNode;
|
||||
if(oLimitsNode.GetAt(i, oLimitNode))
|
||||
{
|
||||
std::wstring sType;
|
||||
if (oLimitNode.GetAttributeIfExist(L"type", sType))
|
||||
{
|
||||
std::vector<std::wstring> aTypes;
|
||||
boost::algorithm::split(aTypes, sType, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
|
||||
|
||||
InputLimit oLimit;
|
||||
XmlUtils::CXmlNode oZipNode;
|
||||
if (oLimitNode.GetNode(L"m_oZip", oZipNode))
|
||||
{
|
||||
oLimit.compressed = std::stoul(oZipNode.GetAttribute(L"compressed", L"0"));
|
||||
oLimit.uncompressed = std::stoul(oZipNode.GetAttribute(L"uncompressed", L"0"));
|
||||
oLimit.pattern = oZipNode.GetAttribute(L"template", L"");
|
||||
}
|
||||
for (int j = 0; j < aTypes.size(); ++j)
|
||||
{
|
||||
m_mapInputLimits[COfficeFileFormatChecker::GetFormatByExtension(L"." + aTypes[j])] = oLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool hasPassword() const
|
||||
{
|
||||
return NULL != m_sPassword;
|
||||
@ -900,6 +956,7 @@ namespace NExtractTools
|
||||
{
|
||||
return NULL != m_bDontSaveAdditional && *m_bDontSaveAdditional;
|
||||
}
|
||||
bool checkInputLimits();
|
||||
};
|
||||
|
||||
static std::wstring string_replaceAll(std::wstring str, const std::wstring& from, const std::wstring& to)
|
||||
|
||||
Reference in New Issue
Block a user