xref: /aoo41x/main/sc/source/ui/vba/vbasheetobject.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_VBA_SHEETOBJECT_HXX
25cdf0e10cSrcweir #define SC_VBA_SHEETOBJECT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <memory>
28cdf0e10cSrcweir #include <ooo/vba/excel/XButton.hpp>
29cdf0e10cSrcweir #include <ooo/vba/excel/XControlObject.hpp>
30cdf0e10cSrcweir #include <ooo/vba/excel/XSheetObject.hpp>
31cdf0e10cSrcweir #include <vbahelper/vbahelperinterface.hxx>
32cdf0e10cSrcweir #include "vbapalette.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace com { namespace sun { namespace star {
35cdf0e10cSrcweir     namespace container { class XIndexContainer; }
36cdf0e10cSrcweir     namespace drawing { class XControlShape; }
37cdf0e10cSrcweir } } }
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // ============================================================================
40cdf0e10cSrcweir 
41cdf0e10cSrcweir typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaButtonCharacters_BASE;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir /** Simple implementation of the Characters symbol for drawing button objects. */
44cdf0e10cSrcweir class ScVbaButtonCharacters : public ScVbaButtonCharacters_BASE
45cdf0e10cSrcweir {
46cdf0e10cSrcweir public:
47cdf0e10cSrcweir 	explicit ScVbaButtonCharacters(
48cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
49cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
50cdf0e10cSrcweir         const css::uno::Reference< css::beans::XPropertySet >& rxPropSet,
51cdf0e10cSrcweir         const ScVbaPalette& rPalette,
52cdf0e10cSrcweir         const css::uno::Any& rStart,
53cdf0e10cSrcweir         const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
54cdf0e10cSrcweir 	virtual ~ScVbaButtonCharacters();
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	// XCharacters attributes
57cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
58cdf0e10cSrcweir 	virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
59cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
60cdf0e10cSrcweir 	virtual void SAL_CALL setText( const ::rtl::OUString& rText ) throw (css::uno::RuntimeException);
61cdf0e10cSrcweir 	virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
62cdf0e10cSrcweir 	virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
63cdf0e10cSrcweir 	virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	// XCharacters methods
66cdf0e10cSrcweir 	virtual void SAL_CALL Insert( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
67cdf0e10cSrcweir 	virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	// XHelperInterface
70cdf0e10cSrcweir     VBAHELPER_DECL_XHELPERINTERFACE
71cdf0e10cSrcweir 
72cdf0e10cSrcweir private:
73cdf0e10cSrcweir     ::rtl::OUString getFullString() const throw (css::uno::RuntimeException);
74cdf0e10cSrcweir     void setFullString( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir private:
77cdf0e10cSrcweir     ScVbaPalette maPalette;
78cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > mxPropSet;
79cdf0e10cSrcweir     sal_Int32 mnStart;
80cdf0e10cSrcweir     sal_Int32 mnLength;
81cdf0e10cSrcweir };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir // ============================================================================
84cdf0e10cSrcweir 
85cdf0e10cSrcweir typedef InheritedHelperInterfaceImpl1< ov::excel::XSheetObject > ScVbaSheetObject_BASE;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir /** Base class for drawing objects embedded in sheets. */
88cdf0e10cSrcweir class ScVbaSheetObjectBase : public ScVbaSheetObject_BASE
89cdf0e10cSrcweir {
90cdf0e10cSrcweir public:
91cdf0e10cSrcweir     explicit ScVbaSheetObjectBase(
92cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
93cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
94cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& rxModel,
95cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XShape >& rxShape ) throw (css::uno::RuntimeException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     // XSheetObject attributes
98cdf0e10cSrcweir     virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
99cdf0e10cSrcweir     virtual void SAL_CALL setLeft( double fLeft ) throw (css::uno::RuntimeException);
100cdf0e10cSrcweir     virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
101cdf0e10cSrcweir     virtual void SAL_CALL setTop( double fTop ) throw (css::uno::RuntimeException);
102cdf0e10cSrcweir     virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
103cdf0e10cSrcweir     virtual void SAL_CALL setWidth( double fWidth ) throw (css::uno::RuntimeException);
104cdf0e10cSrcweir     virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
105cdf0e10cSrcweir     virtual void SAL_CALL setHeight( double fHeight ) throw (css::uno::RuntimeException);
106cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
107cdf0e10cSrcweir     virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
108cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getPlacement() throw (css::uno::RuntimeException);
109cdf0e10cSrcweir     virtual void SAL_CALL setPlacement( sal_Int32 nPlacement ) throw (css::uno::RuntimeException);
110cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
111cdf0e10cSrcweir     virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     /** Sets default properties after a new object has been created. */
114cdf0e10cSrcweir     void setDefaultProperties( sal_Int32 nIndex ) throw (css::uno::RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir protected:
117cdf0e10cSrcweir     /** Derived classes return the base name used for new objects. */
118cdf0e10cSrcweir     virtual ::rtl::OUString implGetBaseName() const = 0;
119cdf0e10cSrcweir     /** Derived classes set default properties for new drawing objects. */
120cdf0e10cSrcweir     virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir protected:
123cdf0e10cSrcweir     ScVbaPalette maPalette;
124cdf0e10cSrcweir     css::uno::Reference< css::frame::XModel > mxModel;
125cdf0e10cSrcweir     css::uno::Reference< css::drawing::XShape > mxShape;
126cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > mxShapeProps;
127cdf0e10cSrcweir };
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // ============================================================================
130cdf0e10cSrcweir 
131cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1< ScVbaSheetObjectBase, ov::excel::XControlObject > ScVbaControlObject_BASE;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir class ScVbaControlObjectBase : public ScVbaControlObject_BASE
134cdf0e10cSrcweir {
135cdf0e10cSrcweir public:
136cdf0e10cSrcweir     /** Specifies the listener used for OnAction events. */
137cdf0e10cSrcweir     enum ListenerType
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir         LISTENER_ACTION,        /// XActionListener.actionPerformed
140cdf0e10cSrcweir         LISTENER_MOUSE,         /// XMouseListener.mouseReleased
141cdf0e10cSrcweir         LISTENER_TEXT,          /// XTextListener.textChanged
142cdf0e10cSrcweir         LISTENER_VALUE,         /// XAdjustmentListener.adjustmentValueChanged
143cdf0e10cSrcweir         LISTENER_CHANGE         /// XChangeListener.changed
144cdf0e10cSrcweir     };
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     explicit ScVbaControlObjectBase(
147cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
148cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
149cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& rxModel,
150cdf0e10cSrcweir         const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
151cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XControlShape >& rxControlShape,
152cdf0e10cSrcweir         ListenerType eListenerType ) throw (css::uno::RuntimeException);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     // XSheetObject attributes
155cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
156cdf0e10cSrcweir     virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
157cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
158cdf0e10cSrcweir     virtual void SAL_CALL setOnAction( const ::rtl::OUString& rMacroName ) throw (css::uno::RuntimeException);
159cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
160cdf0e10cSrcweir     virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     // XControlObject attributes
163cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
164cdf0e10cSrcweir     virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir protected:
167cdf0e10cSrcweir     sal_Int32 getModelIndexInForm() const throw (css::uno::RuntimeException);
168cdf0e10cSrcweir 
169cdf0e10cSrcweir protected:
170cdf0e10cSrcweir     css::uno::Reference< css::container::XIndexContainer > mxFormIC;
171cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > mxControlProps;
172cdf0e10cSrcweir     ::rtl::OUString maListenerType;
173cdf0e10cSrcweir     ::rtl::OUString maEventMethod;
174cdf0e10cSrcweir };
175cdf0e10cSrcweir 
176cdf0e10cSrcweir // ============================================================================
177cdf0e10cSrcweir 
178cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir class ScVbaButton : public ScVbaButton_BASE
181cdf0e10cSrcweir {
182cdf0e10cSrcweir public:
183cdf0e10cSrcweir     explicit ScVbaButton(
184cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
185cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
186cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& rxModel,
187cdf0e10cSrcweir         const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
188cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XControlShape >& rxControlShape ) throw (css::uno::RuntimeException);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     // XButton attributes
191cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
192cdf0e10cSrcweir     virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
193cdf0e10cSrcweir     virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
194cdf0e10cSrcweir     virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
195cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getHorizontalAlignment() throw (css::uno::RuntimeException);
196cdf0e10cSrcweir     virtual void SAL_CALL setHorizontalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
197cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getVerticalAlignment() throw (css::uno::RuntimeException);
198cdf0e10cSrcweir     virtual void SAL_CALL setVerticalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
199cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getOrientation() throw (css::uno::RuntimeException);
200cdf0e10cSrcweir     virtual void SAL_CALL setOrientation( sal_Int32 nOrientation ) throw (css::uno::RuntimeException);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     // XButton methods
203cdf0e10cSrcweir     css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters(
204cdf0e10cSrcweir         const css::uno::Any& rStart, const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     // XHelperInterface
207cdf0e10cSrcweir     VBAHELPER_DECL_XHELPERINTERFACE
208cdf0e10cSrcweir 
209cdf0e10cSrcweir protected:
210cdf0e10cSrcweir     virtual ::rtl::OUString implGetBaseName() const;
211cdf0e10cSrcweir     virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
212cdf0e10cSrcweir };
213cdf0e10cSrcweir 
214cdf0e10cSrcweir // ============================================================================
215cdf0e10cSrcweir 
216cdf0e10cSrcweir #endif
217