update emoji autocorrect entries from po-files
[LibreOffice.git] / fpicker / source / win32 / folderpicker / MtaFop.hxx
blob62a01df6034b4aaf867edff93b5a9943f101d51b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
31 #include <utility>
32 #ifdef __MINGW32__
33 #include <windows.h>
34 #endif
35 #if defined _MSC_VER
36 #pragma warning(push, 1)
37 #pragma warning(disable: 4917)
38 #endif
39 #include <objidl.h>
40 #include <shlobj.h>
41 #if defined _MSC_VER
42 #pragma warning(pop)
43 #endif
44 #include "../misc/WinImplHelper.hxx"
47 // a simple helper class used to provide a buffer for different
48 // Win32 file and directory functions
51 class CAutoPathBuff
53 public:
54 CAutoPathBuff( size_t size = 0 )
56 if (0 == size)
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");
64 ~CAutoPathBuff( )
66 delete [] pBuff;
69 operator sal_Unicode*( )
71 OSL_PRECOND( pBuff, \
72 "No path buffer allocated" );
73 return pBuff;
76 sal_Unicode* get( )
78 OSL_PRECOND( pBuff, \
79 "No path buffer allocated" );
80 return pBuff;
83 private:
84 sal_Unicode* pBuff;
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
98 public:
99 CMtaFolderPicker( sal_uInt32 Flags );
100 virtual ~CMtaFolderPicker( );
102 // shell functions
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( );
115 // XCancellable
118 virtual void SAL_CALL cancel( );
120 protected:
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;
128 private:
129 sal_uInt32 onValidateFailed();
131 // helper functions
132 LPITEMIDLIST SAL_CALL getItemIdListFromPath( const OUString& aDirectory );
133 OUString SAL_CALL getPathFromItemIdList( LPCITEMIDLIST lpItemIdList );
134 void SAL_CALL releaseItemIdList( LPITEMIDLIST lpItemIdList );
136 unsigned int run( );
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 );
154 protected:
155 HWND m_hwnd;
157 private:
158 ATOM SAL_CALL RegisterStaRequestWindowClass( );
159 void SAL_CALL UnregisterStaRequestWindowClass( );
161 private:
162 HANDLE m_hStaThread;
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;
170 BROWSEINFOW m_bi;
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
182 private:
183 CMtaFolderPicker( const CMtaFolderPicker& );
184 CMtaFolderPicker& operator=( const CMtaFolderPicker& );
187 #endif
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */