1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "CommonConverters.hxx"
23 #include "PropertyMapper.hxx"
24 #include "AbstractShapeFactory.hxx"
25 #include <com/sun/star/chart2/XFormattedString.hpp>
26 #include <rtl/math.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/text/ControlCharacter.hpp>
29 #include <com/sun/star/text/XText.hpp>
30 #include <com/sun/star/text/XTextCursor.hpp>
34 using namespace ::com::sun::star
;
35 using namespace ::com::sun::star::chart2
;
37 VTitle::VTitle( const uno::Reference
< XTitle
> & xTitle
)
39 , m_xShapeFactory(NULL
)
43 , m_fRotationAngleDegree(0.0)
54 const uno::Reference
< drawing::XShapes
>& xTargetPage
55 , const uno::Reference
< lang::XMultiServiceFactory
>& xFactory
56 , const OUString
& rCID
)
58 m_xTarget
= xTargetPage
;
59 m_xShapeFactory
= xFactory
;
63 double VTitle::getRotationAnglePi() const
65 return m_fRotationAngleDegree
*F_PI
/180.0;
68 awt::Size
VTitle::getUnrotatedSize() const //size before rotation
72 aRet
= m_xShape
->getSize();
76 awt::Size
VTitle::getFinalSize() const //size after rotation
78 return AbstractShapeFactory::getSizeAfterRotation(
79 m_xShape
, m_fRotationAngleDegree
);
82 void VTitle::changePosition( const awt::Point
& rPos
)
86 uno::Reference
< beans::XPropertySet
> xShapeProp( m_xShape
, uno::UNO_QUERY
);
95 //the matrix needs to be set at the end behind autogrow and such position influencing properties
96 ::basegfx::B2DHomMatrix aM
;
97 aM
.rotate( -m_fRotationAngleDegree
*F_PI
/180.0 );//#i78696#->#i80521#
98 aM
.translate( m_nXPos
, m_nYPos
);
99 xShapeProp
->setPropertyValue( "Transformation", uno::makeAny( B2DHomMatrixToHomogenMatrix3(aM
) ) );
101 catch( const uno::Exception
& e
)
103 ASSERT_EXCEPTION( e
);
107 void VTitle::createShapes(
108 const awt::Point
& rPos
109 , const awt::Size
& rReferenceSize
)
114 uno::Sequence
< uno::Reference
< XFormattedString
> > aStringList
= m_xTitle
->getText();
115 if(aStringList
.getLength()<=0)
121 uno::Reference
< beans::XPropertySet
> xTitleProperties( m_xTitle
, uno::UNO_QUERY
);
125 double fAngleDegree
= 0;
126 xTitleProperties
->getPropertyValue( "TextRotation" ) >>= fAngleDegree
;
127 m_fRotationAngleDegree
+= fAngleDegree
;
129 catch( const uno::Exception
& e
)
131 ASSERT_EXCEPTION( e
);
134 AbstractShapeFactory
* pShapeFactory
= AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory
);
135 m_xShape
=pShapeFactory
->createText( m_xTarget
, rReferenceSize
, rPos
, aStringList
,
136 xTitleProperties
, m_fRotationAngleDegree
, m_aCID
);
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */