Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / ascharanchoredobjectposition.hxx
blob34f42e3643a686922af9cdc58ff4f68226c545b4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <swrect.hxx>
26 #include <o3tl/typed_flags_set.hxx>
28 class SwTextFrame;
29 class SwFormatVertOrient;
31 // flags for positioning algorithm of as-character-anchored objects
32 enum class AsCharFlags {
33 None = 0x00,
34 Quick = 0x01,
35 UlSpace = 0x02,
36 Init = 0x04,
37 Rotate = 0x08,
38 Reverse = 0x10,
39 Bidi = 0x20,
41 namespace o3tl {
42 template<> struct typed_flags<AsCharFlags> : is_typed_flags<AsCharFlags, 0x3f> {};
45 namespace sw
47 // TODO: merge/migrate this to com::sun::star::VertOrientation instead of duplicating?
48 enum class LineAlign
50 NONE,
51 TOP,
52 CENTER,
53 BOTTOM
56 namespace objectpositioning
58 class SwAsCharAnchoredObjectPosition final : public SwAnchoredObjectPosition
60 private:
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
80 Point maAnchorPos;
81 SwTwips mnRelPos;
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.
95 @param _rVert
96 given vertical positioning and alignment
98 @return relative position to the base line
100 SwTwips GetRelPosToBase( const SwTwips _nObjBoundHeight,
101 const SwFormatVertOrient& _rVert );
103 public:
104 /** constructor; provided object to be positioned and needed data
105 for calculation of the object position
107 @param _rDrawObj
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
114 @param _nFlags
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
125 alignments.
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;}
158 #endif
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */