Line data Source code
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 <com/sun/star/text/WritingMode.hpp>
21 : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
22 : #include "oox/drawingml/drawingmltypes.hxx"
23 : #include "drawingml/textbodyproperties.hxx"
24 : #include "oox/token/tokens.hxx"
25 :
26 : using namespace ::com::sun::star::drawing;
27 : using namespace ::com::sun::star::text;
28 :
29 : namespace oox {
30 : namespace drawingml {
31 :
32 3428 : TextBodyProperties::TextBodyProperties()
33 : : mbAnchorCtr(false)
34 3428 : , meVA( TextVerticalAdjust_TOP )
35 : {
36 3428 : }
37 :
38 : /* For Legacy purposes: TODO: Check if it is required at all! */
39 362 : void TextBodyProperties::pushVertSimulation()
40 : {
41 362 : sal_Int32 tVert = moVert.get( XML_horz );
42 362 : if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) {
43 : // #160799# fake different vertical text modes by top-bottom writing mode
44 0 : maPropertyMap.setProperty( PROP_TextWritingMode, WritingMode_TB_RL);
45 :
46 : // workaround for TB_LR as using WritingMode2 doesn't work
47 0 : if( meVA != TextVerticalAdjust_CENTER )
48 : maPropertyMap.setProperty( PROP_TextHorizontalAdjust,
49 0 : (tVert == XML_vert270) ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT);
50 0 : if( tVert == XML_vert270 )
51 0 : maPropertyMap.setProperty( PROP_TextVerticalAdjust, TextVerticalAdjust_BOTTOM);
52 0 : if( ( tVert == XML_vert && meVA == TextVerticalAdjust_TOP ) ||
53 0 : ( tVert == XML_vert270 && meVA == TextVerticalAdjust_BOTTOM ) )
54 0 : maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_RIGHT);
55 0 : else if( meVA == TextVerticalAdjust_CENTER )
56 0 : maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_CENTER);
57 : }
58 362 : }
59 :
60 : /* Push adjusted values, taking into consideration Shape Rotation */
61 1111 : void TextBodyProperties::pushRotationAdjustments()
62 : {
63 1111 : sal_Int32 nOff = 0;
64 1111 : sal_Int32 aProps[] = { PROP_TextLeftDistance, PROP_TextUpperDistance, PROP_TextRightDistance, PROP_TextLowerDistance };
65 1111 : sal_Int32 n = ( sal_Int32 )( sizeof( aProps ) / sizeof( sal_Int32 ) );
66 :
67 1111 : switch( moRotation.get(0) )
68 : {
69 1 : case (90*1*60000): nOff = 3; break;
70 2 : case (90*2*60000): nOff = 2; break;
71 1 : case (90*3*60000): nOff = 1; break;
72 1107 : default: break;
73 : }
74 :
75 5555 : for( sal_Int32 i = 0; i < n; i++ )
76 : {
77 4444 : sal_Int32 nVal = 0;
78 :
79 : // Hack for n#760986
80 : // TODO: Preferred method would be to have a textbox on top
81 : // of the shape and the place it according to the (off,ext)
82 4444 : if( nOff == 0 && moTextOffLeft ) nVal = *moTextOffLeft;
83 4444 : if( nOff == 1 && moTextOffUpper ) nVal = *moTextOffUpper;
84 4444 : if( nOff == 2 && moTextOffRight ) nVal = *moTextOffRight;
85 4444 : if( nOff == 3 && moTextOffLower ) nVal = *moTextOffLower;
86 4444 : if( nVal < 0 ) nVal = 0;
87 :
88 4444 : if( moInsets[i] )
89 2909 : maPropertyMap.setProperty( aProps[ nOff ], static_cast< sal_Int32 >( *moInsets[i] + nVal ));
90 1535 : else if( nVal )
91 0 : maPropertyMap.setProperty( aProps[ nOff ], static_cast< sal_Int32 >( nVal ));
92 :
93 4444 : nOff = (nOff+1) % n;
94 : }
95 1111 : }
96 :
97 : } // namespace drawingml
98 : } // namespace oox
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|