xref: /aoo42x/main/sc/source/ui/vba/vbasheetobject.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SC_VBA_SHEETOBJECT_HXX
29*cdf0e10cSrcweir #define SC_VBA_SHEETOBJECT_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <memory>
32*cdf0e10cSrcweir #include <ooo/vba/excel/XButton.hpp>
33*cdf0e10cSrcweir #include <ooo/vba/excel/XControlObject.hpp>
34*cdf0e10cSrcweir #include <ooo/vba/excel/XSheetObject.hpp>
35*cdf0e10cSrcweir #include <vbahelper/vbahelperinterface.hxx>
36*cdf0e10cSrcweir #include "vbapalette.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir namespace com { namespace sun { namespace star {
39*cdf0e10cSrcweir     namespace container { class XIndexContainer; }
40*cdf0e10cSrcweir     namespace drawing { class XControlShape; }
41*cdf0e10cSrcweir } } }
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir // ============================================================================
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaButtonCharacters_BASE;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir /** Simple implementation of the Characters symbol for drawing button objects. */
48*cdf0e10cSrcweir class ScVbaButtonCharacters : public ScVbaButtonCharacters_BASE
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir public:
51*cdf0e10cSrcweir 	explicit ScVbaButtonCharacters(
52*cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
53*cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
54*cdf0e10cSrcweir         const css::uno::Reference< css::beans::XPropertySet >& rxPropSet,
55*cdf0e10cSrcweir         const ScVbaPalette& rPalette,
56*cdf0e10cSrcweir         const css::uno::Any& rStart,
57*cdf0e10cSrcweir         const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
58*cdf0e10cSrcweir 	virtual ~ScVbaButtonCharacters();
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	// XCharacters attributes
61*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
62*cdf0e10cSrcweir 	virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
63*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
64*cdf0e10cSrcweir 	virtual void SAL_CALL setText( const ::rtl::OUString& rText ) throw (css::uno::RuntimeException);
65*cdf0e10cSrcweir 	virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
66*cdf0e10cSrcweir 	virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
67*cdf0e10cSrcweir 	virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	// XCharacters methods
70*cdf0e10cSrcweir 	virtual void SAL_CALL Insert( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
71*cdf0e10cSrcweir 	virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	// XHelperInterface
74*cdf0e10cSrcweir     VBAHELPER_DECL_XHELPERINTERFACE
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir private:
77*cdf0e10cSrcweir     ::rtl::OUString getFullString() const throw (css::uno::RuntimeException);
78*cdf0e10cSrcweir     void setFullString( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir private:
81*cdf0e10cSrcweir     ScVbaPalette maPalette;
82*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > mxPropSet;
83*cdf0e10cSrcweir     sal_Int32 mnStart;
84*cdf0e10cSrcweir     sal_Int32 mnLength;
85*cdf0e10cSrcweir };
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir // ============================================================================
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir typedef InheritedHelperInterfaceImpl1< ov::excel::XSheetObject > ScVbaSheetObject_BASE;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir /** Base class for drawing objects embedded in sheets. */
92*cdf0e10cSrcweir class ScVbaSheetObjectBase : public ScVbaSheetObject_BASE
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir public:
95*cdf0e10cSrcweir     explicit ScVbaSheetObjectBase(
96*cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
97*cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
98*cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& rxModel,
99*cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XShape >& rxShape ) throw (css::uno::RuntimeException);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     // XSheetObject attributes
102*cdf0e10cSrcweir     virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
103*cdf0e10cSrcweir     virtual void SAL_CALL setLeft( double fLeft ) throw (css::uno::RuntimeException);
104*cdf0e10cSrcweir     virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
105*cdf0e10cSrcweir     virtual void SAL_CALL setTop( double fTop ) throw (css::uno::RuntimeException);
106*cdf0e10cSrcweir     virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
107*cdf0e10cSrcweir     virtual void SAL_CALL setWidth( double fWidth ) throw (css::uno::RuntimeException);
108*cdf0e10cSrcweir     virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
109*cdf0e10cSrcweir     virtual void SAL_CALL setHeight( double fHeight ) throw (css::uno::RuntimeException);
110*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
111*cdf0e10cSrcweir     virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
112*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getPlacement() throw (css::uno::RuntimeException);
113*cdf0e10cSrcweir     virtual void SAL_CALL setPlacement( sal_Int32 nPlacement ) throw (css::uno::RuntimeException);
114*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
115*cdf0e10cSrcweir     virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     /** Sets default properties after a new object has been created. */
118*cdf0e10cSrcweir     void setDefaultProperties( sal_Int32 nIndex ) throw (css::uno::RuntimeException);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir protected:
121*cdf0e10cSrcweir     /** Derived classes return the base name used for new objects. */
122*cdf0e10cSrcweir     virtual ::rtl::OUString implGetBaseName() const = 0;
123*cdf0e10cSrcweir     /** Derived classes set default properties for new drawing objects. */
124*cdf0e10cSrcweir     virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir protected:
127*cdf0e10cSrcweir     ScVbaPalette maPalette;
128*cdf0e10cSrcweir     css::uno::Reference< css::frame::XModel > mxModel;
129*cdf0e10cSrcweir     css::uno::Reference< css::drawing::XShape > mxShape;
130*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > mxShapeProps;
131*cdf0e10cSrcweir };
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir // ============================================================================
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1< ScVbaSheetObjectBase, ov::excel::XControlObject > ScVbaControlObject_BASE;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir class ScVbaControlObjectBase : public ScVbaControlObject_BASE
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir public:
140*cdf0e10cSrcweir     /** Specifies the listener used for OnAction events. */
141*cdf0e10cSrcweir     enum ListenerType
142*cdf0e10cSrcweir     {
143*cdf0e10cSrcweir         LISTENER_ACTION,        /// XActionListener.actionPerformed
144*cdf0e10cSrcweir         LISTENER_MOUSE,         /// XMouseListener.mouseReleased
145*cdf0e10cSrcweir         LISTENER_TEXT,          /// XTextListener.textChanged
146*cdf0e10cSrcweir         LISTENER_VALUE,         /// XAdjustmentListener.adjustmentValueChanged
147*cdf0e10cSrcweir         LISTENER_CHANGE         /// XChangeListener.changed
148*cdf0e10cSrcweir     };
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     explicit ScVbaControlObjectBase(
151*cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
152*cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
153*cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& rxModel,
154*cdf0e10cSrcweir         const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
155*cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XControlShape >& rxControlShape,
156*cdf0e10cSrcweir         ListenerType eListenerType ) throw (css::uno::RuntimeException);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     // XSheetObject attributes
159*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
160*cdf0e10cSrcweir     virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
161*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
162*cdf0e10cSrcweir     virtual void SAL_CALL setOnAction( const ::rtl::OUString& rMacroName ) throw (css::uno::RuntimeException);
163*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
164*cdf0e10cSrcweir     virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     // XControlObject attributes
167*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
168*cdf0e10cSrcweir     virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir protected:
171*cdf0e10cSrcweir     sal_Int32 getModelIndexInForm() const throw (css::uno::RuntimeException);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir protected:
174*cdf0e10cSrcweir     css::uno::Reference< css::container::XIndexContainer > mxFormIC;
175*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > mxControlProps;
176*cdf0e10cSrcweir     ::rtl::OUString maListenerType;
177*cdf0e10cSrcweir     ::rtl::OUString maEventMethod;
178*cdf0e10cSrcweir };
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // ============================================================================
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir class ScVbaButton : public ScVbaButton_BASE
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir public:
187*cdf0e10cSrcweir     explicit ScVbaButton(
188*cdf0e10cSrcweir         const css::uno::Reference< ov::XHelperInterface >& rxParent,
189*cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
190*cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& rxModel,
191*cdf0e10cSrcweir         const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
192*cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XControlShape >& rxControlShape ) throw (css::uno::RuntimeException);
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     // XButton attributes
195*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
196*cdf0e10cSrcweir     virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
197*cdf0e10cSrcweir     virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
198*cdf0e10cSrcweir     virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
199*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getHorizontalAlignment() throw (css::uno::RuntimeException);
200*cdf0e10cSrcweir     virtual void SAL_CALL setHorizontalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
201*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getVerticalAlignment() throw (css::uno::RuntimeException);
202*cdf0e10cSrcweir     virtual void SAL_CALL setVerticalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
203*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getOrientation() throw (css::uno::RuntimeException);
204*cdf0e10cSrcweir     virtual void SAL_CALL setOrientation( sal_Int32 nOrientation ) throw (css::uno::RuntimeException);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     // XButton methods
207*cdf0e10cSrcweir     css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters(
208*cdf0e10cSrcweir         const css::uno::Any& rStart, const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     // XHelperInterface
211*cdf0e10cSrcweir     VBAHELPER_DECL_XHELPERINTERFACE
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir protected:
214*cdf0e10cSrcweir     virtual ::rtl::OUString implGetBaseName() const;
215*cdf0e10cSrcweir     virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
216*cdf0e10cSrcweir };
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir // ============================================================================
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir #endif
221