Virtualize wxXmlNode methods used by wxAuiToolBarXmlHandler.

This fixes the DLL build of aui library as it can now be linked without
leaving any unresolved dependencies to the code in xml library (where
wxXmlNode is implemented).

Closes #15686.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75734 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-01-29 22:25:36 +00:00
parent d94f3f5aba
commit 0a411fd5da
5 changed files with 94 additions and 6 deletions

View File

@ -481,6 +481,7 @@ public:
// e.g. <object class="wxDialog">.
bool IsOfClass(wxXmlNode *node, const wxString& classname) const;
bool IsObjectNode(const wxXmlNode *node) const;
// Gets node content from wxXML_ENTITY_NODE
// The problem is, <tag>content<tag> is represented as
// wxXML_ENTITY_NODE name="tag", content=""
@ -488,6 +489,10 @@ public:
// wxXML_CDATA_SECTION_NODE name="" content="content"
wxString GetNodeContent(const wxXmlNode *node);
wxXmlNode *GetNodeParent(const wxXmlNode *node) const;
wxXmlNode *GetNodeNext(const wxXmlNode *node) const;
wxXmlNode *GetNodeChildren(const wxXmlNode *node) const;
// Check to see if a parameter exists.
bool HasParam(const wxString& param);

View File

@ -52,7 +52,11 @@ public:
virtual wxObject *CreateResource(wxXmlNode *node, wxObject *parent,
wxObject *instance) = 0;
virtual bool IsOfClass(wxXmlNode *node, const wxString& classname) const = 0;
virtual bool IsObjectNode(const wxXmlNode *node) const = 0;
virtual wxString GetNodeContent(const wxXmlNode *node) = 0;
virtual wxXmlNode *GetNodeParent(const wxXmlNode *node) const = 0;
virtual wxXmlNode *GetNodeNext(const wxXmlNode *node) const = 0;
virtual wxXmlNode *GetNodeChildren(const wxXmlNode *node) const = 0;
virtual bool HasParam(const wxString& param) = 0;
virtual wxXmlNode *GetParamNode(const wxString& param) = 0;
virtual wxString GetParamValue(const wxString& param) = 0;
@ -206,10 +210,29 @@ protected:
{
return GetImpl()->IsOfClass(node, classname);
}
bool IsObjectNode(const wxXmlNode *node) const
{
return GetImpl()->IsObjectNode(node);
}
wxString GetNodeContent(const wxXmlNode *node)
{
return GetImpl()->GetNodeContent(node);
}
wxXmlNode *GetNodeParent(const wxXmlNode *node) const
{
return GetImpl()->GetNodeParent(node);
}
wxXmlNode *GetNodeNext(const wxXmlNode *node) const
{
return GetImpl()->GetNodeNext(node);
}
wxXmlNode *GetNodeChildren(const wxXmlNode *node) const
{
return GetImpl()->GetNodeChildren(node);
}
bool HasParam(const wxString& param)
{
return GetImpl()->HasParam(param);

View File

@ -651,11 +651,50 @@ protected:
*/
wxString GetName();
/**
Checks if the given node is an object node.
Object nodes are those named "object" or "object_ref".
@since 3.1.0
*/
bool IsObjectNode(const wxXmlNode *node) const;
/**
Gets node content from wxXML_ENTITY_NODE.
*/
wxString GetNodeContent(wxXmlNode* node);
/**
Gets the parent of the node given.
This method is safe to call with @NULL argument, it just returns @NULL
in this case.
@since 3.1.0
*/
wxXmlNode *GetNodeParent(const wxXmlNode *node) const;
/**
Gets the next sibling node related to the given node, possibly @NULL.
This method is safe to call with @NULL argument, it just returns @NULL
in this case.
@since 3.1.0
*/
wxXmlNode *GetNodeNext(const wxXmlNode *node) const;
/**
Gets the first child of the given node or @NULL.
This method is safe to call with @NULL argument, it just returns @NULL
in this case.
@since 3.1.0
*/
wxXmlNode *GetNodeChildren(const wxXmlNode *node) const;
/**
Finds the node or returns @NULL.
*/

View File

@ -84,7 +84,7 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource()
// also check for the menu specified inside dropdown (it is
// optional and may be absent for e.g. dynamically-created
// menus)
wxXmlNode * const nodeMenu = nodeDropdown->GetChildren();
wxXmlNode * const nodeMenu = GetNodeChildren(nodeDropdown);
if ( nodeMenu )
{
wxObject *res = CreateResFromNode(nodeMenu, NULL);
@ -98,11 +98,11 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource()
);
}
if ( nodeMenu->GetNext() )
if ( GetNodeNext(nodeMenu) )
{
ReportError
(
nodeMenu->GetNext(),
GetNodeNext(nodeMenu),
"unexpected extra contents under drop-down tool"
);
}
@ -195,8 +195,7 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource()
while (n)
{
if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxS("object") || n->GetName() == wxS("object_ref")))
if (IsObjectNode(n))
{
wxObject *created = CreateResFromNode(n, toolbar, NULL);
wxControl *control = wxDynamicCast(created, wxControl);
@ -206,7 +205,7 @@ wxObject *wxAuiToolBarXmlHandler::DoCreateResource()
control != NULL)
toolbar->AddControl(control);
}
n = n->GetNext();
n = GetNodeNext(n);
}
m_isInside = false;

View File

@ -2007,6 +2007,13 @@ bool wxXmlResourceHandlerImpl::IsOfClass(wxXmlNode *node, const wxString& classn
}
bool wxXmlResourceHandlerImpl::IsObjectNode(const wxXmlNode *node) const
{
return node &&
node->GetType() == wxXML_ELEMENT_NODE &&
(node->GetName() == wxS("object") ||
node->GetName() == wxS("object_ref"));
}
wxString wxXmlResourceHandlerImpl::GetNodeContent(const wxXmlNode *node)
{
@ -2024,6 +2031,21 @@ wxString wxXmlResourceHandlerImpl::GetNodeContent(const wxXmlNode *node)
return wxEmptyString;
}
wxXmlNode *wxXmlResourceHandlerImpl::GetNodeParent(const wxXmlNode *node) const
{
return node ? node->GetParent() : NULL;
}
wxXmlNode *wxXmlResourceHandlerImpl::GetNodeNext(const wxXmlNode *node) const
{
return node ? node->GetNext() : NULL;
}
wxXmlNode *wxXmlResourceHandlerImpl::GetNodeChildren(const wxXmlNode *node) const
{
return node ? node->GetChildren() : NULL;
}
wxString wxXmlResourceHandlerImpl::GetParamValue(const wxString& param)