/// Returnes a list of all ParagraphPropertyExceptions which correspond to text /// between the given offsets. std::list<ParagraphPropertyExceptions*>* FormattedDiskPagePAPX::GetParagraphPropertyExceptions ( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream ) { std::list<ParagraphPropertyExceptions*>* ppxList = new std::list<ParagraphPropertyExceptions*>(); std::list<FormattedDiskPagePAPX*>* fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream ); FormattedDiskPagePAPX *fkp = NULL; for ( std::list<FormattedDiskPagePAPX*>::iterator iter = fkps->begin(); iter != fkps->end(); iter++ ) { fkp = (*iter); for ( unsigned int j = 0; j < fkp->grppapxSize; j++ ) { if ( ( fkp->rgfc[j] >= fcMin ) && ( fkp->rgfc[j] < fcMax ) ) { ppxList->push_back( fkp->grppapx[j] ); } } RELEASEOBJECT( fkp ); fkps->clear(); RELEASEOBJECT( fkps ); } return ppxList; }
_UINT32 CPPTXFile::OpenDirectoryToPPTY(std::wstring bsInput, std::wstring bsOutput) { OOX::CPath pathInputDirectory = bsInput; RELEASEOBJECT(m_pPptxDocument); m_pPptxDocument = new PPTX::Document(); if (!m_pPptxDocument->isValid(pathInputDirectory.GetPath())) // true ??? { RELEASEOBJECT(m_pPptxDocument); return AVS_FILEUTILS_ERROR_CONVERT; } m_pPptxDocument->read(pathInputDirectory.GetPath() + FILE_SEPARATOR_STR, (PPTX::IPPTXEvent*)this); if(GetPercent() < 1000000) { RELEASEOBJECT(m_pPptxDocument); return AVS_FILEUTILS_ERROR_CONVERT; } smart_ptr<PPTX::Presentation> presentation = m_pPptxDocument->Get(OOX::Presentation::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>(); if (!presentation.is_init()) { NSDirectory::DeleteDirectory(m_strTempDir, false); return AVS_FILEUTILS_ERROR_CONVERT; } m_strDirectory = pathInputDirectory.GetDirectory(); NSBinPptxRW::CBinaryFileWriter oBinaryWriter; oBinaryWriter.m_pCommon->CheckFontPicker(); oBinaryWriter.m_pCommon->m_pNativePicker->Init(m_strFontDirectory); OOX::CPath pathDstFileOutput = bsOutput; OOX::CPath pathMedia = pathDstFileOutput.GetDirectory() + FILE_SEPARATOR_STR + _T("media"); m_strMediaDirectory = pathMedia.GetPath(); oBinaryWriter.m_strMainFolder = pathDstFileOutput.GetDirectory(); oBinaryWriter.m_pCommon->m_pMediaManager->m_strDstMedia = m_strMediaDirectory; oBinaryWriter.m_pCommon->m_pMediaManager->SetFontManager(oBinaryWriter.m_pCommon->m_pNativePicker->m_pFontManager); NSDirectory::CreateDirectory(m_strMediaDirectory); if (!m_strEmbeddedFontsDirectory.empty()) { NSDirectory::CreateDirectory(m_strEmbeddedFontsDirectory); if (NULL != oBinaryWriter.m_pCommon->m_pFontPicker) { oBinaryWriter.m_pCommon->m_pNativePicker->m_bIsEmbeddedFonts = true; oBinaryWriter.m_pCommon->m_pNativePicker->m_oEmbeddedFonts.m_strEmbeddedFontsFolder = m_strEmbeddedFontsDirectory; } } PPTX2EditorAdvanced::Convert(oBinaryWriter, *m_pPptxDocument, m_strDirectory, pathDstFileOutput.GetPath(), m_bIsNoBase64); return S_OK; }
_UINT32 CPPTXFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring sXMLOptions) { std::wstring localTempDir(sDstPath); if(!localTempDir.empty()) { bool res = NSDirectory::CreateDirectory(localTempDir); if (res == false) return AVS_FILEUTILS_ERROR_CONVERT; put_TempDirectory(sDstPath); } else { bool res = NSDirectory::CreateDirectory(m_strTempDir); if (res == false) return AVS_FILEUTILS_ERROR_CONVERT; } localTempDir = m_strTempDir; std::wstring srcFileName = sSrcFileName; if (m_pCallbackArg) { if(!m_fCallbackExtract(m_pCallbackArg, srcFileName , localTempDir)) return AVS_FILEUTILS_ERROR_CONVERT; } else { localTempDir = sSrcFileName; } RELEASEOBJECT(m_pPptxDocument); m_pPptxDocument = new PPTX::Document(); if(!m_pPptxDocument->isValid(localTempDir)) { RELEASEOBJECT(m_pPptxDocument); return AVS_FILEUTILS_ERROR_CONVERT; } m_pPptxDocument->read(localTempDir, (PPTX::IPPTXEvent*)this); if(GetPercent() < 1000000) { RELEASEOBJECT(m_pPptxDocument); return AVS_FILEUTILS_ERROR_CONVERT; } smart_ptr<PPTX::Presentation> presentation = m_pPptxDocument->Get(OOX::Presentation::FileTypes::Presentation).smart_dynamic_cast<PPTX::Presentation>(); if (!presentation.is_init()) { NSDirectory::DeleteDirectory(m_strTempDir, false); return AVS_FILEUTILS_ERROR_CONVERT; } m_strDirectory = sSrcFileName; size_t nIndex = m_strDirectory.rfind(FILE_SEPARATOR_CHAR); if (std::wstring::npos != nIndex) m_strDirectory = m_strDirectory.substr(0, nIndex); return 0; }
StyleSheet::~StyleSheet() { RELEASEOBJECT (stshi); if ( NULL != Styles ) { for ( std::vector<StyleSheetDescription*>::iterator iter = Styles->begin(); iter != Styles->end(); iter++ ) { RELEASEOBJECT( *iter ); } RELEASEOBJECT( Styles ); } }
void CDocument::Close() { // Все объекты удаляются внутри CXref RELEASEOBJECT(m_pXref); m_pTrailer = NULL; m_pResources = NULL; m_pCatalog = NULL; m_pOutlines = NULL; m_pPageTree = NULL; m_pCurPage = NULL; m_nCurPageNum = 0; m_bEncrypt = false; m_pEncryptDict = NULL; m_pInfo = NULL; m_unCompressMode = COMP_NONE; m_pJbig2 = NULL; m_pTransparencyGroup= NULL; memset((void*)m_sTTFontTag, 0x00, 8); m_vPages.clear(); m_vExtGrStates.clear(); m_vStrokeAlpha.clear(); m_vFillAlpha.clear(); m_vShadings.clear(); m_vTTFonts.clear(); m_vFreeTypeFonts.clear(); if (m_pFreeTypeLibrary) { FT_Done_FreeType(m_pFreeTypeLibrary); m_pFreeTypeLibrary = NULL; } }
void Control::AddObjectTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CMediaManager* pMediaManager) const {//проблема переноса картинок !!! if (spid.IsInit() == false) return; std::wstring s = *spid; if (s.length() < 8) s = _T("_x0000_s") + s; smart_ptr<OOX::IFileContainer> rels; std::wstring xml = GetVmlXmlBySpid(s, rels); if (xml.length() > 0) { std::wstring temp = _T("<v:object>"); temp += xml; temp += L"</v:object>"; NSBinPptxRW::CDrawingConverter oDrawingConverter; oDrawingConverter.SetAdditionalParam(_T("parent_spTree"), (BYTE*)spTreeElements, 0); RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager); oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = pMediaManager; oDrawingConverter.SetRels(rels); std::wstring *main_props = NULL; HRESULT hRes = oDrawingConverter.AddObject(temp, &main_props); oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = NULL; } }
void Control::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { if (spid.IsInit() == false) return; std::wstring s = *spid; if (s.length() < 8) s = _T("_x0000_s") + s; smart_ptr<OOX::IFileContainer> rels; std::wstring xml = GetVmlXmlBySpid(s, rels); if (xml.length() > 0) { std::wstring temp = _T("<v:object>"); temp += xml; temp += L"</v:object>"; NSBinPptxRW::CDrawingConverter oDrawingConverter; //oDrawingConverter.SetFontManager(pFontManager); RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager); oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = pWriter->m_pCommon->m_pMediaManager; std::wstring *main_props = NULL; oDrawingConverter.SetRels(rels); HRESULT hRes = oDrawingConverter.AddObject(temp, &main_props); if (hRes == S_OK && oDrawingConverter.m_pBinaryWriter->GetPosition() > 10) { pWriter->WriteBYTEArray(oDrawingConverter.m_pBinaryWriter->GetBuffer(),oDrawingConverter.m_pBinaryWriter->GetPosition()); } oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = NULL; } }
ListData::~ListData() { for_each(rglvl->begin(), rglvl->end(), DeleteDynamicObject()); RELEASEOBJECT(rglvl); RELEASEARRAYOBJECTS(_rawBytes); }
CFontManager::~CFontManager() { if (m_pLibrary) { FT_Done_FreeType(m_pLibrary); } RELEASEOBJECT(m_pOwnerCache); }
void UnicodeMap::AddRef() { CTemporaryCS *pCS = new CTemporaryCS(&m_oCS); ++m_nRefCount; RELEASEOBJECT(pCS); }
/// Returns a list of all PAPX FCs between they given boundaries. std::list<int>* FormattedDiskPagePAPX::GetFileCharacterPositions ( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream ) { std::list<int>* cpList = new std::list<int>(); std::list<FormattedDiskPagePAPX*> *fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream ); unsigned int i = 0; FormattedDiskPagePAPX* fkp = NULL; for ( std::list<FormattedDiskPagePAPX*>::iterator iter = fkps->begin(); iter != fkps->end(); iter++ ) { fkp = (*iter); //the last entry of each is always the same as the first entry of the next FKP //so, ignore all last _entries except for the last FKP. int max = fkp->rgfcSize; if ( i++ < fkps->size() - 1 ) { max--; } for ( int j = 0; j < max; j++ ) { if( ( fkp->rgfc[j] >= fcMin ) && ( fkp->rgfc[j] < fcMax ) ) { cpList->push_back( fkp->rgfc[j] ); } } RELEASEOBJECT( fkp ); } fkps->clear(); RELEASEOBJECT( fkps ); return cpList; }
TableCellPropertiesMapping::~TableCellPropertiesMapping() { RELEASEOBJECT(_tcPr); RELEASEOBJECT(_tcMar); RELEASEOBJECT(_tcBorders); RELEASEOBJECT(_brcTop); RELEASEOBJECT(_brcLeft); RELEASEOBJECT(_brcRight); RELEASEOBJECT(_brcBottom); }
void UnicodeMap::Release() { CTemporaryCS *pCS = new CTemporaryCS(&m_oCS); bool bDone = (--m_nRefCount == 0); RELEASEOBJECT(pCS); if (bDone) { delete this; } }
FormattedDiskPagePAPX::~FormattedDiskPagePAPX() { RELEASEARRAYOBJECTS( rgfc ); RELEASEARRAYOBJECTS( rgbx ); if ( grppapx != NULL ) { for ( unsigned int i = 0; i < grppapxSize; i++ ) { RELEASEOBJECT( grppapx[i] ); } RELEASEARRAYOBJECTS( grppapx ); } }
NSFonts::IFontFile* CFontsCache::LockFont(NSFonts::CLibrary& library, const std::wstring& strFileName, const int& lFaceIndex, const double& dSize) { if (NULL == m_pApplicationFontStreams) return NULL; std::string sLock = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(strFileName.c_str(), strFileName.length(), false); char buffer[50]; sprintf(buffer, "%d_%.2lf", lFaceIndex, dSize); std::string s(buffer); sLock += s; CFontFile* pFile = m_mapFiles[sLock]; if (NULL != pFile) return pFile; CFontStream* pStream = (CFontStream*)m_pApplicationFontStreams->GetStream(strFileName); pFile = (CFontFile*)CFontManager::LoadFontFile(library, pStream, lFaceIndex); if (NULL == pFile) return NULL; if (-1 != m_lCacheSize) { m_arFiles.push_back(sLock); if ((int)m_arFiles.size() > m_lCacheSize) { std::string sPop = *m_arFiles.begin(); m_arFiles.pop_front(); std::map<std::string, CFontFile*>::iterator _find = m_mapFiles.find(sPop); if (m_mapFiles.end() != _find) { CFontFile* pFontRemove = _find->second; RELEASEOBJECT(pFontRemove); m_mapFiles.erase(_find); } } } pFile->m_pStream = pStream; pFile->m_pStream->AddRef(); m_mapFiles[sLock] = pFile; return pFile; }
VMLShapeTypeMapping::~VMLShapeTypeMapping() { RELEASEOBJECT(_lock); }
void TableCellPropertiesMapping::Apply (IVisitable* visited) { TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>(visited); int nComputedCellWidth = 0; std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend(); for (std::list<SinglePropertyModifier>::const_reverse_iterator iter = tapx->grpprl->rbegin(); iter != rend; ++iter) { switch (iter->OpCode) { case sprmOldTDefTable: case sprmTDefTable: { SprmTDefTable tdef(iter->Arguments, iter->argumentsSize); int cc = tdef.numberOfColumns; _tGrid = tdef.rgdxaCenter; _tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)]; // NOTE: fix for crash appendValueElement( _tcPr, _T( "textDirection" ), FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ).c_str(), false ); if ( _tcDef.vertMerge == Global::fvmMerge ) { appendValueElement( _tcPr, _T( "vMerge" ), _T( "continue" ), false ); } else if ( _tcDef.vertMerge == Global::fvmRestart ) { appendValueElement( _tcPr, _T( "vMerge" ), _T( "restart" ), false ); } appendValueElement( _tcPr, _T( "vAlign" ), FormatUtils::MapValueToWideString( _tcDef.vertAlign, &Global::VerticalAlignMap[0][0], 3, 7 ).c_str(), false ); if ( _tcDef.fFitText ) { appendValueElement( _tcPr, _T( "tcFitText" ), _T( "" ), false ); } if ( _tcDef.fNoWrap ) { appendValueElement( _tcPr, _T( "noWrap" ), _T( "" ), true ); } nComputedCellWidth = (short)( tdef.rgdxaCenter[(size_t)(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1) + 1] - tdef.rgdxaCenter[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)] ); // NOTE: fix for crash if (!IsTableBordersDefined(tapx->grpprl)) { //borders RELEASEOBJECT(_brcTop); _brcTop = new BorderCode(*_tcDef.brcTop); RELEASEOBJECT(_brcLeft); _brcLeft = new BorderCode(*_tcDef.brcLeft); RELEASEOBJECT(_brcRight); _brcRight = new BorderCode(*_tcDef.brcRight); RELEASEOBJECT(_brcBottom); _brcBottom = new BorderCode(*_tcDef.brcBottom); } } break; case sprmTCellPadding: { //margins unsigned char first = iter->Arguments[0]; unsigned char lim = iter->Arguments[1]; unsigned char ftsMargin = iter->Arguments[3]; short wMargin = FormatUtils::BytesToInt16( iter->Arguments, 4, iter->argumentsSize ); if ( ( _cellIndex >= first ) && ( _cellIndex < lim ) ) { if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 0 ) == true ) { appendDxaElement( _tcMar, _T( "top" ), FormatUtils::IntToWideString( wMargin ).c_str(), true ); } if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 1 ) == true ) { appendDxaElement( _tcMar, _T( "left" ), FormatUtils::IntToWideString( wMargin ).c_str(), true ); } if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 2 ) == true ) { appendDxaElement( _tcMar, _T( "bottom" ), FormatUtils::IntToWideString( wMargin ).c_str(), true ); } if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 3 ) == true ) { appendDxaElement( _tcMar, _T( "right" ), FormatUtils::IntToWideString( wMargin ).c_str(), true ); } } } break; case sprmTDefTableShd80: { if (!tapx->IsSkipShading97()) // если такой операнд единственный то учитываем его, иначе скипаем его { apppendCellShading(iter->Arguments, iter->argumentsSize, _cellIndex); } }break; case sprmOldTDefTableShd: case sprmTDefTableShd: { // cell shading for cells 0-20 apppendCellShading(iter->Arguments, iter->argumentsSize, _cellIndex); }break; case sprmTDefTableShd2nd: { // cell shading for cells 21-42 apppendCellShading(iter->Arguments, iter->argumentsSize, (_cellIndex - 21)); }break; case sprmTDefTableShd3rd: { // cell shading for cells 43-62 apppendCellShading(iter->Arguments, iter->argumentsSize, (_cellIndex - 43)); }break; case sprmTCellWidth: { //width unsigned char first = iter->Arguments[0]; unsigned char lim = iter->Arguments[1]; if ((_cellIndex >= first) && (_cellIndex < lim)) { _ftsWidth = (Global::CellWidthType)(iter->Arguments[2]); _width = FormatUtils::BytesToInt16(iter->Arguments, 3, iter->argumentsSize); } } break; case sprmTVertAlign: { //vertical alignment unsigned char first = iter->Arguments[0]; unsigned char lim = iter->Arguments[1]; if ((_cellIndex >= first) && (_cellIndex < lim)) { appendValueElement(_tcPr, _T( "vAlign" ), FormatUtils::MapValueToWideString( (VerticalCellAlignment)iter->Arguments[2], &VerticalCellAlignmentMap[0][0], 3, 7 ).c_str(), true ); } } break; case sprmTFitText: { //Autofit unsigned char first = iter->Arguments[0]; unsigned char lim = iter->Arguments[1]; if ( ( _cellIndex >= first ) && ( _cellIndex < lim ) ) { appendValueElement( _tcPr, _T( "tcFitText" ), FormatUtils::IntToWideString( iter->Arguments[2] ).c_str(), true ); } } break; case sprmOldTSetBrc: case sprmTSetBrc: { //borders (cell definition) unsigned char min = iter->Arguments[0]; unsigned char max = iter->Arguments[1]; int bordersToApply = (int)( iter->Arguments[2] ); if ( ( _cellIndex >= min ) && ( _cellIndex < max ) ) { const int brcSize = 8; unsigned char brcBytes[brcSize]; memcpy( brcBytes, ( iter->Arguments + 3 ), brcSize ); if( FormatUtils::BitmaskToBool( bordersToApply, 0x01 ) ) { RELEASEOBJECT( _brcTop ); _brcTop = new BorderCode( brcBytes, brcSize ); } if( FormatUtils::BitmaskToBool( bordersToApply, 0x02 ) ) { RELEASEOBJECT( _brcLeft ); _brcLeft = new BorderCode( brcBytes, brcSize ); } if ( FormatUtils::BitmaskToBool( bordersToApply, 0x04 ) ) { RELEASEOBJECT( _brcBottom ); _brcBottom = new BorderCode( brcBytes, brcSize ); } if ( FormatUtils::BitmaskToBool( bordersToApply, 0x08 ) ) { RELEASEOBJECT( _brcRight ); _brcRight = new BorderCode( brcBytes, brcSize ); } } } break; } } //width XMLTools::XMLElement<wchar_t> tcW( _T( "w:tcW" ) ); XMLTools::XMLAttribute<wchar_t> tcWType( _T( "w:type" ), FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ).c_str() ); XMLTools::XMLAttribute<wchar_t> tcWVal( _T( "w:w" ), FormatUtils::IntToWideString( _width ).c_str() ); tcW.AppendAttribute( tcWType ); tcW.AppendAttribute( tcWVal ); _tcPr->AppendChild( tcW ); //grid span _gridSpan = 1; if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) ) { //check the number of merged cells int w = _grid->at( _gridIndex ); for ( unsigned int i = _gridIndex + 1; i < _grid->size(); i++ ) { _gridSpan++; w += _grid->at( i ); if ( w >= nComputedCellWidth ) { break; } } appendValueElement( _tcPr, _T( "gridSpan" ), FormatUtils::IntToWideString( _gridSpan ).c_str(), true ); } //append margins if (_tcMar->GetChildCount() > 0) { _tcPr->AppendChild( *(_tcMar) ); } //append borders if (_brcTop) { XMLTools::XMLElement<wchar_t> topBorder(_T("w:top")); appendBorderAttributes(_brcTop, &topBorder); addOrSetBorder(_tcBorders, &topBorder ); } if (_brcLeft ) { XMLTools::XMLElement<wchar_t> leftBorder(_T("w:left")); appendBorderAttributes(_brcLeft, &leftBorder); addOrSetBorder(_tcBorders, &leftBorder); } if (_brcBottom) { XMLTools::XMLElement<wchar_t> bottomBorder(_T("w:bottom")); appendBorderAttributes(_brcBottom, &bottomBorder); addOrSetBorder(_tcBorders, &bottomBorder); } if (_brcRight) { XMLTools::XMLElement<wchar_t> rightBorder( _T( "w:right" ) ); appendBorderAttributes( _brcRight, &rightBorder ); addOrSetBorder( _tcBorders, &rightBorder ); } if ( _tcBorders->GetChildCount() > 0 ) { _tcPr->AppendChild( *(_tcBorders) ); } //write Properties if ((_tcPr->GetChildCount() > 0) || (_tcPr->GetAttributeCount() > 0)) m_pXmlWriter->WriteString(_tcPr->GetXMLString().c_str()); }
void GraphicFrame::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { if (pic.is_init()) { pic->toPPTY(pWriter); return; } if (!smartArt.is_init() && !table.is_init() && !chartRec.is_init() && !spid.is_init() ) return; CString xml_object_vml; CString xml_object_rels; if (spid.is_init()) { xml_object_vml = GetVmlXmlBySpid(xml_object_rels); } if (smartArt.is_init() && !table.is_init() && !chartRec.is_init() && !spid.is_init()) { smartArt->LoadDrawing(pWriter); if (smartArt->m_diag.is_init()) { smartArt->m_diag->nvGrpSpPr.cNvPr = nvGraphicFramePr.cNvPr; smartArt->m_diag->nvGrpSpPr.nvPr = nvGraphicFramePr.nvPr; bool bIsInitCoords = false; if (smartArt->m_diag->grpSpPr.xfrm.is_init()) bIsInitCoords = true; else smartArt->m_diag->grpSpPr.xfrm = new PPTX::Logic::Xfrm(); PPTX::Logic::Xfrm* dst = smartArt->m_diag->grpSpPr.xfrm.GetPointer(); const PPTX::Logic::Xfrm* src = &xfrm; dst->offX = src->offX; dst->offY = src->offY; dst->extX = src->extX; dst->extY = src->extY; if (!bIsInitCoords || !dst->chOffX.is_init() || !dst->chOffY.is_init() || !dst->chExtX.is_init() || !dst->chExtY.is_init()) { dst->chOffX = 0; dst->chOffY = 0; dst->chExtX = src->extX; dst->chExtY = src->extY; } dst->flipH = src->flipH; dst->flipV = src->flipV; dst->rot = src->rot; //удалим индекс плейсхолдера если он есть(p:nvPr) - он будет лишний так как будет имплементация объекта if (smartArt->m_diag->nvGrpSpPr.nvPr.ph.IsInit()) { if(smartArt->m_diag->nvGrpSpPr.nvPr.ph->idx.IsInit()) { smartArt->m_diag->nvGrpSpPr.nvPr.ph.reset(); } } smartArt->toPPTY(pWriter); } return; } if (!table.is_init() && !chartRec.is_init() && xml_object_vml.IsEmpty() == false) { CString temp = _T("<v:object>"); temp.Append(xml_object_vml); temp.Append(_T("</v:object>")); NSBinPptxRW::CDrawingConverter oDrawingConverter; //oDrawingConverter.SetFontManager(pFontManager); RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager); oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = pWriter->m_pCommon->m_pImageManager; CString *main_props = NULL; oDrawingConverter.SetRelsPath(xml_object_rels); oDrawingConverter.SetAdditionalParam(_T("xfrm_override"), (BYTE*)&xfrm, sizeof(xfrm)); HRESULT hRes = oDrawingConverter.AddObject(temp, &main_props); if (hRes == S_OK && oDrawingConverter.m_pBinaryWriter->GetPosition() > 10) { pWriter->WriteBYTEArray(oDrawingConverter.m_pBinaryWriter->GetBuffer()+10,oDrawingConverter.m_pBinaryWriter->GetPosition()-10); } oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = NULL; return; } pWriter->StartRecord(SPTREE_TYPE_GRFRAME); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); pWriter->WriteString2(0, spid); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); pWriter->WriteRecord1(0, nvGraphicFramePr); pWriter->WriteRecord1(1, xfrm); pWriter->WriteRecord2(2, table); if (chartRec.is_init()) { pWriter->WriteRecord2(3, chartRec); } else if (xml_object_vml.IsEmpty() == false) { } pWriter->EndRecord(); }
bool RtfWriter::SaveByItem() { if( NULL == m_oCurTempFileWriter ) { try { CString sNewTempFile = Utils::CreateTempFile( m_sTempFolder ); m_aTempFiles.push_back( sNewTempFile ); RELEASEOBJECT( m_oCurTempFileWriter ); m_oCurTempFileWriter = new NFileWriter::CBufferedFileWriter( sNewTempFile ); CString sNewTempFileSect = Utils::CreateTempFile( m_sTempFolder ); m_aTempFilesSectPr.push_back( sNewTempFileSect ); RELEASEOBJECT( m_oCurTempFileSectWriter ); m_oCurTempFileSectWriter = new NFileWriter::CBufferedFileWriter( sNewTempFileSect ); } catch(...) { return false; } } RenderParameter oNewParam; oNewParam.poDocument = &m_oDocument; oNewParam.poWriter = this; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; if( m_oDocument.GetCount() > 1 && m_oDocument[0]->GetCount() == 0 ) { //пишем конец секции CStringA sRtfExt = "\\sect"; m_oCurTempFileWriter->Write( (BYTE*)(LPCSTR)sRtfExt, sRtfExt.GetLength() ); //окончательно дописываем темповый файл RELEASEOBJECT( m_oCurTempFileWriter ) try { CString sNewTempFile = Utils::CreateTempFile( m_sTempFolder ); m_aTempFiles.push_back( sNewTempFile ); m_oCurTempFileWriter = new NFileWriter::CBufferedFileWriter( sNewTempFile ); } catch(...) { return false; } if( NULL != m_oCurTempFileSectWriter ) { //пишем свойства секции CString sRtf; if( true == m_bFirst ) { //первый свойства секции пишем как свойства документа m_bFirst = false; oNewParam.nType = RENDER_TO_OOX_PARAM_FIRST_SECTION; } sRtf = m_oDocument[0]->m_oProperty.RenderToRtf(oNewParam); RtfUtility::RtfInternalEncoder::Decode( sRtf, *m_oCurTempFileSectWriter ); //дописываем в файл RELEASEOBJECT( m_oCurTempFileSectWriter ); //создаем новый CString sNewTempFileSect = Utils::CreateTempFile( m_sTempFolder ); m_aTempFilesSectPr.push_back( sNewTempFileSect ); m_oCurTempFileSectWriter = new NFileWriter::CBufferedFileWriter( sNewTempFileSect ); //m_aTempFilesSectPr.push_back( sRtf ); //RtfInternalEncoder::Decode( sRtf, *m_oFileWriter ); //m_oFileWriter->Write( (BYTE*)(LPCSTR)sRtf, sRtf.GetLength() ); } //удаляем секцию m_oDocument.RemoveItem( 0 ); }
RevisionData::~RevisionData() { RELEASEOBJECT( Changes ); }
bool CFontConverter::ToOTF2(std::wstring sFontIn, unsigned int* pSymbols, int nCount, std::wstring sNameW, long nFlag, long lFaceIndex, unsigned char*& pDstData, int& nDstLen) { // функция просто скопирована и немного доработана. это все из-за нехватки времени. FT_Library pLibrary = NULL; if ( FT_Init_FreeType( &pLibrary ) ) return false; FT_Face pFace = NULL; NSFile::CFileBinary oFileBinary; if (!oFileBinary.OpenFile(sFontIn)) return false; FT_Long nFileSize = (FT_Long)oFileBinary.GetFileSize(); BYTE* pBaseAddress = new BYTE[nFileSize]; DWORD dwRead = 0; oFileBinary.ReadFile(pBaseAddress, (DWORD)nFileSize, dwRead); FT_Open_Args oOpenArgs; oOpenArgs.flags = FT_OPEN_MEMORY; oOpenArgs.memory_base = (BYTE*)pBaseAddress; oOpenArgs.memory_size = (FT_Long)nFileSize; NSFontConverter::CFontFileTrueType* pTTF = NSFontConverter::CFontFileTrueType::LoadFromFile( sFontIn.c_str() ); FT_Error oerrr; if ( oerrr = FT_Open_Face( pLibrary, &oOpenArgs, lFaceIndex, &pFace ) ) { FT_Done_FreeType( pLibrary ); RELEASEARRAYOBJECTS(pBaseAddress); return false; } std::string sFontFormat( FT_Get_X11_Font_Format( pFace ) ); // Проверим флаг конвертации и исходный формат шрифта bool bNeedConvert = false; if ( nFlag == NSFontConverter::c_lFromAll || ( "TrueType" == sFontFormat && nFlag & NSFontConverter::c_lFromTT ) || ( "CFF" == sFontFormat && nFlag & NSFontConverter::c_lFromCFF ) || ( "Type 1" == sFontFormat && nFlag & NSFontConverter::c_lFromT1 ) ) bNeedConvert = true; bool bIsGids = (NSFontConverter::c_lFlagsGids & nFlag); NSFontConverter::TCharBuffer* pCharBuffer = NULL; if ( bNeedConvert ) { pCharBuffer = new NSFontConverter::TCharBuffer(100000); // ~100Kb if ( "CFF" == sFontFormat || "Type 1" == sFontFormat ) { NSFontConverter::TCharBuffer oCFF; NSFontConverter::CFontFileType1C *pT1C = NULL; if ( "Type 1" == sFontFormat ) { // Сначала сконвертируем Type1 в CFF NSFontConverter::CFontFileType1* pT1 = NSFontConverter::CFontFileType1::LoadFromFile( sFontIn.c_str() ); pT1->ToCFF( &NSFontConverter::CharBufferWrite, &oCFF ); delete pT1; // Конвертируем CFF в OpenTypeCFF pT1C = NSFontConverter::CFontFileType1C::LoadFromBuffer( oCFF.sBuffer, oCFF.nLen ); } else { // FreeType отдает тип шрифта CFF, в случаях когда файл имеет тип OpenType(CFF). // Если так оно и есть, тогда нам с файлом ничего делать на надо. pT1C = NSFontConverter::CFontFileType1C::LoadFromFile( sFontIn.c_str() ); } if ( pT1C ) { pT1C->ToOpenTypeCFF( &NSFontConverter::CharBufferWrite, pCharBuffer, pFace ); } delete pT1C; } else if ( "TrueType" == sFontFormat && ( pSymbols != NULL || !sNameW.empty() ) ) { NSFontConverter::CFontFileTrueType* pTTF = NSFontConverter::CFontFileTrueType::LoadFromFile( sFontIn.c_str() ); if ( pTTF ) { std::string sName = U_TO_UTF8(sNameW); unsigned char *pUseGlyfs = NULL; long lGlyfsCount = pFace->num_glyphs; if ( pSymbols ) { // Сначала составим список нужных нами GID unsigned int* pUnicode = (unsigned int*)pSymbols; unsigned short* pGIDs = new unsigned short[nCount]; int nCMapIndex = 0; int nSymbolicIndex = NSFontConverter::GetSymbolicCmapIndex(pFace); if (!bIsGids) { for ( int nIndex = 0; nIndex < nCount; nIndex++ ) { pGIDs[nIndex] = NSFontConverter::SetCMapForCharCode( pFace, pUnicode[nIndex], &nCMapIndex ); if ((pGIDs[nIndex] == 0) && (-1 != nSymbolicIndex) && (pUnicode[nIndex] < 0xF000)) { pGIDs[nIndex] = NSFontConverter::SetCMapForCharCode( pFace, pUnicode[nIndex] + 0xF000, &nCMapIndex ); } } } else { for (int i = 0; i < nCount; ++i) pGIDs[i] = (unsigned short)pUnicode[i]; } pUseGlyfs = new unsigned char[lGlyfsCount]; ::memset( pUseGlyfs, 0x00, lGlyfsCount * sizeof(unsigned char) ); pUseGlyfs[0] = 1; // нулевой гид всегда записываем for ( int nGID = 1; nGID < lGlyfsCount; nGID++ ) { if ( 1 != pUseGlyfs[nGID] ) { bool bFound = false; for ( int nIndex = 0; nIndex < nCount; nIndex++ ) { if ( nGID == pGIDs[nIndex] ) { bFound = true; break; } } // Если данный символ составной (CompositeGlyf), тогда мы должны учесть все его дочерные символы (subglyfs) if ( bFound && 0 == FT_Load_Glyph( pFace, nGID, FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE ) ) { for ( int nSubIndex = 0; nSubIndex < pFace->glyph->num_subglyphs; nSubIndex++ ) { FT_Int nSubGID; FT_UInt unFlags; FT_Int nArg1; FT_Int nArg2; FT_Matrix oMatrix; FT_Get_SubGlyph_Info( pFace->glyph, nSubIndex, &nSubGID, &unFlags, &nArg1, &nArg2, &oMatrix ); if ( nSubGID < lGlyfsCount ) pUseGlyfs[nSubGID] = 1; } } if ( bFound ) pUseGlyfs[nGID] = 1; } } } pTTF->WriteTTF( &NSFontConverter::CharBufferWrite, pCharBuffer, sName.c_str(), NULL, pUseGlyfs, lGlyfsCount ); } } LONG nSizeFont = pCharBuffer->nLen; nDstLen = (int)nSizeFont; pDstData = new BYTE[nDstLen]; memcpy(pDstData, pCharBuffer->sBuffer, nDstLen); RELEASEOBJECT(pCharBuffer); } else { nDstLen = (int)nFileSize; pDstData = new BYTE[nDstLen]; memcpy(pDstData, pBaseAddress, nDstLen); } FT_Done_Face( pFace ); FT_Done_FreeType( pLibrary ); RELEASEARRAYOBJECTS(pBaseAddress); return true; }
CRITICAL_SECTION::~CRITICAL_SECTION() { RELEASEOBJECT(m_pCS); }
TableRowPropertiesMapping::~TableRowPropertiesMapping() { RELEASEOBJECT(_trPr); RELEASEOBJECT(_tblPrEx); }
CPPTXFile::~CPPTXFile() { RELEASEOBJECT(m_pPptxDocument); }