1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
22 
23 #include <vcl/weld.hxx>
24 #include <rtl/ustring.hxx>
25 #include <map>
26 
27 namespace dbaui
28 {
29 
30     // OpenDocumentButton
31     /** a button which can be used to open a document
32 
33         The text of the button is the same as for the "Open" command in the application
34         UI. Additionally, the icon for this command is also displayed on the button.
35     */
36     class OpenDocumentButton
37     {
38     private:
39         OUString     m_sModule;
40 
41         std::unique_ptr<weld::Button> m_xControl;
42     public:
43         OpenDocumentButton(std::unique_ptr<weld::Button> xControl, const sal_Char* _pAsciiModuleName);
44 
set_sensitive(bool bSensitive)45         void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
get_sensitive() const46         bool get_sensitive() const { return m_xControl->get_sensitive(); }
connect_clicked(const Link<weld::Button &,void> & rLink)47         void connect_clicked(const Link<weld::Button&, void>& rLink) { m_xControl->connect_clicked(rLink); }
48 
49     private:
50         void    impl_init( const sal_Char* _pAsciiModuleName );
51     };
52 
53     // OpenDocumentListBox
54     class OpenDocumentListBox
55     {
56     private:
57         typedef std::pair< OUString, OUString >       StringPair;
58 
59         std::vector<StringPair> m_aURLs;
60 
61         std::unique_ptr<weld::ComboBox> m_xControl;
62 
63     public:
64         OpenDocumentListBox(std::unique_ptr<weld::ComboBox> xControl, const sal_Char* _pAsciiModuleName);
65 
66         OUString  GetSelectedDocumentURL() const;
67 
set_sensitive(bool bSensitive)68         void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
get_sensitive() const69         bool get_sensitive() const { return m_xControl->get_sensitive(); }
grab_focus()70         void grab_focus() { m_xControl->grab_focus(); }
get_count() const71         int get_count() const { return m_xControl->get_count(); }
set_active(int nPos)72         void set_active(int nPos) { m_xControl->set_active(nPos); }
connect_changed(const Link<weld::ComboBox &,void> & rLink)73         void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); }
74 
75     private:
76         StringPair  impl_getDocumentAtIndex( sal_uInt16 _nListIndex ) const;
77 
78         void    impl_init( const sal_Char* _pAsciiModuleName );
79     };
80 
81 } // namespace dbaui
82 
83 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
86