void CHomeLibraryBox::OnSkinChange()
{
	if ( m_pDocument ) delete m_pDocument;
	m_pDocument = NULL;
	m_pdLibraryFiles = m_pdLibraryVolume = m_pdLibraryHashRemaining = NULL;

	SetCaptionmark( _T("CHomeLibraryBox.Caption") );

	CXMLElement* pXML = Skin.GetDocument( _T("CHomeLibraryBox") );
	if ( pXML == NULL ) return;

	SetCaption( pXML->GetAttributeValue( _T("title"), _T("Library") ) );
	HICON hIcon = CoolInterface.ExtractIcon( IDR_LIBRARYFRAME, Settings.General.LanguageRTL );
	if ( hIcon ) SetIcon( hIcon );

	m_pDocument = new CRichDocument();

	CMap< CString, const CString&, CRichElement*, CRichElement* > pMap;
	if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return;

	pMap.Lookup( _T("LibraryFiles"), m_pdLibraryFiles );
	pMap.Lookup( _T("LibraryVolume"), m_pdLibraryVolume );
	pMap.Lookup( _T("LibraryHashRemaining"), m_pdLibraryHashRemaining );

	SetDocument( m_pDocument );

	Update();

	// Update Dropshadow	(Note: Caused app freeze when allowing hovered item during skin change)
	m_wndTip.DestroyWindow();
	m_wndTip.Create( this, &Settings.Interface.TipLibrary );
}
BOOL CSchemaMember::LoadType(CXMLElement* pType)
{
	CString strName = pType->GetName();

	if ( strName.CompareNoCase( _T("simpleType") ) &&
		 strName.CompareNoCase( _T("complexType") ) ) return FALSE;

	m_sType = pType->GetAttributeValue( _T("base"), _T("") );
	CharLower( m_sType.GetBuffer() );
	m_sType.ReleaseBuffer();
	m_bNumeric = ( m_sType == _T("short") || m_sType == _T("int") || m_sType == _T("decimal") );
	
	for ( POSITION pos = pType->GetElementIterator() ; pos ; )
	{
		CXMLElement* pElement	= pType->GetNextElement( pos );
		CString strElement		= pElement->GetName();

		if ( strElement.CompareNoCase( _T("enumeration") ) == 0 )
		{
			CString strValue = pElement->GetAttributeValue( _T("value"), _T("") );
			if ( strValue.GetLength() ) m_pItems.AddTail( strValue );
		}
		else if ( strElement.CompareNoCase( _T("maxInclusive") ) == 0 )
		{
			CString strValue = pElement->GetAttributeValue( _T("value"), _T("0") );
			_stscanf( strValue, _T("%i"), &m_nMaxLength );
		}
	}

	return TRUE;
}
BOOL CBitziDownloader::MergeMetaData(CXMLElement* pOutput, CXMLElement* pInput)
{
	if ( ! pOutput || ! pInput ) return FALSE;

	pOutput	= pOutput->GetFirstElement();

	if ( ! pOutput || pOutput->GetName() != pInput->GetName() ) return FALSE;

	for ( POSITION pos = pInput->GetElementIterator() ; pos ; )
	{
		CXMLElement* pElement	= pInput->GetNextElement( pos );
		CXMLElement* pTarget	= pOutput->GetElementByName( pElement->GetName() );

		if ( pTarget == NULL ) pOutput->AddElement( pElement->Clone() );
	}

	for ( POSITION pos = pInput->GetAttributeIterator() ; pos ; )
	{
		CXMLAttribute* pAttribute	= pInput->GetNextAttribute( pos );
		CXMLAttribute* pTarget		= pOutput->GetAttribute( pAttribute->GetName() );

		if ( pTarget == NULL ) pOutput->AddAttribute( pAttribute->Clone() );
	}

	return TRUE;
}
CXMLElement* CProfiles::FindProcess(LPCTSTR xJobId, POSITION& posNext, CXMLElement** ppActionXML)
{
    CSingleLock pLock( &m_pSection, TRUE );
    if ( ! m_pXMLMonitor ) return NULL;

    CXMLElement* pAction = NULL;
    if ( ! ppActionXML ) ppActionXML = &pAction;

    *ppActionXML = m_pXMLMonitor->GetElementByName( _T("ShortMessage") );

    if ( CXMLElement* pXML = m_pXMLMonitor->GetElementByName( _T("Process") ) )
    {
        if ( ! posNext ) posNext = pXML->GetElementIterator();
        if ( ! posNext ) return NULL;

        CXMLElement* pMap = pXML->GetNextElement( posNext );
        if ( ! pMap->IsNamed( _T("Map") ) ) return posNext ? FindProcess( xJobId, posNext ) : NULL;

        if ( ! xJobId || ! _tcscmp(xJobId, _T("ÈÎÒâ")) ) return pMap;

        CXMLAttribute* pAttri = pMap->GetAttribute( "Host" );
        if ( pAttri && pAttri->GetValue() == xJobId ) return pMap;

        return posNext ? FindProcess( xJobId, posNext, ppActionXML ) : NULL;
    }

    return NULL;
}
CXMLElement* Engine::FileSystem::Config::CXMLDocument::NewElement( const char* name )
{
	CXMLElement* ele = new (elementPool.Alloc()) CXMLElement( this );
	ele->XMLMemPool = &elementPool;
	ele->SetName( name );
	return ele;
}
BOOL CPlayProfilePage::LoadXML()
{
	CString strValue;
	CXMLAttribute* pAttri = NULL;
	
	for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pMap = m_pXML->GetNextElement( pos );
		if ( ! pMap->IsNamed( _T("Map") ) ) continue;
		
		if ( pAttri = pMap->GetAttribute( _T("ID") ) )
		{
			strValue = pAttri->GetValue();
			int nItem = m_wndList.InsertItem(
				LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM,
				m_wndList.GetItemCount(), strValue, 0, 0,
				CoolInterface.ImageForID(ID_REPORT_MUSIC), (LPARAM)pMap );
			
			if ( pAttri = pMap->GetAttribute( _T("Play") ) )
			{
				m_wndList.SetItemText( nItem, 1, pAttri->GetValue() );
			}
		}
	}

	return TRUE;
}
Exemple #7
0
BOOL CGroupingDlg::ProcessMethod(CXMLElement*& pXML)
{
	for ( POSITION pos = pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pSync = pXML->GetNextElement( pos );
		
		CString strValue = pSync->GetAttributeValue( _T("method") );
		
		if ( ! strValue.CompareNoCase( METHOD_INSERT ) )
		{
			ProcessInsert( pSync->GetFirstElement() );
		}
		else if ( ! strValue.CompareNoCase( METHOD_DELETE ) )
		{
			ProcessDelete( pSync->GetFirstElement() );
		}
		else if ( ! strValue.CompareNoCase( METHOD_UPDATE ) )
		{
			ProcessUpdate( pSync->GetFirstElement() );
		}
	}
	
	pXML->Delete();
	pXML	= NULL;
	
	return TRUE;
}
Exemple #8
0
BOOL CSkin::LoadFromXML(CXMLElement* pXML, const CString& strPath)
{
	if ( ! pXML->IsNamed( _T("skin") ) ) return FALSE;
	
	BOOL bSuccess = FALSE;
	
	for ( POSITION pos = pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pSub = pXML->GetNextElement( pos );
		bSuccess = FALSE;
		
		if ( pSub->IsNamed( _T("commandImages") ) )
		{
			if ( ! LoadCommandImages( pSub, strPath ) ) break;
		}
		else if ( pSub->IsNamed( _T("commandMap") ) )
		{
			if ( ! LoadCommandMap( pSub ) ) break;
		}
		else if ( pSub->IsNamed( _T("menus") ) )
		{
			if ( ! LoadMenus( pSub ) ) break;
		}
		else if ( pSub->IsNamed( _T("toolbars") ) )
		{
			if ( ! LoadToolbars( pSub ) ) break;
		}

		bSuccess = TRUE;
	}
	
	return bSuccess;
}
CXMLElement* CHisReport::FindToday() const
{
    CString strValue;

    WORD nYear, nMonth, nDay;
    CTime tt = CTime::GetCurrentTime();
    nYear = tt.GetYear();
    nMonth = tt.GetMonth();
    nDay = tt.GetDay();

    for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; )
    {
        CXMLElement* pXML = m_pXML->GetNextElement( pos );
        if ( ! pXML->IsNamed( _T("History") ) ) continue;

        WORD nYear2, nMonth2, nDay2;
        nYear2 = nMonth2 = nDay2 = 0;

        strValue = pXML->GetAttributeValue( _T("Date") );
        _stscanf( strValue, _T("%d年%d月%d日"), &nYear2, &nMonth2, &nDay2 );

        if ( nYear != nYear2 || nMonth != nMonth2 || nDay != nDay2 ) continue;

        return pXML;
    }

    return NULL;
}
Exemple #10
0
void CUserMeetingDlg::OnCancel()
{
	if (AfxMessageBox(IDS_QUITPROMPT, MB_OKCANCEL | MB_ICONQUESTION | MB_DEFBUTTON2) != IDOK) return;
	
	CXMLElement* pXML = new CXMLElement( NULL, ISyncDataView );
	pXML->AddAttribute( "method", "update" );
	
	CXMLElement* pSync = pXML->AddElement( "table_name" );
	pSync->SetValue( "xmeetingroomlist" );
	
	pSync = pXML->AddElement( "column_name" );
	pSync->SetValue( "set xmeetingused = '0'" );
	
	CString str;
	str.Format( "xmeetingroomfee = '%s'", Network.m_xUserId );
	
	pSync = pXML->AddElement( "search_condition" );
	pSync->SetValue( (LPCTSTR)str );
	
	Network.SendPacket( new CSyncDataView( pXML ) );
	delete pXML;
#if 1
	pXML = new CXMLElement( NULL, ISyncHostFile );
	pXML->AddAttribute( "method", "bye" );
	
	Network.SendPacket( new CSyncHostFile(pXML) );
	delete pXML;
#endif
	
	CDialog::OnCancel();
}
void CAnalogProfilePage::OnItemChangedList(NMHDR* pNMHDR, LRESULT* pResult)
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	*pResult = 0;
	
	if ( pNMListView->iItem >= 0 )
	{
		if ( ( pNMListView->uOldState & LVIS_SELECTED ) != ( pNMListView->uNewState & LVIS_SELECTED ) )
		{
			if ( pNMListView->uNewState & LVIS_SELECTED )
			{
				CXMLElement* pMap = (CXMLElement*)m_wndList.GetItemData( pNMListView->iItem );
				if ( pMap != NULL )
				{
					CString strValue;

					strValue = pMap->GetAttributeValue( _T("ID") );
					m_wndHost.SetWindowText( (LPCTSTR)strValue );
					strValue = pMap->GetAttributeValue( _T("LinkId") );
					m_wndLinkId.SetWindowText( (LPCTSTR)strValue );
					strValue = pMap->GetAttributeValue( _T("LocalId") );
					m_wndLocalId.SetWindowText( (LPCTSTR)strValue );
					
					m_wndDelete.EnableWindow( TRUE );
				}
			}
		}
	}
}
ALERROR CLevelTableOfItemGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load table from XML

	{
	int i;
	ALERROR error;

	for (i = 0; i < pDesc->GetContentElementCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);
		SEntry *pNewEntry = m_Table.Insert();

		pNewEntry->sLevelFrequency = pEntry->GetAttribute(LEVEL_FREQUENCY_ATTRIB);

		pNewEntry->Count.LoadFromXML(pEntry->GetAttribute(COUNT_ATTRIB));
		if (pNewEntry->Count.IsEmpty())
			pNewEntry->Count.SetConstant(1);

		if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &pNewEntry->pEntry))
			return error;
		}

	m_iComputedLevel = -1;

	return NOERROR;
	}
Exemple #13
0
int CPlayerWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if ( CChildWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;
	
	// Load Definitions
	
	Skin.LoadFromResource( AfxGetResourceHandle(), IDR_XML_DEFINITIONS );
	Skin.LoadFromResource( AfxGetResourceHandle(), IDR_XML_DEFAULT );
	
	// Panel
	
	//m_wndPanel.Create( WS_VISIBLE, rectDefault, this );
	
	// Header
	
	if ( ! m_wndHeaderBar.Create( this, WS_CHILD|WS_VISIBLE|CBRS_NOALIGN, AFX_IDW_TOOLBAR ) ) return -1;
	m_wndHeaderBar.SetBarStyle( m_wndHeaderBar.GetBarStyle() | CBRS_TOOLTIPS|CBRS_BORDER_BOTTOM );
	Skin.CreateToolBar( _T("CPlayerWnd.Header"), &m_wndHeaderBar );
	
	m_wndHistory.Create( WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWN|CBS_AUTOHSCROLL,
		rectDefault, &m_wndHeaderBar, ID_PLAYER_HISTORY );
	
	m_wndHistory.SetFont( &CoolInterface.m_fntNormal );
	CXMLElement* pXML = LoadXML( _T("XlivePlayer"), TRUE );
	if ( pXML ) LoadXML( pXML );
	pXML->Delete();
	
	// Bottom
	
	if ( ! m_wndBottom.Create( this, WS_CHILD|WS_VISIBLE|CBRS_NOALIGN, AFX_IDW_TOOLBAR ) ) return -1;
	m_wndBottom.SetBarStyle( m_wndBottom.GetBarStyle() | CBRS_TOOLTIPS|CBRS_BORDER_TOP );
	Skin.CreateToolBar( _T("CPlayerWnd.Bottom"), &m_wndBottom );
	
	return 0;
}
Exemple #14
0
IVertexDecl * ParseVertexFormat( CXMLElement * pBranch )
{
	IVertexDecl * pDecl = g_pRenderer->CreateVertexDecl();

	if ( !pDecl )
		return NULL;

	uint nOffset = 0;

	// Перебираем все дочерние элементы ----------------------------------------

	for ( size_t n = 0; n < pBranch->GetNumChilds(); ++n )
	{
		CXMLElement * pInputElem = pBranch->GetChild( n );
		CXMLAttr * pType = pInputElem->GetAttr( "Type" );
		CXMLAttr * pSem = pInputElem->GetAttr( "D3D_Semantic" );

		ETypeID eType = g_pSystem->GetType( pType->GetValue() );

		pDecl->AddAttr(
			pInputElem->GetName(),
			( NULL != pSem ) ? pSem->GetValue() : NULL,
			eType, nOffset );

		nOffset += g_pSystem->GetSizeOf( eType );
	}

	pDecl->SetStride( nOffset ); // Записывам шаг (размер) вершины в байтах 

	return pDecl;
}
Exemple #15
0
BOOL CSchemaMember::LoadType(const CXMLElement* pType)
{
	CString strName = pType->GetName();

	if ( strName.CompareNoCase( L"simpleType" ) &&
		 strName.CompareNoCase( L"complexType" ) )
		return FALSE;

	m_sType = pType->GetAttributeValue( L"base", L"" );
	ToLower( m_sType );

	m_bNumeric = ( m_sType == L"decimal" || m_sType == L"int" || m_sType == L"short" );
	m_bBoolean = m_sType == L"boolean";
	m_bYear = m_sType == L"year";
	m_bGUID = m_sType == L"guidtype";

	for ( POSITION pos = pType->GetElementIterator(); pos; )
	{
		CXMLElement* pElement	= pType->GetNextElement( pos );
		CString strElement		= pElement->GetName();

		if ( strElement.CompareNoCase( L"enumeration" ) == 0 )
		{
			CString strValue = pElement->GetAttributeValue( L"value", L"" );
			if ( ! strValue.IsEmpty() ) m_pItems.AddTail( strValue );
		}
		else if ( strElement.CompareNoCase( L"maxInclusive" ) == 0 )
		{
			CString strValue = pElement->GetAttributeValue( L"value", L"0" );
			_stscanf( strValue, L"%i", &m_nMaxLength );
		}
	}

	return TRUE;
}
ALERROR CConquerNodesProc::LoadNodeWeightTable (SDesignLoadCtx &Ctx, CXMLElement *pDesc, TArray<SNodeWeight> *retTable)

//	LoadNodeWeightTable
//
//	Loads a node criteria/weight table

	{
	ALERROR error;
	int i;

	//	OK if NULL; it means the element is missing

	if (pDesc == NULL)
		return NOERROR;

	//	Load

	for (i = 0; i < pDesc->GetContentElementCount(); i++)
		{
		CXMLElement *pChanceXML = pDesc->GetContentElement(i);
		SNodeWeight *pChance = retTable->Insert();

		if (error = CTopologyNode::ParseCriteria(pChanceXML->GetAttribute(CRITERIA_ATTRIB),
				&pChance->Criteria,
				&Ctx.sError))
			return error;

		pChance->iWeight = pChanceXML->GetAttributeIntegerBounded(WEIGHT_ATTRIB, 0, -1, 1);
		pChance->iSuccessChance = pChanceXML->GetAttributeIntegerBounded(SUCCESS_CHANCE_ATTRIB, 0, 100, 100);
		}

	return NOERROR;
	}
Exemple #17
0
BOOL CProfiles::IsDenied(IN_ADDR* pAddress)
{
	CSingleLock pLock( &m_pSection, TRUE );
	
	if ( ! m_pXMLSecure ) return FALSE;
	
	CString strValue;
	BOOL bFound = FALSE;
	CXMLAttribute* pAttri = NULL;
	
	for ( POSITION pos = m_pXMLSecure->GetElementIterator() ; pos ; )
	{
		CXMLElement* pMap = m_pXMLSecure->GetNextElement( pos );
		if ( ! pMap->IsNamed( _T("Map") ) ) continue;
		
		if ( pAttri = pMap->GetAttribute( _T("Host") ) )
		{
			strValue = pAttri->GetValue();
			if ( strValue.CompareNoCase( _T("任意") ) == 0
			  || inet_addr((LPCTSTR)strValue) == *(DWORD*)pAddress )
			{
				bFound = TRUE; break;
			}
		}
	}
	
	// 拒绝条件: 拒绝 && bFound ==> TRUE
	//         : !拒绝 && !Found ==> TRUE
	// 受理方法: 异或 = 0 ==> TRUE, 否则 FALSE
	CString xAction = m_pXMLSecure->GetAttributeValue( _T("Action") );
	if ( xAction.CompareNoCase( _T("拒绝") ) ^ bFound  ) return FALSE;
	
	return TRUE;
}
bool CXMLDocumentFile::ResolveIncludes()
{
	CXMLElement* pInclude = nullptr;

	while ((pInclude = (CXMLElement*)(this->DescendantsNamed(STRING("include")))) != 0)
	{
		CXMLAttribute* pFile = pInclude->AttributeNamed(STRING("file"));
		if (!pFile) { return false; }

		CFile File(m_pFile->Path() + STRING("\\") + pFile->ValueString());

		if (File.Exists())
		{
			CStreamFileRead        ReadStream(File);
			CStreamReadTextGeneric ReadStreamText(ReadStream);

			CXMLDocument* pDocument = new CXMLDocument(ReadStreamText);

			if (pDocument)
			{
				//This replaces the include node with the root element node from the resolved document (severs the ties to the XML document object)
				pInclude->ReplaceWith(*pDocument->RootElementRetrieve());

				delete pInclude;
				delete pDocument;
			}
			else { return false; }
		}
		else { return false; }
	}

	return true;
}
Exemple #19
0
ALERROR CEffectVariantCreator::OnEffectCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID)

//	OnEffectCreateFromXML
//
//	Creates from XML

	{
	ALERROR error;
	int i;

	//	Allocate the creator array

	int iCount = pDesc->GetContentElementCount();
	if (iCount == 0)
		{
		Ctx.sError = CONSTLIT("<Variants> effect must have at least one sub-element.");
		return ERR_FAIL;
		}

	m_Effects.InsertEmpty(iCount);

	for (i = 0; i < iCount; i++)
		{
		CString sSubUNID = strPatternSubst(CONSTLIT("%s/%d"), sUNID, i);

		CXMLElement *pCreatorDesc = pDesc->GetContentElement(i);
		if (error = CEffectCreator::CreateFromXML(Ctx, pCreatorDesc, sSubUNID, &m_Effects[i].pEffect))
			return error;

		m_Effects[i].iMaxValue = pCreatorDesc->GetAttributeInteger(MAX_VALUE_ATTRIB);
		}

	return NOERROR;
	}
Exemple #20
0
ALERROR WriteModuleSounds (CTDBCompiler &Ctx, CXMLElement *pModule, const CString &sFolder, CDataFile &Out)
	{
	ALERROR error;
	int i;

	for (i = 0; i < pModule->GetContentElementCount(); i++)
		{
		CXMLElement *pItem = pModule->GetContentElement(i);
		if (strEquals(pItem->GetTag(), TAG_SOUNDS))
			{
			CString sSubFolder = pathAddComponent(sFolder, pItem->GetAttribute(ATTRIB_FOLDER));

			if (error = WriteModuleSounds(Ctx, pItem, sSubFolder, Out))
				return error;
			}
		else if (strEquals(pItem->GetTag(), TAG_SOUND))
			{
			CString sFilename = pItem->GetAttribute(ATTRIB_FILENAME);
			if (error = WriteResource(Ctx, sFilename, sFolder, false, Out))
				continue;
			}
		}

	return NOERROR;
	}
Exemple #21
0
void CSovereign::InitRelationships (void)

//	InitRelationships
//
//	Initialize relationships from XML element

	{
	int i;

	DeleteRelationships();

	if (m_pInitialRelationships)
		{
		for (i = 0; i < m_pInitialRelationships->GetContentElementCount(); i++)
			{
			CXMLElement *pRelDesc = m_pInitialRelationships->GetContentElement(i);
			CSovereign *pTarget = g_pUniverse->FindSovereign(pRelDesc->GetAttributeInteger(SOVEREIGN_ATTRIB));
			if (pTarget)
				{
				CString sDisposition = pRelDesc->GetAttribute(DISPOSITION_ATTRIB);
				if (strEquals(sDisposition, DISP_FRIEND))
					SetDispositionTowards(pTarget, dispFriend);
				else if (strEquals(sDisposition, DISP_NEUTRAL))
					SetDispositionTowards(pTarget, dispNeutral);
				else if (strEquals(sDisposition, DISP_ENEMY))
					SetDispositionTowards(pTarget, dispEnemy);
				}
			}
		}
	}
Exemple #22
0
Bool CXMLDocument::AddDTD(char *data, unsigned long tlength)
{
	if (!isinited()) return False;
	xmlParserInputBufferPtr dtdInputBufferPtr; 
	xmlDtdPtr dtd; 
	dtdInputBufferPtr = xmlParserInputBufferCreateMem(data, tlength, XML_CHAR_ENCODING_UTF8); 
	dtd = xmlIOParseDTD(NULL, dtdInputBufferPtr, XML_CHAR_ENCODING_UTF8); 
	if (!dtd) return False;
	if (dtd->name != NULL)
		xmlFree((char*)dtd->name);
	CXMLElement telement;
	GetRootElement(&telement);
	dtd->name = xmlStrdup((xmlChar *)telement.GetName());
	doc->intSubset = dtd;
    if (dtd->ExternalID != NULL) { 
           xmlFree((xmlChar *) dtd->ExternalID); 
           dtd->ExternalID = NULL; 
       } 
       if (dtd->SystemID != NULL) { 
           xmlFree((xmlChar *) dtd->SystemID); 
           dtd->SystemID = NULL; 
       } 
	dtd->doc = doc;
	dtd->parent = doc;
	if (doc->children == NULL) xmlAddChild((xmlNodePtr)doc, (xmlNodePtr)dtd);
	else xmlAddPrevSibling(doc->children, (xmlNodePtr)dtd);
	return Validate();
}
Exemple #23
0
CXMLElement* CXMLElement::Clone(CXMLElement* pParent) const
{
	CXMLElement* pClone = new CXMLElement( pParent, m_sName );
	if ( ! pClone ) return NULL;			// Out of memory

	for ( POSITION pos = GetAttributeIterator() ; pos ; )
	{
		CXMLAttribute* pAttribute = GetNextAttribute( pos )->Clone( pClone );
		if ( ! pAttribute ) return NULL;	// Out of memory

		CString strNameLower( pAttribute->m_sName );
		strNameLower.MakeLower();

		// Delete the old attribute if one exists
		CXMLAttribute* pExisting;
		if ( pClone->m_pAttributes.Lookup( strNameLower, pExisting ) )
			delete pExisting;

		pClone->m_pAttributes.SetAt( strNameLower, pAttribute );

		if ( ! pClone->m_pAttributesInsertion.Find( strNameLower ) )
			pClone->m_pAttributesInsertion.AddTail( strNameLower );		// Track output order workaround
	}

	for ( POSITION pos = GetElementIterator() ; pos ; )
	{
		CXMLElement* pElement = GetNextElement( pos );
		pClone->m_pElements.AddTail( pElement->Clone( pClone ) );
	}

	ASSERT( ! pClone->m_sName.IsEmpty() );
	pClone->m_sValue = m_sValue;

	return pClone;
}
void CSchemaMember::SetValueTo(CXMLElement* pBase, LPCTSTR pszValue)
{
	if ( CXMLElement* pElement = pBase->GetElementByName( m_sName ) )
	{
		if ( m_bElement && pszValue != NULL && _tcslen( pszValue ) > 0 )
			pElement->SetValue( pszValue );
		else
			pElement->Delete();
	}
	else if ( m_bElement && pszValue != NULL && _tcslen( pszValue ) > 0 )
	{
		CXMLElement* pElement = pBase->AddElement( m_sName );
		pElement->SetValue( pszValue );
	}
	
	if ( CXMLAttribute* pAttribute = pBase->GetAttribute( m_sName ) )
	{
		if ( ! m_bElement && pszValue != NULL && _tcslen( pszValue ) > 0 )
			pAttribute->SetValue( pszValue );
		else
			pAttribute->Delete();
	}
	else if ( ! m_bElement && pszValue != NULL && _tcslen( pszValue ) > 0 )
	{
		pBase->AddAttribute( m_sName, pszValue );
	}
}
BOOL CAnalogProfilePage::LoadXML()
{
	CString strValue;
	CXMLAttribute* pAttri = NULL;
	
	for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pMap = m_pXML->GetNextElement( pos );
		if ( ! pMap->IsNamed( _T("Map") ) ) continue;
		
		if ( pAttri = pMap->GetAttribute( _T("ID") ) )
		{
			int nItem = m_wndList.InsertItem( LVIF_IMAGE|LVIF_PARAM,
				m_wndList.GetItemCount(), NULL, 0, 0, 28, (LPARAM)pMap );
			
			strValue = pAttri->GetValue();
			m_wndList.SetItemText( nItem, 1, pAttri->GetValue() );
			
			if ( pAttri = pMap->GetAttribute( _T("LinkId") ) )
			{
				m_wndList.SetItemText( nItem, 0, pAttri->GetValue() );
			}
			
			if ( pAttri = pMap->GetAttribute( _T("LocalId") ) )
			{
				m_wndList.SetItemText( nItem, 2, pAttri->GetValue() );
			}
		}
	}

	return TRUE;
}
Exemple #26
0
BOOL CGroupingDlg::OnSyncDataViewResp(CXMLElement* pXML)
{
	CWaitCursor pCursor;
	
	m_wndGroup.ResetContent();
	m_pXML->Delete(); m_pXML = pXML;
	
	for ( POSITION posNext = pXML->GetElementIterator(); posNext; )
	{
		CXMLElement* pSync = pXML->GetNextElement( posNext );
		if ( ! pSync->IsNamed( "SyncOrder" ) ) continue;
		
		static LPCTSTR pszGroup[] = { _T("xgroupname"), _T("xgroupnum") };
		
		CXMLAttribute* pAttri = pSync->GetAttribute( pszGroup[0] );
		if ( ! pAttri || pAttri->GetValue().IsEmpty() ) pAttri = pSync->GetAttribute( pszGroup[1] );
		
		if ( pAttri && m_wndGroup.FindStringExact( -1, pAttri->GetValue() ) == CB_ERR )
		m_wndGroup.SetItemDataPtr( m_wndGroup.AddString( pAttri->GetValue() ), pXML );
	}
	
	m_wndGroup.SetCurSel( 0 );
	SendMessage(WM_COMMAND, MAKELONG(m_wndGroup.GetDlgCtrlID(),CBN_SELCHANGE), (LPARAM)m_hWnd);
	
	return TRUE;
}
BOOL CAlbumFolder::MetaToFiles(BOOL bAggressive)
{
	if ( m_pSchema == NULL || m_pXML == NULL ) return FALSE;

	for ( POSITION pos = GetFileIterator() ; pos ; )
	{
		CLibraryFile* pFile	= GetNextFile( pos );
		CSchema* pSchema	= pFile->m_pSchema;

		if ( pSchema == NULL ) continue;

		if ( CSchemaChild* pChild = m_pSchema->GetContained( pSchema->m_sURI ) )
		{
			CXMLElement* pXML = pFile->m_pMetadata->Clone();

			if ( pChild->MemberCopy( m_pXML, pXML, TRUE, bAggressive ) )
			{
				CXMLElement* pRoot = pSchema->Instantiate( TRUE );
				pRoot->AddElement( pXML );
				pFile->SetMetadata( pRoot );
				delete pRoot;
			}
			else
			{
				delete pXML;
			}
		}
	}

	return TRUE;
}
BOOL CProfiles::Setup()
{
    Release();

    CSingleLock pLock( &m_pSection, TRUE );

    CString strXML;

    strXML = Settings.General.Path;
    int nLength = strXML.GetLength();

    if ( nLength > 0 && strXML.GetAt(nLength-1) != '\\' ) strXML += '\\';
    strXML += _T("xProfile.xml");

    if ( CXMLElement* pXML = CXMLElement::FromFile( strXML, TRUE ) )
    {
        CXMLElement* pXMLSub;

        if ( pXMLSub = pXML->GetElementByName( _T("Monitor") ) )
        {
            m_pXMLMonitor = pXMLSub->Clone();
        }

        delete pXML;
        return TRUE;
    }

    return FALSE;
}
Exemple #29
0
ALERROR CGroupOfGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load from XML

	{
	int i;
	ALERROR error;

	//	Load content elements

	m_Table.InsertEmpty(pDesc->GetContentElementCount());
	for (i = 0; i < m_Table.GetCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);
			
		m_Table[i].iChance = pEntry->GetAttributeInteger(CHANCE_ATTRIB);
		if (m_Table[i].iChance == 0)
			m_Table[i].iChance = 100;

		CString sCount = pEntry->GetAttribute(COUNT_ATTRIB);
		if (sCount.IsBlank())
			m_Table[i].Count = DiceRange(0, 0, 1);
		else
			m_Table[i].Count.LoadFromXML(sCount);

		if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &m_Table[i].pItem))
			return error;
		}

	//	See if we force an average value

	CString sAttrib;
	if (pDesc->FindAttribute(LEVEL_VALUE_ATTRIB, &sAttrib))
		{
		TArray<int> Values;
		ParseIntegerList(sAttrib, 0, &Values);

		m_AverageValue.InsertEmpty(MAX_ITEM_LEVEL + 1);
		m_AverageValue[0] = 0;
		for (i = 0; i < Values.GetCount(); i++)
			m_AverageValue[i + 1] = Values[i];

		for (i = Values.GetCount() + 1; i <= MAX_ITEM_LEVEL; i++)
			m_AverageValue[i] = 0;
		}
	else if (pDesc->FindAttribute(VALUE_ATTRIB, &sAttrib))
		{
		int iValue = strToInt(sAttrib, 0);

		m_AverageValue.InsertEmpty(MAX_ITEM_LEVEL + 1);
		m_AverageValue[0] = 0;
		for (i = 1; i <= MAX_ITEM_LEVEL; i++)
			m_AverageValue[i] = iValue;
		}

	return NOERROR;
	}
Exemple #30
0
BOOL CSkin::LoadCommandBitmap(CXMLElement* pBase, const CString& strPath)
{
	static LPCTSTR pszNames[] = { _T("id"), _T("id1"), _T("id2"), _T("id3"), _T("id4"), _T("id5"), _T("id6"), _T("id7"), _T("id8"), _T("id9"), NULL };
	
	CString strFile = strPath;
	strFile += pBase->GetAttributeValue( _T("id") );
	strFile += pBase->GetAttributeValue( _T("path") );
	
	HBITMAP hBitmap = LoadBitmap( strFile );
	if ( hBitmap == NULL ) return TRUE;
	
	strFile = pBase->GetAttributeValue( _T("mask") );
	COLORREF crMask = RGB( 0, 255, 0 );
	
	if ( strFile.GetLength() == 6 )
	{
		int nRed, nGreen, nBlue;
		_stscanf( strFile.Mid( 0, 2 ), _T("%x"), &nRed );
		_stscanf( strFile.Mid( 2, 2 ), _T("%x"), &nGreen );
		_stscanf( strFile.Mid( 4, 2 ), _T("%x"), &nBlue );
		crMask = RGB( nRed, nGreen, nBlue );
	}
	
	CoolInterface.ConfirmImageList();
	int nBase = ImageList_AddMasked( CoolInterface.m_pImages.m_hImageList, hBitmap, crMask );
	
	if ( nBase < 0 )
	{
		DeleteObject( hBitmap );
		return FALSE;
	}
	
	int nIndex = 0;
	
	for ( POSITION pos = pBase->GetElementIterator() ; pos ; )
	{
		CXMLElement* pXML = pBase->GetNextElement( pos );
		if ( ! pXML->IsNamed( _T("image") ) ) continue;
		
		strFile = pXML->GetAttributeValue( _T("index") );
		if ( strFile.GetLength() ) _stscanf( strFile, _T("%i"), &nIndex );
		nIndex += nBase;
		
		for ( int nName = 0 ; pszNames[ nName ] ; nName++ )
		{
			UINT nID = LookupCommandID( pXML, pszNames[ nName ] );
			if ( nID ) CoolInterface.m_pImageMap.SetAt( (LPVOID)nID, (LPVOID)nIndex );
			if ( nName && ! nID ) break;
		}
		
		nIndex -= nBase;
		nIndex ++;
	}
	
	DeleteObject( hBitmap );
	
	return TRUE;
}