bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / vba / vbatitle.hxx
blob3f4d105c38083bfb6d58a948788a3b385eedfdc2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef SC_VBA_TITLE_HXX
20 #define SC_VBA_TITLE_HXX
22 #include <vbahelper/vbahelperinterface.hxx>
23 #include "excelvbahelper.hxx"
24 #include "vbainterior.hxx"
25 #include "vbafont.hxx"
26 #include "vbapalette.hxx"
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <ooo/vba/excel/XTitle.hpp>
30 #include <ooo/vba/excel/XCharacters.hpp>
31 #include <basic/sberrors.hxx>
32 #include <memory>
34 template< typename Ifc1 >
35 class TitleImpl : public InheritedHelperInterfaceImpl< Ifc1 >
37 typedef InheritedHelperInterfaceImpl< Ifc1 > BaseClass;
39 protected:
40 css::uno::Reference< css::drawing::XShape > xTitleShape;
41 css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
42 SAL_WNODEPRECATED_DECLARATIONS_PUSH
43 std::auto_ptr<ov::ShapeHelper> oShapeHelper;
44 SAL_WNODEPRECATED_DECLARATIONS_POP
45 ScVbaPalette m_Palette;
46 public:
47 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 )
49 xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
50 oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
52 css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
54 // #TODO find out what the proper parent should be
55 // leaving as set by the helperapi for the moment
56 // #TODO we really need the ScDocument to pass to ScVbaInterior
57 // otherwise attemps to access the palette will fail
58 return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
60 css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
62 // #TODO find out what the proper parent should be
63 // leaving as set by the helperapi for the moment
64 return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
67 void SAL_CALL setText( const OUString& Text ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
69 try
71 xShapePropertySet->setPropertyValue( OUString("String"), css::uno::makeAny( Text ));
73 catch ( css::uno::Exception& )
75 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
78 OUString SAL_CALL getText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
80 OUString sText;
81 try
83 xShapePropertySet->getPropertyValue( OUString("String") ) >>= sText;
85 catch ( css::uno::Exception& )
87 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
89 return sText;
92 css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
94 // #FIXME #TODO the helperapi Characters implementation doesn't
95 // seem to do very much, need to know how the existing Characters
96 // impl ( that we use for Range ) can be reused
97 return css::uno::Reference< ov::excel::XCharacters > ();
100 void SAL_CALL setTop( double Top ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
102 oShapeHelper->setTop( Top );
104 double SAL_CALL getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
106 return oShapeHelper->getTop();
108 void SAL_CALL setLeft( double Left ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
110 oShapeHelper->setLeft( Left );
112 double SAL_CALL getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
114 return oShapeHelper->getLeft();
116 void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
120 xShapePropertySet->setPropertyValue(OUString("TextRotation"), css::uno::makeAny(_nOrientation*100));
122 catch (css::uno::Exception& )
124 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
127 ::sal_Int32 SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
129 sal_Int32 nSOOrientation = 0;
132 xShapePropertySet->getPropertyValue( OUString("TextRotation")) >>= nSOOrientation;
134 catch (css::uno::Exception& )
136 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
138 return static_cast< sal_Int32 >(nSOOrientation / 100) ;
140 // XHelperInterface
141 OUString getServiceImplName()
143 return OUString("TitleImpl");
145 css::uno::Sequence< OUString > getServiceNames()
147 static css::uno::Sequence< OUString > aServiceNames;
148 if ( aServiceNames.getLength() == 0 )
150 aServiceNames.realloc( 1 );
151 aServiceNames[ 0 ] = OUString("ooo.vba.excel.XTitle" );
153 return aServiceNames;
156 #endif
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */