Exemplo n.º 1
0
bool CHelpDB::ChangeItem(CTSTRING& sAlias, CTSTRING& sText)
{
    MSXML::IXMLDOMElementPtr El;
    HRESULT hr = 0;
    bool r = false;
    if(m_doc == 0) return false;

    if(GetItemElement(sAlias, El, false))
    {
        if(SUCCEEDED(hr = El->setAttribute(TAG_TEXT, sText.c_str())))
        {
            g_pLog->msg(_T("Item changed: %s = %s"), sAlias.c_str(), sText.c_str());
            r = true;
        }
        else
        {
            g_pLog->msg(_T("SetAttribute(%s=%s) failed, hr=0x%08x"), TAG_TEXT, sText.c_str(), hr);
        }
    }
    else
    {
        sprintf(m_err, _T("%s was not found in the database."), sAlias.c_str());
        g_pLog->msg(_T("CHelpDB::ChangeItem(%s) - Item wasn't found."), sAlias.c_str());
    }

    return r;
}
Exemplo n.º 2
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();
}
Exemplo n.º 3
0
bool CVideoExchange::AddElement(LPCTSTR strName, LPCTSTR strValue)
{
    MSXML::IXMLDOMElementPtr pRoot;
    MSXML::IXMLDOMElementPtr pElem;

    pRoot = m_pDocument->getElementsByTagName(L"CARDVIDEO")->item[0];
    pElem = m_pDocument->createElement(_bstr_t(strName));
    pElem->text = (LPCTSTR)strValue;
    pRoot->appendChild(pElem);
    pElem.Release();
    return true;
}
Exemplo n.º 4
0
Result GetFirstElementByTagName(MSXML::IXMLDOMElementPtr& parent, const string& tagName, MSXML::IXMLDOMElementPtr& pEl)
{
	Result r;

	try
	{
		pEl = 0;
		MSXML::IXMLDOMNodeListPtr pList = parent->getElementsByTagName(tagName.c_str());
		if(pList == NULL)
		{
			r.Fail(Format("No '%' nodes found (pList = 0)").s(tagName).Str());
		}
		else
		{
			if(!pList->length)
			{
				r.Fail(Format("No '%' nodes found (length = 0)").s(tagName).Str());
			}
			else
			{
				pEl = pList->nextNode();
				r.Succeed();
			}
		}
	}
	catch(_com_error& e)
	{
		r.Fail(Format("Com error: % %").s(e.ErrorMessage()).s(e.Description()).Str());
	}

	return r;
}
Exemplo n.º 5
0
////////////////////////////////////////////////////////////////////////////
// Function: Create an XML DOM Document from Scratch in memory
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::Build()
{
	// Create a root node
	MSXML::IXMLDOMNodePtr pRoot;
	m_pDoc->createNode(CComVariant(MSXML::NODE_ELEMENT), CComBSTR("Root"), NULL, &pRoot);

	// add child nodes
	HRESULT hr = S_OK;
	for (int i = 0; i < 10; i++)
	{
		MSXML::IXMLDOMNodePtr pNode;
		m_pDoc->createNode(CComVariant(MSXML::NODE_ELEMENT), CComBSTR("Order"), NULL, &pNode);

		MSXML::IXMLDOMElementPtr pElement = pNode;
		if (pElement != NULL)
			pElement->setAttribute(CComBSTR("id"), CComVariant(i));

		MSXML::IXMLDOMNodePtr p0 = NULL;
		CComVariant after;
		hr = pRoot->insertBefore(pNode, after, &p0);
		hr = CheckHR(hr, "inserting node");

		// The XML Document should now own the node.
		for (int j = 0; j < 10; j++)
		{
			MSXML::IXMLDOMNodePtr pNode2;
			m_pDoc->createNode(CComVariant(MSXML::NODE_ELEMENT), CComBSTR("Item"), NULL, &pNode2);

			MSXML::IXMLDOMElementPtr pElement2 = pNode2;
			if (pElement2 != NULL)
				pElement2->setAttribute(CComBSTR("id"), CComVariant((i*10) + j));
	
			MSXML::IXMLDOMNodePtr p1 = NULL;
			CComVariant after;
			hr = p0->insertBefore(pNode2, after, &p1);
			hr = CheckHR(hr, "inserting node");
			// The XML Document should now own the node.
		}
	}

	// Now attach this new subtree to the document.
	m_pDoc->appendChild(pRoot, NULL);

	return hr;
}
Exemplo n.º 6
0
bool CHelpDB::GetItemElement(CTSTRING& _sAlias, MSXML::IXMLDOMElementPtr& Out, bool bCreate)
{
    bool r = false;
    TSTRING sXPath;
    MSXML::IXMLDOMNodePtr Node;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // this will look something like MSG[@ALIAS="hithere"]
    sprintf(sXPath, TAG_MSG _T("[@") TAG_ALIAS _T("=\"%s\"]"), sAlias.c_str());

    try
    {
        Node = m_root->selectSingleNode(_bstr_t(sXPath.c_str()));

        if((Node == NULL) && (bCreate == true))
        {
            MSXML::IXMLDOMElementPtr NewEl;
            MSXML::IXMLDOMNodePtr NewNode;

            NewEl = m_doc->createElement("MSG");
            NewEl.QueryInterface(__uuidof(MSXML::IXMLDOMNode), &NewNode);
            Node = m_root->appendChild(NewNode);
        }

        if(Node != NULL)
        {
            Node.QueryInterface(__uuidof(MSXML::IXMLDOMElement), &Out);
            r = true;
        }
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error());
        g_pLog->msg(_T("CHelpDB::GetItemElement(%s)"), _sAlias.c_str());
    }

    return r;
}
Exemplo n.º 7
0
bool CHelpDB::DeleteItem(CTSTRING& sAlias)
{
    MSXML::IXMLDOMElementPtr El;
    MSXML::IXMLDOMNodePtr Node;
    MSXML::IXMLDOMNodePtr Parent;
    bool r = false;
    if(m_doc == 0) return false;

    if(GetItemElement(sAlias, El, false))
    {
        El.QueryInterface(__uuidof(MSXML::IXMLDOMNode), &Node);
        Parent = Node->GetparentNode();
        Parent->removeChild(Node);
        r = true;
    }

    return r;
}
Exemplo n.º 8
0
Result XMLSetAttribute(const _variant_t& val, MSXML::IXMLDOMElementPtr pEl, const string& sAttribute)
{
	Result r;
	try
	{
		pEl->setAttribute(sAttribute.c_str(), val);
		r.Succeed();
	}
	catch(_com_error& e)
	{
		r.Fail(Format("Com error: % %").s(e.ErrorMessage()).s(e.Description()).Str());
	}
	return r;
}
Exemplo n.º 9
0
bool CHelpDB::NewItem(CTSTRING& _sAlias, CTSTRING& sText, CTSTRING& sCreator)
{
    MSXML::IXMLDOMElementPtr El;
    bool r = false;
    if(m_doc == 0) return false;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // Just determine if it exists.
    if(GetItemElement(sAlias, El, false))
    {
        // it already exists; fail.
        sprintf(m_err, _T("%s already exists.  If you want to change the existing entry, use !msgchange."), sAlias.c_str());
        g_pLog->msg(_T("%s"), m_err.c_str());
    }
    else
    {
        // doesn't already exist... we're golden like the shower.  This time
        // just call GetItemElement() with bCreate set to true.
        if(!GetItemElement(sAlias, El, true))
        {
            sprintf(m_err, _T("%s could not be added."), sAlias.c_str());
            g_pLog->msg(_T("%s"), m_err.c_str());
        }
        else
        {
            El->setAttribute(TAG_ALIAS, sAlias.c_str());
            El->setAttribute(TAG_CREATOR, sCreator.c_str());
            El->setAttribute(TAG_TEXT, sText.c_str());
            El->setAttribute(TAG_USAGE, _T("0"));
            SYSTEMTIME st;
            TSTRING sTime;
            GetLocalTime(&st);
            Bin2Str(sTime, (BYTE*)&st, sizeof(st));
            El->setAttribute(TAG_TIME, sTime.c_str());

            g_pLog->msg(_T("New db item: %s = %s"), _sAlias.c_str(), sText.c_str());

            r = true;
        }
    }

    return r;
}
Exemplo n.º 10
0
Result XMLGetAttribute(_variant_t& out, MSXML::IXMLDOMElementPtr pEl, const string& sAttribute)
{
	Result r;
	try
	{
    out = pEl->getAttribute(sAttribute.c_str());
		if(out.vt == VT_NULL)
		{
			r.Fail(Format("Attribute '%' not found, or VT_NULL").s(sAttribute).Str());
		}
		else
		{
			r.Succeed();
		}
	}
	catch(_com_error& e)
	{
		r.Fail(Format("Error reading the %s attribute from xml. % %").s(sAttribute).s(e.ErrorMessage()).s(e.Description()).Str());
	}
	return r;
}
Exemplo n.º 11
0
bool CHelpDB::ElementToStruct(CHelpMessage& info, MSXML::IXMLDOMElementPtr& El, bool bIncUsage)
{
    bool r = false;

    try
    {
        _variant_t vAlias = El->getAttribute(TAG_ALIAS);
        _variant_t vCreator = El->getAttribute(TAG_CREATOR);
        _variant_t vText = El->getAttribute(TAG_TEXT);
        _variant_t vCreated = El->getAttribute(TAG_TIME);
        _variant_t vUsage = El->getAttribute(TAG_USAGE);

        HW2T(info.Alias, vAlias.bstrVal);
        HW2T(info.Creator, vCreator.bstrVal);
        HW2T(info.Text, vText.bstrVal);

        TSTRING sTemp;

        HW2T(sTemp, vCreated.bstrVal);
        Str2Bin(sTemp, (PBYTE)&info.Created, sizeof(info.Created));

        HW2T(sTemp, vUsage.bstrVal);
        info.nUsage = _tcstoul(sTemp.c_str(), 0, 10);

        if(bIncUsage)
        {
            TCHAR tsz[500];
            info.nUsage++;
            _ultot(info.nUsage, tsz, 10);
            El->setAttribute(_bstr_t(TAG_USAGE), _variant_t(tsz));
        }

        r = true;
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error(), (TCHAR*)e.Description());
        g_pLog->msg(_T("CHelpDB::ElementToStruct ERROR"));
    }

    return r;
}
Exemplo n.º 12
0
bool CVideoExchange::Dehydrate(void)
{
    if (m_pDocument)
        m_pDocument.Release();
    MSXML::IXMLDOMElementPtr pRoot;
    MSXML::IXMLDOMElementPtr pElem;
    TCHAR chBuffer[255];

    HRESULT hr = m_pDocument.CreateInstance(L"MSXML.FreeThreadedDOMDocument");
    ASSERT(ERROR_SUCCESS == hr);

    pElem = m_pDocument->createElement(L"CARDVIDEO");
    pRoot = m_pDocument->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"BITRATE");
    pElem->text = (LPCTSTR)m_sBitRate;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"FILENAME");
    pElem->text = (LPCTSTR)m_sFileName;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"MPEGFORMAT");
    pElem->text = (LPCTSTR)m_sMPEGFormat;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"CARDID");
    pElem->text = (LPCTSTR)m_sCardId;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"ROOMID");
    pElem->text = _ltot(m_nRoomId,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"TIMESTART");
    pElem->text = (LPCTSTR)m_odtStart.Format(_T("%m-%d-%Y %H:%M:%S"));
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"TIMESTOP");
    pElem->text = (LPCTSTR)m_odtStop.Format(_T("%m-%d-%Y %H:%M:%S"));
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"DURATION");
    pElem->text = _ltot(m_nDuration,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"VIDEOSTORAGESERVERID");
    pElem->text = _ltot(m_nVideoStorageServerId,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"STREAMINGENCODERID");
    pElem->text = _ltot(m_nStreamingEncoderId,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"SESSIONID");
    pElem->text = (LPCTSTR)m_sSessionId;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"SESSIONNAME");
    pElem->text = (LPCTSTR)m_sSessionName;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"DISPLAYNAME");
    pElem->text = (LPCTSTR)m_sDisplayName;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"FILETITLE");
    pElem->text = (LPCTSTR)m_sFileTitle;
    pRoot->appendChild(pElem);
    pElem.Release();
    return false;
}
Exemplo n.º 13
0
void CArc::Load(MSXML::IXMLDOMElementPtr pGO)
{
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
	MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    pStatic=pGO->selectSingleNode(L"./static");
    //position
    pAttr=pStatic->selectSingleNode(L"./position");
    //x1
    val=pAttr->getAttribute(L"x1");
    val.ChangeType(VT_I4);
    m_lx1=val.lVal;
    //y1
    val=pAttr->getAttribute(L"y1");
    val.ChangeType(VT_I4);
    m_ly1=val.lVal;
    //x2
    val=pAttr->getAttribute(L"x2");
    val.ChangeType(VT_I4);
    m_lx2=val.lVal;
    //y2
    val=pAttr->getAttribute(L"y2");
    val.ChangeType(VT_I4);
    m_ly2=val.lVal;
    //x3
    val=pAttr->getAttribute(L"x3");
    val.ChangeType(VT_I4);
    m_lx3=val.lVal;
    //y3
    val=pAttr->getAttribute(L"y3");
    val.ChangeType(VT_I4);
    m_ly3=val.lVal;
    //x4
    val=pAttr->getAttribute(L"x4");
    val.ChangeType(VT_I4);
    m_lx4=val.lVal;
    //y4
    val=pAttr->getAttribute(L"y4");
    val.ChangeType(VT_I4);
    m_ly4=val.lVal;

    //pen
    pAttr=pStatic->selectSingleNode(L"./pen");
    //style
    val=pAttr->getAttribute(L"s");
    val.ChangeType(VT_UI4);
    m_pen.lopnStyle=val.ulVal;
    //width
    val=pAttr->getAttribute(L"w");
    val.ChangeType(VT_I4);
    m_pen.lopnWidth.x=val.lVal;
    //color
    val=pAttr->getAttribute(L"c");
    val.ChangeType(VT_UI4);
    m_pen.lopnColor=val.ulVal;

    //load dynamic attribution if have
    pDynamic=pGO->selectSingleNode(L"./dynamic");
    val=pDynamic->getAttribute(L"linked");
    val.ChangeType(VT_BOOL);
    if(val.boolVal){
        m_DnyAttr.Load(pDynamic);
        m_DnyAttr.m_Linked=true;
    }else{
        m_DnyAttr.m_Linked=false;
    }
}
Exemplo n.º 14
0
void CArc::Save(MSXML::IXMLDOMElementPtr pRoot)
{
	MSXML::IXMLDOMElementPtr pGO;
	MSXML::IXMLDOMElementPtr pStatic;
	MSXML::IXMLDOMElementPtr pDynamic;
	MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

	MSXML::IXMLDOMDocumentPtr pDoc=pRoot->ownerDocument;
    
    //add a graphy object
    pGO=pDoc->createElement(L"go");    
    val.vt=VT_BSTR;
    val.bstrVal=::SysAllocString(L"arc");
    pGO->setAttribute(L"type",val);
    pRoot->appendChild(pGO);

    //add a group static attribution
    pStatic=pDoc->createElement(L"static");
    pGO->appendChild(pStatic);
    
    //position
    pAttr=pDoc->createElement(L"position");
    pStatic->appendChild(pAttr);
    //x1
    val.vt=VT_I4;
    val.lVal=m_lx1;
    pAttr->setAttribute(L"x1",val);
    //y1
    val.vt=VT_I4;
    val.lVal=m_ly1;
    pAttr->setAttribute(L"y1",val);
    //x2
    val.vt=VT_I4;
    val.lVal=m_lx2;
    pAttr->setAttribute(L"x2",val);
    //y2
    val.vt=VT_I4;
    val.lVal=m_ly2;
    pAttr->setAttribute(L"y2",val);
    //x3
    val.vt=VT_I4;
    val.lVal=m_lx3;
    pAttr->setAttribute(L"x3",val);
    //y3
    val.vt=VT_I4;
    val.lVal=m_ly1;
    pAttr->setAttribute(L"y3",val);
    //x4
    val.vt=VT_I4;
    val.lVal=m_lx4;
    pAttr->setAttribute(L"x4",val);
    //y4
    val.vt=VT_I4;
    val.lVal=m_ly4;
    pAttr->setAttribute(L"y4",val);

    //pen
    pAttr=pDoc->createElement("pen");
    pStatic->appendChild(pAttr);
    //style
    val.vt=VT_UI4;
    val.ulVal=m_pen.lopnStyle;
    pAttr->setAttribute(L"s",val);
    //width
    val.vt=VT_I4;
    val.lVal=m_pen.lopnWidth.x;
    pAttr->setAttribute(L"w",val);
    //color
    val.vt=VT_UI4;
    val.ulVal=m_pen.lopnColor;
    pAttr->setAttribute(L"c",val);

    //if linked then save dynamic attribution
    pDynamic=pDoc->createElement("dynamic");
    pGO->appendChild(pDynamic);
    if(m_DnyAttr.m_Linked){
        //linked
        val.vt=VT_BOOL;
        val.boolVal=-1;
        pDynamic->setAttribute(L"linked",val);
        //save dynamic attribution
        m_DnyAttr.Save(pDoc,pDynamic);
    }else{
        //unlinked
        val.vt=VT_BOOL;
        val.boolVal=FALSE;
        pDynamic->setAttribute(L"linked",val);
    }
}
Exemplo n.º 15
0
/*
 * ----- main -----
 */
