[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 1256
Date       : Mon Jun  5 18:02:35 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/rechdoc.cpp
   M /Trunk/XaraLX/Kernel/spread.cpp

Tweaks to allow reloading of multi-spread documents.


Diff:
Index: Trunk/XaraLX/Kernel/rechdoc.cpp
===================================================================
--- Trunk/XaraLX/Kernel/rechdoc.cpp	(revision 1255)
+++ Trunk/XaraLX/Kernel/rechdoc.cpp	(revision 1256)
@@ -464,84 +464,102 @@
 	IncSpreadInsertedCount();
 
 	// If this is not the first spread in the file, ignore the rest of the file
-	if (GetSpreadInsertedCount() > 1)
+	if (GetSpreadInsertedCount() <= 1)
 	{
-		EndOfFile();
-		return TRUE;
-	}
+		// Mainstream code used between 1994 and 2006
+		//
+		// Ignore this record if we are importing into an existing file
+		if (IsImporting())
+			return TRUE;
 
-	// Ignore this record if we are importing into an existing file
-	if (IsImporting())
-		return TRUE;
+		Node* pContextNode = GetInsertContextNode();
+		ERROR2IF(pContextNode == NULL, FALSE, "What? No context node?");
 
-	Node* pContextNode = GetInsertContextNode();
-	ERROR2IF(pContextNode == NULL, FALSE, "What? No context node?");
+		// JCF: bodge insertion context.
+		if (IS_A(pContextNode, NodeSetSentinel))
+		{
+			SetInsertContextNode(0);
+			pContextNode = GetInsertContextNode();
+		}
 
-	// JCF: bodge insertion context.
-	if (IS_A(pContextNode, NodeSetSentinel))
-	{
-		SetInsertContextNode(0);
-		pContextNode = GetInsertContextNode();
-	}
+		Spread* pSpread = (Spread*) pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
+		ERROR2IF(pSpread == NULL, FALSE, "Can't find the spread");
 
-	Spread* pSpread = (Spread*) pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
-	ERROR2IF(pSpread == NULL, FALSE, "Can't find the spread");
+		SetLastSpreadInserted(pSpread);
+		SetInsertContextNode(pSpread);
+		InsertNextNodeAsChild();
 
-	SetLastSpreadInserted(pSpread);
-	SetInsertContextNode(pSpread);
-	InsertNextNodeAsChild();
+		Layer* pLayer = pSpread->FindFirstLayer();
+		if (pLayer != NULL)
+		{
+			SetInsertContextNode(pLayer);
+			InsertNextNodeAsChild();
+		}
 
-	Layer* pLayer = pSpread->FindFirstLayer();
-	if (pLayer != NULL)
+		return TRUE;
+	}
+	else
 	{
-		SetInsertContextNode(pLayer);
-		InsertNextNodeAsChild();
-	}
+		// Multi-spread code written before 1994, resurrected in 2006 by Phil
+		//
+		// For some reason the above code assumes that a spread already
+		// exists and simply "overloads" it.
+		// Some of the logic below creates grid and page nodes in a similar
+		// vein. Not sure why...
+		//
+		Node* pContextNode = GetInsertContextNode();
+		ERROR2IF(pContextNode == NULL,FALSE,"What? No context node?");
 
-	return TRUE;
+		// JCF: bodge insertion context.
+		if (IS_A(pContextNode, NodeSetSentinel))
+		{
+			SetInsertContextNode(0);
+			pContextNode = GetInsertContextNode();
+		}
 
-/*
-	Node* pContextNode = GetInsertContextNode();
-	ERROR2IF(pContextNode == NULL,FALSE,"What? No context node?");
+		Node* pSpread = pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
+		if (pSpread != NULL)
+		{
+			SetInsertContextNode(pSpread);
+			InsertNextNodeAsSibling();
+		}
 
-	Node* pSpread = pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
-	if (pSpread != NULL)
-	{
-		SetInsertContextNode(pSpread);
-		InsertNextNodeAsSibling();
-	}
+		BOOL ok = FALSE;
 
-	BOOL ok = FALSE;
+		{
+			Spread* pNewSpread = new Spread;
+			if (pNewSpread != NULL)
+				ok = InsertNode(pNewSpread);
 
-	{
-		Spread* pNewSpread = new Spread;
-		if (pNewSpread != NULL)
-			ok = InsertNode(pNewSpread);
+			if (ok)
+			{
+				SetLastSpreadInserted(pNewSpread);
+				InsertNextNodeAsChild();
 
-		SetLastSpreadInserted(pNewSpread);
-		InsertNextNodeAsChild();
+				NodeGrid::MakeDefaultGrid(pNewSpread);
 
-		NodeGrid::MakeDefaultGrid(pNewSpread);
-		Page* pPage = new Page;
-		if (pPage == NULL)
-			return FALSE;
+				Page* pPage = new Page;
+				ok = (pPage != NULL);
 
-		pPage->AttachNode(pNewSpread,LASTCHILD);
+				if (ok)
+					pPage->AttachNode(pNewSpread,LASTCHILD);
 
-		SetInsertContextNode(pPage);
-		InsertNextNodeAsSibling();
-	}
+				SetInsertContextNode(pNewSpread);
+				InsertNextNodeAsChild();
+			}
+		}
 
-	if (ok && pSpread != NULL)
-	{
-		pSpread->CascadeDelete();
-		delete pSpread;
-		pSpread = NULL;
+		if (!ok && pSpread != NULL)
+		{
+			pSpread->CascadeDelete();
+			delete pSpread;
+			pSpread = NULL;
+		}
+		return ok;
 	}
-	return ok;
-*/
 }
 
+
 /********************************************************************************************
 
 >	BOOL DocumentRecordHandler::HandleSpreadInformationRecord(CXaraFileRecord* pCXaraFileRecord)
Index: Trunk/XaraLX/Kernel/spread.cpp
===================================================================
--- Trunk/XaraLX/Kernel/spread.cpp	(revision 1255)
+++ Trunk/XaraLX/Kernel/spread.cpp	(revision 1256)
@@ -3592,6 +3592,9 @@
 		DocRect Bounds = GetBoundingRect();
 		DocCoordToSpreadCoord(&Bounds);
 		ExpandPasteboardToInclude(Bounds);
+
+		AdjustPasteboards();
+
 		return(TRUE);
 	}
 


Xara