Exemple #1
0
		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 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();
		}