1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FPICKER_SOURCE_WIN32_FOLDERPICKER_MTAFOP_HXX
21 #define INCLUDED_FPICKER_SOURCE_WIN32_FOLDERPICKER_MTAFOP_HXX
23 #include <sal/config.h>
25 #include <sal/log.hxx>
26 #include <sal/types.h>
27 #include <rtl/ustring.hxx>
28 #include <osl/diagnose.h>
29 #include <osl/mutex.hxx>
36 #pragma warning(push, 1)
37 #pragma warning(disable: 4917)
44 #include "../misc/WinImplHelper.hxx"
47 // a simple helper class used to provide a buffer for different
48 // Win32 file and directory functions
54 CAutoPathBuff( size_t size
= 0 )
57 size
= 32000; // max path length under Win2000
59 pBuff
= new sal_Unicode
[size
];
61 SAL_WARN_IF(!pBuff
, "fpicker", "Could not allocate path buffer");
69 operator sal_Unicode
*( )
72 "No path buffer allocated" );
79 "No path buffer allocated" );
88 // the Mta-Ole clipboard class is for internal use only!
89 // only one instance of this class should be created, the
90 // user has to ensure this!
91 // the class is not thread-safe because it will be used
92 // only from within the clipboard service and the methods
93 // of the clipboard service are already synchronized
96 class CMtaFolderPicker
99 CMtaFolderPicker( sal_uInt32 Flags
);
100 virtual ~CMtaFolderPicker( );
103 sal_Bool SAL_CALL
browseForFolder( );
105 virtual void SAL_CALL
setDisplayDirectory( const OUString
& aDirectory
);
106 virtual OUString SAL_CALL
getDisplayDirectory( );
107 virtual OUString SAL_CALL
getDirectory( );
109 virtual void SAL_CALL
setDescription( const OUString
& aDescription
);
111 virtual void SAL_CALL
setTitle( const OUString
& aTitle
);
112 OUString SAL_CALL
getTitle( );
118 virtual void SAL_CALL
cancel( );
121 void SAL_CALL
enableOk( sal_Bool bEnable
);
122 void SAL_CALL
setSelection( const OUString
& aDirectory
);
123 void SAL_CALL
setStatusText( const OUString
& aStatusText
);
125 virtual void SAL_CALL
onInitialized( );
126 virtual void SAL_CALL
onSelChanged( const OUString
& aNewPath
) = 0;
129 sal_uInt32
onValidateFailed();
132 LPITEMIDLIST SAL_CALL
getItemIdListFromPath( const OUString
& aDirectory
);
133 OUString SAL_CALL
getPathFromItemIdList( LPCITEMIDLIST lpItemIdList
);
134 void SAL_CALL
releaseItemIdList( LPITEMIDLIST lpItemIdList
);
138 // create a hidden windows which serves as an request
139 // target; so we guarantee synchronization
140 sal_Bool SAL_CALL
createStaRequestWindow( );
143 // message handler functions; remember these functions are called
144 // from a different thread context!
147 sal_Bool SAL_CALL
onBrowseForFolder( );
149 static LRESULT CALLBACK
StaWndProc( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
150 static unsigned int WINAPI
StaThreadProc( LPVOID pParam
);
152 static int CALLBACK
FolderPickerCallback( HWND hwnd
, UINT uMsg
, LPARAM lParam
, LPARAM lpData
);
158 ATOM SAL_CALL
RegisterStaRequestWindowClass( );
159 void SAL_CALL
UnregisterStaRequestWindowClass( );
163 unsigned m_uStaThreadId
;
164 HANDLE m_hEvtThrdReady
;
165 HWND m_hwndStaRequestWnd
;
166 OUString m_dialogTitle
;
167 OUString m_Description
;
168 OUString m_displayDir
;
169 OUString m_SelectedDir
;
171 CAutoPathBuff m_pathBuff
;
172 HINSTANCE m_hInstance
;
174 // the request window class has to be registered only
175 // once per process, so multiple instance of this class
176 // share the registered window class
177 static ATOM s_ClassAtom
;
178 static osl::Mutex s_Mutex
;
179 static sal_Int32 s_StaRequestWndRegisterCount
;
181 // prevent copy and assignment
183 CMtaFolderPicker( const CMtaFolderPicker
& );
184 CMtaFolderPicker
& operator=( const CMtaFolderPicker
& );
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */