1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski #ifndef INCLUDED_unotools_CMDOPTIONS_HXX
24*b1cdbd2cSJim Jagielski #define INCLUDED_unotools_CMDOPTIONS_HXX
25*b1cdbd2cSJim Jagielski 
26*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
27*b1cdbd2cSJim Jagielski //	includes
28*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
29*b1cdbd2cSJim Jagielski 
30*b1cdbd2cSJim Jagielski #include "unotools/unotoolsdllapi.h"
31*b1cdbd2cSJim Jagielski #include <sal/types.h>
32*b1cdbd2cSJim Jagielski #include <osl/mutex.hxx>
33*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/Sequence.h>
34*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XFrame.hpp>
35*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx>
36*b1cdbd2cSJim Jagielski #include <unotools/options.hxx>
37*b1cdbd2cSJim Jagielski 
38*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
39*b1cdbd2cSJim Jagielski //	types, enums, ...
40*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
41*b1cdbd2cSJim Jagielski 
42*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//**
43*b1cdbd2cSJim Jagielski 	@descr			The method GetList() returns a list of property values.
44*b1cdbd2cSJim Jagielski 					Use follow defines to seperate values by names.
45*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/
46*b1cdbd2cSJim Jagielski #define CMDOPTIONS_PROPERTYNAME_URL                    ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CommandURL" ))
47*b1cdbd2cSJim Jagielski 
48*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
49*b1cdbd2cSJim Jagielski //	forward declarations
50*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
51*b1cdbd2cSJim Jagielski 
52*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//**
53*b1cdbd2cSJim Jagielski 	@short			forward declaration to our private date container implementation
54*b1cdbd2cSJim Jagielski 	@descr			We use these class as internal member to support small memory requirements.
55*b1cdbd2cSJim Jagielski 					You can create the container if it is neccessary. The class which use these mechanism
56*b1cdbd2cSJim Jagielski 					is faster and smaller then a complete implementation!
57*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/
58*b1cdbd2cSJim Jagielski 
59*b1cdbd2cSJim Jagielski class SvtCommandOptions_Impl;
60*b1cdbd2cSJim Jagielski 
61*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
62*b1cdbd2cSJim Jagielski //	declarations
63*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
64*b1cdbd2cSJim Jagielski 
65*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//**
66*b1cdbd2cSJim Jagielski     @short          collect informations about dynamic menus
67*b1cdbd2cSJim Jagielski     @descr          Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
68*b1cdbd2cSJim Jagielski 
69*b1cdbd2cSJim Jagielski 	@implements		-
70*b1cdbd2cSJim Jagielski 	@base			-
71*b1cdbd2cSJim Jagielski 
72*b1cdbd2cSJim Jagielski 	@devstatus		ready to use
73*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/
74*b1cdbd2cSJim Jagielski 
75*b1cdbd2cSJim Jagielski class UNOTOOLS_DLLPUBLIC SvtCommandOptions: public utl::detail::Options
76*b1cdbd2cSJim Jagielski {
77*b1cdbd2cSJim Jagielski 	friend class SvtCommandOptions_Impl;
78*b1cdbd2cSJim Jagielski 
79*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
80*b1cdbd2cSJim Jagielski 	//	public methods
81*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
82*b1cdbd2cSJim Jagielski 
83*b1cdbd2cSJim Jagielski 	public:
84*b1cdbd2cSJim Jagielski 
85*b1cdbd2cSJim Jagielski 		enum CmdOption
86*b1cdbd2cSJim Jagielski 		{
87*b1cdbd2cSJim Jagielski 			CMDOPTION_DISABLED,
88*b1cdbd2cSJim Jagielski 			CMDOPTION_NONE
89*b1cdbd2cSJim Jagielski 		};
90*b1cdbd2cSJim Jagielski 
91*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
92*b1cdbd2cSJim Jagielski 		//	constructor / destructor
93*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
94*b1cdbd2cSJim Jagielski 
95*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
96*b1cdbd2cSJim Jagielski 			@short		standard constructor and destructor
97*b1cdbd2cSJim Jagielski 			@descr		This will initialize an instance with default values.
98*b1cdbd2cSJim Jagielski 						We implement these class with a refcount mechanism! Every instance of this class increase it
99*b1cdbd2cSJim Jagielski 						at create and decrease it at delete time - but all instances use the same data container!
100*b1cdbd2cSJim Jagielski 						He is implemented as a static member ...
101*b1cdbd2cSJim Jagielski 
102*b1cdbd2cSJim Jagielski 			@seealso	member m_nRefCount
103*b1cdbd2cSJim Jagielski 			@seealso	member m_pDataContainer
104*b1cdbd2cSJim Jagielski 
105*b1cdbd2cSJim Jagielski 			@param		-
106*b1cdbd2cSJim Jagielski 			@return		-
107*b1cdbd2cSJim Jagielski 
108*b1cdbd2cSJim Jagielski 			@onerror	-
109*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
110*b1cdbd2cSJim Jagielski 
111*b1cdbd2cSJim Jagielski          SvtCommandOptions();
112*b1cdbd2cSJim Jagielski         virtual ~SvtCommandOptions();
113*b1cdbd2cSJim Jagielski 
114*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
115*b1cdbd2cSJim Jagielski 		//	interface
116*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
117*b1cdbd2cSJim Jagielski 
118*b1cdbd2cSJim Jagielski         /*-****************************************************************************************************//**
119*b1cdbd2cSJim Jagielski 			@short		clear complete sepcified list
120*b1cdbd2cSJim Jagielski             @descr      Call this methods to clear the whole list.
121*b1cdbd2cSJim Jagielski                         To fill it again use AppendItem().
122*b1cdbd2cSJim Jagielski 
123*b1cdbd2cSJim Jagielski 			@seealso	-
124*b1cdbd2cSJim Jagielski 
125*b1cdbd2cSJim Jagielski             @param      "eMenu" select right menu to clear.
126*b1cdbd2cSJim Jagielski 			@return		-
127*b1cdbd2cSJim Jagielski 
128*b1cdbd2cSJim Jagielski 			@onerror	-
129*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
130*b1cdbd2cSJim Jagielski 
131*b1cdbd2cSJim Jagielski         void Clear( CmdOption eOption );
132*b1cdbd2cSJim Jagielski 
133*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
134*b1cdbd2cSJim Jagielski             @short      return complete specified list
135*b1cdbd2cSJim Jagielski             @descr      Call it to get all entries of an dynamic menu.
136*b1cdbd2cSJim Jagielski                         We return a list of all nodes with his names and properties.
137*b1cdbd2cSJim Jagielski 
138*b1cdbd2cSJim Jagielski 			@seealso	-
139*b1cdbd2cSJim Jagielski 
140*b1cdbd2cSJim Jagielski             @param      "eOption" select the list to retrieve.
141*b1cdbd2cSJim Jagielski             @return     A list of command strings is returned.
142*b1cdbd2cSJim Jagielski 
143*b1cdbd2cSJim Jagielski             @onerror    We return an empty list.
144*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
145*b1cdbd2cSJim Jagielski 
146*b1cdbd2cSJim Jagielski         sal_Bool HasEntries( CmdOption eOption ) const;
147*b1cdbd2cSJim Jagielski 
148*b1cdbd2cSJim Jagielski         /*-****************************************************************************************************//**
149*b1cdbd2cSJim Jagielski 			@short		Lookup if a command URL is inside a given list
150*b1cdbd2cSJim Jagielski             @descr      Lookup if a command URL is inside a given lst
151*b1cdbd2cSJim Jagielski 
152*b1cdbd2cSJim Jagielski 			@seealso	-
153*b1cdbd2cSJim Jagielski 
154*b1cdbd2cSJim Jagielski             @param      "eOption" select right command list
155*b1cdbd2cSJim Jagielski 			@param		"aCommandURL" a command URL that is used for the look up
156*b1cdbd2cSJim Jagielski 			@return		"sal_True" if the command is inside the list otherwise "sal_False"
157*b1cdbd2cSJim Jagielski 
158*b1cdbd2cSJim Jagielski 			@onerror	-
159*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
160*b1cdbd2cSJim Jagielski 
161*b1cdbd2cSJim Jagielski         sal_Bool Lookup( CmdOption eOption, const ::rtl::OUString& aCommandURL ) const;
162*b1cdbd2cSJim Jagielski 
163*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
164*b1cdbd2cSJim Jagielski             @short      return complete specified list
165*b1cdbd2cSJim Jagielski             @descr      Call it to get all entries of an dynamic menu.
166*b1cdbd2cSJim Jagielski                         We return a list of all nodes with his names and properties.
167*b1cdbd2cSJim Jagielski 
168*b1cdbd2cSJim Jagielski 			@seealso	-
169*b1cdbd2cSJim Jagielski 
170*b1cdbd2cSJim Jagielski             @param      "eOption" select the list to retrieve.
171*b1cdbd2cSJim Jagielski             @return     A list of command strings is returned.
172*b1cdbd2cSJim Jagielski 
173*b1cdbd2cSJim Jagielski             @onerror    We return an empty list.
174*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
175*b1cdbd2cSJim Jagielski 
176*b1cdbd2cSJim Jagielski         ::com::sun::star::uno::Sequence< ::rtl::OUString > GetList( CmdOption eOption ) const;
177*b1cdbd2cSJim Jagielski 
178*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
179*b1cdbd2cSJim Jagielski             @short      adds a new command to specified options list
180*b1cdbd2cSJim Jagielski             @descr      You can add a command to specified options list!
181*b1cdbd2cSJim Jagielski 
182*b1cdbd2cSJim Jagielski 			@seealso	method Clear()
183*b1cdbd2cSJim Jagielski 
184*b1cdbd2cSJim Jagielski 			@param		"eOption"			specifies the command list
185*b1cdbd2cSJim Jagielski 			@param      "sURL"              URL for dispatch
186*b1cdbd2cSJim Jagielski 			@return		-
187*b1cdbd2cSJim Jagielski 
188*b1cdbd2cSJim Jagielski 			@onerror	-
189*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
190*b1cdbd2cSJim Jagielski 
191*b1cdbd2cSJim Jagielski         void AddCommand( CmdOption eOption, const ::rtl::OUString& sURL );
192*b1cdbd2cSJim Jagielski 
193*b1cdbd2cSJim Jagielski         /*-****************************************************************************************************//**
194*b1cdbd2cSJim Jagielski             @short      register an office frame, which must update its dispatches if
195*b1cdbd2cSJim Jagielski                         the underlying configuration was changed.
196*b1cdbd2cSJim Jagielski 
197*b1cdbd2cSJim Jagielski             @descr      To avoid using of "dead" frame objects or implementing
198*b1cdbd2cSJim Jagielski                         deregistration mechanism too, we use weak references to
199*b1cdbd2cSJim Jagielski                         the given frames.
200*b1cdbd2cSJim Jagielski 
201*b1cdbd2cSJim Jagielski             @param      "xFrame"            points to the frame, which wish to be
202*b1cdbd2cSJim Jagielski                                             notified, if configuration was changed.
203*b1cdbd2cSJim Jagielski             @return     -
204*b1cdbd2cSJim Jagielski 
205*b1cdbd2cSJim Jagielski             @onerror    -
206*b1cdbd2cSJim Jagielski         *//*-*****************************************************************************************************/
207*b1cdbd2cSJim Jagielski 
208*b1cdbd2cSJim Jagielski         void EstablisFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
209*b1cdbd2cSJim Jagielski 
210*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
211*b1cdbd2cSJim Jagielski 	//	private methods
212*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
213*b1cdbd2cSJim Jagielski 
214*b1cdbd2cSJim Jagielski 	private:
215*b1cdbd2cSJim Jagielski 
216*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
217*b1cdbd2cSJim Jagielski 			@short		return a reference to a static mutex
218*b1cdbd2cSJim Jagielski 			@descr		These class is partially threadsafe (for de-/initialization only).
219*b1cdbd2cSJim Jagielski 						All access methods are'nt safe!
220*b1cdbd2cSJim Jagielski 						We create a static mutex only for one ime and use at different times.
221*b1cdbd2cSJim Jagielski 
222*b1cdbd2cSJim Jagielski 			@seealso	-
223*b1cdbd2cSJim Jagielski 
224*b1cdbd2cSJim Jagielski 			@param		-
225*b1cdbd2cSJim Jagielski 			@return		A reference to a static mutex member.
226*b1cdbd2cSJim Jagielski 
227*b1cdbd2cSJim Jagielski 			@onerror	-
228*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
229*b1cdbd2cSJim Jagielski 
230*b1cdbd2cSJim Jagielski         UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex();
231*b1cdbd2cSJim Jagielski 
232*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
233*b1cdbd2cSJim Jagielski 	//	private member
234*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
235*b1cdbd2cSJim Jagielski 
236*b1cdbd2cSJim Jagielski 	private:
237*b1cdbd2cSJim Jagielski 
238*b1cdbd2cSJim Jagielski 		/*Attention
239*b1cdbd2cSJim Jagielski 
240*b1cdbd2cSJim Jagielski 			Don't initialize these static member in these header!
241*b1cdbd2cSJim Jagielski 			a) Double dfined symbols will be detected ...
242*b1cdbd2cSJim Jagielski 			b) and unresolved externals exist at linking time.
243*b1cdbd2cSJim Jagielski 			Do it in your source only.
244*b1cdbd2cSJim Jagielski 		 */
245*b1cdbd2cSJim Jagielski 
246*b1cdbd2cSJim Jagielski         static SvtCommandOptions_Impl*	m_pDataContainer    ;   /// impl. data container as dynamic pointer for smaller memory requirements!
247*b1cdbd2cSJim Jagielski         static sal_Int32				m_nRefCount         ;   /// internal ref count mechanism
248*b1cdbd2cSJim Jagielski 
249*b1cdbd2cSJim Jagielski };      // class SvtCmdOptions
250*b1cdbd2cSJim Jagielski 
251*b1cdbd2cSJim Jagielski #endif  // #ifndef INCLUDED_unotools_CMDOPTIONS_HXX
252