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_BASCTL_SOURCE_BASICIDE_MACRODLG_HXX
21 #define INCLUDED_BASCTL_SOURCE_BASICIDE_MACRODLG_HXX
22 
23 #include <bastype2.hxx>
24 #include <sfx2/basedlgs.hxx>
25 #include <com/sun/star/frame/XFrame.hpp>
26 #include <vcl/weld.hxx>
27 
28 namespace basctl
29 {
30 
31 enum MacroExitCode {
32     Macro_Close = 110,
33     Macro_OkRun = 111,
34     Macro_New   = 112,
35     Macro_Edit  = 114,
36 };
37 
38 class MacroChooser : public SfxDialogController
39 {
40 public:
41     enum Mode {
42         All = 1,
43         ChooseOnly = 2,
44         Recording = 3,
45     };
46 
47 private:
48     OUString                       m_aMacrosInTxtBaseStr;
49 
50     // For forwarding to Assign dialog
51     ::css::uno::Reference< ::css::frame::XFrame > m_xDocumentFrame;
52 
53     bool                    bForceStoreBasic;
54 
55     Mode                    nMode;
56 
57     DECL_LINK(MacroSelectHdl, weld::TreeView&, void);
58     DECL_LINK(MacroDoubleClickHdl, weld::TreeView&, bool);
59     DECL_LINK(BasicSelectHdl, weld::TreeView&, void);
60     DECL_LINK(EditModifyHdl, weld::Entry&, void);
61     DECL_LINK(ButtonHdl, weld::Button&, void);
62 
63     void                CheckButtons();
64     void                SaveSetCurEntry(weld::TreeView& rBox, const weld::TreeIter& rEntry);
65     void                UpdateFields();
66 
67     void                EnableButton(weld::Button& rButton, bool bEnable);
68 
69     static OUString     GetInfo( SbxVariable* pVar );
70 
71     void                StoreMacroDescription();
72     void                RestoreMacroDescription();
73 
74     std::unique_ptr<weld::Entry> m_xMacroNameEdit;
75     std::unique_ptr<weld::Label> m_xMacroFromTxT;
76     std::unique_ptr<weld::Label> m_xMacrosSaveInTxt;
77     std::unique_ptr<SbTreeListBox> m_xBasicBox;
78     std::unique_ptr<weld::TreeIter> m_xBasicBoxIter;
79     std::unique_ptr<weld::Label> m_xMacrosInTxt;
80     std::unique_ptr<weld::TreeView> m_xMacroBox;
81     std::unique_ptr<weld::TreeIter> m_xMacroBoxIter;
82     std::unique_ptr<weld::Button> m_xRunButton;
83     std::unique_ptr<weld::Button> m_xCloseButton;
84     std::unique_ptr<weld::Button> m_xAssignButton;
85     std::unique_ptr<weld::Button> m_xEditButton;
86     std::unique_ptr<weld::Button> m_xDelButton;
87     std::unique_ptr<weld::Button> m_xNewButton;
88     std::unique_ptr<weld::Button> m_xOrganizeButton;
89     std::unique_ptr<weld::Button> m_xNewLibButton;
90     std::unique_ptr<weld::Button> m_xNewModButton;
91 public:
92     MacroChooser(weld::Window *pParent, const ::css::uno::Reference< ::css::frame::XFrame >& xDocFrame);
93     virtual ~MacroChooser() override;
94 
95     SbMethod*           GetMacro();
96     void                DeleteMacro();
97     SbMethod*           CreateMacro();
98 
99     virtual short       run() override;
100 
101     void                SetMode (Mode);
GetMode() const102     Mode                GetMode () const { return nMode; }
103 };
104 
105 } // namespace basctl
106 
107 #endif // INCLUDED_BASCTL_SOURCE_BASICIDE_MACRODLG_HXX
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
110