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