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 #ifndef INCLUDED_UNOTOOLS_CMDOPTIONS_HXX
20 #define INCLUDED_UNOTOOLS_CMDOPTIONS_HXX
21 
22 #include <unotools/unotoolsdllapi.h>
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
25 #include <unotools/options.hxx>
26 #include <memory>
27 
28 namespace com::sun::star::uno
29 {
30 template <typename> class Reference;
31 }
32 
33 namespace com::sun::star::frame
34 {
35 class XFrame;
36 }
37 namespace osl
38 {
39 class Mutex;
40 }
41 
42 /*-************************************************************************************************************
43     @descr          The method GetList() returns a list of property values.
44                     Use follow defines to separate values by names.
45 **-***********************************************************************************************************/
46 
47 /*-************************************************************************************************************
48     @short          forward declaration to our private date container implementation
49     @descr          We use these class as internal member to support small memory requirements.
50                     You can create the container if it is necessary. The class which use these mechanism
51                     is faster and smaller then a complete implementation!
52 **-***********************************************************************************************************/
53 
54 class SvtCommandOptions_Impl;
55 
56 /*-************************************************************************************************************
57     @short          collect information about dynamic menus
58     @descr          Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
59     @devstatus      ready to use
60 **-***********************************************************************************************************/
61 
62 class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtCommandOptions final : public utl::detail::Options
63 {
64     friend class SvtCommandOptions_Impl;
65 
66 public:
67     enum CmdOption
68     {
69         CMDOPTION_DISABLED,
70         CMDOPTION_NONE
71     };
72 
73     SvtCommandOptions();
74     virtual ~SvtCommandOptions() override;
75 
76     /*-****************************************************************************************************
77         @short      return complete specified list
78         @descr      Call it to get all entries of an dynamic menu.
79                     We return a list of all nodes with its names and properties.
80         @param      "eOption" select the list to retrieve.
81         @return     A list of command strings is returned.
82 
83         @onerror    We return an empty list.
84     **-***************************************************************************************************/
85 
86     bool HasEntries(CmdOption eOption) const;
87 
88     /*-****************************************************************************************************
89         @short      Lookup if a command URL is inside a given list
90         @descr      Lookup if a command URL is inside a given lst
91         @param      "eOption" select right command list
92         @param      "aCommandURL" a command URL that is used for the look up
93         @return     "sal_True" if the command is inside the list otherwise "sal_False"
94     **-***************************************************************************************************/
95 
96     bool Lookup(CmdOption eOption, const OUString& aCommandURL) const;
97 
98     /*-****************************************************************************************************
99         @short      register an office frame, which must update its dispatches if
100                     the underlying configuration was changed.
101 
102         @descr      To avoid using of "dead" frame objects or implementing
103                     deregistration mechanism too, we use weak references to
104                     the given frames.
105 
106         @param      "xFrame"            points to the frame, which wishes to be
107                                         notified, if configuration was changed.
108     **-***************************************************************************************************/
109 
110     void EstablishFrameCallback(const css::uno::Reference<css::frame::XFrame>& xFrame);
111 
112 private:
113     /*-****************************************************************************************************
114         @short      return a reference to a static mutex
115         @descr      These class is partially threadsafe (for de-/initialization only).
116                     All access methods aren't safe!
117                     We create a static mutex only for one ime and use at different times.
118         @return     A reference to a static mutex member.
119     **-***************************************************************************************************/
120 
121     UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex();
122 
123 private:
124     std::shared_ptr<SvtCommandOptions_Impl> m_pImpl;
125 
126 }; // class SvtCmdOptions
127 
128 #endif // INCLUDED_UNOTOOLS_CMDOPTIONS_HXX
129 
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
131