Update ooo320-m1
[ooovba.git] / sc / source / ui / vba / vbatitle.hxx
blobe20922126a55fc9492b22f46a471adbe7c11ae08
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbatitle.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef SC_VBA_TITLE_HXX
31 #define SC_VBA_TITLE_HXX
33 #include <vbahelper/vbahelperinterface.hxx>
34 #include "excelvbahelper.hxx"
35 #include "vbainterior.hxx"
36 #include "vbafont.hxx"
37 #include "vbapalette.hxx"
38 #include <com/sun/star/drawing/XShape.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <ooo/vba/excel/XTitle.hpp>
41 #include <ooo/vba/excel/XCharacters.hpp>
42 #include <basic/sberrors.hxx>
43 #include <memory>
45 template< typename Ifc1 >
46 class TitleImpl : public InheritedHelperInterfaceImpl< Ifc1 >
48 typedef InheritedHelperInterfaceImpl< Ifc1 > BaseClass;
50 protected:
51 css::uno::Reference< css::drawing::XShape > xTitleShape;
52 css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
53 std::auto_ptr<ov::ShapeHelper> oShapeHelper;
54 ScVbaPalette m_Palette;
55 public:
56 TitleImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& _xTitleShape ) : BaseClass( xParent, xContext ), xTitleShape( _xTitleShape )
58 xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
59 oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
61 css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
63 // #TODO find out what the proper parent should be
64 // leaving as set by the helperapi for the moment
65 // #TODO we really need the ScDocument to pass to ScVbaInterior
66 // otherwise attemps to access the palette will fail
67 return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
69 css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
71 // #TODO find out what the proper parent should be
72 // leaving as set by the helperapi for the moment
73 return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
76 void SAL_CALL setText( const ::rtl::OUString& Text ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
78 try
80 xShapePropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("String") ), css::uno::makeAny( Text ));
82 catch ( css::uno::Exception& )
84 throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
87 ::rtl::OUString SAL_CALL getText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
89 ::rtl::OUString sText;
90 try
92 xShapePropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("String") ) ) >>= sText;
94 catch ( css::uno::Exception& )
96 throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
98 return sText;
101 css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
103 // #FIXME #TODO the helperapi Characters implementation doesn't
104 // seem to do very much, need to know how the existing Characters
105 // impl ( that we use for Range ) can be reused
106 return css::uno::Reference< ov::excel::XCharacters > ();
109 void SAL_CALL setTop( double Top ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
111 oShapeHelper->setTop( Top );
113 double SAL_CALL getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
115 return oShapeHelper->getTop();
117 void SAL_CALL setLeft( double Left ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
119 oShapeHelper->setLeft( Left );
121 double SAL_CALL getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
123 return oShapeHelper->getLeft();
125 void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
129 xShapePropertySet->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextRotation")), css::uno::makeAny(_nOrientation*100));
131 catch (css::uno::Exception& )
133 throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
136 ::sal_Int32 SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
138 sal_Int32 nSOOrientation = 0;
141 xShapePropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextRotation"))) >>= nSOOrientation;
143 catch (css::uno::Exception& )
145 throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
147 return static_cast< sal_Int32 >(nSOOrientation / 100) ;
149 // XHelperInterface
150 rtl::OUString& getServiceImplName()
152 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("TitleImpl") );
153 return sImplName;
155 css::uno::Sequence< rtl::OUString > getServiceNames()
157 static css::uno::Sequence< rtl::OUString > aServiceNames;
158 if ( aServiceNames.getLength() == 0 )
160 aServiceNames.realloc( 1 );
161 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XTitle" ) );
163 return aServiceNames;
166 #endif