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