Esempio n. 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);
				}
			}
		}
	}
}
Esempio n. 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);
		}
	}
}
Esempio n. 3
0
void Annotation::Load(const XMLNode& node)
{
	if (MakeCString(node.tagName) != pszTagAnnotation)
		return;

	int borderType;
	if (node.GetIntAttribute(pszAttrBorder, borderType))
	{
		if (borderType >= BorderNone && borderType <= BorderXOR)
			nBorderType = borderType;
	}

	COLORREF color;
	if (node.GetColorAttribute(pszAttrBorderColor, color))
		crBorder = color;

	int nHideBorder;
	if (node.GetIntAttribute(pszAttrBorderHideInactive, nHideBorder))
		bHideInactiveBorder = !!nHideBorder;

	int fillType;
	if (node.GetIntAttribute(pszAttrFill, fillType))
	{
		if (fillType >= FillNone && fillType <= FillXOR)
			nFillType = fillType;
	}

	if (node.GetColorAttribute(pszAttrFillColor, color))
		crFill = color;

	int nPercent;
	if (node.GetIntAttribute(pszAttrFillTransparency, nPercent))
	{
		if (nPercent >= 0 && nPercent <= 100)
			fTransparency = nPercent / 100.0;
	}

	int nHideFill;
	if (node.GetIntAttribute(pszAttrFillHideInactive, nHideFill))
		bHideInactiveFill = !!nHideFill;

	wstring str;
	if (node.GetAttribute(pszAttrComment, str))
		strComment = MakeUTF8String(str);

	int nShowComment;
	if (node.GetIntAttribute(pszAttrCommentAlwaysShow, nShowComment))
		bAlwaysShowComment = !!nShowComment;

	if (node.GetAttribute(pszAttrURL, str))
		strURL = MakeUTF8String(str);

	rects.clear();
	list<XMLNode>::const_iterator it;
	for (it = node.childElements.begin(); it != node.childElements.end(); ++it)
	{
		const XMLNode& child = *it;
		if (MakeCString(child.tagName) == pszTagRect)
		{
			GRect rect;
			if (!child.GetIntAttribute(pszAttrLeft, rect.xmin)
					|| !child.GetIntAttribute(pszAttrTop, rect.ymin)
					|| !child.GetIntAttribute(pszAttrRight, rect.xmax)
					|| !child.GetIntAttribute(pszAttrBottom, rect.ymax))
				continue;

			rects.push_back(rect);
		}
	}

	UpdateBounds();
}