Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SC_VBA_TITLE_HXX
29 : : #define SC_VBA_TITLE_HXX
30 : :
31 : : #include <vbahelper/vbahelperinterface.hxx>
32 : : #include "excelvbahelper.hxx"
33 : : #include "vbainterior.hxx"
34 : : #include "vbafont.hxx"
35 : : #include "vbapalette.hxx"
36 : : #include <com/sun/star/drawing/XShape.hpp>
37 : : #include <com/sun/star/beans/XPropertySet.hpp>
38 : : #include <ooo/vba/excel/XTitle.hpp>
39 : : #include <ooo/vba/excel/XCharacters.hpp>
40 : : #include <basic/sberrors.hxx>
41 : : #include <memory>
42 : :
43 : : template< typename Ifc1 >
44 [ # # ][ # # ]: 0 : class TitleImpl : public InheritedHelperInterfaceImpl< Ifc1 >
45 : : {
46 : : typedef InheritedHelperInterfaceImpl< Ifc1 > BaseClass;
47 : :
48 : : protected:
49 : : css::uno::Reference< css::drawing::XShape > xTitleShape;
50 : : css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
51 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
52 : : std::auto_ptr<ov::ShapeHelper> oShapeHelper;
53 : : SAL_WNODEPRECATED_DECLARATIONS_POP
54 : : ScVbaPalette m_Palette;
55 : : public:
56 : 0 : 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 )
57 : : {
58 [ # # ]: 0 : xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
59 [ # # ][ # # ]: 0 : oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
60 : 0 : }
61 : 0 : css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
62 : : {
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 [ # # ][ # # ]: 0 : return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
[ # # ]
68 : : }
69 : 0 : css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
70 : : {
71 : : // #TODO find out what the proper parent should be
72 : : // leaving as set by the helperapi for the moment
73 [ # # ][ # # ]: 0 : return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
[ # # ]
74 : :
75 : : }
76 : 0 : void SAL_CALL setText( const ::rtl::OUString& Text ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
77 : : {
78 : : try
79 : : {
80 [ # # ][ # # ]: 0 : xShapePropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("String") ), css::uno::makeAny( Text ));
81 : : }
82 [ # # ]: 0 : catch ( css::uno::Exception& )
83 : : {
84 [ # # ]: 0 : throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
85 : : }
86 : 0 : }
87 : 0 : ::rtl::OUString SAL_CALL getText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
88 : : {
89 : 0 : ::rtl::OUString sText;
90 : : try
91 : : {
92 [ # # ][ # # ]: 0 : xShapePropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("String") ) ) >>= sText;
93 : : }
94 [ # # ]: 0 : catch ( css::uno::Exception& )
95 : : {
96 [ # # ]: 0 : throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
97 : : }
98 : 0 : return sText;
99 : : }
100 : :
101 : : css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
102 : : {
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 > ();
107 : : }
108 : :
109 : 0 : void SAL_CALL setTop( double Top ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
110 : : {
111 : 0 : oShapeHelper->setTop( Top );
112 : 0 : }
113 : 0 : double SAL_CALL getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
114 : : {
115 : 0 : return oShapeHelper->getTop();
116 : : }
117 : 0 : void SAL_CALL setLeft( double Left ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
118 : : {
119 : 0 : oShapeHelper->setLeft( Left );
120 : 0 : }
121 : 0 : double SAL_CALL getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
122 : : {
123 : 0 : return oShapeHelper->getLeft();
124 : : }
125 : 0 : void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
126 : : {
127 : : try
128 : : {
129 [ # # ][ # # ]: 0 : xShapePropertySet->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextRotation")), css::uno::makeAny(_nOrientation*100));
[ # # ]
130 : : }
131 [ # # ]: 0 : catch (css::uno::Exception& )
132 : : {
133 [ # # ]: 0 : throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
134 : : }
135 : 0 : }
136 : 0 : ::sal_Int32 SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
137 : : {
138 : 0 : sal_Int32 nSOOrientation = 0;
139 : : try
140 : : {
141 [ # # ][ # # ]: 0 : xShapePropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextRotation"))) >>= nSOOrientation;
142 : : }
143 [ # # ]: 0 : catch (css::uno::Exception& )
144 : : {
145 [ # # ]: 0 : throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
146 : : }
147 : 0 : return static_cast< sal_Int32 >(nSOOrientation / 100) ;
148 : : }
149 : : // XHelperInterface
150 : 0 : rtl::OUString getServiceImplName()
151 : : {
152 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TitleImpl"));
153 : : }
154 : 0 : css::uno::Sequence< rtl::OUString > getServiceNames()
155 : : {
156 [ # # ][ # # ]: 0 : static css::uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
157 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
158 : : {
159 : 0 : aServiceNames.realloc( 1 );
160 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XTitle" ) );
161 : : }
162 : 0 : return aServiceNames;
163 : : }
164 : : };
165 : : #endif
166 : :
167 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|