void XmlAttributeUnitTests::testEmpty()
{
	XmlAttribute attr;
	CPPUNIT_ASSERT(attr.GetValue().empty());
	CPPUNIT_ASSERT(false == attr.GetBoolValue(false));
	CPPUNIT_ASSERT(true == attr.GetBoolValue(true));
}
bool OpenOfficeAction::_readNodeCallback(XmlNode node, void *data)
{
	vector <XmlAttribute>* attributes;
	bool bIsItem;

	if (parsing_state == PropUILocale && node.GetName().compare(L"value")==0)
	{		
		wstring* lang_found = (wstring *) data;
		*lang_found = node.GetText();
		parsing_state = ItemOther;
		return false;
	}

	bIsItem = node.GetName().compare(L"item") == 0;

	if (bIsItem && parsing_state != ItemOther)
	{
		parsing_state = ItemOther;
	}	

	attributes = node.GetAttributes();
	for (unsigned int i = 0; i < attributes->size(); i++)
	{
		XmlAttribute attribute;

		attribute = attributes->at(i);

		if (parsing_state == ItemOther && bIsItem && attribute.GetName() == L"oor:path" && attribute.GetValue() == L"/org.openoffice.Office.Linguistic/General")
		{
			parsing_state = ItemLinguisticGeneral;			
		}

		if (parsing_state == ItemLinguisticGeneral && attribute.GetName() == L"oor:name" && attribute.GetValue() == L"UILocale")
		{
			parsing_state = PropUILocale;
		}
	}
	
	return true;
}
Ejemplo n.º 3
0
//[-------------------------------------------------------]
//[ Protected virtual XmlTextElement functions            ]
//[-------------------------------------------------------]
void XmlTextImage::OnParse(XmlNode &cXmlNode)
{
	// Is this an XML element?
	if (cXmlNode.GetType() == XmlNode::Element) {
		// Destroy the previous image
		if (m_pImage) {
			delete m_pImage;
			m_pImage = nullptr;
		}

		// Get XML element
		XmlElement &cXmlElement = static_cast<XmlElement&>(cXmlNode);

		// Parse attributes
		XmlAttribute *pAttribute = cXmlElement.GetFirstAttribute();
		while (pAttribute) {
			// Get name and value
			String sName  = pAttribute->GetName();
			String sValue = pAttribute->GetValue();

			// Save attribute
			if (sName.CompareNoCase("Src")) {
				// Image filename
				m_sFilename = sValue;
			} else if (sName.CompareNoCase("Width")) {
				// Image width
				m_vSize.x = sValue.GetInt();
			} if (sName.CompareNoCase("Height")) {
				// Image height
				m_vSize.y = sValue.GetInt();
			}

			// Next attribute
			pAttribute = pAttribute->GetNext();
		}

	}
}