xref: /aoo41x/main/sc/source/ui/vba/vbasheetobject.hxx (revision 38d50f7b)
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 SC_VBA_SHEETOBJECT_HXX
25 #define SC_VBA_SHEETOBJECT_HXX
26 
27 #include <memory>
28 #include <ooo/vba/excel/XButton.hpp>
29 #include <ooo/vba/excel/XControlObject.hpp>
30 #include <ooo/vba/excel/XSheetObject.hpp>
31 #include <vbahelper/vbahelperinterface.hxx>
32 #include "vbapalette.hxx"
33 
34 namespace com { namespace sun { namespace star {
35     namespace container { class XIndexContainer; }
36     namespace drawing { class XControlShape; }
37 } } }
38 
39 // ============================================================================
40 
41 typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaButtonCharacters_BASE;
42 
43 /** Simple implementation of the Characters symbol for drawing button objects. */
44 class ScVbaButtonCharacters : public ScVbaButtonCharacters_BASE
45 {
46 public:
47 	explicit ScVbaButtonCharacters(
48         const css::uno::Reference< ov::XHelperInterface >& rxParent,
49         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
50         const css::uno::Reference< css::beans::XPropertySet >& rxPropSet,
51         const ScVbaPalette& rPalette,
52         const css::uno::Any& rStart,
53         const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
54 	virtual ~ScVbaButtonCharacters();
55 
56 	// XCharacters attributes
57 	virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
58 	virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
59 	virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
60 	virtual void SAL_CALL setText( const ::rtl::OUString& rText ) throw (css::uno::RuntimeException);
61 	virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
62 	virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
63 	virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
64 
65 	// XCharacters methods
66 	virtual void SAL_CALL Insert( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
67 	virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
68 
69 	// XHelperInterface
70     VBAHELPER_DECL_XHELPERINTERFACE
71 
72 private:
73     ::rtl::OUString getFullString() const throw (css::uno::RuntimeException);
74     void setFullString( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
75 
76 private:
77     ScVbaPalette maPalette;
78     css::uno::Reference< css::beans::XPropertySet > mxPropSet;
79     sal_Int32 mnStart;
80     sal_Int32 mnLength;
81 };
82 
83 // ============================================================================
84 
85 typedef InheritedHelperInterfaceImpl1< ov::excel::XSheetObject > ScVbaSheetObject_BASE;
86 
87 /** Base class for drawing objects embedded in sheets. */
88 class ScVbaSheetObjectBase : public ScVbaSheetObject_BASE
89 {
90 public:
91     explicit ScVbaSheetObjectBase(
92         const css::uno::Reference< ov::XHelperInterface >& rxParent,
93         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
94         const css::uno::Reference< css::frame::XModel >& rxModel,
95         const css::uno::Reference< css::drawing::XShape >& rxShape ) throw (css::uno::RuntimeException);
96 
97     // XSheetObject attributes
98     virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
99     virtual void SAL_CALL setLeft( double fLeft ) throw (css::uno::RuntimeException);
100     virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
101     virtual void SAL_CALL setTop( double fTop ) throw (css::uno::RuntimeException);
102     virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
103     virtual void SAL_CALL setWidth( double fWidth ) throw (css::uno::RuntimeException);
104     virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
105     virtual void SAL_CALL setHeight( double fHeight ) throw (css::uno::RuntimeException);
106     virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
107     virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
108     virtual sal_Int32 SAL_CALL getPlacement() throw (css::uno::RuntimeException);
109     virtual void SAL_CALL setPlacement( sal_Int32 nPlacement ) throw (css::uno::RuntimeException);
110     virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
111     virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
112 
113     /** Sets default properties after a new object has been created. */
114     void setDefaultProperties( sal_Int32 nIndex ) throw (css::uno::RuntimeException);
115 
116 protected:
117     /** Derived classes return the base name used for new objects. */
118     virtual ::rtl::OUString implGetBaseName() const = 0;
119     /** Derived classes set default properties for new drawing objects. */
120     virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
121 
122 protected:
123     ScVbaPalette maPalette;
124     css::uno::Reference< css::frame::XModel > mxModel;
125     css::uno::Reference< css::drawing::XShape > mxShape;
126     css::uno::Reference< css::beans::XPropertySet > mxShapeProps;
127 };
128 
129 // ============================================================================
130 
131 typedef ::cppu::ImplInheritanceHelper1< ScVbaSheetObjectBase, ov::excel::XControlObject > ScVbaControlObject_BASE;
132 
133 class ScVbaControlObjectBase : public ScVbaControlObject_BASE
134 {
135 public:
136     /** Specifies the listener used for OnAction events. */
137     enum ListenerType
138     {
139         LISTENER_ACTION,        /// XActionListener.actionPerformed
140         LISTENER_MOUSE,         /// XMouseListener.mouseReleased
141         LISTENER_TEXT,          /// XTextListener.textChanged
142         LISTENER_VALUE,         /// XAdjustmentListener.adjustmentValueChanged
143         LISTENER_CHANGE         /// XChangeListener.changed
144     };
145 
146     explicit ScVbaControlObjectBase(
147         const css::uno::Reference< ov::XHelperInterface >& rxParent,
148         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
149         const css::uno::Reference< css::frame::XModel >& rxModel,
150         const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
151         const css::uno::Reference< css::drawing::XControlShape >& rxControlShape,
152         ListenerType eListenerType ) throw (css::uno::RuntimeException);
153 
154     // XSheetObject attributes
155     virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
156     virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
157     virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
158     virtual void SAL_CALL setOnAction( const ::rtl::OUString& rMacroName ) throw (css::uno::RuntimeException);
159     virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
160     virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
161 
162     // XControlObject attributes
163     virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
164     virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
165 
166 protected:
167     sal_Int32 getModelIndexInForm() const throw (css::uno::RuntimeException);
168 
169 protected:
170     css::uno::Reference< css::container::XIndexContainer > mxFormIC;
171     css::uno::Reference< css::beans::XPropertySet > mxControlProps;
172     ::rtl::OUString maListenerType;
173     ::rtl::OUString maEventMethod;
174 };
175 
176 // ============================================================================
177 
178 typedef ::cppu::ImplInheritanceHelper1< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;
179 
180 class ScVbaButton : public ScVbaButton_BASE
181 {
182 public:
183     explicit ScVbaButton(
184         const css::uno::Reference< ov::XHelperInterface >& rxParent,
185         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
186         const css::uno::Reference< css::frame::XModel >& rxModel,
187         const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
188         const css::uno::Reference< css::drawing::XControlShape >& rxControlShape ) throw (css::uno::RuntimeException);
189 
190     // XButton attributes
191     virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
192     virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
193     virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
194     virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
195     virtual sal_Int32 SAL_CALL getHorizontalAlignment() throw (css::uno::RuntimeException);
196     virtual void SAL_CALL setHorizontalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
197     virtual sal_Int32 SAL_CALL getVerticalAlignment() throw (css::uno::RuntimeException);
198     virtual void SAL_CALL setVerticalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
199     virtual sal_Int32 SAL_CALL getOrientation() throw (css::uno::RuntimeException);
200     virtual void SAL_CALL setOrientation( sal_Int32 nOrientation ) throw (css::uno::RuntimeException);
201 
202     // XButton methods
203     css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters(
204         const css::uno::Any& rStart, const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
205 
206     // XHelperInterface
207     VBAHELPER_DECL_XHELPERINTERFACE
208 
209 protected:
210     virtual ::rtl::OUString implGetBaseName() const;
211     virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
212 };
213 
214 // ============================================================================
215 
216 #endif
217