dbgthumb.cpp

Go to the documentation of this file.
00001 // $Id: dbgthumb.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // The "Import from URL..." menu item
00099 
00100 //GTODO: Tidy up these includes
00101 #include "camtypes.h"
00102 
00103 //#include "pathname.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "app.h"          //For Camelot.GetFilterManager() - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "barsdlgs.h"     //For _R(IDD_BARCONTROLSTORE)
00106 
00107 #include "urlimp.h"
00108 #include "fileutil.h"
00109 
00110 //#include "resimmap.h"     //For _R(IDS_HTMLIMPORT_FILEDOWNLOAD)
00111 #include "urldlg.h"         //For URLImportDlg
00112 #include "filtrmgr.h"       //For FilterManager::FindFilterFromID
00113 
00114 #include "gendwnd.h"        //For the download operation
00115 //#include "webster.h"
00116 
00117 CC_IMPLEMENT_DYNCREATE(OpURLImport, OpMenuImport)
00118 
00119 /********************************************************************************************
00120 
00121 >   BOOL OpURLImport::Init()
00122 
00123     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    6/6/97
00125     Returns:    TRUE if worked, FALSE if failed (out of memory)
00126     Purpose:    Declares the OpDescriptor
00127     Errors:     -
00128 
00129 ********************************************************************************************/
00130 
00131 BOOL OpURLImport::Init()
00132 {
00133     return RegisterOpDescriptor(
00134                                     0,                          // Tool ID
00135                                     _R(IDS_URLIMPORT),                  // String resource ID
00136                                     CC_RUNTIME_CLASS(OpURLImport),  // Runtime class
00137                                     OPTOKEN_URLIMPORT,          // Token string
00138                                     GetState,                   // GetState function
00139                                     0,                          // help ID GTODO: Is this needed?
00140                                     _R(IDBBL_URLIMPORT),            // bubble help
00141                                     _R(IDD_BARCONTROLSTORE),        // resource ID
00142                                     _R(IDC_FILEURLIMPORT),              // control ID
00143                                     SYSTEMBAR_FILE,             // Bar ID
00144                                     TRUE,                       // Receive system messages
00145                                     FALSE,                      // Smart duplicate operation
00146                                     TRUE,                       // Clean operation
00147                                     0,      // String for one copy only error
00148                                     (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags
00149                                 );
00150     
00151 }
00152 
00153 /********************************************************************************************
00154 
00155 >   void OpURLImport::Do(OpDescriptor*)
00156 
00157     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00158     Created:    6/6/97
00159     Purpose:    Imports a URL into the current document
00160     Errors:     -
00161 
00162 ********************************************************************************************/
00163 
00164 void OpURLImport::Do(OpDescriptor*)
00165 {
00166     //First display our Import from URL dialog and get a filename from it
00167     WebAddress urlToGet;
00168     
00169     BOOL ok=URLImportDlg::OpenAndGetURL(&urlToGet);
00170 
00171     //And if the user clicked OK
00172     if (ok)
00173     {
00174 
00175         //So, is the URL we've got back a local filename?
00176         if (urlToGet.IsLocalFile())
00177         {
00178             //Yes. So get it as a pathname
00179             PathName pthToGet=urlToGet.GetPathName();
00180 
00181             //And first get a pointer to the All filter
00182             Filter* pAllFilter=GetAllFilter();
00183 
00184             //And if we found it
00185             if (pAllFilter)
00186             {
00187                 //Then import the pathname
00188                 String_256 strToGet=pthToGet.GetPath();
00189 
00190                 DoImport(pthToGet, pAllFilter, &strToGet);
00191             }
00192 
00193         }
00194         else
00195         {
00196             //No, it's a URL.
00197 
00198             //So download it
00199             ImportURL(urlToGet);
00200         }
00201     }
00202 
00203 
00204 
00205 
00206 
00207 }
00208 
00209 /********************************************************************************************
00210 
00211 >   OpURLImport::OpURLImport()
00212 
00213     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00214     Created:    6/6/97
00215     Purpose:    Default constructor
00216 
00217 ********************************************************************************************/
00218 
00219 OpURLImport::OpURLImport()
00220 {
00221     OpFlags.HasOwnTimeIndicator = TRUE; // The OpURLImport op has its own time indicator
00222 }
00223 
00224 /********************************************************************************************
00225 
00226 >   OpState OpURLImport::GetState(String_256*, OpDescriptor*)
00227 
00228     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00229     Created:    6/6/97
00230     Purpose:    This item is always available, so long as a document is visible.
00231 
00232 ********************************************************************************************/
00233 
00234 OpState OpURLImport::GetState(String_256*, OpDescriptor*)
00235 {
00236     OpState OpSt;
00237 
00238     return OpSt;
00239 }
00240 
00241 /*****************************************************************
00242 
00243   Toolkit functions
00244 
00245   ****************************************************************/
00246 
00247  /********************************************************************************************
00248 
00249 >   BOOL OpURLImport::ImportURL(WebAddress urlToGet)
00250 
00251     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00252     Created:    6/6/97
00253     Inputs:     urlToGet    The URL to import
00254     Purpose:    Imports the URL given
00255 
00256   GTODO: Handle local files
00257   GTODO: HMOve this function somewhere useful
00258 
00259 ********************************************************************************************/
00260 
00261 BOOL OpURLImport::ImportURL(WebAddress urlToGet)
00262 {
00263     //First, set up some variables. We must do this now because I'm 
00264     //going to use a goto in a moment
00265     GenericDownloadParam* Param;
00266     OpDescriptor* pOpDesc;
00267     PathName pthTemp;
00268 
00269     //We want to import urlToGet using the best available filter
00270 
00271     //To get the best available filter, we simply download to the "All" filter
00272     //So get a pointer to the All filter
00273     Filter* pAllFilter=GetAllFilter();
00274 
00275     //Check we found it
00276     if (pAllFilter==NULL)
00277         goto ReturnError;
00278 
00279     //Now, get ready to download the file. This is rather complex.
00280 
00281     //First create a new set of download parameters
00282     //This object will be deleted when the download finishes
00283     Param = new GenericDownloadParam;
00284     
00285     //Now find the generic download OpDescriptor
00286     pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_OPGENERICDOWNLOAD);
00287 
00288     //And check we found it
00289     if (pOpDesc==NULL)
00290         goto ReturnError;
00291   
00292     //Now, create a temporary file to download to
00293     pthTemp=FileUtil::GetTemporaryPathName();
00294 
00295 
00296 
00297     /*            GTODO: Take all this out
00298                 TCHAR TempDir[MAX_PATH];
00299                 FileUtil::GetTemporaryPath(MAX_PATH,TempDir);
00300                 // get temp file name
00301                 TCHAR TempFileName[256];
00302                 TCHAR Prefix[] = "TMP"; // the first three letters of the new file name
00303                 FileUtil::GetTemporaryFileName(TempDir,Prefix,0,TempFileName);
00304                 */
00305 
00306     //And now fill in our parameters
00307     Param->type = TYPE_GENERIC;
00308     Param->priority = AsynchDownload::PRIORITY_NORMAL;
00309     Param->strDescription = String_256(_R(IDS_HTMLIMPORT_FILEDOWNLOAD));
00310     Param->uCaptionID = _R(IDS_GENERICPROGRESSDLGCAPTION);
00311     Param->uErrorMsgID = _R(IDS_GENERICDOWNLOADFAILED);
00312     Param->file = pthTemp.GetPath();
00313 
00314     Param->strURL = urlToGet.GetWebAddress();
00315                 
00316     Param->Output = NULL;
00317 
00318     Param->m_pFilter = pAllFilter;
00319     Param->m_Op = this;                     
00320     Param->pDoc = Document::GetCurrent();
00321 
00322     //And, finally, start the download going, if we've got a URL to download
00323     if (!Param->strURL.IsEmpty())
00324         pOpDesc->Invoke((OpParam*) Param);
00325     
00326     //And return TRUE
00327     return TRUE;
00328 
00329 ReturnError:
00330     if (Param)
00331         delete Param;
00332 
00333     return FALSE;
00334 }
00335 
00336  /********************************************************************************************
00337 
00338 >   Filter* OpURLImport::GetAllFilter()
00339 
00340     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00341     Created:    10/6/97
00342     Inputs:     -
00343     Purpose:    Gets a pointer to the All filter.
00344     
00345 ********************************************************************************************/
00346 
00347 Filter* OpURLImport::GetAllFilter()
00348 {
00349     //So get a pointer to the All filter
00350     FilterManager* pFilterManager=Camelot.GetFilterManager();
00351 
00352     ERROR2IF(pFilterManager==NULL, FALSE, "OpURLImport::ImportURL - FilterManager does not exist");
00353 
00354     return pFilterManager->FindFilterFromID(FILTERID_GENERIC);
00355         
00356 }
00357 
00358 

Generated on Sat Nov 10 03:45:00 2007 for Camelot by  doxygen 1.4.4