int main(int argc, char* argv[]) {
	
	if ( argc != 2 ) {
		cerr << "fsm <URL for FSM>" << endl;
		return 1;
	}
	
	if ( FAILED(CoInitialize(0)) ) {
		cerr << "Can't initialize COM" << endl;
		return 1;
	}
	
	try {
		
		/*
		 * XML Parser の生成と初期化
		 */
		MSXML::IXMLDOMDocumentPtr document("MSXML.DOMDocument");
		document->validateOnParse = VARIANT_TRUE; // 検証を行う
		document->async = VARIANT_FALSE;          // Parse完了までloadメソッドをブロック
		
		/*
		 * 引数に与えられたURLで示されたXMLをロードする
		 */
		document->load(argv[1]);
		
		/*
		 * Parseエラーがあれば出力
		 */
		MSXML::IXMLDOMParseErrorPtr error = document->parseError;
		if ( error->errorCode != 0 ) {
			if ( error->line ) {
				cerr << "line     : " << error->line << endl;
				cerr << "position : " << error->linepos << endl;
				cerr << "source   : " << (const char*)error->srcText << endl;
			}
			cerr << "URL        : " << (const char*)error->url       << endl;
			cerr << "code       : " << error->errorCode << endl;
			cerr << "reason     : " << (const char*)error->reason    << endl;
			return 1;
		}
		
		/*
		 * ルートエレメントを取得する
		 */
		MSXML::IXMLDOMElementPtr root = document->documentElement;
		
		/*
		 * 全イベントを取り出す
		 */
		set<string> event_set;
		MSXML::IXMLDOMNodeListPtr events = root->getElementsByTagName("Event");
		for ( int i = 0; i < events->length; ++i ) {
			MSXML::IXMLDOMElementPtr node = events->item[i];
			event_set.insert(get_attribute(node,"name"));
		}
		
		/*
		 * 初期状態 / 終了状態 を取得する
		 */
		string state_name     = get_attribute(root,"initial");
		string terminal_name  = get_attribute(root,"terminal");
		
		string fsm_name       = get_attribute(root,"name");
		cout << "FSM : " << fsm_name << endl;
		
		/*
		 * 状態遷移表を駆動する
		 */
		while ( state_name != terminal_name ) {
			
			/*
			 * state_name で示される State を見つける
			 */
			MSXML::IXMLDOMElementPtr state  = find_element(root,"name",state_name);
			if ( state == 0 ) {
				cerr << "can't find state : " << state_name << endl;
				break;
			}
			
			/*
			 * 現在の状態とイベント一覧を出力する
			 */
			cout << "state : " << state_name << endl;
			cout << "enter an event (";
			copy(event_set.begin(), event_set.end(), ostream_iterator<string>(cout,","));
			cout << "exit) ? " << flush;
			
			/*
			 * ユーザからのイベント入力
			 */
			string event_name;
			cin >> event_name;
			if ( event_name == "exit" )
				break;
			if ( event_set.find(event_name) == event_set.end() ) {
				cerr << event_name << " is not valid." << endl;
				continue;
			}
			
			/*
			 * event_name で示される Event を見つける
			 */
			MSXML::IXMLDOMElementPtr event = find_element(state,"name",event_name);
			if ( event == 0 ) {
				cerr << "can't find event : " << event_name << endl;
				break;
			}
			
			/*
			 * アクションを実行する
			 */
			string action_name = get_attribute(event,"action");
			if ( action_name != "none" )
				cout << "action : " << action_name << endl;
			
			/*
			 * 次の状態へ遷移する
			 */
			string transition_name = get_attribute(event,"transition");
			if ( transition_name != "none" )
				state_name = transition_name;
		}
		
	} catch ( _com_error& ex ) {
		cerr << "COM error occurred : " << ex.ErrorMessage() << endl;
	}
	
	CoUninitialize();
	return 0;
}
Exemplo n.º 16
0
void CText::Load(MSXML::IXMLDOMElementPtr pGO)
{
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
    MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    pStatic=pGO->selectSingleNode(L"./static");
    //position
    pAttr=pStatic->selectSingleNode(L"./position");
    //x1
    val=pAttr->getAttribute(L"x1");
    val.ChangeType(VT_I4);
    m_lx1=val.lVal;
    m_lox1=m_lx1;
    //y1
    val=pAttr->getAttribute(L"y1");
    val.ChangeType(VT_I4);
    m_ly1=val.lVal;
    m_loy1=m_ly1;
    //x2
    val=pAttr->getAttribute(L"x2");
    val.ChangeType(VT_I4);
    m_lx2=val.lVal;
    m_lox2=m_lx2;
    //y2
    val=pAttr->getAttribute(L"y2");
    val.ChangeType(VT_I4);
    m_ly2=val.lVal;
    m_loy2=m_ly2;

    //face color
    pAttr=pStatic->selectSingleNode(L"./color");
    //color
    val=pAttr->getAttribute(L"c");
    val.ChangeType(VT_UI4);
    m_FaceColor=val.ulVal;
    m_oFaceColor=m_FaceColor;

    //font
    pAttr=pStatic->selectSingleNode(L"./font");
    //lfHeight
    val=pAttr->getAttribute(L"h");
    val.ChangeType(VT_I4);
    m_font.lfHeight=val.ulVal;
    //lfWidth
    val=pAttr->getAttribute(L"wd");
    val.ChangeType(VT_I4);
    m_font.lfWidth=val.ulVal;
    //lfEscapement
    val=pAttr->getAttribute(L"e");
    val.ChangeType(VT_I4);
    m_font.lfEscapement=val.ulVal;
    //lfOrientation
    val=pAttr->getAttribute(L"o");
    val.ChangeType(VT_I4);
    m_font.lfOrientation=val.ulVal;
    //lfWeight
    val=pAttr->getAttribute(L"wg");
    val.ChangeType(VT_I4);
    m_font.lfWeight=val.ulVal;
    //lfItalic
    val=pAttr->getAttribute(L"i");
    val.ChangeType(VT_UI1);
    m_font.lfItalic=val.ulVal;
    //lfUnderline
    val=pAttr->getAttribute(L"u");
    val.ChangeType(VT_UI1);
    m_font.lfUnderline=val.ulVal;
    //lfStrikeOut
    val=pAttr->getAttribute(L"so");
    val.ChangeType(VT_UI1);
    m_font.lfStrikeOut=val.ulVal;
    //lfCharSet
    val=pAttr->getAttribute(L"cs");
    val.ChangeType(VT_UI1);
    m_font.lfCharSet=val.ulVal;
    //lfOutPrecision
    val=pAttr->getAttribute(L"op");
    val.ChangeType(VT_UI1);
    m_font.lfOutPrecision=val.ulVal;
    //lfClipPrecision
    val=pAttr->getAttribute(L"cp");
    val.ChangeType(VT_UI1);
    m_font.lfClipPrecision=val.ulVal;
    //lfQuality
    val=pAttr->getAttribute(L"q");
    val.ChangeType(VT_UI1);
    m_font.lfQuality=val.ulVal;
    //lfPitchAndFamily
    val=pAttr->getAttribute(L"paf");
    val.ChangeType(VT_UI1);
    m_font.lfPitchAndFamily=val.ulVal;
    //lfFaceName
    val=pAttr->getAttribute(L"fn");
    CString strFaceName=val.bstrVal;
    sprintf(m_font.lfFaceName,"%s",(LPCTSTR)strFaceName);

    //text
    pAttr=pStatic->selectSingleNode(L"./text");
    val=pAttr->getAttribute(L"t");
    m_text=val.bstrVal;

    //load dynamic attribution if have
    pDynamic=pGO->selectSingleNode(L"./dynamic");
    val=pDynamic->getAttribute(L"linked");
    val.ChangeType(VT_BOOL);
    if(val.boolVal) {
        m_DnyAttr.Load(pDynamic);
        m_DnyAttr.m_Linked=true;
    } else {
        m_DnyAttr.m_Linked=false;
    }
}
Exemplo n.º 17
0
void CText::Save(MSXML::IXMLDOMElementPtr pRoot)
{
    MSXML::IXMLDOMElementPtr pGO;
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
    MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    MSXML::IXMLDOMDocumentPtr pDoc=pRoot->ownerDocument;

    //add a graphy object
    pGO=pDoc->createElement(L"go");
    val.vt=VT_BSTR;
    val.bstrVal=::SysAllocString(L"text");
    pGO->setAttribute(L"type",val);
    pRoot->appendChild(pGO);

    //add a group static attribution
    pStatic=pDoc->createElement(L"static");
    pGO->appendChild(pStatic);

    //position
    pAttr=pDoc->createElement(L"position");
    pStatic->appendChild(pAttr);
    //x1
    val.vt=VT_I4;
    val.lVal=m_lx1;
    pAttr->setAttribute(L"x1",val);
    //y1
    val.vt=VT_I4;
    val.lVal=m_ly1;
    pAttr->setAttribute(L"y1",val);
    //x2
    val.vt=VT_I4;
    val.lVal=m_lx2;
    pAttr->setAttribute(L"x2",val);
    //y2
    val.vt=VT_I4;
    val.lVal=m_ly2;
    pAttr->setAttribute(L"y2",val);

    //face color
    pAttr=pDoc->createElement("color");
    pStatic->appendChild(pAttr);
    //color
    val.vt=VT_UI4;
    val.ulVal=m_FaceColor;
    pAttr->setAttribute(L"c",val);

    //font
    pAttr=pDoc->createElement("font");
    pStatic->appendChild(pAttr);
    //lfHeight
    val.vt=VT_I4;
    val.lVal=m_font.lfHeight;
    pAttr->setAttribute(L"h",val);
    //lfWidth
    val.vt=VT_I4;
    val.lVal=m_font.lfWidth;
    pAttr->setAttribute(L"wd",val);
    //lfEscapement
    val.vt=VT_I4;
    val.lVal=m_font.lfEscapement;
    pAttr->setAttribute(L"e",val);
    //lfOrientation
    val.vt=VT_I4;
    val.lVal=m_font.lfOrientation;
    pAttr->setAttribute(L"o",val);
    //lfWeight
    val.vt=VT_I4;
    val.lVal=m_font.lfWeight;
    pAttr->setAttribute(L"wg",val);
    //lfItalic
    val.vt=VT_UI1;
    val.bVal=m_font.lfItalic;
    pAttr->setAttribute(L"i",val);
    //lfUnderline
    val.vt=VT_UI1;
    val.bVal=m_font.lfUnderline;
    pAttr->setAttribute(L"u",val);
    //lfStrikeOut
    val.vt=VT_UI1;
    val.bVal=m_font.lfStrikeOut;
    pAttr->setAttribute(L"so",val);
    //lfCharSet
    val.vt=VT_UI1;
    val.bVal=m_font.lfCharSet;
    pAttr->setAttribute(L"cs",val);
    //lfOutPrecision
    val.vt=VT_UI1;
    val.bVal=m_font.lfOutPrecision;
    pAttr->setAttribute(L"op",val);
    //lfClipPrecision
    val.vt=VT_UI1;
    val.bVal=m_font.lfClipPrecision;
    pAttr->setAttribute(L"cp",val);
    //lfQuality
    val.vt=VT_UI1;
    val.bVal=m_font.lfQuality;
    pAttr->setAttribute(L"q",val);
    //lfPitchAndFamily
    val.vt=VT_UI1;
    val.bVal=m_font.lfPitchAndFamily;
    pAttr->setAttribute(L"paf",val);
    //lfFaceName
    CString strFaceName=m_font.lfFaceName;
    //strFaceName.Format("%s",m_font.lfFaceName);
    val.vt=VT_BSTR;
    val.bstrVal=strFaceName.AllocSysString();
    pAttr->setAttribute(L"fn",val);

    //text
    pAttr=pDoc->createElement("text");
    pStatic->appendChild(pAttr);
    val.vt=VT_BSTR;
    val.bstrVal=m_text.AllocSysString();
    pAttr->setAttribute(L"t",val);

    //if linked then save dynamic attribution
    pDynamic=pDoc->createElement("dynamic");
    pGO->appendChild(pDynamic);
    if(m_DnyAttr.m_Linked) {
        //linked
        val.vt=VT_BOOL;
        val.boolVal=-1;
        pDynamic->setAttribute(L"linked",val);
        //save dynamic attribution
        m_DnyAttr.Save(pDoc,pDynamic);
    } else {
        //unlinked
        val.vt=VT_BOOL;
        val.boolVal=FALSE;
        pDynamic->setAttribute(L"linked",val);
    }
}
Exemplo n.º 18
0
/*
 * elementからattribute_nameなるアトリビュート値を取り出す
 */
