[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : luke
Repository : xara
Revision : 1461
Date : Tue Jul 18 10:50:42 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/app.cpp
M /Trunk/XaraLX/Kernel/app.h
M /Trunk/XaraLX/Kernel/menuops.cpp
M /Trunk/XaraLX/Kernel/menuops.h
M /Trunk/XaraLX/Kernel/nativeop.cpp
M /Trunk/XaraLX/wxOil/Makefile.am
M /Trunk/XaraLX/wxOil/camdoc.cpp
M /Trunk/XaraLX/wxOil/fileutil.cpp
M /Trunk/XaraLX/wxOil/fileutil.h
M /Trunk/XaraLX/wxOil/giffiltr.cpp
M /Trunk/XaraLX/wxOil/menucmds.cpp
A /Trunk/XaraLX/wxOil/tmplmngr.cpp
A /Trunk/XaraLX/wxOil/tmplmngr.h
Add support for a user local template directory. Also relationalise template code into 1 class / file
Diff:
Index: Trunk/XaraLX/Kernel/menuops.h
===================================================================
--- Trunk/XaraLX/Kernel/menuops.h (revision 1460)
+++ Trunk/XaraLX/Kernel/menuops.h (revision 1461)
@@ -405,12 +405,7 @@
void Do(OpDescriptor*); // "Do" function
-public:
- static String_256 ms_strDefaultAnimationTemplate;
- static String_256 ms_strDefaultDrawingTemplate;
- static PathName GetDefaultAnimationTemplate();
- static PathName GetDefaultDrawingTemplate();
};
Index: Trunk/XaraLX/Kernel/app.cpp
===================================================================
--- Trunk/XaraLX/Kernel/app.cpp (revision 1460)
+++ Trunk/XaraLX/Kernel/app.cpp (revision 1461)
@@ -144,6 +144,7 @@
//#include "plugmngr.h" // Plug-in Manager
#include "filtrmgr.h" // Filter Manager
#include "tmpltarg.h" // WizOp(s)
+#include "tmplmngr.h"
#include "noisebas.h"
#ifdef AUTOMATION
@@ -164,19 +165,6 @@
Application Camelot;
-/********************************************************************************************
-
- Preference: Path
- Section: Templates
- Range: 0 .. 256 characters
- Purpose: The path to load the templates from and save the templates to.
- Defaults to blank which means alongside the exe.
- SeeAlso: CCamDoc::LoadDefaultDocument; OpMenuSave::Do;
-
-********************************************************************************************/
-
-String_256 Application::m_TemplatesPath = TEXT("");
-
/***********************************************************************************************
> Application::Application()
@@ -194,7 +182,7 @@
***********************************************************************************************/
-Application::Application()
+Application::Application() : m_pTemplateManager( new CTemplateManager )
{
// WEBSTER - markn 25/4/97
// No pen stuff required in Webster
@@ -606,34 +594,8 @@
return FALSE;
#endif // PLUGINSUPPORT
- // As the preference system is up, declare our preference to it
- // This is the pathname that the templates should be loaded from and saved to
- // If blank, the default, then it should use the exe path
- GetApplication()->DeclareSection(TEXT("Templates"), 2);
- GetApplication()->DeclarePref(TEXT("Templates"), TEXT("Path"), &m_TemplatesPath);
+ m_pTemplateManager->Init();
- //Graham 21/10/97: If it is blank, then we should use the
- //exe path with " emplates\" on the end
- if( m_TemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_TemplatesPath ) )
- {
- // Put the path name into a string
- PathName ModulePath( CCamApp::GetResourceDirectory() );
-
- m_TemplatesPath = ModulePath.GetLocation(TRUE);
-
- //And add "templates\" to the end
- String_256 strRelativePath(_R(IDS_NEWTEMPLATES_RELATIVEPATH));
-
- m_TemplatesPath+=strRelativePath;
-
-#if defined(_DEBUG)
- if( !SGLibOil::DirExists( m_TemplatesPath ) )
- m_TemplatesPath = _T("/usr/share/xaralx/Templates/");
-#endif
- }
-
- TRACEUSER( "jlh92", _T("Using %s as template store
"), PCTSTR(m_TemplatesPath) );
-
// Everything went ok
return TRUE;
}
@@ -1841,46 +1803,6 @@
}
-/***********************************************************************************************
-
-> String_256& Application::GetTemplatesPath()
-
- Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 03/03/97
- Inputs: -
- Outputs: -
- Returns: The specfied templates path in a string
- Purpose: To find out the user's preference for a path to the template file.
- SeeAlso: CCamDoc::LoadDefaultDocument; OpMenuSave::Do;
-
-***********************************************************************************************/
-
-String_256& Application::GetTemplatesPath()
-{
- // Add a trailing slash if it hasn't got one
- SGLibOil::AppendSlashIfNotPresent(&m_TemplatesPath);
-
- return m_TemplatesPath;
-}
-
-/***********************************************************************************************
-
-> void Application::SetTemplatesPath(String_256& strToSet)
-
- Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 28/20/97
- Inputs: strToSet - the new value
- Returns: -
- Purpose: To set the default templates path
- SeeAlso: -
-
-***********************************************************************************************/
-
-void Application::SetTemplatesPath(String_256& strToSet)
-{
- m_TemplatesPath=strToSet;
-}
-
/********************************************************************************************
> void DocView::RegenerateNodesInList()
Index: Trunk/XaraLX/Kernel/nativeop.cpp
===================================================================
--- Trunk/XaraLX/Kernel/nativeop.cpp (revision 1460)
+++ Trunk/XaraLX/Kernel/nativeop.cpp (revision 1461)
@@ -119,6 +119,8 @@
//#include "filtrres.h" // New native filter strings
//#include "fixmem.h" // CCFree - in camtypes.h [AUTOMATICALLY REMOVED]
#include "bubbleid.h"
+#include "tmplmngr.h"
+#include "fileutil.h"
#include "camdoc.h" // for CCamDoc::GetTemplateFilename
//#include "justin3.h" // for _R(IDS_SAVE_AS_DEFAULT_EMBEDDED)
@@ -491,13 +493,16 @@
}
//And we'll need a pointer to the application
- Application* pCamelot=GetApplication();
+ Application* pCamelot = GetApplication();
+ CTemplateManager& TemplateManager( pCamelot->GetTemplateManager() );
//And put the default templates path in the dialog
- PathName pathToPutInDialog=pCamelot->GetTemplatesPath();
+ PathName pathToPutInDialog = TemplateManager.GetTemplatesPath();
+
+ FileUtil::RecursiveCreateDirectory( pathToPutInDialog.GetPath() );
//Now create the dialog
- SaveTemplateDialog dialogToDisplay(pathToPutInDialog);
+ SaveTemplateDialog dialogToDisplay(pathToPutInDialog);
//And show it
if (dialogToDisplay.ShowModal() == wxID_OK)
@@ -532,18 +537,18 @@
{
if (pdocToSave->IsAnimated())
{
- DocOps::ms_strDefaultAnimationTemplate=strPathToSaveTo;
+ CTemplateManager::SetDefaultAnimationTemplate( strPathToSaveTo );
}
else
{
- DocOps::ms_strDefaultDrawingTemplate=strPathToSaveTo;
+ CTemplateManager::SetDefaultDrawingTemplate( strPathToSaveTo );
}
}
if (SaveTemplateDialog::m_fDefaultTemplatesFolder)
{
- String_256 strDefaultPath=pathToSaveTo.GetLocation(TRUE);
- pCamelot->SetTemplatesPath(strDefaultPath);
+ String_256 strDefaultPath = pathToSaveTo.GetLocation( TRUE );
+ CTemplateManager::SetTemplatesPath( strDefaultPath );
}
}
Index: Trunk/XaraLX/Kernel/menuops.cpp
===================================================================
--- Trunk/XaraLX/Kernel/menuops.cpp (revision 1460)
+++ Trunk/XaraLX/Kernel/menuops.cpp (revision 1461)
@@ -165,8 +165,8 @@
//#include "registry.h"
//#include "register.h"
//#include "liveeffectres.h"
+#include "tmplmngr.h"
-
#if (_OLE_VER >= 0x200)
#include "srvritem.h"
#endif
@@ -264,34 +264,9 @@
ERRORIF(!Blobby, _R(IDE_NOMORE_MEMORY), FALSE);\
}
-/********************************************************************************************
- Preference: DefaultAnimationTemplate
- Section: Templates
- Range: String
- Purpose: The path to the default animation template. By default, this
- is the EXE path with " emplatesnimation.xar" added to the end
- SeeAlso: -
-********************************************************************************************/
-String_256 DocOps::ms_strDefaultAnimationTemplate = _T("");
-
-/********************************************************************************************
-
- Preference: DefaultDrawingTemplate
- Section: Templates
- Range: String
- Purpose: The path to the default drawing template. By default, this
- is the EXE path with " emplates\drawing.xar" added to the end
- SeeAlso: -
-
-********************************************************************************************/
-
-String_256 DocOps::ms_strDefaultDrawingTemplate = _T("");
-
-
-
CC_IMPLEMENT_DYNCREATE (DocOps, Operation)
CC_IMPLEMENT_DYNCREATE (MenuPopupOps, Operation)
CC_IMPLEMENT_DYNCREATE (HelpOps, Operation)
@@ -491,7 +466,7 @@
//We need to change the name of the command to the name of the
//default template file, converted so the first character
//is upper case and the rest is lower
- PathName pathDefaultDrawingTemplate=GetDefaultDrawingTemplate();
+ PathName pathDefaultDrawingTemplate = CTemplateManager::GetDefaultDrawingTemplate();
String_256 strToReturn=pathDefaultDrawingTemplate.GetFileName(FALSE);
@@ -545,91 +520,34 @@
pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE9) ||
pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE10))
{
- //First find the default template path
- Application* pApplication=GetApplication();
-
- PathName pathTemplates=pApplication->GetTemplatesPath();
-
- //Now search that path for templates
- //Start by setting the leaf name to *.xar
- String_256 strSearchFilename(_R(IDS_NEWTEMPLATES_DEFAULTTEMPLATEEXTENSION));
-
- pathTemplates.SetFileNameAndType(strSearchFilename);
-
//Now find out which template in that path we want
//(This code isn't particularly pleasant)
- String_256 strNumberOfTemplate;
-
- INT32 iPositionOfFCharacter=pOp->Token.FindNextChar( 'F', 0 );
+ INT32 iPositionOfFCharacter = pOp->Token.FindNextChar( 'F', 0 );
TRACEUSER( "jlh92", _T("Token = %s(%d)
"), PCTSTR(pOp->Token), iPositionOfFCharacter );
-
- pOp->Token.Left(&strNumberOfTemplate, iPositionOfFCharacter);
+ String_256 strNumberOfTemplate;
+ pOp->Token.Left( &strNumberOfTemplate, iPositionOfFCharacter );
- TCHAR* pszTmp;
- INT32 iNumberOfTemplate = camStrtol( (TCHAR *)strNumberOfTemplate, &pszTmp, 10 );
+ // Convert the template ordinal into the template name
+ TCHAR* pszTmp;
+ INT32 iNumberOfTemplate = camStrtol( (TCHAR *)strNumberOfTemplate, &pszTmp, 10 );
+ String_256 strNameOfFile;
+ CTemplateManager& TemplateManager( GetApplication()->GetTemplateManager() );
+ bool fSuccess = TemplateManager.GetTemplateFilename( iNumberOfTemplate, &strNameOfFile );
- //And search the path for xar files that are
- //NOT the default animation or drawing templates
- String_256 strTemplates=pathTemplates.GetPath(FALSE);
- if (FileUtil::StartFindingFiles(&strTemplates))
- {
- String_256 strNameOfFile;
- PathName pathOfFile=pathTemplates;
+ // Don't allow any errors set while searching to propagate outside this scope
+ Error::ClearError();
- TRACEUSER( "jlh92", _T("SFF = true
") );
+ // Tell the menu item to remove itsled if we don't have the template
+ if( !fSuccess )
+ return OpState(FALSE, FALSE, TRUE);
- String_256 strPathOfDrawingTemplate=GetDefaultDrawingTemplate().GetPath(FALSE);
- String_256 strPathOfAnimationTemplate=GetDefaultAnimationTemplate().GetPath(FALSE);
- strPathOfDrawingTemplate.SwapChar( _T('_'), _T(' ') );
- String_256 strPathOfFile;
+ //We've found a file. So strip the .xar from the name and capitalize, as follows...
+ PathName pathTemplates;
+ pathTemplates.SetFileNameAndType( strNameOfFile );
+ *UIDescription = pathTemplates.GetFileName(FALSE);
+ UIDescription->toTitle();
- TRACEUSER( "jlh92", _T("DefPath = %s, %s
"), PCTSTR(strPathOfDrawingTemplate),
- PCTSTR(strPathOfAnimationTemplate) );
-
- std::set<String_256> setSortFilename;
-
- while( FileUtil::FindNextFile( &strNameOfFile ) )
- {
- pathOfFile.SetFileNameAndType(strNameOfFile);
- strPathOfFile=pathOfFile.GetFileName(TRUE);
-
- if( 0 != strPathOfFile.CompareTo( strPathOfDrawingTemplate, FALSE ) &&
- 0 != strPathOfFile.CompareTo( strPathOfAnimationTemplate, FALSE ) )
- {
- setSortFilename.insert( strPathOfFile );
- TRACEUSER( "jlh92", _T("Curr = %s
"), PCTSTR(strPathOfFile) );
- }
- }
- FileUtil::StopFindingFiles();
-
- if( iNumberOfTemplate > INT32(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(strNameOfFile) );
-
- //We've found a file. So strip the .xar from the name, as follows...
- pathTemplates.SetFileNameAndType(strNameOfFile);
- *UIDescription=pathTemplates.GetFileName(FALSE);
-
- UIDescription->toTitle();
-
- // Don't allow any errors set while searching to propagate outside this scope
- Error::ClearError();
-
- return OpState(FALSE, FALSE, FALSE);
- }
-
- // Don't allow any errors set while searching to propagate outside this scope
- Error::ClearError();
+ return OpState(FALSE, FALSE, FALSE);
}
// File/SaveAll is only available if there is a document that is "dirty".
@@ -1295,106 +1213,12 @@
TRUE // Recieve system messages
);
ERRORIF(!ok, _R(IDE_NOMORE_MEMORY), FALSE);
-
- //Graham 20/10/97
- if (Camelot.DeclareSection( _T("NewTemplates"), 10))
- {
- Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultAnimationFile"), &ms_strDefaultAnimationTemplate);
- Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultDrawingFile"), &ms_strDefaultDrawingTemplate);
- }
-
- if (ms_strDefaultAnimationTemplate==String_256(_T("")))
- {
- String_256 strNameOfAnimationTemplate( _R(IDS_NEWTEMPLATES_DEFAULTANIMATIONFILE) );
- String_256 strPathOfTemplate( GetApplication()->GetTemplatesPath() );
- strPathOfTemplate += strNameOfAnimationTemplate;
-
- ms_strDefaultAnimationTemplate=strPathOfTemplate;
-
- TRACEUSER( "jlh92", _T("DefAnimTempl = %s
"), PCTSTR(ms_strDefaultAnimationTemplate) );
- }
-
- if( ms_strDefaultDrawingTemplate == String_256( _T("") ) ||
- 0 == camStrcmp( ms_strDefaultDrawingTemplate, _T("default.xar") ) )
- {
- 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];
-
- 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 strNameOfDrawingTemplate(_R(IDS_DEFAULTDOCNAME));
-
- String_256 strPathOfTemplate=strPathOfExe;
- strPathOfTemplate+=strTemplatesDirectory;
- strPathOfTemplate+=strNameOfDrawingTemplate;
-
- ms_strDefaultDrawingTemplate=strPathOfTemplate;
-#endif
- }
return TRUE;
}
-/********************************************************************************************
-> PathName DocOps::GetDefaultAnimationTemplate()
- Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 23/10/97
- Inputs: -
- Outputs: -
- Returns: The path of the default animation template
- Purpose: As above
- Errors: -
- SeeAlso: -
-
-********************************************************************************************/
-
-PathName DocOps::GetDefaultAnimationTemplate()
-{
- PathName pathToReturn=ms_strDefaultAnimationTemplate;
-
- return pathToReturn;
-}
-
-/********************************************************************************************
-
-> PathName DocOps::GetDefaultDrawingTemplate()
-
- Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 23/10/97
- Inputs: -
- Outputs: -
- Returns: The path of the default drawing template
- Purpose: As above
- Errors: -
- SeeAlso: -
-
-********************************************************************************************/
-
-PathName DocOps::GetDefaultDrawingTemplate()
-{
- PathName pathToReturn=ms_strDefaultDrawingTemplate;
-
- return pathToReturn;
-}
-
-
-
-
//********************************************************************************************
// HELP USING & HELP INDEX OPERATION
Index: Trunk/XaraLX/Kernel/app.h
===================================================================
--- Trunk/XaraLX/Kernel/app.h (revision 1460)
+++ Trunk/XaraLX/Kernel/app.h (revision 1461)
@@ -136,6 +136,7 @@
class ConcurrencyController;
class WizOps;
class CBitmapCache;
+class CTemplateManager;
#define FONTMANAGER (GetApplication()->GetFontManager())
#define NOISEMANAGER (GetApplication()->GetNoiseManager())
@@ -447,17 +448,15 @@
// Temporary
StatusLine* m_pStatusLine;
- // At some point this may well go to a template manager but for the present
- // moment the most logical places is here as loading is in CCamDoc and saving
- // is in OpMenuSave::Do.
- static String_256 m_TemplatesPath;
+ std::auto_ptr<CTemplateManager> m_pTemplateManager;
public:
- // Public access to the user's defined template path
- String_256& GetTemplatesPath();
- void SetTemplatesPath(String_256& strToSet);
+ // Public access to the template manager
+ CTemplateManager& GetTemplateManager()
+ {
+ return *m_pTemplateManager.get();
+ }
-
// return a pointer to the objectcache
ObjectCache* GetObjectCache();
Index: Trunk/XaraLX/wxOil/menucmds.cpp
===================================================================
--- Trunk/XaraLX/wxOil/menucmds.cpp (revision 1460)
+++ Trunk/XaraLX/wxOil/menucmds.cpp (revision 1461)
@@ -136,6 +136,7 @@
#include "rechblnd.h" // so that can reset blend pointers
//#include "urls.h"
#include "filedlgs.h"
+#include "tmplmngr.h"
DECLARE_SOURCE("$Revision$");
#define THIRTY_TWO 32
@@ -197,7 +198,7 @@
{
//First tell the document system that the next template to use is the
//default animation template
- CCamDoc::SetNextTemplateToUse(DocOps::GetDefaultDrawingTemplate());
+ CCamDoc::SetNextTemplateToUse( CTemplateManager::GetDefaultDrawingTemplate() );
// OnFileOpen needs an event, but doesn't use it
wxCommandEvent event;
@@ -226,7 +227,7 @@
{
//First tell the document system that the next template to use is the
//default animation template
- CCamDoc::SetNextTemplateToUse(DocOps::GetDefaultAnimationTemplate());
+ CCamDoc::SetNextTemplateToUse( CTemplateManager::GetDefaultAnimationTemplate() );
PORTNOTETRACE("other", "FileNewAnimationAction does nothing");
#if !defined(EXCLUDE_FROM_XARALX)
@@ -254,69 +255,16 @@
void FileNewTemplateAction(INT32 iNumberOfTemplate)
{
- //First we must find the name of the template to use
-
- //So search through the templates directory
- String_256 strSearchFilename(_R(IDS_NEWTEMPLATES_DEFAULTTEMPLATEEXTENSION));
-
//First find the default template path
- Application* pApplication=GetApplication();
+ CTemplateManager& TemplateManager = GetApplication()->GetTemplateManager();
+ String_256 strPathOfFile;
+ if( !TemplateManager.GetTemplateFilename( iNumberOfTemplate, &strPathOfFile ) )
+ return;
- PathName pathTemplates=pApplication->GetTemplatesPath();
-
- pathTemplates.SetFileNameAndType(strSearchFilename);
-
- //And search the path for xar files that are
- //NOT the default animation or drawing templates
- String_256 strTemplates=pathTemplates.GetPath(FALSE);
-
- String_256 strPathOfFile;
-
-
- if (FileUtil::StartFindingFiles(&strTemplates))
- {
- String_256 strNameOfFile;
- PathName pathOfFile=pathTemplates;
-
- String_256 strPathOfDrawingTemplate=DocOps::GetDefaultDrawingTemplate().GetPath(FALSE);
- String_256 strPathOfAnimationTemplate=DocOps::GetDefaultAnimationTemplate().GetPath(FALSE);
- strPathOfDrawingTemplate.SwapChar( _T('_'), _T(' ') );
-
- std::set<String_256> setSortFilename;
-
- while( FileUtil::FindNextFile( &strNameOfFile ) )
- {
- pathOfFile.SetFileNameAndType(strNameOfFile);
- strPathOfFile=pathOfFile.GetFileName(TRUE);
-
- if( 0 != strPathOfFile.CompareTo( strPathOfDrawingTemplate, FALSE ) &&
- 0 != strPathOfFile.CompareTo( strPathOfAnimationTemplate, FALSE ) )
- {
- setSortFilename.insert( strPathOfFile );
- }
- }
- FileUtil::StopFindingFiles();
-
- if( iNumberOfTemplate > (INT32)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( strPathOfFile );
- CCamDoc::SetNextTemplateToUse(pathTemplates);
-
// OnFileOpen needs an event, but doesn't use it
wxCommandEvent event;
AfxGetApp().GetDocumentManager()->OnFileNew( event );
Index: Trunk/XaraLX/wxOil/Makefile.am
===================================================================
--- Trunk/XaraLX/wxOil/Makefile.am (revision 1460)
+++ Trunk/XaraLX/wxOil/Makefile.am (revision 1461)
@@ -37,7 +37,7 @@
camprocess.cpp dropdown.cpp coldrop.cpp fontdrop.cpp bfxalu.cpp bfxpixop.cpp \
binreloc.c exceptio.cpp colpick.cpp dragpick.cpp sgldrag.cpp cctime.cpp \
lddirect.cpp prncamvw.cpp prdlgctl.cpp psdc.cpp grndprnt.cpp printprg.cpp \
- oilruler.cpp bitmapdropdown.cpp helptabs.cpp imgmgkft.cpp ppmfiltr.cpp \
+ oilruler.cpp bitmapdropdown.cpp helptabs.cpp tmplmngr.cpp imgmgkft.cpp ppmfiltr.cpp \
resources.cpp
# Keep resources.cpp on a separate line as it is odd
Index: Trunk/XaraLX/wxOil/tmplmngr.h
===================================================================
--- Trunk/XaraLX/wxOil/tmplmngr.h (revision 0)
+++ Trunk/XaraLX/wxOil/tmplmngr.h (revision 1461)
@@ -0,0 +1,146 @@
+// $Id: app.h 1361 2006-06-25 16:43:38Z alex $
+/* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
+================================XARAHEADERSTART===========================
+
+ Xara LX, a vector drawing and manipulation program.
+ Copyright (C) 1993-2006 Xara Group Ltd.
+ Copyright on certain contributions may be held in joint with their
+ respective authors. See AUTHORS file for details.
+
+LICENSE TO USE AND MODIFY SOFTWARE
+----------------------------------
+
+This file is part of Xara LX.
+
+Xara LX is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 as published
+by the Free Software Foundation.
+
+Xara LX and its component source files are distributed in the hope
+that it will be useful, but WITHOUT ANY WARRANTY; without even the
+implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with Xara LX (see the file GPL in the root directory of the
+distribution); if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+ADDITIONAL RIGHTS
+-----------------
+
+Conditional upon your continuing compliance with the GNU General Public
+License described above, Xara Group Ltd grants to you certain additional
+rights.
+
+The additional rights are to use, modify, and distribute the software
+together with the wxWidgets library, the wxXtra library, and the "CDraw"
+library and any other such library that any version of Xara LX relased
+by Xara Group Ltd requires in order to compile and execute, including
+the static linking of that library to XaraLX. In the case of the
+"CDraw" library, you may satisfy obligation under the GNU General Public
+License to provide source code by providing a binary copy of the library
+concerned and a copy of the license accompanying it.
+
+Nothing in this section restricts any of the rights you have under
+the GNU General Public License.
+
+
+SCOPE OF LICENSE
+----------------
+
+This license applies to this program (XaraLX) and its constituent source
+files only, and does not necessarily apply to other Xara products which may
+in part share the same code base, and are subject to their own licensing
+terms.
+
+This license does not apply to files in the wxXtra directory, which
+are built into a separate library, and are subject to the wxWindows
+license contained within that directory in the file "WXXTRA-LICENSE".
+
+This license does not apply to the binary libraries (if any) within
+the "libs" directory, which are subject to a separate license contained
+within that directory in the file "LIBS-LICENSE".
+
+
+ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
+----------------------------------------------
+
+Subject to the terms of the GNU Public License (see above), you are
+free to do whatever you like with your modifications. However, you may
+(at your option) wish contribute them to Xara's source tree. You can
+find details of how to do this at:
+ http://www.xaraxtreme.org/developers/
+
+Prior to contributing your modifications, you will need to complete our
+contributor agreement. This can be found at:
+ http://www.xaraxtreme.org/developers/contribute/
+
+Please note that Xara will not accept modifications which modify any of
+the text between the start and end of this header (marked
+XARAHEADERSTART and XARAHEADEREND).
+
+
+MARKS
+-----
+
+Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
+designs are registered or unregistered trademarks, design-marks, and/or
+service marks of Xara Group Ltd. All rights in these marks are reserved.
+
+
+ Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+ http://www.xara.com/
+
+=================================XARAHEADEREND============================
+ */
+
+#ifndef INC_TEMPLATE_MANAGER
+#define INC_TEMPLATE_MANAGER
+
+/*********************************************************************************************
+
+> class CTemplateManager
+
+ Author: Luke_Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+ Created: 17/07/2006
+ Base Class: None
+ Purpose:
+ Errors: None.
+
+*********************************************************************************************/
+
+class CCAPI CTemplateManager
+{
+public:
+ CTemplateManager();
+ ~CTemplateManager();
+
+ BOOL Init();
+
+ // Public access to the user's defined template path
+ static String_256& GetTemplatesPath();
+ static void SetTemplatesPath(String_256& strToSet);
+
+ bool GetTemplateMenuName( UINT32 ordNumberOfTemplate, String_256* pStrPathOfFile );
+ bool GetTemplateFilename( UINT32 ordNumberOfTemplate, String_256* pStrPathOfFile );
+
+ static PathName GetDefaultAnimationTemplate();
+ static void SetDefaultAnimationTemplate( const String_256& strPath ) { ms_strDefaultAnimationTemplate = strPath; }
+ static PathName GetDefaultDrawingTemplate();
+ static void SetDefaultDrawingTemplate( const String_256& strPath ) { ms_strDefaultDrawingTemplate = strPath; }
+
+private:
+ static String_256 m_TemplatesPath;
+ static String_256 m_LocalTemplatesPath;
+
+ static String_256 ms_strDefaultAnimationTemplate;
+ static String_256 ms_strDefaultDrawingTemplate;
+
+ typedef std::map<String_256, bool> CTemplateList;
+ void GetTemplateList( CTemplateList* pList, const String_256& strTemplatePath, bool fLocal );
+};
+
+#endif
+
Index: Trunk/XaraLX/wxOil/giffiltr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/giffiltr.cpp (revision 1460)
+++ Trunk/XaraLX/wxOil/giffiltr.cpp (revision 1461)
@@ -139,6 +139,7 @@
#include "selall.h" // For OPTOKEN_EDITSELECTALL
#include "bmpprefs.h"
//#include "animparams.h" - in camtypes.h [AUTOMATICALLY REMOVED]
+#include "tmplmngr.h"
DECLARE_SOURCE("$Revision$");
@@ -2536,7 +2537,7 @@
BOOL TI_GIFFilter::IsDefaultDocRequired(const TCHAR* pcszPathName)
{
//Tell the system to use the default animation template
- CCamDoc::SetNextTemplateToUse(DocOps::GetDefaultAnimationTemplate());
+ CCamDoc::SetNextTemplateToUse( CTemplateManager::GetDefaultAnimationTemplate() );
return TRUE;
}
Index: Trunk/XaraLX/wxOil/fileutil.h
===================================================================
--- Trunk/XaraLX/wxOil/fileutil.h (revision 1460)
+++ Trunk/XaraLX/wxOil/fileutil.h (revision 1461)
@@ -144,6 +144,8 @@
static BOOL SetCurrentDirectory(const PathName& NewCurrentPath);
static BOOL SetCurrentDirectory(const String_256& NewCurrentPath);
+ static BOOL RecursiveCreateDirectory( const String_256& strDirPath );
+
//A straightforward wrapper for the MFC function GetFileAttributes
static DWORD FindFileAttributes(LPCTSTR lpFileName)
{
Index: Trunk/XaraLX/wxOil/camdoc.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camdoc.cpp (revision 1460)
+++ Trunk/XaraLX/wxOil/camdoc.cpp (revision 1461)
@@ -104,6 +104,7 @@
#include "nativeop.h"
#include "dbugtree.h"
#include "brushmsg.h"
+#include "tmplmngr.h"
#include "camdoc.h"
//#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
@@ -523,7 +524,7 @@
}
}
- PathName pathToReturn(DocOps::GetDefaultDrawingTemplate());
+ PathName pathToReturn( CTemplateManager::GetDefaultDrawingTemplate() );
return pathToReturn;
}
Index: Trunk/XaraLX/wxOil/fileutil.cpp
===================================================================
--- Trunk/XaraLX/wxOil/fileutil.cpp (revision 1460)
+++ Trunk/XaraLX/wxOil/fileutil.cpp (revision 1461)
@@ -582,6 +582,45 @@
return !status;
}
+
+/*******************************************************************************************
+
+> static BOOL FileUtil::RecursiveCreateDirectory(const String_256& strDirPath)
+
+ Author: Luke_Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+ Created: 18/07/2006
+ Inputs: strDirPath - the path to verify and create
+ Returns: TRUE if succesful, FALSE otherwise
+ Purpose: Recursivly create directory path
+
+*******************************************************************************************/
+
+BOOL FileUtil::RecursiveCreateDirectory( const String_256& strDirPath )
+{
+ // Go down path making sure each directory exists (and creating if needed), we
+ // start from the second character becuase we don't want to deal with '/'
+ UINT32 ord = 1;
+ while( _T('
+ {
+ if( _T('/') == strDirPath[ord] )
+ {
+ String_256 strPath;
+ strDirPath.Left( &strPath, ord );
+ if( !wxDir::Exists( (PCTSTR)strPath ) )
+ wxMkdir( (PCTSTR)strPath );
+ }
+
+ ++ord;
+ }
+
+ // Make sure the path as a whole exists
+ if( !wxDir::Exists( (PCTSTR)strDirPath ) )
+ wxMkdir( (PCTSTR)strDirPath );
+
+ return TRUE;
+}
+
+
PORTNOTE("other", "Removed lots of Windows'isms" )
#if !defined(EXCLUDE_FROM_XARALX)
Index: Trunk/XaraLX/wxOil/tmplmngr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/tmplmngr.cpp (revision 0)
+++ Trunk/XaraLX/wxOil/tmplmngr.cpp (revision 1461)
@@ -0,0 +1,475 @@
+// $Id: app.cpp 1437 2006-07-13 09:05:53Z luke $
+/* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
+================================XARAHEADERSTART===========================
+
+ Xara LX, a vector drawing and manipulation program.
+ Copyright (C) 1993-2006 Xara Group Ltd.
+ Copyright on certain contributions may be held in joint with their
+ respective authors. See AUTHORS file for details.
+
+LICENSE TO USE AND MODIFY SOFTWARE
+----------------------------------
+
+This file is part of Xara LX.
+
+Xara LX is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 as published
+by the Free Software Foundation.
+
+Xara LX and its component source files are distributed in the hope
+that it will be useful, but WITHOUT ANY WARRANTY; without even the
+implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with Xara LX (see the file GPL in the root directory of the
+distribution); if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+ADDITIONAL RIGHTS
+-----------------
+
+Conditional upon your continuing compliance with the GNU General Public
+License described above, Xara Group Ltd grants to you certain additional
+rights.
+
+The additional rights are to use, modify, and distribute the software
+together with the wxWidgets library, the wxXtra library, and the "CDraw"
+library and any other such library that any version of Xara LX relased
+by Xara Group Ltd requires in order to compile and execute, including
+the static linking of that library to XaraLX. In the case of the
+"CDraw" library, you may satisfy obligation under the GNU General Public
+License to provide source code by providing a binary copy of the library
+concerned and a copy of the license accompanying it.
+
+Nothing in this section restricts any of the rights you have under
+the GNU General Public License.
+
+
+SCOPE OF LICENSE
+----------------
+
+This license applies to this program (XaraLX) and its constituent source
+files only, and does not necessarily apply to other Xara products which may
+in part share the same code base, and are subject to their own licensing
+terms.
+
+This license does not apply to files in the wxXtra directory, which
+are built into a separate library, and are subject to the wxWindows
+license contained within that directory in the file "WXXTRA-LICENSE".
+
+This license does not apply to the binary libraries (if any) within
+the "libs" directory, which are subject to a separate license contained
+within that directory in the file "LIBS-LICENSE".
+
+
+ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
+----------------------------------------------
+
+Subject to the terms of the GNU Public License (see above), you are
+free to do whatever you like with your modifications. However, you may
+(at your option) wish contribute them to Xara's source tree. You can
+find details of how to do this at:
+ http://www.xaraxtreme.org/developers/
+
+Prior to contributing your modifications, you will need to complete our
+contributor agreement. This can be found at:
+ http://www.xaraxtreme.org/developers/contribute/
+
+Please note that Xara will not accept modifications which modify any of
+the text between the start and end of this header (marked
+XARAHEADERSTART and XARAHEADEREND).
+
+
+MARKS
+-----
+
+Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
+designs are registered or unregistered trademarks, design-marks, and/or
+service marks of Xara Group Ltd. All rights in these marks are reserved.
+
+
+ Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+ http://www.xara.com/
+
+=================================XARAHEADEREND============================
+ */
+
+#include "camtypes.h"
+
+#include "camelot.h"
+#include "sgliboil.h" // AppendSlashIfNotPresent
+#include "fileutil.h"
+
+#include "tmplmngr.h"
+
+DECLARE_SOURCE("$Revision: 1437 $");
+
+/********************************************************************************************
+
+ Preference: Path
+ Section: Templates
+ Range: 0 .. 256 characters
+ Purpose: The path to load the templates from and save the templates to.
+ Defaults to blank which means alongside the exe.
+ SeeAlso: CCamDoc::LoadDefaultDocument; OpMenuSave::Do;
+
+********************************************************************************************/
+
+String_256 CTemplateManager::m_TemplatesPath = TEXT("");
+String_256 CTemplateManager::m_LocalTemplatesPath = TEXT("");
+
+/********************************************************************************************
+
+ Preference: DefaultAnimationTemplate
+ Section: Templates
+ Range: String
+ Purpose: The path to the default animation template. By default, this
+ is the EXE path with " emplatesnimation.xar" added to the end
+ SeeAlso: -
+
+********************************************************************************************/
+
+String_256 CTemplateManager::ms_strDefaultAnimationTemplate = _T("");
+
+/********************************************************************************************
+
+ Preference: DefaultDrawingTemplate
+ Section: Templates
+ Range: String
+ Purpose: The path to the default drawing template. By default, this
+ is the EXE path with " emplates\drawing.xar" added to the end
+ SeeAlso: -
+
+********************************************************************************************/
+
+String_256 CTemplateManager::ms_strDefaultDrawingTemplate = _T("");
+
+
+/***********************************************************************************************
+
+> CTemplateManager::CTemplateManager()
+
+ Author: Luke_Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+ Created: 17/07/2006
+
+ Inputs: -
+ Outputs: -
+ Returns: -
+
+ Purpose: Initialise the manager.
+
+ Errors: None.
+
+***********************************************************************************************/
+
+CTemplateManager::CTemplateManager()
+{
+}
+
+/***********************************************************************************************
+
+> CTemplateManager::~CTemplateManager()
+
+ Author: Luke_Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+ Created: 17/07/2006
+
+ Inputs: -
+ Outputs: -
+ Returns: -
+
+ Purpose: Destroys the manager.
+
+ Errors: None.
+
+***********************************************************************************************/
+
+CTemplateManager::~CTemplateManager()
+{
+}
+
+
+/***********************************************************************************************
+
+> BOOL CTemplateManager::Init()
+
+ Author: Luke_Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+ Created: 17/07/2006
+
+ Inputs: -
+ Outputs: -
+ Returns: TRUE if the object initialised ok.
+
+ Purpose: Initialise the manger
+
+ Errors: None.
+
+***********************************************************************************************/
+
+BOOL CTemplateManager::Init()
+{
+ //Graham 20/10/97
+ if (Camelot.DeclareSection( _T("NewTemplates"), 10))
+ {
+ Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultAnimationFile"), &ms_strDefaultAnimationTemplate);
+ Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultDrawingFile"), &ms_strDefaultDrawingTemplate);
+ }
+
+ if (ms_strDefaultAnimationTemplate==String_256(_T("")))
+ {
+ String_256 strNameOfAnimationTemplate( _R(IDS_NEWTEMPLATES_DEFAULTANIMATIONFILE) );
+ String_256 strPathOfTemplate( GetTemplatesPath() );
+ strPathOfTemplate += strNameOfAnimationTemplate;
+
+ ms_strDefaultAnimationTemplate=strPathOfTemplate;
+
+ TRACEUSER( "jlh92", _T("DefAnimTempl = %s
"), PCTSTR(ms_strDefaultAnimationTemplate) );
+ }
+
+ if( ms_strDefaultDrawingTemplate == String_256( _T("") ) ||
+ 0 == camStrcmp( ms_strDefaultDrawingTemplate, _T("default.xar") ) )
+ {
+ 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];
+
+ 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 strNameOfDrawingTemplate(_R(IDS_DEFAULTDOCNAME));
+
+ String_256 strPathOfTemplate=strPathOfExe;
+ strPathOfTemplate+=strTemplatesDirectory;
+ strPathOfTemplate+=strNameOfDrawingTemplate;
+
+ ms_strDefaultDrawingTemplate=strPathOfTemplate;
+#endif
+ }
+
+ // As the preference system is up, declare our preference to it
+ // This is the pathname that the templates should be loaded from and saved to
+ // If blank, the default, then it should use the exe path
+ GetApplication()->DeclareSection(TEXT("Templates"), 2);
+ GetApplication()->DeclarePref(TEXT("Templates"), TEXT("Path"), &m_TemplatesPath);
+ GetApplication()->DeclarePref(TEXT("Templates"), TEXT("LocalPath"), &m_LocalTemplatesPath);
+
+ //Graham 21/10/97: If it is blank, then we should use the
+ //exe path with " emplates\" on the end
+ if( m_TemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_TemplatesPath ) )
+ {
+ // Put the path name into a string
+ PathName ModulePath( CCamApp::GetResourceDirectory() );
+
+ m_TemplatesPath = ModulePath.GetLocation(TRUE);
+
+ //And add "templates\" to the end
+ String_256 strRelativePath(_R(IDS_NEWTEMPLATES_RELATIVEPATH));
+
+ m_TemplatesPath+=strRelativePath;
+
+#if defined(_DEBUG)
+ if( !SGLibOil::DirExists( m_TemplatesPath ) )
+ m_TemplatesPath = _T("/usr/share/xaralx/Templates/");
+#endif
+ }
+
+ if( m_LocalTemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_LocalTemplatesPath ) )
+ {
+ wxString strHome( ::wxGetHomeDir() );
+ m_LocalTemplatesPath = (PCTSTR)strHome;
+ m_LocalTemplatesPath += _T("/.xaralx/templates/");
+ }
+
+ TRACEUSER( "jlh92", _T("Using %s as template store
"), PCTSTR(m_TemplatesPath) );
+ return TRUE;
+}
+
+
+/***********************************************************************************************
+
+> String_256& CTemplateManager::GetTemplatesPath()
+
+ Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 03/03/97
+ Inputs: -
+ Outputs: -
+ Returns: The specfied templates path in a string
+ Purpose: To find out the user's preference for a path to the template file.
+ SeeAlso: CCamDoc::LoadDefaultDocument; OpMenuSave::Do;
+
+***********************************************************************************************/
+
+String_256& CTemplateManager::GetTemplatesPath()
+{
+ // Add a trailing slash if it hasn't got one
+ SGLibOil::AppendSlashIfNotPresent(&m_TemplatesPath);
+
+ return m_LocalTemplatesPath;
+}
+
+/***********************************************************************************************
+
+> void CTemplateManager::SetTemplatesPath(String_256& strToSet)
+
+ Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 28/20/97
+ Inputs: strToSet - the new value
+ Returns: -
+ Purpose: To set the default templates path
+ SeeAlso: -
+
+***********************************************************************************************/
+
+void CTemplateManager::SetTemplatesPath(String_256& strToSet)
+{
+ m_LocalTemplatesPath = strToSet;
+
+ // Add a trailing slash if it hasn't got one
+ SGLibOil::AppendSlashIfNotPresent(&m_TemplatesPath);
+}
+
+/********************************************************************************************
+
+> PathName DocOps::GetDefaultAnimationTemplate()
+
+ Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 23/10/97
+ Inputs: -
+ Outputs: -
+ Returns: The path of the default animation template
+ Purpose: As above
+ Errors: -
+ SeeAlso: -
+
+********************************************************************************************/
+
+PathName CTemplateManager::GetDefaultAnimationTemplate()
+{
+ PathName pathToReturn=ms_strDefaultAnimationTemplate;
+
+ return pathToReturn;
+}
+
+/********************************************************************************************
+
+> PathName DocOps::GetDefaultDrawingTemplate()
+
+ Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 23/10/97
+ Inputs: -
+ Outputs: -
+ Returns: The path of the default drawing template
+ Purpose: As above
+ Errors: -
+ SeeAlso: -
+
+********************************************************************************************/
+
+PathName CTemplateManager::GetDefaultDrawingTemplate()
+{
+ PathName pathToReturn=ms_strDefaultDrawingTemplate;
+
+ return pathToReturn;
+}
+
+void CTemplateManager::GetTemplateList( CTemplateList* pList, const String_256& strTemplatePath, bool fLocal )
+{
+ // Don't bother with any of this is directory is invalid
+ if( !wxDir::Exists( (PCTSTR)strTemplatePath ) )
+ return;
+
+ //Now search that path for templates
+ //Start by setting the leaf name to *.xar
+ String_256 strSearchFilename( _R(IDS_NEWTEMPLATES_DEFAULTTEMPLATEEXTENSION) );
+
+ String_256 strPathOfDrawingTemplate = CTemplateManager::GetDefaultDrawingTemplate().GetPath(FALSE);
+ strPathOfDrawingTemplate.SwapChar( _T('_'), _T(' ') );
+ String_256 strPathOfAnimationTemplate = CTemplateManager::GetDefaultAnimationTemplate().GetPath(FALSE);
+ strPathOfAnimationTemplate.SwapChar( _T('_'), _T(' ') );
+ String_256 strPathOfFile;
+
+ TRACEUSER( "jlh92", _T("DefPath = %s, %s
"), PCTSTR(strPathOfDrawingTemplate),
+ PCTSTR(strPathOfAnimationTemplate) );
+
+ // Build system template path
+ PathName pathTemplates( strTemplatePath );
+ pathTemplates.SetFileNameAndType( strSearchFilename );
+ PathName pathOfFile( pathTemplates );
+ String_256 strTemplates = pathTemplates.GetPath( FALSE );
+
+ //And search the path for xar files that are
+ //NOT the default animation or drawing templates
+ String_256 strNameOfFile;
+ if( FileUtil::StartFindingFiles( &strTemplates ) )
+ {
+ while( FileUtil::FindNextFile( &strNameOfFile ) )
+ {
+ pathOfFile.SetFileNameAndType( strNameOfFile );
+ strPathOfFile = pathOfFile.GetFileName(TRUE);
+
+ if( 0 != strPathOfFile.CompareTo( strPathOfDrawingTemplate, FALSE ) &&
+ 0 != strPathOfFile.CompareTo( strPathOfAnimationTemplate, FALSE ) )
+ {
+ (*pList)[strPathOfFile] = fLocal;
+ TRACEUSER( "jlh92", _T("Curr = %s
"), PCTSTR(strPathOfFile) );
+ }
+ }
+ FileUtil::StopFindingFiles();
+ }
+
+ // Don't allow any errors set while searching to propagate outside this scope
+ Error::ClearError();
+}
+
+bool CTemplateManager::GetTemplateMenuName( UINT32 ordNumberOfTemplate, String_256* pStrNameOfFile )
+{
+ CTemplateList setSortFilename;
+ GetTemplateList( &setSortFilename, m_TemplatesPath, false );
+ GetTemplateList( &setSortFilename, m_LocalTemplatesPath, true );
+
+ if( ordNumberOfTemplate > UINT32(setSortFilename.size()) )
+ return false;
+
+ CTemplateList::iterator iter = setSortFilename.begin();
+ for( UINT32 i = 1; i < ordNumberOfTemplate; ++i, ++iter )
+ { /*Do nothing!*/ }
+
+ *pStrNameOfFile = iter->first;
+ TRACEUSER( "jlh92", _T("Final(%d) = %s
"), ordNumberOfTemplate, PCTSTR(*pStrNameOfFile) );
+
+ return true;
+}
+
+bool CTemplateManager::GetTemplateFilename( UINT32 ordNumberOfTemplate, String_256* pStrNameOfFile )
+{
+ CTemplateList setSortFilename;
+ GetTemplateList( &setSortFilename, m_TemplatesPath, false );
+ GetTemplateList( &setSortFilename, m_LocalTemplatesPath, true );
+
+ if( ordNumberOfTemplate > UINT32(setSortFilename.size()) )
+ return false;
+
+ CTemplateList::iterator iter = setSortFilename.begin();
+ for( UINT32 i = 1; i < ordNumberOfTemplate; ++i, ++iter )
+ { /*Do nothing!*/ }
+
+ PathName pathTemplates = iter->second ? m_LocalTemplatesPath : m_TemplatesPath;
+ pathTemplates.SetFileNameAndType( iter->first );
+
+ *pStrNameOfFile = pathTemplates.GetPath();
+ TRACEUSER( "jlh92", _T("Final(%d) = %s
"), ordNumberOfTemplate, PCTSTR(*pStrNameOfFile) );
+
+ return true;
+}
Xara