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 std::unique_ptr<ov::ShapeHelper> oShapeHelper;
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 ), xTitleShape(std::move( _xTitleShape )), m_Palette(nullptr)
46 {
47 xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
48 oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
49 }
50 css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) override
51 {
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 attempts to access the palette will fail
57 }
58 css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) override
59 {
60 // #TODO find out what the proper parent should be
61 // leaving as set by the helperapi for the moment
63
64 }
65 void SAL_CALL setText( const OUString& Text ) override
66 {
67 try
68 {
69 xShapePropertySet->setPropertyValue("String", css::uno::Any( Text ));
70 }
71 catch ( css::uno::Exception& )
72 {
73 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
74 }
75 }
76 OUString SAL_CALL getText( ) override
77 {
78 OUString sText;
79 try
80 {
81 xShapePropertySet->getPropertyValue("String") >>= sText;
82 }
83 catch ( css::uno::Exception& )
84 {
85 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
86 }
87 return sText;
88 }
89
90 void SAL_CALL setTop( double Top ) override
91 {
92 oShapeHelper->setTop( Top );
93 }
94 double SAL_CALL getTop( ) override
95 {
96 return oShapeHelper->getTop();
97 }
98 void SAL_CALL setLeft( double Left ) override
99 {
100 oShapeHelper->setLeft( Left );
101 }
102 double SAL_CALL getLeft( ) override
103 {
104 return oShapeHelper->getLeft();
105 }
106 void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) override
107 {
108 try
109 {
110 xShapePropertySet->setPropertyValue("TextRotation", css::uno::Any(_nOrientation*100));
111 }
112 catch (css::uno::Exception& )
113 {
114 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
115 }
116 }
117 ::sal_Int32 SAL_CALL getOrientation( ) override
118 {
119 sal_Int32 nSOOrientation = 0;
120 try
121 {
122 xShapePropertySet->getPropertyValue("TextRotation") >>= nSOOrientation;
123 }
124 catch (css::uno::Exception& )
125 {
126 throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
127 }
128 return static_cast< sal_Int32 >(nSOOrientation / 100) ;
129 }
130// XHelperInterface
131 OUString getServiceImplName() override
132 {
133 return "TitleImpl";
134 }
135 css::uno::Sequence< OUString > getServiceNames() override
136 {
137 static const css::uno::Sequence< OUString > aServiceNames{ "ooo.vba.excel.XTitle" };
138 return aServiceNames;
139 }
140};
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::WeakReference< ov::XHelperInterface > mxParent
ScVbaPalette m_Palette
Definition: vbatitle.hxx:40
void SAL_CALL setLeft(double Left) override
Definition: vbatitle.hxx:98
double SAL_CALL getLeft() override
Definition: vbatitle.hxx:102
::sal_Int32 SAL_CALL getOrientation() override
Definition: vbatitle.hxx:117
double SAL_CALL getTop() override
Definition: vbatitle.hxx:94
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:65
css::uno::Reference< css::beans::XPropertySet > xShapePropertySet
Definition: vbatitle.hxx:38
void SAL_CALL setTop(double Top) override
Definition: vbatitle.hxx:90
std::unique_ptr< ov::ShapeHelper > oShapeHelper
Definition: vbatitle.hxx:39
css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior() override
Definition: vbatitle.hxx:50
OUString getServiceImplName() override
Definition: vbatitle.hxx:131
OUString SAL_CALL getText() override
Definition: vbatitle.hxx:76
css::uno::Reference< css::drawing::XShape > xTitleShape
Definition: vbatitle.hxx:37
void SAL_CALL setOrientation(::sal_Int32 _nOrientation) override
Definition: vbatitle.hxx:106
css::uno::Sequence< OUString > getServiceNames() override
Definition: vbatitle.hxx:135
css::uno::Reference< ov::excel::XFont > SAL_CALL Font() override
Definition: vbatitle.hxx:58
Sequence< OUString > aServiceNames
#define ERRCODE_BASIC_METHOD_FAILED
@ Left
Definition: tphfedit.hxx:40