1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CONTROLCOMMAND_HXX_
29 #define _CONTROLCOMMAND_HXX_
30 
31 //------------------------------------------------------------------------
32 // includes
33 //------------------------------------------------------------------------
34 
35 #include <sal/types.h>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <rtl/ustring.hxx>
38 
39 //---------------------------------------------
40 //
41 //---------------------------------------------
42 
43 class CFilePickerState;
44 class CControlCommandRequest;
45 class CControlCommandResult;
46 
47 //---------------------------------------------
48 //
49 //---------------------------------------------
50 
51 class CControlCommand
52 {
53 public:
54     CControlCommand( sal_Int16 aControlId );
55     virtual ~CControlCommand( );
56 
57     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState ) = 0;
58 
59     // the client inherits the ownership of the returned
60     // CControlCommandResult and has to delete it or he may
61     // use the auto_ptr template for automatic deletion
62     virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest );
63 
64     // clients of this method should use the returned
65     // pointer only temporary because it's not ref-counted
66     // and the ownerhsip belongs to this instance
67     CControlCommand* SAL_CALL getNextCommand( ) const;
68 
69     // transfers the ownership to this class
70     void SAL_CALL setNextCommand( CControlCommand* nextCommand );
71 
72 protected:
73     sal_Int16 SAL_CALL getControlId( ) const;
74 
75 private:
76     CControlCommand* m_NextCommand;
77     sal_Int16        m_aControlId;
78 };
79 
80 //---------------------------------------------
81 //
82 //---------------------------------------------
83 
84 class CValueControlCommand : public CControlCommand
85 {
86 public:
87     CValueControlCommand(
88         sal_Int16 aControlId,
89         sal_Int16 aControlAction,
90         const ::com::sun::star::uno::Any& aValue );
91 
92     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState );
93 
94     virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest );
95 
96     sal_Int16 SAL_CALL getControlAction( ) const;
97 
98     ::com::sun::star::uno::Any SAL_CALL getValue( ) const;
99 
100 private:
101     sal_Int16                  m_aControlAction;
102     ::com::sun::star::uno::Any m_aValue;
103 };
104 
105 //---------------------------------------------
106 //
107 //---------------------------------------------
108 
109 class CLabelControlCommand : public CControlCommand
110 {
111 public:
112     CLabelControlCommand(
113         sal_Int16 aControlId,
114         const rtl::OUString& aLabel );
115 
116     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState );
117 
118     virtual CControlCommandResult* SAL_CALL handleRequest( CControlCommandRequest* aRequest );
119 
120     rtl::OUString SAL_CALL getLabel( ) const;
121 
122 private:
123     rtl::OUString m_aLabel;
124 };
125 
126 //---------------------------------------------
127 //
128 //---------------------------------------------
129 
130 class CEnableControlCommand : public CControlCommand
131 {
132 public:
133     CEnableControlCommand(
134         sal_Int16 controlId,
135         sal_Bool bEnable );
136 
137     virtual void SAL_CALL exec( CFilePickerState* aFilePickerState );
138 
139 private:
140     sal_Bool m_bEnable;
141 };
142 
143 #endif
144