clipext.h

Go to the documentation of this file.
00001 // $Id: clipext.h 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 // External clipboard interface - classes for managing communications with the windows clipboard
00099 
00100 #ifndef INC_CLIPEXT
00101 #define INC_CLIPEXT
00102 
00103 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "clipmap.h"
00108 //#include "dialogop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 #include "scrcamvw.h"
00110 
00111 
00112 class ExternalClipboard;
00113 class OpClipboardExport;
00114 class OpClipboardImport;
00115 
00116 class Filter;
00117 class PathName;
00118 
00119 class CCamDataSource;
00120 class COleDataObject;
00121 
00122 
00123 
00124 /********************************************************************************************
00125 
00126 >   class ExternalClipboard : public CC_CLASS_MEMDUMP
00127 
00128     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00129     Created:    16/4/95
00130     
00131     Purpose:    Handlers for external (Windows) clipboard functions.
00132                 Interacts with the internal clipboard document.
00133 
00134     SeeAlso:    class InternalClipboard
00135 
00136 *********************************************************************************************/
00137 
00138 class CCAPI ExternalClipboard : public CC_CLASS_MEMDUMP
00139 {
00140 friend class InternalClipboard;
00141 friend class CMainFrame;
00142 friend class OpClipboardImport;
00143 friend class PasteSpecialDlg;
00144 friend class ScreenCamView;
00145 
00146 CC_DECLARE_MEMDUMP(ExternalClipboard)
00147 
00148 
00149 //
00150 //  The OLE clipboard
00151 //
00152 
00153 #if (_OLE_VER >= 0x200)
00154 
00155 public:
00156 
00157     // ***TEMP: until this obsolete architecture is sorted out
00158     static void DelayRenderData(CCamDataSource* pDataSource);
00159 
00160     // Call this to set the memory the clipboard should delay-render into.  If hMem is
00161     // null then the render functions will try to allocate the memory themselves.
00162     void SetRenderMemory(HGLOBAL hMem);
00163 
00164     // Call this get the handle to the memory block that was rendered into (if you
00165     // passed null to SetRenderMemory).
00166     HGLOBAL GetRenderMemory() const;
00167 
00168     // Call this to get the most suitable format for pasting from those in the given
00169     // data object.  If it returns 0 then there is no suitable format.
00170     static CLIPFORMAT GetBestPasteFormat(COleDataObject* pDataObject);
00171 
00172 protected:
00173 
00174     // This is just like PrepareForPaste but it takes the data out of the given
00175     // COleDataObject instead.  Pass NULL to use the COleDataObject associated
00176     // with the Windows clipboard.
00177     BOOL PrepareForOlePaste(COleDataObject* pDataObject);
00178 
00179 private:
00180 
00181     // Implementation.
00182     HGLOBAL     m_hMem;             // the memory to delay-render into
00183     DWORD       m_cbMemSize;        // the size of the supplied memory
00184     BOOL        m_fIgnoreChange;    // whether to ignore clipboard-change messages or not
00185     Document*   m_pDoc;             // the kernel Document to import/export
00186 
00187 public:
00188 
00189     // Call this before importing or exporting to set the document to use for import/export
00190     void SetDocument(Document* pDoc)            { m_pDoc = pDoc; }
00191 
00192 #endif
00193 
00194 public:
00195     
00196     // This returns TRUE if the clipboard currently belongs to us.
00197     BOOL IsOurs() const;
00198 
00200 
00201 
00202 public:     // Construction/Destruction
00203     ExternalClipboard();
00204     virtual ~ExternalClipboard();
00205 
00206 
00207 public:     // Initialisation/DeInit
00208     static BOOL Init(void );
00209     static void Deinit(void);
00210 
00211 public:     // Registration
00212     static void RegisterDataType(ClipboardMapping *TypeInfo);
00213         // Called by filters to register mappings between internal and external types
00214 
00215 
00216 public:     // Misc public interface
00217     static void PrepareForShutdown(void);
00218         // Asks the user and renders all formats if necessary, on shutdown.
00219         // Called *before* camelot closes documents and windows so it can do progress indication etc
00220 
00221     void CheckKeepClipboardOnExit(void);
00222         // Checks if the user wants the clipboard contents kept after exit
00223 
00224     static BOOL CanImport(UINT32 WindowsFormat);
00225         // Returns TRUE if there is an import mapping which can handle the given format
00226 
00227 
00228 protected:      // InternalClipboard interface
00229     static BOOL IsEmpty(void);
00230             // Returns TRUE if the external clipboard cannot supply any data
00231 
00232     static void DescribeContents(String_64 *Result);
00233             // Finds the text description for the current clipboard contents
00234 
00235 
00236 public:
00237     static void GetExternalFormatName(UINT32 ExternalFormat, String_64 *Result);
00238             // Finds a text description of a given windows format
00239 
00240 
00241 protected:      // InternalClipboard interfaces
00242     BOOL PrepareForCopy(void);
00243             // Prepare the clipboard for accepting Copied/Cut data
00244             // Returns FALSE if the clipboard is unavailable
00245 
00246     BOOL CopyCompleted(void);
00247             // Tidy up after copying data to the clipboard
00248             // (Grabs ownership of the clipboard and lets windows know what formats
00249             // of export data are available based on the new InternalClipboard contents)
00250 
00251     BOOL PrepareForPaste(void);
00252             // Prepare the clipboard for providing data to paste
00253             // (Interrogates Windows to find clipboard data to grab)
00254             // Returns FALSE if there is nothing avaiable to paste
00255 
00256     BOOL PasteCompleted(void);
00257             // Tidy up after pasting data from the clipboard
00258 
00259 
00260 public:     // Communications from the external (windows) clipboard
00261 
00262     void DestroyClipboard(void);
00263         // Handles a WM_DESTROYCLIPBOARD (we are no longer the clipboard owner)
00264 
00265     void RenderFormat(UINT32 ClipboardFormat);
00266     void RenderFormat(ClipboardMapping *Info);
00267         // Handles the WM_RENDER_FORMAT command
00268 
00269     void RenderAllFormats(void);
00270         // Handles the WM_RENDER_ALL_FORMATS command
00271 
00272     void WindowsClipboardHasChanged(void);
00273         // Called to notify us when the external clipboard has been changed by another
00274         // application copying to it - we must clear the internal clipboard cache
00275 
00276 
00277 public:     // Access methods
00278     static ExternalClipboard* GetExternalClipboard(void);
00279 
00280     // Make temporary clipboards and set static pointers
00281     static ExternalClipboard*   LinkTempClipboard();
00282     BOOL                        UnlinkTempClipboard();
00283 
00284 
00285 protected:
00286     static ExternalClipboard* pInstance;    // The one and only instance of the ExtClipboard
00287     List Mappings;                          // A list of the supported data mappings
00288 
00289     BOOL KeepFormatsOnExit;                 // TRUE if we should put al formats on the clipboard
00290                                             // when we exit, FALSE if we just wipe the clipboard
00291 
00292 protected:      // Internal/Friend-class methods
00293     static CWnd *GetOwnerWindow(void);
00294 
00295 private:
00296     static BOOL m_fUpdateSystemClipboard;       // if FALSE then don't notify Windows etc
00297 
00298 public:
00299     
00300     // Quick and dirty hack so that drag'n'drop doesn't get put on the Windows clipboard
00301     // as well!
00302     static void UpdateSystemClipboard(BOOL fState)
00303                                 { m_fUpdateSystemClipboard = fState; }
00304 };
00305 
00306 
00307 
00308 
00309 /********************************************************************************************
00310 
00311 >   class OpClipboardExport : public Operation
00312 
00313     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00314     Created:    21/4/95
00315     Purpose:    Exports the InternalClipboard to the external clipboard according to the
00316                 ClipboardMapping info passed in the DoWithParam info.
00317 
00318 ********************************************************************************************/
00319 
00320 #define OPTOKEN_CLIPBOARDEXPORT _T("ExportClipboard")
00321 
00322 class OpClipboardExport : public Operation
00323 {
00324     CC_DECLARE_DYNCREATE(OpClipboardExport)
00325 
00326 public:
00327     
00328     virtual void DoWithParam(OpDescriptor*, OpParam* pOpParam);
00329     virtual void Do(OpDescriptor* pOpDesc);
00330 
00331     static BOOL Init();
00332     static OpState GetState(String_256*, OpDescriptor*);
00333 };
00334 
00335 
00336 #if (_OLE_VER >= 0x200)
00337 
00338     // Use this to pass parameters to this Operation.
00339     struct OpClipboardExportParams
00340     {
00341         ClipboardMapping* pMapping;     // the format mapping to 'export' into the memory
00342         HGLOBAL           hMem;         // the memory to export to, or null to allocate
00343         DWORD             cbMemSize;    // the size of the memory to export to
00344         Document*         pDoc;         // the document to export from
00345     };
00346 
00347 #endif
00348 
00349 
00350 
00351 
00352 
00353 /********************************************************************************************
00354 
00355 >   class OpClipboardImport : public SelOperation
00356 
00357     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00358     Created:    21/4/95
00359     Purpose:    Imports the InternalClipboard from the external clipboard according to the
00360                 ClipboardMapping info passed in the DoWithParam info.
00361 
00362 ********************************************************************************************/
00363 
00364 #define OPTOKEN_CLIPBOARDIMPORT _T("ImportClipboard")
00365 
00366 class OpClipboardImport : public SelOperation
00367 {
00368     CC_DECLARE_DYNCREATE(OpClipboardImport)
00369 
00370 public:
00371     virtual void DoWithParam(OpDescriptor*, OpParam* pOpParam);
00372     virtual void Do(OpDescriptor* pOpDesc);
00373 
00374     static BOOL Init();
00375     static OpState GetState(String_256*, OpDescriptor*);
00376 };
00377 
00378 
00379 
00380 
00381 
00382 
00383 /********************************************************************************************
00384 
00385 >   class ClipboardView : public View
00386 
00387     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00388     Created:    22/4/95
00389 
00390     Purpose:    Simple view class for use when rendering (exporting) the clipboard
00391 
00392     SeeAlso:    View
00393 
00394 ********************************************************************************************/
00395 
00396 class ClipboardView : public View
00397 {
00398     CC_DECLARE_DYNAMIC(ClipboardView);
00399 public:
00400     virtual ~ClipboardView();   
00401     BOOL Init();
00402 
00403 public:
00404     virtual BOOL ViewStateChanged();            // informs us that ViewState has changed
00405 
00406 public:
00407     virtual void SetViewPixelSize();            // Set pixel size according to this view.
00408 
00409 public:
00410     virtual void ContinueRenderView(RenderRegion*, Spread*, BOOL = TRUE, BOOL = TRUE,
00411                                      BOOL bForceImmediate = FALSE);
00412     virtual CDC *GetRenderDC();
00413 
00414 public:
00415     virtual BOOL GetForeBackMode();
00416     virtual void SetForeBackMode(BOOL);
00417 
00418 public:
00419     virtual DocRect GetDocViewRect(Spread*);
00420     virtual void SetExtent(DocCoord, DocCoord); // Reset the extent of the document
00421     virtual WorkRect GetViewRect();             // The physical rect of the view
00422 };
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430 #define OPTOKEN_PASTESPECIALDLG _T("PasteSpecialDlg")
00431 
00432 /********************************************************************************************
00433 
00434 >   class PasteSpecialDlg : public DialogOp
00435 
00436     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00437     Created:    2/5/95
00438 
00439     Purpose:    Allows the user to choose the clipbaord format to be pasted
00440 
00441     Notes:      Call InvokeDialog to show the dialogue
00442 
00443 ********************************************************************************************/
00444 
00445 class PasteSpecialDlg : public DialogOp
00446 {         
00447 CC_DECLARE_DYNCREATE(PasteSpecialDlg)
00448 
00449 public:     // External inteface
00450     static UINT32 InvokeDialog(void);
00451 
00452 public:     // DialogOp interface
00453     PasteSpecialDlg();
00454 
00455     void DoWithParam(OpDescriptor*, OpParam*);
00456     BOOL Create(); 
00457 
00458     static const INT32 IDD;
00459     static const CDlgMode Mode;
00460 
00461     static OpState GetState(String_256*, OpDescriptor*);    
00462     static BOOL Init();                        
00463 
00464     virtual MsgResult Message(Msg* Message);
00465 
00466 protected:
00467     OpParam *pParam;
00468 }; 
00469 
00470 
00471 #endif

Generated on Sat Nov 10 03:48:16 2007 for Camelot by  doxygen 1.4.4