Beispiel #1
0
HRESULT touchmind::shell::Clipboard::PasteNodeModel(
    IN HWND hWnd,
    OUT std::shared_ptr<touchmind::model::node::NodeModel> &node,
    OUT std::vector<std::shared_ptr<model::link::LinkModel>> &links)
{
    HRESULT hr = _InitializeClipboard();
    if (SUCCEEDED(hr)) {
        int formatId = GetPriorityClipboardFormat(
                           &m_pFormatPriorityList.front(),
                           static_cast<int>(m_pFormatPriorityList.size()));
        if (formatId >= 0) {
            if (formatId == m_touchMindClipboardFormatId) {
                std::wstring s_xml;
                _PasteXML(hWnd, s_xml);
                LOG(SEVERITY_LEVEL_DEBUG) << s_xml;
                MSXML::IXMLDOMDocumentPtr pXMLDoc;
                hr = pXMLDoc.CreateInstance(__uuidof(MSXML::DOMDocument60), nullptr, CLSCTX_INPROC_SERVER);
                _bstr_t xml(s_xml.c_str());
                pXMLDoc->loadXML(xml);
                MSXML::IXMLDOMElementPtr pElement = pXMLDoc->firstChild;
                m_pNodeModelXMLDecoder->Decode(pElement, node, links, false, false);
            } else if (formatId == CF_UNICODETEXT) {
                std::wstring text;
                _PasteTEXT(hWnd, text);
                touchmind::converter::NodeModelToTextConverter textConverter;
                textConverter.SetSelectionManager(m_pSelectionManager);
                node = textConverter.FromText(text);
            }
        }
    }
    return hr;
}
HRESULT CSolarSystemDoc::LoadFromXmlString(const CString& str)
{
	if (str.IsEmpty()) return E_FAIL;

	MSXML::IXMLDOMDocumentPtr pDocument;

	HRESULT hResult = pDocument.CreateInstance(__uuidof(DOMDocument));

	if (FAILED(hResult)) return hResult;

	try
	{
		pDocument->async = VARIANT_FALSE;

		if (VARIANT_FALSE == pDocument->loadXML(bstr_t(str)))
			return E_FAIL;

		ParseXmlDocument(pDocument);
	}
	catch (_com_error &e)
	{
		return e.Error();
	}

	return S_OK;
}
Beispiel #3
0
void NewVersionDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
	CDialog::OnShowWindow(bShow, nStatus);

	int iTotalTextLength = ctlDetails.GetWindowTextLength();
	ctlDetails.SetSel(iTotalTextLength, iTotalTextLength);
	BeginWaitCursor();
	CString sResult;
	CWebAccess webAccess;
	webAccess.Get("www.milow.net/site/projects/parnrar/pnrVersions.xml", sResult);

	if (sResult != "")
		{
		MSXML::IXMLDOMDocumentPtr domVersions;	

		if (CoCreateInstance( MSXML::CLSID_DOMDocument, 0, CLSCTX_INPROC_SERVER, MSXML::IID_IXMLDOMDocument, (void**)&domVersions ) != S_OK)
		{
			ctlDetails.ReplaceSel("Error: Failed to create DOMDocument object");
			goto CLEANUP;
		}
		domVersions->loadXML(sResult.GetBuffer(0));
		CString sXml = static_cast<char *>(domVersions->xml);
		if (sXml == "")
		{
			ctlDetails.ReplaceSel("Error: Failed to download version information");
			goto CLEANUP;
		}
		MSXML::IXMLDOMElementPtr eVer = domVersions->selectSingleNode("/Versions/Version");
		CString sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number")));
		if (sVer == theApp.GetMyVersion())
		{
			ctlDetails.ReplaceSel("You are currently running the latest version of Par-N-Rar");
			goto CLEANUP;
		}

		//Get all info about later versions
		CString sText = "You are currently running v" + theApp.GetMyVersion();
		sText += "\n";
		sText += "The latest version is v" + sVer;
		sText += "\n\n";

		MSXML::IXMLDOMNodeListPtr nlVersions = domVersions->selectNodes( "/Versions/Version");	
		for (long l=0; l<nlVersions->length; l++)
		{
			eVer = nlVersions->Getitem(l);
			sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number")));
			if (sVer == theApp.GetMyVersion())
				break;
			sText += "****************************************************\nVersion " + sVer;
			sText += ": \n";
			sText += static_cast<char *>(eVer->text);
			sText += "\n\n";
		}
		ctlDetails.ReplaceSel(sText);
	}

CLEANUP:
	Resize();
	EndWaitCursor();
}
Beispiel #4
0
Result StringToXML(MSXML::IXMLDOMDocumentPtr& p, const string& s)
{
	Result r;

	try
	{
		HRESULT hr;
		if(FAILED(hr = p.CreateInstance("msxml.domdocument")))
		{
			r.Fail(Format("Failed to create instance of msxml.domdocument.  Error code: %").ul(hr).Str());
		}
		else
		{
      VARIANT_BOOL b = p->loadXML(s.c_str());
			if(b == VARIANT_FALSE)
			{
				MSXML::IXMLDOMParseErrorPtr pErr = p->GetparseError();
				if(pErr == NULL)
				{
					r.Fail(_T("Failed to load XML into msxml.domdocument.  Could not get IXMLDOMParseErrorPtr for details."));
				}
				else
				{
					r.Fail(Format("Failed to parse xml.  %").s(pErr->reason).Str());
				}
			}
			else
			{
				r.Succeed();
			}
		}
	}
	catch(_com_error& e)
	{
		r.Fail(Format("Error loading XML into msxml.domdocument. % %").s(e.ErrorMessage()).s(e.Description()).Str());
	}

	return r;
}