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 .
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/properties.hxx>
25 #include <oox/token/tokens.hxx>
27 using namespace ::com::sun::star::drawing
;
28 using namespace ::com::sun::star::text
;
33 TextBodyProperties::TextBodyProperties()
35 , meVA( TextVerticalAdjust_TOP
)
40 /* For Legacy purposes: TODO: Check if it is required at all! */
41 void TextBodyProperties::pushVertSimulation()
43 sal_Int32 tVert
= moVert
.get( XML_horz
);
44 if( tVert
== XML_vert
|| tVert
== XML_eaVert
|| tVert
== XML_vert270
|| tVert
== XML_mongolianVert
) {
45 // #160799# fake different vertical text modes by top-bottom writing mode
46 maPropertyMap
.setProperty( PROP_TextWritingMode
, WritingMode_TB_RL
);
48 // workaround for TB_LR as using WritingMode2 doesn't work
49 if( meVA
!= TextVerticalAdjust_CENTER
)
50 maPropertyMap
.setProperty( PROP_TextHorizontalAdjust
,
51 (tVert
== XML_vert270
) ? TextHorizontalAdjust_RIGHT
: TextHorizontalAdjust_LEFT
);
52 if( tVert
== XML_vert270
)
53 maPropertyMap
.setProperty( PROP_TextVerticalAdjust
, TextVerticalAdjust_BOTTOM
);
54 if( ( tVert
== XML_vert
&& meVA
== TextVerticalAdjust_TOP
) ||
55 ( tVert
== XML_vert270
&& meVA
== TextVerticalAdjust_BOTTOM
) )
56 maPropertyMap
.setProperty( PROP_TextHorizontalAdjust
, TextHorizontalAdjust_RIGHT
);
57 else if( meVA
== TextVerticalAdjust_CENTER
)
58 maPropertyMap
.setProperty( PROP_TextHorizontalAdjust
, TextHorizontalAdjust_CENTER
);
62 /* Push adjusted values, taking into consideration Shape Rotation */
63 void TextBodyProperties::pushRotationAdjustments()
66 static sal_Int32
const aProps
[] { PROP_TextLeftDistance
, PROP_TextUpperDistance
, PROP_TextRightDistance
, PROP_TextLowerDistance
};
67 sal_Int32 n
= SAL_N_ELEMENTS( aProps
);
69 switch( moRotation
.get(0) )
71 case 90*1*60000: nOff
= 3; break;
72 case 90*2*60000: nOff
= 2; break;
73 case 90*3*60000: nOff
= 1; break;
77 for( sal_Int32 i
= 0; i
< n
; i
++ )
82 // TODO: Preferred method would be to have a textbox on top
83 // of the shape and the place it according to the (off,ext)
84 if( nOff
== 0 && moTextOffLeft
) nVal
= *moTextOffLeft
;
85 if( nOff
== 1 && moTextOffUpper
) nVal
= *moTextOffUpper
;
86 if( nOff
== 2 && moTextOffRight
) nVal
= *moTextOffRight
;
87 if( nOff
== 3 && moTextOffLower
) nVal
= *moTextOffLower
;
88 if( nVal
< 0 ) nVal
= 0;
91 maPropertyMap
.setProperty( aProps
[ nOff
], static_cast< sal_Int32
>( *moInsets
[i
] + nVal
));
93 maPropertyMap
.setProperty( aProps
[ nOff
], nVal
);
99 } // namespace drawingml
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */