soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SObjDefAttr.cpp
1#include "souistd.h"
2#include "res.mgr/SObjDefAttr.h"
3#include "SApp.h"
4
5SNSBEGIN
6
8{
9 if (!xmlNode)
10 return FALSE;
11 // clear old data
12 RemoveAll();
13 m_xmlRoot.root().RemoveAllChilden();
14
15 m_xmlRoot.root().append_copy(xmlNode);
16
17 SXmlNode xmlObjAttr = m_xmlRoot.root().child(L"objattr").first_child();
18 while (xmlObjAttr)
19 {
20 AddKeyObject(xmlObjAttr.name(), xmlObjAttr);
21 xmlObjAttr = xmlObjAttr.next_sibling();
22 }
23
24 SPOSITION pos = m_mapNamedObj->GetStartPosition();
25 while (pos)
26 {
27 SMap<SStringW, SXmlNode>::CPair *p = m_mapNamedObj->GetNext(pos);
28 BuildClassAttribute(p->m_value, p->m_key);
29 }
30
31 return TRUE;
32}
33
34void SObjDefAttr::BuildClassAttribute(SXmlNode &xmlNode, LPCWSTR pszClassName)
35{
36 SObjectInfo baseClassInfo = SApplication::getSingleton().BaseObjectInfoFromObjectInfo(ObjInfo_New(pszClassName, Window));
37 if (!ObjInfo_IsValid(&baseClassInfo))
38 return;
39
40 if (HasKey(baseClassInfo.szName))
41 {
42 SXmlNode xmlNodeAttrs = GetKeyObject(baseClassInfo.szName);
43 SXmlAttr attr = xmlNodeAttrs.first_attribute();
44 while (attr)
45 {
46 if (!xmlNode.attribute(attr.name()))
47 xmlNode.append_attribute(attr.name()).set_value(attr.value());
48 attr = attr.next_attribute();
49 }
50 }
51 BuildClassAttribute(xmlNode, baseClassInfo.szName);
52}
53
55{
56 SASSERT(pszClassName);
57 if (!HasKey(pszClassName))
58 {
59 SObjectInfo baseClassInfo = SApplication::getSingleton().BaseObjectInfoFromObjectInfo(ObjInfo_New(pszClassName, Window));
60 if (!ObjInfo_IsValid(&baseClassInfo))
61 return SXmlNode();
62
63 return GetDefAttribute(baseClassInfo.szName);
64 }
65 else
66 {
67 return GetKeyObject(pszClassName);
68 }
69}
70
71SNSEND
SOUI_EXP BOOL ObjInfo_IsValid(const SObjectInfo *pObjInfo)
Checks if the object information is valid.
SNSBEGIN SOUI_EXP SObjectInfo ObjInfo_New(LPCWSTR name, int type, LPCWSTR alise=NULL)
Creates a new object information structure.
bool GetKeyObject(const SStringW &key, SXmlNode &obj) const
Definition SCmnMap.h:65
SMap< SStringW, SXmlNode > * m_mapNamedObj
Definition SCmnMap.h:168
bool AddKeyObject(const SStringW &key, const SXmlNode &obj)
Definition SCmnMap.h:94
bool HasKey(const SStringW &key) const
Definition SCmnMap.h:52
void BuildClassAttribute(SXmlNode &xmlNode, LPCWSTR pszClassName)
Builds the class attributes from an XML node.
BOOL Init(SXmlNode xmlNode)
Initializes the default attributes from an XML node.
SXmlNode GetDefAttribute(LPCWSTR pszClassName)
Retrieves the default attributes for a specific class.
SObjectInfo BaseObjectInfoFromObjectInfo(const SObjectInfo &objInfo)
Gets the base object information from a given object information.
static SApplication & getSingleton(void)
Definition SSingleton.h:63
Class representing an XML attribute.
Definition SXml.h:20
bool set_value(const wchar_t *rhs)
Sets the attribute value.
Definition SXml.cpp:130
Class representing an XML node.
Definition SXml.h:352
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
Definition SXml.cpp:393
SXmlAttr first_attribute() const
Gets the first attribute of the node.
Definition SXml.cpp:373
SXmlNode first_child() const
Gets the first child node of the node.
Definition SXml.cpp:383
const wchar_t * name() const
Gets the name of the node.
Definition SXml.cpp:363
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
Definition SXml.cpp:428
SXmlAttr append_attribute(const wchar_t *name)
Adds an attribute with the specified name.
Definition SXml.cpp:458
SXmlNode root() const
Gets the root node of the DOM tree this node belongs to.
Definition SXml.cpp:418
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Definition SXml.cpp:423
Bitfield structure for font style attributes.