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 #ifndef INCLUDED_SC_SOURCE_UI_VBA_VBATITLE_HXX
20 #define INCLUDED_SC_SOURCE_UI_VBA_VBATITLE_HXX
21 
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 
32 template< typename... Ifc >
33 class TitleImpl : public InheritedHelperInterfaceImpl< 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;
41 public:
42  TitleImpl( const css::uno::Reference< ov::XHelperInterface >& xParent,
43  const css::uno::Reference< css::uno::XComponentContext >& xContext,
44  const css::uno::Reference< css::drawing::XShape >& _xTitleShape )
45  : BaseClass( xParent, xContext ), xTitleShape( _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
56  return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
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
62  return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
63 
64  }
65  void SAL_CALL setText( const OUString& Text ) override
66  {
67  try
68  {
69  xShapePropertySet->setPropertyValue("String", css::uno::makeAny( 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::makeAny(_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 css::uno::Sequence< OUString > aServiceNames;
138  if ( !aServiceNames.hasElements() )
139  {
140  aServiceNames.realloc( 1 );
141  aServiceNames[ 0 ] = "ooo.vba.excel.XTitle";
142  }
143  return aServiceNames;
144  }
145 };
146 #endif
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString getServiceImplName() override
Definition: vbatitle.hxx:131
void SAL_CALL setTop(double Top) override
Definition: vbatitle.hxx:90
ScVbaPalette m_Palette
Definition: vbatitle.hxx:40
css::uno::Reference< css::drawing::XShape > xTitleShape
Definition: vbatitle.hxx:37
Sequence< OUString > aServiceNames
css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior() override
Definition: vbatitle.hxx:50
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:42
double SAL_CALL getLeft() override
Definition: vbatitle.hxx:102
void SAL_CALL setText(const OUString &Text) override
Definition: vbatitle.hxx:65
css::uno::WeakReference< ov::XHelperInterface > mxParent
css::uno::Reference< css::beans::XPropertySet > xShapePropertySet
Definition: vbatitle.hxx:38
std::unique_ptr< ov::ShapeHelper > oShapeHelper
Definition: vbatitle.hxx:39
css::uno::Sequence< OUString > getServiceNames() override
Definition: vbatitle.hxx:135
::sal_Int32 SAL_CALL getOrientation() override
Definition: vbatitle.hxx:117
css::uno::Reference< css::uno::XComponentContext > mxContext
#define ERRCODE_BASIC_METHOD_FAILED
OUString SAL_CALL getText() override
Definition: vbatitle.hxx:76
double SAL_CALL getTop() override
Definition: vbatitle.hxx:94
css::uno::Reference< ov::excel::XFont > SAL_CALL Font() override
Definition: vbatitle.hxx:58
InheritedHelperInterfaceImpl< Ifc... > BaseClass
Definition: vbatitle.hxx:35
void SAL_CALL setLeft(double Left) override
Definition: vbatitle.hxx:98
void SAL_CALL setOrientation(::sal_Int32 _nOrientation) override
Definition: vbatitle.hxx:106