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

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 1160
Date       : Mon May 22 17:24:39 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/app.cpp
   M /Trunk/XaraLX/Kernel/filelist.cpp
   M /Trunk/XaraLX/Kernel/menuops.cpp
   M /Trunk/XaraLX/wxOil/camelot.cpp
   M /Trunk/XaraLX/wxOil/menucmds.cpp
   M /Trunk/XaraLX/wxOil/sgliboil.cpp
   M /Trunk/XaraLX/wxOil/sgliboil.h
   A /Trunk/XaraLX/wxOil/xrc/800_by_600_drawing.xar (from /Trunk/XaraLX/wxOil/xrc/default.xar:1154)
   M /Trunk/XaraLX/wxOil/xrc/EN/rik-strings.xrc
   D /Trunk/XaraLX/wxOil/xrc/default.xar

Fixes for bugzilla #904 & #1090 (you may find you need to delete ~/.XaraLX for the changed code to make any difference, due to the default template being cached in the config file)


Diff:
Index: Trunk/XaraLX/Kernel/app.cpp
===================================================================
--- Trunk/XaraLX/Kernel/app.cpp	(revision 1159)
+++ Trunk/XaraLX/Kernel/app.cpp	(revision 1160)
@@ -611,7 +611,7 @@
 
 	//Graham 21/10/97: If it is blank, then we should use the
 	//exe path with "	emplates\" on the end
-	if( m_TemplatesPath.IsEmpty() || !wxDir::Exists( m_TemplatesPath ) )
+	if( m_TemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_TemplatesPath ) )
 	{
 		std::auto_ptr<char> Pathname( br_find_data_dir( "/usr/share" ) );
 
@@ -628,7 +628,7 @@
 		m_TemplatesPath+=strRelativePath;
 
 #if defined(_DEBUG)
-		if( !wxDir::Exists( m_TemplatesPath ) )
+		if( !SGLibOil::DirExists( m_TemplatesPath ) )
 			m_TemplatesPath = _T("/usr/share/xaralx/Templates/");
 #endif
 	}
Index: Trunk/XaraLX/Kernel/menuops.cpp
===================================================================
--- Trunk/XaraLX/Kernel/menuops.cpp	(revision 1159)
+++ Trunk/XaraLX/Kernel/menuops.cpp	(revision 1160)
@@ -500,20 +500,24 @@
 
 		strToReturn.toTitle();
 
+PORTNOTE("other", "Mangle file name to replace _'s with spaces")
+		strToReturn.SwapChar( _T('_'), _T(' ') );
+
 		*UIDescription=strToReturn;
 		
 		return OpState(FALSE, FALSE);
 	}
 
 	if (pOp->Token == String(OPTOKEN_FILENEW_ANIMATION))
