1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _OTRANSFERABLE_HXX_
24 #define _OTRANSFERABLE_HXX_
25 
26 #include <svpm.h>
27 
28 #include <cppuhelper/implbase1.hxx>
29 #include <rtl/ustring.hxx>
30 #include <rtl/unload.h>
31 #include <com/sun/star/datatransfer/DataFlavor.hpp>
32 #include <com/sun/star/datatransfer/XTransferable.hpp>
33 
34 using namespace cppu;
35 using namespace osl;
36 using namespace rtl;
37 using namespace com::sun::star::io;
38 using namespace com::sun::star::uno;
39 using namespace com::sun::star::datatransfer;
40 
41 
42 // undocumented(?)
43 #ifndef DC_PREPAREITEM
44 #define DC_PREPAREITEM   0x0040
45 #endif
46 
47 // rendering mechanism
48 #define DTSHARE_NAME    "\\SHAREMEM\\AOO_DND"
49 #define DTSHARE_RMF     "<DRM_DTSHARE,DRF_TEXT>"
50 
51 #define SHAREDMEM_RMF   "<DRM_SHAREDMEM,DRF_TEXT>"
52 
53 #define OS2FILE_NAME    "AOO_TGT.TMP"
54 #define OS2FILE_TXTRMF  "<DRM_OS2FILE,DRF_TEXT>"
55 #define OS2FILE_UNKRMF  "<DRM_OS2FILE,DRF_UNKNOWN>"
56 
57 
58 class OTransferable: public ::cppu::WeakImplHelper1<XTransferable>
59 {
60     com::sun::star::uno::Sequence<DataFlavor> m_aFlavorList;
61 
62 private:
63     HWND mHwndTarget;
64     PDRAGINFO mDragInfo;
65     bool removeOnExit;
66     char fullpath[CCHMAXPATH];
67     void *pDTShare;
68     char *pSharedMem;
69     enum _DRM { DRM_NULL, DRM_ATOM, DRM_DTSHARE, DRM_OS2FILE, DRM_SHAREDMEM};
70     _DRM renderDRM;
71     enum _MIMETYPE { MIMETYPE_NULL, MIMETYPE_TEXT, MIMETYPE_FILE};
72     _MIMETYPE mimeType;
73 
74 public:
75 
76 public:
77     OTransferable( HWND hwnd, PDRAGINFO dragInfo);
78     ~OTransferable();
79 
80     virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor)
81         throw(UnsupportedFlavorException, IOException, RuntimeException);
82     virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors()
83         throw(RuntimeException);
84     virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor)
85         throw(RuntimeException);
86 
87     bool renderComplete( PDRAGTRANSFER pdxfer);
88     bool requestRendering( void);
89 
90 private:
91     bool RequestFileRendering( PDRAGITEM pditem, HWND hwnd, PCSZ pRMF, PCSZ pName);
92     bool RenderToOS2File( PDRAGITEM pditem, HWND hwnd);
93     bool RenderToDTShare( PDRAGITEM pditem, HWND hwnd);
94     bool RenderToSharedMem( PDRAGITEM pditem, HWND hwnd);
95 
96 };
97 
98 #endif // _OTRANSFERABLE_HXX_
99