Exemple #1
0
LRESULT CSVGSymbolsDlg::OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if (m_selectedItemIndex >= 0)
	{
		CComPtr<IWebXMLViewGroup> viewGroup;
		m_document->GetActiveViewGroup(&viewGroup);
		if (viewGroup)
		{
			CEXMLViewGroup* pViewGroup = static_cast<CEXMLViewGroup*>(viewGroup.p);

//			CElementImpl* pElement = ((CEXMLDocument*)m_document.p)->m_pTree->FindDOMElement(m_items[m_selectedItemIndex]);
			CComPtr<IEElement> pElement;
			m_document->GetEElementFromDOMElement(m_items[m_selectedItemIndex], &pElement);

			pViewGroup->ActivateElement(pElement, 0, NULL);
		}
	}

	return 0;
}
Exemple #2
0
LRESULT CSVGSwatchesDlg::OnSwatchesNewSolidColor(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	if (m_viewGroup)
	{
		CComPtr<IEXMLDocument> eXMLDocument;
		m_viewGroup->get_eXMLDocument(&eXMLDocument);

		CComQIPtr<IEDocument> eDocument = eXMLDocument;

		CComPtr<ILDOMDocument> document;
		eXMLDocument->get_DOMDocument(&document);

		CSVGFilterOptionsDlg dlg;
		dlg.m_document = document;

		if (dlg.DoModal() == IDOK)
		{
			CComPtr<IOleUndoManager> undoManager;
			eDocument->get_undoManager(&undoManager);

			CComObject<CUndoParent>* pParentUndo;
			CComObject<CUndoParent>::CreateInstance(&pParentUndo);
			if (pParentUndo)
			{
				pParentUndo->AddRef();	// ???
				undoManager->Open(pParentUndo);

				CComPtr<ILSVGElement> svgDefsElement;
				eXMLDocument->FindOrCreateSVGDefs(&svgDefsElement);

				if (svgDefsElement)
				{
					CComPtr<ILSVGElement> svgElement;
					document->createElementNS(L"http://www.w3.org/2000/svg", L"solidColor", (ILDOMElement**)&svgElement);

					if (svgElement)
					{
						svgElement->setAttribute(L"id", dlg.m_id);

					//	CComPtr<IOleUndoManager> undoManager;
					//	m_document->get_undoManager(&undoManager);

						CComBSTR styleValue;
						styleValue += L"solid-color:";
						styleValue += static_cast<CEXMLDocument*>(eXMLDocument.p)->m_lastColor;
						styleValue += L";";

						svgElement->setAttribute(L"style", styleValue);

						CComObject<CWEUndoNewElement>* pUndo;
						CComObject<CWEUndoNewElement>::CreateInstance(&pUndo);
						if (pUndo)
						{
						//	pUndo->AddRef();
							pUndo->m_pDocument = static_cast<CEXMLDocument*>(eXMLDocument.p);

							pUndo->DoInitial(undoManager, svgElement, svgDefsElement, NULL);

							// TODO: do this here?
							//CComPtr<IWebXMLViewGroup> viewGroup;
							//m_document->GetActiveViewGroup(&viewGroup);
							//if (viewGroup)
							{
								CEXMLViewGroup* pViewGroup = m_viewGroup;

	//							CElementImpl* pElement = ((CEXMLDocument*)m_document.p)->m_pTree->FindDOMElement(svgFilterElement);
								CComPtr<IEElement> eElement;
								eXMLDocument->GetEElementFromDOMElement(svgElement, &eElement);

								{
									pViewGroup->m_colorEditing = L"solid-color";

									pViewGroup->SetCurrentSelectionColor();
									pViewGroup->Fire_ColorChanged();
								}

								pViewGroup->m_activeReferencedElement = eElement;	// ??? reference element is still NULL
								m_viewGroup->ActivateElement(eElement, 0, NULL);
							}
						}
					}
				}

				undoManager->Close(pParentUndo, TRUE/*commit*/);
			}
		}
	}

	return 0;
}
Exemple #3
0
LRESULT CSVGFontsDlg::OnFontNewFont(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	if (m_document)
	{
		CComQIPtr<IEDocument> eDocument = m_document;

		CComPtr<ILDOMDocument> document;
		m_document->get_DOMDocument(&document);

		CSVGFilterOptionsDlg dlg;
		dlg.m_document = document;

		if (dlg.DoModal() == IDOK)
		{
			CComPtr<IOleUndoManager> undoManager;
			eDocument->get_undoManager(&undoManager);

			CComObject<CUndoParent>* pParentUndo;
			CComObject<CUndoParent>::CreateInstance(&pParentUndo);
			if (pParentUndo)
			{
				pParentUndo->AddRef();	// ???
				undoManager->Open(pParentUndo);

				CComPtr<ILSVGElement> svgDefsElement;
				m_document->FindOrCreateSVGDefs(&svgDefsElement);

				if (svgDefsElement)
				{
					CComPtr<ILSVGFilterElement> svgElement;
					document->createElementNS(L"http://www.w3.org/2000/svg", L"font", (ILDOMElement**)&svgElement);

					if (svgElement)
					{
						svgElement->setAttribute(L"id", dlg.m_id);

						CComObject<CWEUndoNewElement>* pUndo;
						CComObject<CWEUndoNewElement>::CreateInstance(&pUndo);
						if (pUndo)
						{
						//	pUndo->AddRef();
							pUndo->m_pDocument = static_cast<CEXMLDocument*>(m_document.p);

							pUndo->DoInitial(undoManager, svgElement, svgDefsElement, NULL);

							// TODO: do this here?
							CComPtr<IEXMLViewGroup> viewGroup;
							m_document->GetActiveViewGroup(&viewGroup);
							if (viewGroup)
							{
								CEXMLViewGroup* pViewGroup = static_cast<CEXMLViewGroup*>(viewGroup.p);

	//							CElementImpl* pElement = ((CEXMLDocument*)m_document.p)->m_pTree->FindDOMElement(svgFilterElement);
								CComPtr<IEElement> pElement;
								m_document->GetEElementFromDOMElement(svgElement, &pElement);

								pViewGroup->ActivateElement(pElement, 0, NULL);
							}
						}
					}
				}

				undoManager->Close(pParentUndo, TRUE/*commit*/);
			}
		}
	}

	return 0;
}