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 
22 #include "vbainterior.hxx"
23 #include "vbafont.hxx"
24 #include "vbapalette.hxx"
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/drawing/XShape.hpp>
27 #include <com/sun/star/script/BasicErrorException.hpp>
28 #include <basic/sberrors.hxx>
29 #include <memory>
30 
31 template< typename... Ifc >
32 class TitleImpl : public InheritedHelperInterfaceImpl< Ifc... >
33 {
35 
36  css::uno::Reference< css::drawing::XShape > xTitleShape;
37  css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
38  std::unique_ptr<ov::ShapeHelper> oShapeHelper;
40 public:
41  TitleImpl( const css::uno::Reference< ov::XHelperInterface >& xParent,
42  const css::uno::Reference< css::uno::XComponentContext >& xContext,
43  const css::uno::Reference< css::drawing::XShape >& _xTitleShape )
44  : BaseClass( xParent, xContext ), xTitleShape( _xTitleShape ), m_Palette(nullptr)
45  {
46  xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
47  oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
48  }
49  css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) override
50  {
51  // #TODO find out what the proper parent should be
52  // leaving as set by the helperapi for the moment
53  // #TODO we really need the ScDocument to pass to ScVbaInterior
54  // otherwise attempts to access the palette will fail
55  return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
56  }
57  css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) override
58  {
59  // #TODO find out what the proper parent should be
60  // leaving as set by the helperapi for the moment
61  return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
62 
63  }
64  void SAL_CALL setText( const OUString& Text ) override
65  {
66  try
67  {
68  xShapePropertySet->setPropertyValue("String", css::uno::makeAny( Text ));
69  }
70  catch ( css::uno::Exception& )
71  {
72  throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
73  }
74  }
75  OUString SAL_CALL getText( ) override
76  {
77  OUString sText;
78  try
79  {
80  xShapePropertySet->getPropertyValue("String") >>= sText;
81  }
82  catch ( css::uno::Exception& )
83  {
84  throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
85  }
86  return sText;
87  }
88 
89  void SAL_CALL setTop( double Top ) override
90  {
91  oShapeHelper->setTop( Top );
92  }
93  double SAL_CALL getTop( ) override
94  {
95  return oShapeHelper->getTop();
96  }
97  void SAL_CALL setLeft( double Left ) override
98  {
99  oShapeHelper->setLeft( Left );
100  }
101  double SAL_CALL getLeft( ) override
102  {
103  return oShapeHelper->getLeft();
104  }
105  void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) override
106  {
107  try
108  {
109  xShapePropertySet->setPropertyValue("TextRotation", css::uno::makeAny(_nOrientation*100));
110  }
111  catch (css::uno::Exception& )
112  {
113  throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
114  }
115  }
116  ::sal_Int32 SAL_CALL getOrientation( ) override
117  {
118  sal_Int32 nSOOrientation = 0;
119  try
120  {
121  xShapePropertySet->getPropertyValue("TextRotation") >>= nSOOrientation;
122  }
123  catch (css::uno::Exception& )
124  {
125  throw css::script::BasicErrorException( OUString(), css::uno::Reference< css::uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), OUString() );
126  }
127  return static_cast< sal_Int32 >(nSOOrientation / 100) ;
128  }
129 // XHelperInterface
130  OUString getServiceImplName() override
131  {
132  return "TitleImpl";
133  }
134  css::uno::Sequence< OUString > getServiceNames() override
135  {
136  static const css::uno::Sequence< OUString > aServiceNames{ "ooo.vba.excel.XTitle" };
137  return aServiceNames;
138  }
139 };
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString getServiceImplName() override
Definition: vbatitle.hxx:130
void SAL_CALL setTop(double Top) override
Definition: vbatitle.hxx:89
ScVbaPalette m_Palette
Definition: vbatitle.hxx:39
css::uno::Reference< css::drawing::XShape > xTitleShape
Definition: vbatitle.hxx:36
Sequence< OUString > aServiceNames
css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior() override
Definition: vbatitle.hxx:49
TitleImpl(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::drawing::XShape > &_xTitleShape)
Definition: vbatitle.hxx:41
double SAL_CALL getLeft() override
Definition: vbatitle.hxx:101
void SAL_CALL setText(const OUString &Text) override
Definition: vbatitle.hxx:64
css::uno::WeakReference< ov::XHelperInterface > mxParent
css::uno::Reference< css::beans::XPropertySet > xShapePropertySet
Definition: vbatitle.hxx:37
std::unique_ptr< ov::ShapeHelper > oShapeHelper
Definition: vbatitle.hxx:38
css::uno::Sequence< OUString > getServiceNames() override
Definition: vbatitle.hxx:134
::sal_Int32 SAL_CALL getOrientation() override
Definition: vbatitle.hxx:116
css::uno::Reference< css::uno::XComponentContext > mxContext
#define ERRCODE_BASIC_METHOD_FAILED
OUString SAL_CALL getText() override
Definition: vbatitle.hxx:75
double SAL_CALL getTop() override
Definition: vbatitle.hxx:93
css::uno::Reference< ov::excel::XFont > SAL_CALL Font() override
Definition: vbatitle.hxx:57
InheritedHelperInterfaceImpl< Ifc... > BaseClass
Definition: vbatitle.hxx:34
void SAL_CALL setLeft(double Left) override
Definition: vbatitle.hxx:97
void SAL_CALL setOrientation(::sal_Int32 _nOrientation) override
Definition: vbatitle.hxx:105