LibreOffice Module chart2 (master) 1
VTitle.cxx
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
20#include "VTitle.hxx"
21#include <CommonConverters.hxx>
22#include <ShapeFactory.hxx>
23#include <Title.hxx>
24#include <com/sun/star/chart2/XTitle.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <utility>
28
29namespace chart
30{
31using namespace ::com::sun::star;
32using namespace ::com::sun::star::chart2;
33
35 : m_xTitle(std::move(xTitle))
36 , m_fRotationAngleDegree(0.0)
37 , m_nXPos(0)
38 , m_nYPos(0)
39{
40}
41
43{
44}
45
47 const rtl::Reference<SvxShapeGroupAnyD>& xTargetPage
48 , const OUString& rCID )
49{
50 m_xTarget = xTargetPage;
51 m_aCID = rCID;
52}
53
55{
57}
58
59awt::Size VTitle::getUnrotatedSize() const //size before rotation
60{
61 awt::Size aRet;
62 if(m_xShape.is())
63 aRet = m_xShape->getSize();
64 return aRet;
65}
66
67awt::Size VTitle::getFinalSize() const //size after rotation
68{
71}
72
73void VTitle::changePosition( const awt::Point& rPos )
74{
75 if(!m_xShape.is())
76 return;
77 try
78 {
79 m_nXPos = rPos.X;
80 m_nYPos = rPos.Y;
81
82 //set position matrix
83 //the matrix needs to be set at the end behind autogrow and such position influencing properties
85 aM.rotate( basegfx::deg2rad(-m_fRotationAngleDegree) );//#i78696#->#i80521#
87 m_xShape->SvxShape::setPropertyValue( "Transformation", uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ) );
88 }
89 catch( const uno::Exception& )
90 {
91 TOOLS_WARN_EXCEPTION("chart2", "" );
92 }
93}
94
96 if (!xTitle.is()) {
97 return false;
98 }
99 bool bShow = true;
100 try {
101 xTitle->getPropertyValue("Visible") >>= bShow;
102 } catch (const uno::Exception &) {
103 DBG_UNHANDLED_EXCEPTION("chart2");
104 }
105 return bShow;
106}
107
108
110 const awt::Point& rPos
111 , const awt::Size& rReferenceSize
112 , const awt::Size& rTextMaxWidth
113 , bool bYAxisTitle )
114{
115 if(!m_xTitle.is())
116 return;
117
119 if(!aStringList.hasElements())
120 return;
121
122 m_nXPos = rPos.X;
123 m_nYPos = rPos.Y;
124
125 uno::Reference< beans::XPropertySet > xTitleProperties( m_xTitle, uno::UNO_QUERY );
126
127 try
128 {
129 double fAngleDegree = 0;
130 xTitleProperties->getPropertyValue( "TextRotation" ) >>= fAngleDegree;
131 m_fRotationAngleDegree += fAngleDegree;
132 }
133 catch( const uno::Exception& )
134 {
135 TOOLS_WARN_EXCEPTION("chart2", "" );
136 }
137
138 sal_Int32 nTextMaxWidth;
139 if (bYAxisTitle)
140 {
141 if (m_fRotationAngleDegree < 75.0 || m_fRotationAngleDegree > 285.0
142 || (m_fRotationAngleDegree > 105.0 && m_fRotationAngleDegree < 255.0))
143 nTextMaxWidth = rTextMaxWidth.Width;
144 else
145 nTextMaxWidth = rTextMaxWidth.Height;
146 }
147 else if (m_fRotationAngleDegree <= 15.0 || m_fRotationAngleDegree >= 345.0
148 || (m_fRotationAngleDegree >= 165.0 && m_fRotationAngleDegree <= 195.0))
149 nTextMaxWidth = rTextMaxWidth.Width;
150 else
151 nTextMaxWidth = rTextMaxWidth.Height;
152
153 m_xShape = ShapeFactory::createText( m_xTarget, rReferenceSize, rPos, aStringList, xTitleProperties,
154 m_fRotationAngleDegree, m_aCID, nTextMaxWidth );
155}
156
157} //namespace chart
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void rotate(double fRadiant)
void translate(double fX, double fY)
static css::awt::Size getSizeAfterRotation(SvxShape &rShape, double fRotationAngleDegree)
static rtl::Reference< SvxShapeText > createText(const rtl::Reference< SvxShapeGroupAnyD > &xTarget2D, const OUString &rText, const tNameSequence &rPropNames, const tAnySequence &rPropValues, const css::uno::Any &rATransformation)
double getRotationAnglePi() const
Definition: VTitle.cxx:54
sal_Int32 m_nYPos
Definition: VTitle.hxx:68
css::awt::Size getFinalSize() const
Definition: VTitle.cxx:67
rtl::Reference< SvxShapeText > m_xShape
Definition: VTitle.hxx:63
void createShapes(const css::awt::Point &rPos, const css::awt::Size &rReferenceSize, const css::awt::Size &nTextMaxWidth, bool bYAxisTitle)
Definition: VTitle.cxx:109
sal_Int32 m_nXPos
Definition: VTitle.hxx:67
void init(const rtl::Reference< SvxShapeGroupAnyD > &xTargetPage, const OUString &rCID)
Definition: VTitle.cxx:46
void changePosition(const css::awt::Point &rPos)
Definition: VTitle.cxx:73
double m_fRotationAngleDegree
Definition: VTitle.hxx:66
css::awt::Size getUnrotatedSize() const
Definition: VTitle.cxx:59
css::uno::Reference< css::chart2::XTitle > m_xTitle
Definition: VTitle.hxx:62
OUString m_aCID
Definition: VTitle.hxx:64
static bool isVisible(const rtl::Reference< ::chart::Title > &xTitle)
Definition: VTitle.cxx:95
VTitle(css::uno::Reference< css::chart2::XTitle > xTitle)
Definition: VTitle.cxx:34
rtl::Reference< SvxShapeGroupAnyD > m_xTarget
Definition: VTitle.hxx:61
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr double deg2rad(double v)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix3 B2DHomMatrixToHomogenMatrix3(const ::basegfx::B2DHomMatrix &rM)
B2DHomMatrix <-> HomogenMatrix3.
const std::u16string_view aStringList[]