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 #ifndef INCLUDED_SW_SOURCE_CORE_INC_ASCHARANCHOREDOBJECTPOSITION_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_ASCHARANCHOREDOBJECTPOSITION_HXX
23 #include "anchoredobjectposition.hxx"
24 #include <swtypes.hxx>
26 #include <o3tl/typed_flags_set.hxx>
29 class SwFormatVertOrient
;
31 // flags for positioning algorithm of as-character-anchored objects
32 enum class AsCharFlags
{
42 template<> struct typed_flags
<AsCharFlags
> : is_typed_flags
<AsCharFlags
, 0x3f> {};
47 // TODO: merge/migrate this to com::sun::star::VertOrientation instead of duplicating?
56 namespace objectpositioning
58 class SwAsCharAnchoredObjectPosition final
: public SwAnchoredObjectPosition
61 // data to calculate object position
62 // Proposed anchor position, starting point for the calculation
63 // of the object position.
64 const Point
& mrProposedAnchorPos
;
65 // flags that influences the calculation of the anchor position
66 // AsCharFlags::Quick : quick formatting - calculated position not set at object
67 // AsCharFlags::UlSpace : consider upper/lower spacing - adjustment of anchor position
68 // AsCharFlags::Init : initial calculation
69 // AsCharFlags::Rotate : object is rotated by 90 degrees
70 // AsCharFlags::Reverse : object is reversed (rotated by 270 degrees)
71 // AsCharFlags::Bidi : object belongs to a BIDI-multi-portion
72 const AsCharFlags mnFlags
;
73 // needed line values for the different alignments.
74 const SwTwips mnLineAscent
;
75 const SwTwips mnLineDescent
;
76 const SwTwips mnLineAscentInclObjs
;
77 const SwTwips mnLineDescentInclObjs
;
79 // calculated data for object position
82 SwRect maObjBoundRect
;
83 // line alignment relative to line height
84 sw::LineAlign mnLineAlignment
;
86 // method to cast <SwAnchoredObjectPosition::GetAnchorFrame()>
87 const SwTextFrame
& GetAnchorTextFrame() const;
89 /** determine the relative position to base line for object position
91 @param _ObjBoundHeight
92 height including corresponding spacing of the object, for which
93 the Y-position has to be calculated.
96 given vertical positioning and alignment
98 @return relative position to the base line
100 SwTwips
GetRelPosToBase( const SwTwips _nObjBoundHeight
,
101 const SwFormatVertOrient
& _rVert
);
104 /** constructor; provided object to be positioned and needed data
105 for calculation of the object position
108 input parameter - object, that is be positioned.
110 @param _rProposedAnchorPos
111 proposed anchor position; starting point for the calculation
112 of the anchor position
115 flags that influences the calculation of the anchor position
116 AsCharFlags::Quick : quick formatting - calculated position not set at object
117 AsCharFlags::UlSpace : consider upper/lower spacing - adjustment of anchor position
118 AsCharFlags::Init : initial calculation
119 AsCharFlags::Rotate : object is rotated by 90 degrees
120 AsCharFlags::Reverse : object is reversed (rotated by 270 degrees)
121 AsCharFlags::Bidi : object belongs to a BIDI-multi-portion
123 @param _nLineAscent, _nLineDescent, _nLineAscentInclObjs,
124 _nLineDescentInclObjs - needed line values for the different
127 SwAsCharAnchoredObjectPosition( SdrObject
& _rDrawObj
,
128 const Point
& _rProposedAnchorPos
,
129 const AsCharFlags _nFlags
,
130 const SwTwips _nLineAscent
,
131 const SwTwips _nLineDescent
,
132 const SwTwips _nLineAscentInclObjs
,
133 const SwTwips _nLineDescentInclObjs
);
134 virtual ~SwAsCharAnchoredObjectPosition() override
;
136 /** calculate position for object position
138 members <maAnchorPos>, <mnRelPos>, <maObjBoundRect> and
139 <mnLineAlignment> are calculated.
140 calculated position is set at the given object.
142 virtual void CalcPosition() override
;
144 // calculated anchored position for object position type AS_CHAR
145 const Point
& GetAnchorPos() const { return maAnchorPos
;}
147 // calculated relative position to base line for object position type AS_CHAR
148 SwTwips
GetRelPosY() const { return mnRelPos
;}
150 // determined object rectangle including spacing for object position type AS_CHAR
151 const SwRect
& GetObjBoundRectInclSpacing() const { return maObjBoundRect
;}
153 // determined line alignment relative to line height
154 sw::LineAlign
GetLineAlignment() const { return mnLineAlignment
;}
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */