1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONTROLCOMMAND_HXX_
25 #define _CONTROLCOMMAND_HXX_
26 
27 //------------------------------------------------------------------------
28 // includes
29 //------------------------------------------------------------------------
30 
31 #include <sal/types.h>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <rtl/ustring.hxx>
34 
35 //---------------------------------------------
36 //
37 //---------------------------------------------
38 
39 class CFilePickerState;
40 class CControlCommandRequest;
41 class CControlCommandResult;
42 
43 //---------------------------------------------
44 //
45 //---------------------------------------------
46 
47 class CControlCommand
48 {
49 public:
50     CControlCommand( sal_Int16 aControlId );
51     virtual ~CControlCommand( );
52 
53     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState ) = 0;
54 
55     // the client inherits the ownership of the returned
56     // CControlCommandResult and has to delete it or he may
57     // use the auto_ptr template for automatic deletion
58     virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest );
59 
60     // clients of this method should use the returned
61     // pointer only temporary because it's not ref-counted
62     // and the ownerhsip belongs to this instance
63     CControlCommand* SAL_CALL getNextCommand( ) const;
64 
65     // transfers the ownership to this class
66     void SAL_CALL setNextCommand( CControlCommand* nextCommand );
67 
68 protected:
69     sal_Int16 SAL_CALL getControlId( ) const;
70 
71 private:
72     CControlCommand* m_NextCommand;
73     sal_Int16        m_aControlId;
74 };
75 
76 //---------------------------------------------
77 //
78 //---------------------------------------------
79 
80 class CValueControlCommand : public CControlCommand
81 {
82 public:
83     CValueControlCommand(
84         sal_Int16 aControlId,
85         sal_Int16 aControlAction,
86         const ::com::sun::star::uno::Any& aValue );
87 
88     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState );
89 
90     virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest );
91 
92     sal_Int16 SAL_CALL getControlAction( ) const;
93 
94     ::com::sun::star::uno::Any SAL_CALL getValue( ) const;
95 
96 private:
97     sal_Int16                  m_aControlAction;
98     ::com::sun::star::uno::Any m_aValue;
99 };
100 
101 //---------------------------------------------
102 //
103 //---------------------------------------------
104 
105 class CLabelControlCommand : public CControlCommand
106 {
107 public:
108     CLabelControlCommand(
109         sal_Int16 aControlId,
110         const rtl::OUString& aLabel );
111 
112     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState );
113 
114     virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest );
115 
116     rtl::OUString SAL_CALL getLabel( ) const;
117 
118 private:
119     rtl::OUString m_aLabel;
120 };
121 
122 //---------------------------------------------
123 //
124 //---------------------------------------------
125 
126 class CEnableControlCommand : public CControlCommand
127 {
128 public:
129     CEnableControlCommand(
130         sal_Int16 controlId,
131         sal_Bool bEnable );
132 
133     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState );
134 
135 private:
136     sal_Bool m_bEnable;
137 };
138 
139 #endif
140