-		
 	{
-		//Does the default animation template exist?
 PORTNOTE("other", "Remove template existance check - too annoying while it's not there!")
 #ifndef EXCLUDE_FROM_XARALX
+		//Does the default animation template exist?
 		PathName pathDefaultAnimationTemplate=GetDefaultAnimationTemplate();
 		BOOL fFileExists=SGLibOil::FileExists(&pathDefaultAnimationTemplate);
 
+		TRACEUSER( "jlh92", _T("Template Anim = %s, %d
"), PCTSTR(pathDefaultAnimationTemplate.GetPath()), fFileExists );
+
 		String_256 strToReturn=pathDefaultAnimationTemplate.GetFileName(FALSE);
 
 		if (strToReturn.IsEmpty())
@@ -527,7 +531,7 @@
 #endif
 
 		//If not, grey the menu item
-		return OpState(FALSE, !fFileExists);
+		return OpState(FALSE, !fFileExists, TRUE);
 	}
 
 	if (pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE1) ||
@@ -576,6 +580,7 @@
 
 			String_256 strPathOfDrawingTemplate=GetDefaultDrawingTemplate().GetPath(FALSE);
 			String_256 strPathOfAnimationTemplate=GetDefaultAnimationTemplate().GetPath(FALSE);
+			strPathOfDrawingTemplate.SwapChar( _T('_'), _T(' ') );
 			String_256 strPathOfFile;
 
 			TRACEUSER( "jlh92", _T("DefPath = %s, %s
"), PCTSTR(strPathOfDrawingTemplate),
@@ -597,7 +602,7 @@
 			}
 			FileUtil::StopFindingFiles();
 
-			if( iNumberOfTemplate >= setSortFilename.size() )
+			if( iNumberOfTemplate > INT32(setSortFilename.size()) )
 			{
 				// Don't allow any errors set while searching to propagate outside this scope
 				Error::ClearError();
@@ -609,7 +614,7 @@
 			{ /*Do nothing!*/ }
 
 			strNameOfFile = *iter;
-			TRACEUSER( "jlh92", _T("Final(%d) = %s
"), iNumberOfTemplate, PCTSTR(strPathOfFile) );
+			TRACEUSER( "jlh92", _T("Final(%d) = %s
"), iNumberOfTemplate, PCTSTR(strNameOfFile) );
 
 			//We've found a file. So strip the .xar from the name, as follows...
 			pathTemplates.SetFileNameAndType(strNameOfFile);
@@ -1298,35 +1303,23 @@
 		Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultDrawingFile"), &ms_strDefaultDrawingTemplate);
 	}
 
-PORTNOTETRACE("other","DocOps::Init - remove code to setup paths");
-#if !defined(EXCLUDE_FROM_XARALX)
 	if (ms_strDefaultAnimationTemplate==String_256(_T("")))
 	{
-		//Then assume it's the exe path with 	emplatesnimation.xar on the end
-		TCHAR Pathname[MAX_PATH];
+		String_256 strNameOfAnimationTemplate( _R(IDS_NEWTEMPLATES_DEFAULTANIMATIONFILE) );
+		String_256 strPathOfTemplate( GetApplication()->GetTemplatesPath() );
+		strPathOfTemplate += strNameOfAnimationTemplate;
 
-		if(GetModuleFileName(NULL, Pathname, MAX_PATH) == 0) //Should be in the winoil really
-			return FALSE;
-
-		// Put the path name into a string
-		String_256 strPathOfExe(Pathname);
-		PathName pathPathOfExe(strPathOfExe);
-
-		strPathOfExe = pathPathOfExe.GetLocation(TRUE);
-
-		//And add "templates\" to the end
-		String_256 strTemplatesDirectory(_R(IDS_NEWTEMPLATES_RELATIVEPATH));
-		String_256 strNameOfAnimationTemplate(_R(IDS_NEWTEMPLATES_DEFAULTANIMATIONFILE));
-
-		String_256 strPathOfTemplate=strPathOfExe;
-		strPathOfTemplate+=strTemplatesDirectory;
-		strPathOfTemplate+=strNameOfAnimationTemplate;
-
 		ms_strDefaultAnimationTemplate=strPathOfTemplate;
+
+		TRACEUSER( "jlh92", _T("DefAnimTempl = %s
"), PCTSTR(ms_strDefaultAnimationTemplate) );
 	}
 
 	if (ms_strDefaultDrawingTemplate==String_256(_T("")))
 	{
+		ms_strDefaultDrawingTemplate=String_256(_R(IDS_DEFAULTDOCNAME));
+
+PORTNOTETRACE("other","DocOps::Init - remove code to setup paths");
+#if !defined(EXCLUDE_FROM_XARALX)
 		//Then assume it's the exe path with 	emplates\drawing.xar on the end
 		TCHAR Pathname[MAX_PATH];
 
@@ -1348,18 +1341,8 @@
 		strPathOfTemplate+=strNameOfDrawingTemplate;
 
 		ms_strDefaultDrawingTemplate=strPathOfTemplate;
-	}
-#else
-	if (ms_strDefaultAnimationTemplate==String_256(_T("")))
-	{
-		ms_strDefaultAnimationTemplate=String_256(_T("animation.xar"));
-	}
-
-	if (ms_strDefaultDrawingTemplate==String_256(_T("")))
-	{
-		ms_strDefaultDrawingTemplate=String_256(_T("default.xar"));
-	}
 #endif
+	}
 	
 	return TRUE;
 }
Index: Trunk/XaraLX/Kernel/filelist.cpp
===================================================================
--- Trunk/XaraLX/Kernel/filelist.cpp	(revision 1159)
+++ Trunk/XaraLX/Kernel/filelist.cpp	(revision 1160)
@@ -293,6 +293,8 @@
 	camStrncpy(FileNum, pOpDesc->Token, 2);
 	FileNum[2] = 0;
 
+	TRACEUSER( "jlh92", _T("Op = %s
"), FileNum );
+
 	// make sure that it contains digits.
 	if (isdigit(FileNum[0]) && isdigit(FileNum[1]))
 	{
@@ -300,6 +302,8 @@
 		TCHAR *pszMark;
 		INT32 RecentFileNum = camStrtol( FileNum, &pszMark, 10 );
 
+		TRACEUSER( "jlh92", _T("Recent = %d
"), RecentFileNum );
+
 		// Ask the app to load the file specified (it will look up the file name etc)
 		WorkedOK = AfxGetApp().OnRecentFile(RecentFileNum-1);
 		CCamDoc::EnableRemoveUntouchedDocs();
Index: Trunk/XaraLX/wxOil/menucmds.cpp
===================================================================
--- Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1159)
+++ Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1160)
@@ -278,6 +278,7 @@
 
 		String_256 strPathOfDrawingTemplate=DocOps::GetDefaultDrawingTemplate().GetPath(FALSE);
 		String_256 strPathOfAnimationTemplate=DocOps::GetDefaultAnimationTemplate().GetPath(FALSE);
+		strPathOfDrawingTemplate.SwapChar( _T('_'), _T(' ') );
 		
 		std::set<String_256>	setSortFilename;
 
@@ -294,7 +295,7 @@
 		}
 		FileUtil::StopFindingFiles();
 
-		if( iNumberOfTemplate >= (INT32)setSortFilename.size() )
+		if( iNumberOfTemplate > (INT32)setSortFilename.size() )
 		{
 			//We failed to find a template. So remove this
 			//item from the menu.
Index: Trunk/XaraLX/wxOil/sgliboil.h
===================================================================
--- Trunk/XaraLX/wxOil/sgliboil.h	(revision 1159)
+++ Trunk/XaraLX/wxOil/sgliboil.h	(revision 1160)
@@ -239,6 +239,7 @@
 	static INT32 FileSize(PathName *FileName);
 	static BOOL FileDelete(PathName *FileName);
  	static UINT32 FileModified(PathName *FileName);
+	static BOOL DirExists( const PathName &FileName );
 	static BOOL IsRootDirectory(String_256 *Path);
 	static void AppendSlashIfNotPresent(String_256 *Str);
 	static DWORD GetDriveSerialNumber(String_256 *PathStr);
Index: Trunk/XaraLX/wxOil/sgliboil.cpp
===================================================================
--- Trunk/XaraLX/wxOil/sgliboil.cpp	(revision 1159)
+++ Trunk/XaraLX/wxOil/sgliboil.cpp	(revision 1160)
@@ -1268,32 +1268,43 @@
 
 BOOL SGLibOil::FileExists(PathName *FileName)
 {
-	PORTNOTETRACE("dialog","SGLibOil::FileExists - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
-	ERROR3IF(FileName == NULL || !FileName->IsValid(), "SGLibOil::FileExists problem with filename");
+	return wxFile::Exists( PCTSTR(FileName->GetPath()) );
 
-	// Do we have read access on file ?
+#if 0
+	CCDiskFile File;
+	BOOL OldTEState = File.SetThrowExceptions(FALSE);
+	BOOL OldREState = File.SetReportErrors(FALSE);
 	BOOL Found = FALSE;
+	 
+	// Open file - returns false if there was an error (file doesn't exist)
+	Found = File.open(FileName->GetPath(), ios::in | ios::binary | ios::nocreate);
+	if(Found) File.close();
+		
+	File.SetThrowExceptions(OldTEState);
+	File.SetReportErrors(OldREState);
+ 	Error::ClearError();
 
-	try
-	{
-		INT32 Value = _taccess( (const TCHAR *)FileName->GetPath(), ios::in );
-		if(Value == 0)
-			Found = TRUE;
-	}
-	catch( ... )
-	{
-		// File probably not found due to exception.
-		// This can be caused by stuff such as disks not in drives, invalid pathnames...
-		Found = FALSE;
-		Error::ClearError();
-	}
-
 	return Found;
-#else
-	return TRUE;
 #endif
+}
 
+/***********************************************************************************************
+
+>	static BOOL SGLibOil::DirExists(PathName *FileName)
+
+	Author:		Luke Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+	Created:	21/05/06
+	Inputs:		File - Pointer to path and filename of dir
+	Returns:	Returns true if the specified dir exists
+	Purpose:	To find out whether a dir actually exists.
+	Notes:
+
+***********************************************************************************************/
+
+BOOL SGLibOil::DirExists( const PathName& FileName )
+{
+	return wxDir::Exists( PCTSTR(FileName.GetPath()) );
+
 #if 0
 	CCDiskFile File;
 	BOOL OldTEState = File.SetThrowExceptions(FALSE);
@@ -1312,7 +1323,6 @@
 #endif
 }
 
-
 /***********************************************************************************************
 
 >	static INT32 SGLibOil::FileSize(PathName *FileName)
Index: Trunk/XaraLX/wxOil/camelot.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camelot.cpp	(revision 1159)
+++ Trunk/XaraLX/wxOil/camelot.cpp	(revision 1160)
@@ -879,45 +879,24 @@
 
 bool CCamApp::OnRecentFile(INT32 RecentFileNumber)
 {
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
-	// Go and Find out about the File Number (m_pRecentFileList)
-	if (pFileList!=NULL)
+	wxFileHistory*	pFileHist = m_docManager->GetFileHistory();
+
+	if( RecentFileNumber < INT32(pFileHist->GetCount()) )
 	{
-		if (pFileList->GetSize() > RecentFileNumber)
-		{
-			// Go get the requested file out of the file list
-			CString FileName;
-			FileName = pFileList->GetFileName(RecentFileNumber);
+		wxString	FileName( pFileHist->GetHistoryFile( RecentFileNumber ) );
 
-			// We do not know what type of filter to use for this file, so get it to try them all
-			OpenFileDialog::SelectedFilter = 0;
-
-			// Get the App to open the File
-			if (!FileName.IsEmpty())
-			{
-				// See if we got a document out of the deal
-				CDocument* pDoc = OpenDocumentFile(FileName);
-				if (pDoc!=NULL)
-				{
-					// Get the filename as a proper path
-					PathName Path((const char*)FileName);
-
-					// Make sure that the files name is sensible
-					MakeDocumentNative(pDoc, &Path);
-
-					// add it to the recent file list
-					// This actually moves it to the top of the list
-					AddToRecentFileList((const char*)FileName);
-
-					return TRUE;
-				}
-			}
+		// Get the App to open the File
+		if (!FileName.IsEmpty())
+		{
+			// See if we got a document out of the deal
+			wxDocument* pDoc = m_docManager->CreateDocument( FileName, wxDOC_SILENT );
+			if( pDoc != NULL )
+				return true;
 		}
 	}
-#endif
 
-	// failed
-	return false;
+	// Failed to find an entry for this item
+	return false;	
 }
 
 
Index: Trunk/XaraLX/wxOil/xrc/EN/rik-strings.xrc
===================================================================
--- Trunk/XaraLX/wxOil/xrc/EN/rik-strings.xrc	(revision 1159)
+++ Trunk/XaraLX/wxOil/xrc/EN/rik-strings.xrc	(revision 1160)
@@ -457,7 +457,7 @@
 			<object class="sizeritem">
 				<flag>wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
 				<object class="wxStaticText" name="IDS_DEFAULTDOCNAME">
-					<label>800 by 600 drawing.xar</label>
+					<label>800_by_600_drawing.xar</label>
 				</object>
 			</object>
 			<object class="sizeritem">
Index: Trunk/XaraLX/wxOil/xrc/800_by_600_drawing.xar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: Trunk/XaraLX/wxOil/xrc/800_by_600_drawing.xar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Index: Trunk/XaraLX/wxOil/xrc/default.xar (deleted)
===================================================================


Xara