inline string get_attribute(MSXML::IXMLDOMElementPtr element, const char* attribute_name) {
	return (const char*)_bstr_t(element->getAttribute(attribute_name));
}
HRESULT touchmind::converter::NodeModelXMLEncoder::Encode(IN std::shared_ptr<touchmind::model::node::NodeModel> node,
                                                          IN MSXML::IXMLDOMDocumentPtr pXMLDoc,
                                                          OUT MSXML::IXMLDOMElementPtr &xmlNodeElement) {
  HRESULT hr = S_OK;
  try {
    // id
    std::wstring ws_idValue;
    touchmind::NodeIdToString(node->GetId(), ws_idValue);
    _variant_t v_idValue(ws_idValue.c_str());
    xmlNodeElement->setAttribute(s_id, v_idValue);

    // position
    if (node->GetPosition() == NODE_SIDE_LEFT) {
      xmlNodeElement->setAttribute(s_position, v_positionLeftValue);
    } else if (node->GetPosition() == NODE_SIDE_RIGHT) {
      xmlNodeElement->setAttribute(s_position, v_positionRightValue);
    }

    // created time
    std::wstring ws_createdTime;
    touchmind::SystemtimeToString(&node->GetCreatedTime(), ws_createdTime);
    _variant_t v_createdTimeValue(ws_createdTime.c_str());
    xmlNodeElement->setAttribute(s_createdTime, v_createdTimeValue);

    // modified time
    std::wstring ws_modifiedTime;
    touchmind::SystemtimeToString(&node->GetModifiedTime(), ws_modifiedTime);
    _variant_t v_modifiedTimeValue(ws_modifiedTime.c_str());
    xmlNodeElement->setAttribute(s_modifiedTime, v_modifiedTimeValue);

    // width
    std::wstring ws_width;
    touchmind::SizeToString(node->GetWidth(), ws_width);
    _variant_t v_width(ws_width.c_str());
    xmlNodeElement->setAttribute(s_width, v_width);

    // height
    std::wstring ws_height;
    touchmind::SizeToString(node->GetHeight(), ws_height);
    _variant_t v_height(ws_height.c_str());
    xmlNodeElement->setAttribute(s_height, v_height);

    // background color
    if (!touchmind::util::ColorUtil::Equal(node->GetBackgroundColor(), D2D1::ColorF(D2D1::ColorF::White))) {
      std::wstring ws_backgroundColorValue;
      // touchmind::ColorrefToString(touchmind::util::ColorUtil::ToColorref(node->GetBackgroundColor()),
      // ws_backgroundColorValue);
      touchmind::ColorFToString(node->GetBackgroundColor(), ws_backgroundColorValue);
      _variant_t v_backgroundColorValue(ws_backgroundColorValue.c_str());
      xmlNodeElement->setAttribute(s_backgroundColor, v_backgroundColorValue);
    }

    // shape
    if (node->GetNodeShape() != prop::NodeShape::GetDefaultNodeShape()) {
      std::wstring ws_nodeShape = prop::NodeShape::ToString(node->GetNodeShape());
      _variant_t v_nodeShape(ws_nodeShape.c_str());
      xmlNodeElement->setAttribute(s_shape, v_nodeShape);
    }

    xmlNodeElement->setAttribute(s_height, v_height);
    // text element
    MSXML::IXMLDOMElementPtr xmlTextElement = pXMLDoc->createElement(s_text);
    xmlNodeElement->appendChild(xmlTextElement);

    // text
    _bstr_t s_textValue(node->GetText().c_str());
    MSXML::IXMLDOMTextPtr pText = pXMLDoc->createTextNode(s_textValue);
    xmlTextElement->appendChild(pText);

    if (node->GetFontAttributeCount() > 0) {
      // fontAttriutes element
      MSXML::IXMLDOMElementPtr xmlFontAttributesElement = pXMLDoc->createElement(s_fontAttributes);
      xmlTextElement->appendChild(xmlFontAttributesElement);

      for (size_t i = 0; i < node->GetFontAttributeCount(); ++i) {
        // fontAttribute
        MSXML::IXMLDOMElementPtr xmlFontAttributeElement = pXMLDoc->createElement(s_fontAttribute);
        xmlFontAttributesElement->appendChild(xmlFontAttributeElement);

        // start position
        wchar_t buf[1024];
        _ltow_s(node->GetFontAttribute(i).startPosition, buf, 1024, 10);
        _variant_t v_startPositionValue(buf);
        xmlFontAttributeElement->setAttribute(s_startPosition, v_startPositionValue);

        // length
        _ltow_s(node->GetFontAttribute(i).length, buf, 1024, 10);
        _variant_t v_lengthValue(buf);
        xmlFontAttributeElement->setAttribute(s_length, v_lengthValue);

        // font family
        if (node->GetFontAttribute(i).fontFamilyName.length() > 0) {
          _variant_t v_fontFamilyValue(node->GetFontAttribute(i).fontFamilyName.c_str());
          xmlFontAttributeElement->setAttribute(s_fontFamily, v_fontFamilyValue);
        }

        // font size
        if (node->GetFontAttribute(i).fontSize > 0.0f) {
          std::wstring ws_fontSizeValue;
          touchmind::FontSizeToString(node->GetFontAttribute(i).fontSize, ws_fontSizeValue);
          _variant_t v_fontSizeValue(ws_fontSizeValue.c_str());
          xmlFontAttributeElement->setAttribute(s_fontSize, v_fontSizeValue);
        }

        // bold
        if (node->GetFontAttribute(i).bold) {
          xmlFontAttributeElement->setAttribute(s_bold, v_boolTrueValue);
        }

        // italic
        if (node->GetFontAttribute(i).italic) {
          xmlFontAttributeElement->setAttribute(s_italic, v_boolTrueValue);
        }

        // underline
        if (node->GetFontAttribute(i).underline) {
          xmlFontAttributeElement->setAttribute(s_underline, v_boolTrueValue);
        }

        // strikethrough
        if (node->GetFontAttribute(i).strikethrough) {
          xmlFontAttributeElement->setAttribute(s_strikethrough, v_boolTrueValue);
        }

        // foreground color
        if (node->GetFontAttribute(i).foregroundColor
            != static_cast<LONG>(touchmind::text::FontAttributeCommand::DEFAULT_FONT_COLOR)) {
          std::wstring ws_foregroundColorValue;
          touchmind::ColorrefToString(node->GetFontAttribute(i).foregroundColor, ws_foregroundColorValue);
          _variant_t v_foregroundColorValue(ws_foregroundColorValue.c_str());
          xmlFontAttributeElement->setAttribute(s_foregroundColor, v_foregroundColorValue);
        }
      }
    }

    {
      bool hasOutput = false;
      // ***** path *****
      auto path = node->GetPathModel();
      // path
      MSXML::IXMLDOMElementPtr xmlPathElement = pXMLDoc->createElement(s_path);

      // path width
      if (path->GetWidth() != LINE_WIDTH_1) {
        std::wstring ws_pathWidth = prop::LineWidth::ToString(path->GetWidth());
        _variant_t v_pathWidth(ws_pathWidth.c_str());
        xmlPathElement->setAttribute(s_width, v_pathWidth);
        hasOutput = true;
      }

      // path color
      if (!touchmind::util::ColorUtil::Equal(path->GetColor(), D2D1::ColorF(D2D1::ColorF::Black))) {
        std::wstring ws_colorValue;
        touchmind::ColorFToString(path->GetColor(), ws_colorValue);
        _variant_t v_colorValue(ws_colorValue.c_str());
        xmlPathElement->setAttribute(s_color, v_colorValue);
        hasOutput = true;
      }

      // path style
      if (path->GetStyle() != LINE_STYLE_SOLID) {
        std::wstring ws_pathStyle = prop::LineStyle::ToString(path->GetStyle());
        _variant_t v_pathStyle(ws_pathStyle.c_str());
        xmlPathElement->setAttribute(s_style, v_pathStyle);
        hasOutput = true;
      }

      if (hasOutput) {
        xmlNodeElement->appendChild(xmlPathElement);
      }
    }

    for (size_t i = 0; i < node->GetNumberOfLinks(); ++i) {
      auto wlink = node->GetLink(i);
      if (!wlink.expired()) {
        auto link = wlink.lock();
        if (link->GetNode(EDGE_ID_1) == node) {
          MSXML::IXMLDOMElementPtr xmlLinkElement = pXMLDoc->createElement(s_link);
          xmlNodeElement->appendChild(xmlLinkElement);

          // destination
          std::wstring ws_idValue;
          touchmind::NodeIdToString(link->GetNode(EDGE_ID_2)->GetId(), ws_idValue);
          _variant_t v_idValue(ws_idValue.c_str());
          xmlLinkElement->setAttribute(s_destination, v_idValue);

          // link width
          std::wstring ws_linkWidth = prop::LineWidth::ToString(link->GetLineWidth());
          _variant_t v_linkWidth(ws_linkWidth.c_str());
          xmlLinkElement->setAttribute(s_width, v_linkWidth);

          // link color
          if (!touchmind::util::ColorUtil::Equal(link->GetLineColor(), D2D1::ColorF(D2D1::ColorF::Black))) {
            std::wstring ws_colorValue;
            touchmind::ColorFToString(link->GetLineColor(), ws_colorValue);
            _variant_t v_colorValue(ws_colorValue.c_str());
            xmlLinkElement->setAttribute(s_color, v_colorValue);
          }

          // link style
          std::wstring ws_lineStyle = prop::LineStyle::ToString(link->GetLineStyle());
          _variant_t v_lineStyle(ws_lineStyle.c_str());
          xmlLinkElement->setAttribute(s_style, v_lineStyle);

          // link edge style 1
          std::wstring ws_edgeStyle1 = prop::LineEdgeStyle::ToString(link->GetEdge(EDGE_ID_1)->GetStyle());
          _variant_t v_edgeStyle1(ws_edgeStyle1.c_str());
          xmlLinkElement->setAttribute(s_startStyle, v_edgeStyle1);

          // link edge style 2
          std::wstring ws_edgeStyle2 = prop::LineEdgeStyle::ToString(link->GetEdge(EDGE_ID_2)->GetStyle());
          _variant_t v_edgeStyle2(ws_edgeStyle2.c_str());
          xmlLinkElement->setAttribute(s_endStyle, v_edgeStyle2);

          // handle 1
          std::wstring ws_handle1;
          HandleToString(link->GetEdge(EDGE_ID_1)->GetAngle(), link->GetEdge(EDGE_ID_1)->GetLength(), ws_handle1);
          _variant_t v_handle1(ws_handle1.c_str());
          xmlLinkElement->setAttribute(s_startHandle, v_handle1);

          // handle 2
          std::wstring ws_handle2;
          HandleToString(link->GetEdge(EDGE_ID_2)->GetAngle(), link->GetEdge(EDGE_ID_2)->GetLength(), ws_handle2);
          _variant_t v_handle2(ws_handle2.c_str());
          xmlLinkElement->setAttribute(s_endHandle, v_handle2);
        }
      }
    }

    for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) {
      std::shared_ptr<touchmind::model::node::NodeModel> child = node->GetChild(i);
      MSXML::IXMLDOMElementPtr xmlChildNodeElement = pXMLDoc->createElement(s_node);
      xmlNodeElement->appendChild(xmlChildNodeElement);
      Encode(child, pXMLDoc, xmlChildNodeElement);
    }

  } catch (_com_error &errorObject) {
    LOG(SEVERITY_LEVEL_ERROR) << "Exception thrown, HRESULT: " << errorObject.Error();
    return errorObject.Error();
  }

  return hr;
}
Exemplo n.º 20
0
void CMeta::Load(MSXML::IXMLDOMElementPtr pGO)
{
    MSXML::IXMLDOMElementPtr pStatic;
    MSXML::IXMLDOMElementPtr pDynamic;
	MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

    pStatic=pGO->selectSingleNode(L"./static");
    //position
    pAttr=pStatic->selectSingleNode(L"./position");
    //x1
    val=pAttr->getAttribute(L"x1");
    val.ChangeType(VT_I4);
    m_lx1=val.lVal;
	m_lox1=m_lx1;
    //y1
    val=pAttr->getAttribute(L"y1");
    val.ChangeType(VT_I4);
    m_ly1=val.lVal;
	m_loy1=m_ly1;
    //x2
    val=pAttr->getAttribute(L"x2");
    val.ChangeType(VT_I4);
    m_lx2=val.lVal;
	m_lox2=m_lx2;
    //y2
    val=pAttr->getAttribute(L"y2");
    val.ChangeType(VT_I4);
    m_ly2=val.lVal;
	m_loy2=m_ly2;
    //file
    pAttr=pStatic->selectSingleNode(L"./file");
    //path
    val=pAttr->getAttribute(L"path");
    m_sPicFile=val.bstrVal;

    //load dynamic attribution if have
    pDynamic=pGO->selectSingleNode(L"./dynamic");
    val=pDynamic->getAttribute(L"linked");
    val.ChangeType(VT_BOOL);
    if(val.boolVal){
        m_DnyAttr.Load(pDynamic);
        m_DnyAttr.m_Linked=true;
    }else{
        m_DnyAttr.m_Linked=false;
    }
}
Exemplo n.º 21
0
void CMeta::Save(MSXML::IXMLDOMElementPtr pRoot)
{
	MSXML::IXMLDOMElementPtr pGO;
	MSXML::IXMLDOMElementPtr pStatic;
	MSXML::IXMLDOMElementPtr pDynamic;
	MSXML::IXMLDOMElementPtr pAttr;
    _variant_t val;

	MSXML::IXMLDOMDocumentPtr pDoc=pRoot->ownerDocument;
    
    //add a graphy object
    pGO=pDoc->createElement(L"go");    
    val.vt=VT_BSTR;
    val.bstrVal=::SysAllocString(L"meta");
    pGO->setAttribute(L"type",val);
    pRoot->appendChild(pGO);

    //add a group static attribution
    pStatic=pDoc->createElement(L"static");
    pGO->appendChild(pStatic);
    
    //position
    pAttr=pDoc->createElement(L"position");
    pStatic->appendChild(pAttr);
    //x1
    val.vt=VT_I4;
    val.lVal=m_lx1;
    pAttr->setAttribute(L"x1",val);
    //y1
    val.vt=VT_I4;
    val.lVal=m_ly1;
    pAttr->setAttribute(L"y1",val);
    //x2
    val.vt=VT_I4;
    val.lVal=m_lx2;
    pAttr->setAttribute(L"x2",val);
    //y2
    val.vt=VT_I4;
    val.lVal=m_ly2;
    pAttr->setAttribute(L"y2",val);

    //picture file
    pAttr=pDoc->createElement("file");
    pStatic->appendChild(pAttr);
    val.vt=VT_BSTR;
    val.bstrVal=m_sPicFile.AllocSysString();
    pAttr->setAttribute(L"path",val);

    //if linked then save dynamic attribution
    pDynamic=pDoc->createElement("dynamic");
    pGO->appendChild(pDynamic);
    if(m_DnyAttr.m_Linked){
        //linked
        val.vt=VT_BOOL;
        val.boolVal=-1;
        pDynamic->setAttribute(L"linked",val);
        //save dynamic attribution
        m_DnyAttr.Save(pDoc,pDynamic);
    }else{
        //unlinked
        val.vt=VT_BOOL;
        val.boolVal=FALSE;
        pDynamic->setAttribute(L"linked",val);
    }
}