Example #1
0
void DocSettings::Load(const XMLNode& node)
{
	CString strTagName = MakeCString(node.tagName);
	if (strTagName != pszTagSettings && strTagName != pszTagContent)
		return;

	if (strTagName == pszTagSettings)
	{
		node.GetIntAttribute(pszAttrStartPage, nPage);
		node.GetLongAttribute(pszAttrOffsetX, ptOffset.x);
		node.GetLongAttribute(pszAttrOffsetY, ptOffset.y);
		node.GetIntAttribute(pszAttrZoomType, nZoomType);
		node.GetDoubleAttribute(pszAttrZoom, fZoom);
		node.GetIntAttribute(pszAttrLayout, nLayout);
		node.GetIntAttribute(pszAttrDisplayMode, nDisplayMode);
		node.GetIntAttribute(pszAttrRotate, nRotate);
		node.GetIntAttribute(pszAttrOpenSidebarTab, nOpenSidebarTab);

		int nFirstPage;
		if (node.GetIntAttribute(pszAttrFirstPage, nFirstPage))
			bFirstPageAlone = (nFirstPage != 0);

		int nRightToLeft;
		if (node.GetIntAttribute(pszAttrRightToLeft, nRightToLeft))
			bRightToLeft = (nRightToLeft != 0);
	}

	pageSettings.clear();
	bookmarks.clear();

	list<XMLNode>::const_iterator it;
	for (it = node.childElements.begin(); it != node.childElements.end(); ++it)
	{
		const XMLNode& child = *it;
		if (MakeCString(child.tagName) == pszTagPageSettings)
		{
			int pageNo;
			if (!child.GetIntAttribute(pszAttrNumber, pageNo))
				continue;

			PageSettings& data = pageSettings[pageNo - 1];
			data.Load(child);
		}
		else if (MakeCString(child.tagName) == pszTagBookmarks)
		{
			list<XMLNode>::const_iterator it;
			for (it = child.childElements.begin(); it != child.childElements.end(); ++it)
			{
				const XMLNode& bmNode = *it;
				if (MakeCString(bmNode.tagName) == pszTagBookmark)
				{
					bookmarks.push_back(Bookmark());
					Bookmark& bookmark = bookmarks.back();
					bookmark.Load(bmNode);
				}
			}
		}
	}
}
Example #2
0
void Bookmark::Load(const XMLNode& node)
{
	if (MakeCString(node.tagName) != pszTagBookmark)
		return;

	wstring str;
	if (node.GetAttribute(pszAttrTitle, str))
		strTitle = MakeUTF8String(str);

	node.GetIntAttribute(pszAttrType, nLinkType);

	if (nLinkType == URL)
	{
		if (node.GetAttribute(pszAttrURL, str))
			strURL = MakeUTF8String(str);
	}
	else if (nLinkType == Page || nLinkType == View)
	{
		node.GetIntAttribute(pszAttrPage, nPage);
		if (nLinkType == View)
		{
			node.GetLongAttribute(pszAttrOffsetX, ptOffset.x);
			node.GetLongAttribute(pszAttrOffsetY, ptOffset.y);

			int nMargin;
			if (node.GetIntAttribute(pszAttrMargin, nMargin))
				bMargin = (nMargin != 0);
		}
	}

	list<XMLNode>::const_iterator it;
	for (it = node.childElements.begin(); it != node.childElements.end(); ++it)
	{
		const XMLNode& child = *it;
		if (MakeCString(child.tagName) == pszTagBookmark)
		{
			children.push_back(Bookmark());
			Bookmark& bookmark = children.back();
			bookmark.Load(child);
		}
	}
}