LibreOffice Module sc (master) 1
vbatitle.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <utility>
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>
30#include <memory>
31
32template< typename... Ifc >
34{
36
37 css::uno::Reference< css::drawing::XShape > xTitleShape;
38 css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
39 ov::ShapeHelper maShapeHelper;
41public:
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 ),
49 m_Palette(nullptr)
50 {
51 }
52 css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) override
53 {
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
59 }
60 css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) override
61 {
62 // #TODO find out what the proper parent should be
63 // leaving as set by the helperapi for the moment
65
66 }
67 void SAL_CALL setText( const OUString& Text ) override
68 {
69 try
70 {
71 xShapePropertySet->setPropertyValue("String", css::uno::Any( Text ));
72 }
73 catch ( css::uno::Exception& )
74 {
75 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
76 }
77 }
78 OUString SAL_CALL getText( ) override
79 {
80 OUString sText;
81 try
82 {
83 xShapePropertySet->getPropertyValue("String") >>= sText;
84 }
85 catch ( css::uno::Exception& )
86 {
87 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
88 }
89 return sText;
90 }
91
92 void SAL_CALL setTop( double Top ) override
93 {
94 maShapeHelper.setTop( Top );
95 }
96 double SAL_CALL getTop( ) override
97 {
98 return maShapeHelper.getTop();
99 }
100 void SAL_CALL setLeft( double Left ) override
101 {
102 maShapeHelper.setLeft( Left );
103 }
104 double SAL_CALL getLeft( ) override
105 {
106 return maShapeHelper.getLeft();
107 }
108 void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) override
109 {
110 try
111 {
112 xShapePropertySet->setPropertyValue("TextRotation", css::uno::Any(_nOrientation*100));
113 }
114 catch (css::uno::Exception& )
115 {
116 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
117 }
118 }
119 ::sal_Int32 SAL_CALL getOrientation( ) override
120 {
121 sal_Int32 nSOOrientation = 0;
122 try
123 {
124 xShapePropertySet->getPropertyValue("TextRotation") >>= nSOOrientation;
125 }
126 catch (css::uno::Exception& )
127 {
128 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
129 }
130 return static_cast< sal_Int32 >(nSOOrientation / 100) ;
131 }
132// XHelperInterface
133 OUString getServiceImplName() override
134 {
135 return "TitleImpl";
136 }
137 css::uno::Sequence< OUString > getServiceNames() override
138 {
139 static const css::uno::Sequence< OUString > aServiceNames{ "ooo.vba.excel.XTitle" };
140 return aServiceNames;
141 }
142};
143
144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::WeakReference< ov::XHelperInterface > mxParent
ov::ShapeHelper maShapeHelper
Definition: vbatitle.hxx:39
ScVbaPalette m_Palette
Definition: vbatitle.hxx:40
void SAL_CALL setLeft(double Left) override
Definition: vbatitle.hxx:100
double SAL_CALL getLeft() override
Definition: vbatitle.hxx:104
::sal_Int32 SAL_CALL getOrientation() override
Definition: vbatitle.hxx:119
double SAL_CALL getTop() override
Definition: vbatitle.hxx:96
InheritedHelperInterfaceImpl< Ifc... > BaseClass
Definition: vbatitle.hxx:35
TitleImpl(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::drawing::XShape > _xTitleShape)
Definition: vbatitle.hxx:42
void SAL_CALL setText(const OUString &Text) override
Definition: vbatitle.hxx:67
css::uno::Reference< css::beans::XPropertySet > xShapePropertySet
Definition: vbatitle.hxx:38
void SAL_CALL setTop(double Top) override
Definition: vbatitle.hxx:92
css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior() override
Definition: vbatitle.hxx:52
OUString getServiceImplName() override
Definition: vbatitle.hxx:133
OUString SAL_CALL getText() override
Definition: vbatitle.hxx:78
css::uno::Reference< css::drawing::XShape > xTitleShape
Definition: vbatitle.hxx:37
void SAL_CALL setOrientation(::sal_Int32 _nOrientation) override
Definition: vbatitle.hxx:108
css::uno::Sequence< OUString > getServiceNames() override
Definition: vbatitle.hxx:137
css::uno::Reference< ov::excel::XFont > SAL_CALL Font() override
Definition: vbatitle.hxx:60
Sequence< OUString > aServiceNames
#define ERRCODE_BASIC_METHOD_FAILED
@ Left
Definition: tphfedit.hxx:40