fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbatitle.hxx
blob06767bb89d8866fb3283536f598a803b55e9e4ea
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 INCLUDED_SC_SOURCE_UI_VBA_VBATITLE_HXX
20 #define INCLUDED_SC_SOURCE_UI_VBA_VBATITLE_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 std::unique_ptr<ov::ShapeHelper> oShapeHelper;
43 ScVbaPalette m_Palette;
44 public:
45 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 )
47 xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
48 oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
50 css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
52 // #TODO find out what the proper parent should be
53 // leaving as set by the helperapi for the moment
54 // #TODO we really need the ScDocument to pass to ScVbaInterior
55 // otherwise attemps to access the palette will fail
56 return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
58 css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
60 // #TODO find out what the proper parent should be
61 // leaving as set by the helperapi for the moment
62 return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
65 void SAL_CALL setText( const OUString& Text ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
67 try
69 xShapePropertySet->setPropertyValue("String", css::uno::makeAny( Text ));
71 catch ( css::uno::Exception& )
73 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
76 OUString SAL_CALL getText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
78 OUString sText;
79 try
81 xShapePropertySet->getPropertyValue("String") >>= sText;
83 catch ( css::uno::Exception& )
85 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
87 return sText;
90 css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
92 // #FIXME #TODO the helperapi Characters implementation doesn't
93 // seem to do very much, need to know how the existing Characters
94 // impl ( that we use for Range ) can be reused
95 return css::uno::Reference< ov::excel::XCharacters > ();
98 void SAL_CALL setTop( double Top ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
100 oShapeHelper->setTop( Top );
102 double SAL_CALL getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
104 return oShapeHelper->getTop();
106 void SAL_CALL setLeft( double Left ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
108 oShapeHelper->setLeft( Left );
110 double SAL_CALL getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
112 return oShapeHelper->getLeft();
114 void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
118 xShapePropertySet->setPropertyValue("TextRotation", css::uno::makeAny(_nOrientation*100));
120 catch (css::uno::Exception& )
122 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
125 ::sal_Int32 SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
127 sal_Int32 nSOOrientation = 0;
130 xShapePropertySet->getPropertyValue("TextRotation") >>= nSOOrientation;
132 catch (css::uno::Exception& )
134 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, OUString() );
136 return static_cast< sal_Int32 >(nSOOrientation / 100) ;
138 // XHelperInterface
139 OUString getServiceImplName()
141 return OUString("TitleImpl");
143 css::uno::Sequence< OUString > getServiceNames()
145 static css::uno::Sequence< OUString > aServiceNames;
146 if ( aServiceNames.getLength() == 0 )
148 aServiceNames.realloc( 1 );
149 aServiceNames[ 0 ] = "ooo.vba.excel.XTitle";
151 return aServiceNames;
154 #endif
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */