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

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 1150
Date       : Mon May 22 11:18:30 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/menuops.cpp
   M /Trunk/XaraLX/wxOil/menucmds.cpp

Fix inclusion of animation and default in template list and add sorting (had to do manually what the Windows did as the default)


Diff:
Index: Trunk/XaraLX/Kernel/menuops.cpp
===================================================================
--- Trunk/XaraLX/Kernel/menuops.cpp	(revision 1149)
+++ Trunk/XaraLX/Kernel/menuops.cpp	(revision 1150)
@@ -578,29 +578,39 @@
 			String_256 strPathOfAnimationTemplate=GetDefaultAnimationTemplate().GetPath(FALSE);
 			String_256 strPathOfFile;
 
-			for (INT32 i=0; i<iNumberOfTemplate; i++)
+			TRACEUSER( "jlh92", _T("DefPath = %s, %s
"), PCTSTR(strPathOfDrawingTemplate),
+				PCTSTR(strPathOfAnimationTemplate) );
+
+			std::set<String_256>	setSortFilename;
+
+			while( FileUtil::FindNextFile( &strNameOfFile ) )
 			{
-				do
+				pathOfFile.SetFileNameAndType(strNameOfFile);
+				strPathOfFile=pathOfFile.GetFileName(TRUE);
+
+				if( 0 != strPathOfFile.CompareTo( strPathOfDrawingTemplate, FALSE ) &&
+					0 != strPathOfFile.CompareTo( strPathOfAnimationTemplate, FALSE ) )
 				{
-					if (!FileUtil::FindNextFile(&strNameOfFile))
-					{
-						//We failed to find a template. So remove this
-						//item from the menu.
-						FileUtil::StopFindingFiles();
-						// Don't allow any errors set while searching to propagate outside this scope
-						Error::ClearError();
-						return OpState(FALSE, FALSE, TRUE);
-					}
-
-					pathOfFile.SetFileNameAndType(strNameOfFile);
-					strPathOfFile=pathOfFile.GetPath(FALSE);
+					setSortFilename.insert( strPathOfFile );
+					TRACEUSER( "jlh92", _T("Curr = %s
"), PCTSTR(strPathOfFile) );
 				}
-				while (strPathOfFile.CompareTo(strPathOfDrawingTemplate, FALSE)==0 ||
-					strPathOfFile.CompareTo(strPathOfAnimationTemplate, FALSE)==0);
 			}
-
 			FileUtil::StopFindingFiles();
 
+			if( iNumberOfTemplate >= setSortFilename.size() )
+			{
+				// Don't allow any errors set while searching to propagate outside this scope
+				Error::ClearError();
+				return OpState(FALSE, FALSE, TRUE);
+			}
+
+			std::set<String_256>::iterator iter = setSortFilename.begin();
+			for( INT32 i = 1; i < iNumberOfTemplate; ++i, ++iter )
+			{ /*Do nothing!*/ }
+
+			strNameOfFile = *iter;
+			TRACEUSER( "jlh92", _T("Final(%d) = %s
"), iNumberOfTemplate, PCTSTR(strPathOfFile) );
+
 			//We've found a file. So strip the .xar from the name, as follows...
 			pathTemplates.SetFileNameAndType(strNameOfFile);
 			*UIDescription=pathTemplates.GetFileName(FALSE);
@@ -1201,7 +1211,7 @@
 		FileNewTemplateAction(7); 
 	else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE8))
 		FileNewTemplateAction(8); 
-		else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE9))
+	else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE9))
 		FileNewTemplateAction(9); 
 	else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE10))
 		FileNewTemplateAction(10); 
Index: Trunk/XaraLX/wxOil/menucmds.cpp
===================================================================
--- Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1149)
+++ Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1150)
@@ -270,6 +270,7 @@
 
 	String_256 strPathOfFile;
 
+
 	if (FileUtil::StartFindingFiles(&strTemplates))
 	{
 		String_256 strNameOfFile;
@@ -278,27 +279,37 @@
 		String_256 strPathOfDrawingTemplate=DocOps::GetDefaultDrawingTemplate().GetPath(FALSE);
 		String_256 strPathOfAnimationTemplate=DocOps::GetDefaultAnimationTemplate().GetPath(FALSE);
 		
-		for (INT32 i=0; i<iNumberOfTemplate; i++)
+		std::set<String_256>	setSortFilename;
+
+		while( FileUtil::FindNextFile( &strNameOfFile ) )
 		{
-			do
+			pathOfFile.SetFileNameAndType(strNameOfFile);
+			strPathOfFile=pathOfFile.GetFileName(TRUE);
+
+			if( 0 != strPathOfFile.CompareTo( strPathOfDrawingTemplate, FALSE ) &&
+				0 != strPathOfFile.CompareTo( strPathOfAnimationTemplate, FALSE ) )
 			{
-				if (!FileUtil::FindNextFile(&strNameOfFile))
-				{
-					//We failed to find a template. So remove this
-					//item from the menu.
-					strNameOfFile="";
-				}
-
-				pathOfFile.SetFileNameAndType(strNameOfFile);
-				strPathOfFile=pathOfFile.GetPath(FALSE);
+				setSortFilename.insert( strPathOfFile );
 			}
-			while (strPathOfFile.CompareTo(strPathOfDrawingTemplate, FALSE)==0 ||
-				strPathOfFile.CompareTo(strPathOfAnimationTemplate, FALSE)==0);
 		}
+		FileUtil::StopFindingFiles();
 
-		FileUtil::StopFindingFiles();
+		if( iNumberOfTemplate >= setSortFilename.size() )
+		{
+			//We failed to find a template. So remove this
+			//item from the menu.
+			strNameOfFile="";
+		}
+
+		std::set<String_256>::iterator iter = setSortFilename.begin();
+		for( INT32 i = 1; i < iNumberOfTemplate; ++i, ++iter )
+		{ /*Do nothing!*/ }
+
+		strPathOfFile = *iter;
 	}
 
+	TRACEUSER( "jlh92", _T("Opening %s
"), PCTSTR(strPathOfFile) );
+
 	pathTemplates.SetFileNameAndType(strPathOfFile);
 
 	CCamDoc::SetNextTemplateToUse(pathTemplates);


Xara