1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: winshell.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
36 #include <tools/prewin.h>
38 #include <tools/postwin.h>
40 #include <tools/string.hxx>
42 //----------------------------------------------------------------------------
44 //----------------------------------------------------------------------------
50 CItemIDList( const CItemIDList
& );
51 CItemIDList( LPCITEMIDLIST
);
52 CItemIDList( const String
& );
53 CItemIDList( int nFolder
);
56 CItemIDList
& operator = ( const CItemIDList
& );
57 CItemIDList
& operator += ( const CItemIDList
& );
58 CItemIDList
operator + ( const CItemIDList
& ) const;
60 int operator == ( const CItemIDList
& ) const;
61 int operator != ( const CItemIDList
& rIDList
) const
62 { return ! operator == ( rIDList
); };
64 operator LPCITEMIDLIST() const
67 int GetTokenCount() const;
68 CItemIDList
GetToken( int nIndex
) const;
69 CItemIDList
GetParent( int nLevelFromBottom
= 1) const;
70 CItemIDList
GetChild( int nLevelFromBottom
= 1 ) const;
71 void Split( CItemIDList
& rParent
, CItemIDList
& rChild
, int nLevelFromBottom
= 1 ) const;
73 CItemIDList
operator []( int nIndex
) const
74 { return GetToken( nIndex
); };
76 String
GetFilePath() const;
79 { return m_pidl
!= NULL
&& m_pidl
->mkid
.cb
!= sizeof(USHORT
); }
90 inline CItemIDList
CItemIDList::operator + ( const CItemIDList
& rIDList
) const
92 CItemIDList
aCopy( *this );
97 //----------------------------------------------------------------------------
98 // Types for CShellFolder
99 //----------------------------------------------------------------------------
101 // Notification Events fuer CShellFolder
103 enum NotificationEvent
105 NotificationEvent_Error
,
106 NotificationEvent_Signaled
,
107 NotificationEvent_Canceled
110 // Volume information
112 typedef struct _WIN32_VOLUME_DATA
114 TCHAR cDeviceName
[MAX_PATH
];
115 TCHAR cVolumeName
[MAX_PATH
];
116 TCHAR cFileSystemName
[MAX_PATH
];
117 DWORD dwSerialNumber
;
118 DWORD dwFileSystemFlags
;
119 DWORD nMaxComponentLength
;
122 // Bekannte Class-IDs fuer wichtige Ordner
124 // {871C5380-42A0-1069-A2EA-08002B30309D} Internet Explorer 4.0
125 static const GUID CLSID_IE4
=
126 { 0x871C5380, 0x42A0, 0x1069, { 0xA2, 0xEA, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D } };
128 // {208D2C60-3AEA-1069-A2D7-08002B30309D} Netzwerkumgebung
129 static const GUID CLSID_Network
=
130 { 0x208D2C60, 0x3AEA, 0x1069, { 0xA2, 0xD7, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D } };
132 // {645FF040-5081-101B-9F08-00AA002F954E} Papierkorb
133 static const GUID CLSID_RecycleBin
=
134 { 0x645FF040, 0x5081, 0x101B, { 0x9F, 0x08, 0x00, 0xAA, 0x00, 0x2F, 0x95, 0x4E } };
136 // {20D04FE0-3AEA-1069-A2D8-08002B30309D} Arbeitsplatz
137 static const GUID CLSID_MyComputer
=
138 { 0x20D04FE0, 0x3AEA, 0x1069, { 0xA2, 0xD8, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D } };
140 // {D6277990-4C6A-11CF-8D87-00AA0060F5BF} Geplante Vorgänge
141 static const GUID CLSID_Tasks
=
142 { 0xD6277990, 0x4C6A, 0x11CF, { 0x8D, 0x87, 0x00, 0xAA, 0x00, 0x60, 0xF5, 0xBF } };
146 #define SHGDN_INCLUDE_NONFILESYS 0x2000
148 #define CSIDL_UNKNOWN -1
149 #define CSIDL_ROOT -2
150 #define CSIDL_SYSTEM -3
152 // Suchmaske fuer IEnumIDList
154 #define SHCONTF_ALL (SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN)
156 // SHITEM Prefix Kinds
158 #define SHGII_CONTAINER_MASK 0x70
160 #define SHGII_COMPUTER 0x20
162 #define SHGII_COMPUTER_REMOVABLE 0x22
163 #define SHGII_COMPUTER_FIXED 0x23
164 #define SHGII_COMPUTER_REMOTE 0x24
165 #define SHGII_COMPUTER_CDROM 0x25
166 #define SHGII_COMPUTER_RAMDISK 0x26
167 #define SHGII_COMPUTER_FLOPPY525 0x28
168 #define SHGII_COMPUTER_FLOPPY35 0x29
169 #define SHGII_COMPUTER_NETWORK 0x2A
170 #define SHGII_COMPUTER_REGITEM 0x2E
172 #define SHGII_ROOT 0x10
173 #define SHGII_ROOT_REGITEM 0x1F
175 #define SHGII_NETWORK 0x40
176 #define SHGII_NETWORK_TREE 0x47
177 #define SHGII_NETWORK_SERVER 0x42
178 #define SHGII_NETWORK_DIRECTORY 0x43
179 #define SHGII_NETWORK_PRINTER 0x41
181 #define SHGII_FILESYSTEM 0x30
182 #define SHGII_FILESYSTEM_FILE 0x31
183 #define SHGII_FILESYSTEM_DIRECTORY 0x32
185 #define SHGII_ANCESTOR 0x80
187 #define SHITEMCONTAINER( pidl ) ((pidl)->mkid.abID[0] & SHGII_CONTAINER_MASK)
188 #define SHITEMKIND( pidl ) ((pidl)->mkid.abID[0] & 0x7F)
190 //----------------------------------------------------------------------------
192 //----------------------------------------------------------------------------
194 class CShellFolderData
198 virtual ~CShellFolderData();
200 IShellFolder
*m_pShellFolder
;
201 IEnumIDList
*m_pEnumIDList
;
202 IShellIcon
*m_pShellIcon
;
204 HANDLE m_hCancelEvent
;
205 DWORD m_dwContentFlags
;
208 //----------------------------------------------------------------------------
210 //----------------------------------------------------------------------------
212 // Ganz "normaler" Ordner basierend auf dem IShellFolder Interface
214 class CShellFolder
: public CShellFolderData
217 CShellFolder( const CItemIDList
& );
218 CShellFolder( const CShellFolder
& );
219 CShellFolder( IShellFolder
* );
221 // Retrieval of Item IDs
223 virtual BOOL
Reset();
225 BOOL
GetNextValidID( CItemIDList
& );
227 virtual BOOL
GetNextID( CItemIDList
& );
228 virtual BOOL
ValidateID( const CItemIDList
& );
230 // Getting information about Items
232 virtual BOOL
GetAttributesOf( const CItemIDList
&, LPDWORD pdwInOut
);
233 virtual BOOL
GetNameOf( const CItemIDList
&, String
& );
235 virtual BOOL
GetFileInfo( const CItemIDList
&, WIN32_FIND_DATA
* );
236 virtual BOOL
GetVolumeInfo( const CItemIDList
& rIDList
, WIN32_VOLUME_DATA
* );
238 // Modifying the folder contents
240 virtual BOOL
SetNameOf( const CItemIDList
&, const String
&, CItemIDList
& );
241 virtual BOOL
DeleteItem( const CItemIDList
& );
245 virtual int CompareIDs( const CItemIDList
&, const CItemIDList
& );
249 virtual IContextMenu
*GetContextMenu( int nItems
, const CItemIDList
* );
250 virtual String
GetIconLocation( const CItemIDList
& );
254 virtual NotificationEvent
WaitForChanges();
255 virtual void CancelWaitNotifications();
258 CShellFolder() : CShellFolderData() {};
260 void Initialize( IShellFolder
*pShellFolder
);
261 void Initialize( LPCITEMIDLIST
);
264 //----------------------------------------------------------------------------
266 //----------------------------------------------------------------------------
268 // Reiner !!! Filesystem-Ordner. Benutzt optimierten Notification Mechanismus
270 class CFileSystemFolder
: public CShellFolder
273 CFileSystemFolder( LPCSTR pszPath
);
275 virtual NotificationEvent
WaitForChanges();
278 CFileSystemFolder() : CShellFolder() {};
280 void Initialize( LPCTSTR pszPath
);
282 TCHAR m_szPath
[MAX_PATH
];
285 //----------------------------------------------------------------------------
287 //----------------------------------------------------------------------------
289 // Wie SHellFolder, aber andere Konstruktion ueber definierte Junktion-Points
291 class CSpecialFolder
: public CShellFolder
294 CSpecialFolder( int nFolder
);
297 CSpecialFolder() : CShellFolder() {};
299 void Initialize( int nFolder
);
304 //----------------------------------------------------------------------------
306 //----------------------------------------------------------------------------
308 // Der MS-Windows "Arbeitsplatz"
310 class CMyComputerFolder
: public CSpecialFolder
313 CMyComputerFolder() : CSpecialFolder( CSIDL_DRIVES
) {};
316 //----------------------------------------------------------------------------
318 //----------------------------------------------------------------------------
320 // Wie CMyComputersFolder, enthält aber nur die Laufwerke
322 class CVolumesFolder
: public CMyComputerFolder
325 CVolumesFolder() : CMyComputerFolder() {};
327 virtual BOOL
ValidateID( const CItemIDList
& );
328 virtual NotificationEvent
WaitForChanges();
331 //----------------------------------------------------------------------------
333 //----------------------------------------------------------------------------
335 // Wie CMyComputersFolder, enthält aber keine!!! Laufwerke
337 class CWorkplaceFolder
: public CMyComputerFolder
339 CWorkplaceFolder() : CMyComputerFolder() {};
341 virtual BOOL
ValidateID( const CItemIDList
& );
342 virtual NotificationEvent
WaitForChanges();
345 //----------------------------------------------------------------------------
347 //----------------------------------------------------------------------------
349 // Der MS-Windows Desktop
351 class CDesktopFolder
: public CSpecialFolder
354 CDesktopFolder() : CSpecialFolder( CSIDL_DESKTOP
) {};
357 //----------------------------------------------------------------------------
358 // CDesktopAncestorsFolder
359 //----------------------------------------------------------------------------
361 // Wie CDesktopFolder, enthält aber nur Arbeitsplatz und Netzwerk
363 class CDesktopAncestorsFolder
: public CDesktopFolder
366 CDesktopAncestorsFolder() : CDesktopFolder() {};
368 virtual BOOL
ValidateID( const CItemIDList
& );
369 virtual NotificationEvent
WaitForChanges();
372 //----------------------------------------------------------------------------
373 // CDesktopContentsFolder
374 //----------------------------------------------------------------------------
376 // Wie CDesktopFolder, aber ohne!!! Arbeitsplatz und Netzwerk
378 class CDesktopContentsFolder
: public CDesktopFolder
381 CDesktopContentsFolder() : CDesktopFolder() {};
383 virtual BOOL
ValidateID( const CItemIDList
& );
384 virtual NotificationEvent
WaitForChanges();
389 #endif // _WINSHELL_HXX