1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <vbahelper/vbahelperinterface.hxx>
23 #include "vbainterior.hxx"
24 #include "vbafont.hxx"
25 #include "vbapalette.hxx"
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/script/BasicErrorException.hpp>
29 #include <basic/sberrors.hxx>
32 template< typename
... Ifc
>
33 class TitleImpl
: public InheritedHelperInterfaceImpl
< Ifc
... >
35 typedef InheritedHelperInterfaceImpl
< Ifc
... > BaseClass
;
37 css::uno::Reference
< css::drawing::XShape
> xTitleShape
;
38 css::uno::Reference
< css::beans::XPropertySet
> xShapePropertySet
;
39 ov::ShapeHelper maShapeHelper
;
40 ScVbaPalette m_Palette
;
42 TitleImpl( const css::uno::Reference
< ov::XHelperInterface
>& xParent
,
43 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
44 css::uno::Reference
< css::drawing::XShape
> _xTitleShape
)
45 : BaseClass( xParent
, xContext
),
46 xTitleShape(std::move( _xTitleShape
)),
47 xShapePropertySet( xTitleShape
, css::uno::UNO_QUERY_THROW
),
48 maShapeHelper( xTitleShape
),
52 css::uno::Reference
< ov::excel::XInterior
> SAL_CALL
Interior( ) override
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 attempts 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( ) override
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
) override
71 xShapePropertySet
->setPropertyValue(u
"String"_ustr
, css::uno::Any( Text
));
73 catch ( css::uno::Exception
& )
75 throw css::script::BasicErrorException( OUString(), css::uno::Reference
< css::uno::XInterface
>(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED
), OUString() );
78 OUString SAL_CALL
getText( ) override
83 xShapePropertySet
->getPropertyValue(u
"String"_ustr
) >>= sText
;
85 catch ( css::uno::Exception
& )
87 throw css::script::BasicErrorException( OUString(), css::uno::Reference
< css::uno::XInterface
>(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED
), OUString() );
92 void SAL_CALL
setTop( double Top
) override
94 maShapeHelper
.setTop( Top
);
96 double SAL_CALL
getTop( ) override
98 return maShapeHelper
.getTop();
100 void SAL_CALL
setLeft( double Left
) override
102 maShapeHelper
.setLeft( Left
);
104 double SAL_CALL
getLeft( ) override
106 return maShapeHelper
.getLeft();
108 void SAL_CALL
setOrientation( ::sal_Int32 _nOrientation
) override
112 xShapePropertySet
->setPropertyValue(u
"TextRotation"_ustr
, css::uno::Any(_nOrientation
*100));
114 catch (css::uno::Exception
& )
116 throw css::script::BasicErrorException( OUString(), css::uno::Reference
< css::uno::XInterface
>(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED
), OUString() );
119 ::sal_Int32 SAL_CALL
getOrientation( ) override
121 sal_Int32 nSOOrientation
= 0;
124 xShapePropertySet
->getPropertyValue(u
"TextRotation"_ustr
) >>= nSOOrientation
;
126 catch (css::uno::Exception
& )
128 throw css::script::BasicErrorException( OUString(), css::uno::Reference
< css::uno::XInterface
>(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED
), OUString() );
130 return static_cast< sal_Int32
>(nSOOrientation
/ 100) ;
133 OUString
getServiceImplName() override
135 return u
"TitleImpl"_ustr
;
137 css::uno::Sequence
< OUString
> getServiceNames() override
139 static const css::uno::Sequence
< OUString
> aServiceNames
{ u
"ooo.vba.excel.XTitle"_ustr
};
140 return aServiceNames
;
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */