LibreOffice Module sw (master) 1
anchoredobjectposition.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_SW_SOURCE_CORE_INC_ANCHOREDOBJECTPOSITION_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_ANCHOREDOBJECTPOSITION_HXX
22
23#include <swtypes.hxx>
24#include "frame.hxx"
25#include <nodeoffset.hxx>
26
27class SdrObject;
28class SwFlyFrame;
29class SwContact;
30class SwFrameFormat;
31class SwRect;
32class SvxLRSpaceItem;
33class SvxULSpaceItem;
36
38{
40
42 {
43 private:
44 // object to be positioned
46 // #i26791# - anchored object the object belongs to;
48 // frame the object is anchored at
50 // contact object
52 // frame format
54 // does the object represents a Writer fly frame
56 // #i62875#
58 // #i62875#
59 // for compatibility option <DoNotCaptureDrawObjsOnPage>
61
67 void GetInfoAboutObj();
68
69 // #i62875#
70 // --> OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
71 SwTwips ImplAdjustVertRelPos( const SwTwips nTopOfAnch,
72 const bool bVert,
73 const bool bVertL2R,
74 const SwFrame& rPageAlignLayFrame,
75 const SwTwips nProposedRelPosY,
76 const bool bFollowTextFlow,
77 const bool bCheckBottom ) const;
78 SwTwips ImplAdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame,
79 const SwTwips _nProposedRelPosX ) const;
80
81 protected:
84
85 // accessors for object and its corresponding data/information
87 {
88 return mrDrawObj;
89 }
90 bool IsObjFly() const
91 {
92 return mbIsObjFly;
93 }
95 {
96 return *mpAnchoredObj;
97 }
99 {
100 return *mpAnchorFrame;
101 }
103 {
104 return *mpFrameFormat;
105 }
106 // #i62875#
108 {
109 return mbFollowTextFlow;
110 }
111
112 // virtual methods providing data for to character anchored objects.
113 virtual bool IsAnchoredToChar() const;
114 virtual const SwFrame* ToCharOrientFrame() const;
115 virtual const SwRect* ToCharRect() const;
116 // #i22341#
117 virtual SwTwips ToCharTopOfLine() const;
118
124 SwTwips GetTopForObjPos( const SwFrame& _rFrame,
125 const SwRectFn& _fnRect,
126 const bool _bVert ) const;
127
128 void GetVertAlignmentValues( const SwFrame& _rVertOrientFrame,
129 const SwFrame& _rPageAlignLayFrame,
130 const sal_Int16 _eRelOrient,
131 SwTwips& _orAlignAreaHeight,
132 SwTwips& _orAlignAreaOffset ) const;
133
134 // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos>
135 SwTwips GetVertRelPos( const SwFrame& _rVertOrientFrame,
136 const SwFrame& _rPageAlignLayFrame,
137 const sal_Int16 _eVertOrient,
138 const sal_Int16 _eRelOrient,
139 const SwTwips _nVertPos,
140 const SvxLRSpaceItem& _rLRSpacing,
141 const SvxULSpaceItem& _rULSpacing,
142 SwTwips& _roVertOffsetToFrameAnchorPos ) const;
143
184 const bool bVert,
185 const bool bVertL2R,
186 const SwFrame& rPageAlignLayFrame,
187 const SwTwips nProposedRelPosY,
188 const bool bFollowTextFlow,
189 const bool bCheckBottom = true ) const
190 {
192 ? ImplAdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
193 rPageAlignLayFrame,
194 nProposedRelPosY,
195 bFollowTextFlow,
196 bCheckBottom )
197 : nProposedRelPosY;
198 }
199
236 SwTwips CalcRelPosX( const SwFrame& _rHoriOrientFrame,
237 const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
238 const SwFormatHoriOrient& _rHoriOrient,
239 const SvxLRSpaceItem& _rLRSpacing,
240 const SvxULSpaceItem& _rULSpacing,
241 const bool _bObjWrapThrough,
242 const SwTwips _nRelPosY,
243 SwTwips& _roHoriOffsetToFrameAnchorPos
244 ) const;
245
263 SwTwips AdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame,
264 const SwTwips _nProposedRelPosX ) const
265 {
267 ? ImplAdjustHoriRelPos( _rPageAlignLayFrame, _nProposedRelPosX )
268 : _nProposedRelPosX;
269 }
270
285 static void ToggleHoriOrientAndAlign( const bool _bToggleLeftRight,
286 sal_Int16& _ioeHoriOrient,
287 sal_Int16& _iopeRelOrient
288 );
289
327 void GetHoriAlignmentValues( const SwFrame& _rHoriOrientFrame,
328 const SwFrame& _rPageAlignLayFrame,
329 const sal_Int16 _eRelOrient,
330 const bool _bObjWrapThrough,
331 SwTwips& _orAlignAreaWidth,
332 SwTwips& _orAlignAreaOffset,
333 bool& _obAlignedRelToPage ) const;
334
366 SwTwips AdjustHoriRelPosForDrawAside( const SwFrame& _rHoriOrientFrame,
367 const SwTwips _nProposedRelPosX,
368 const SwTwips _nRelPosY,
369 const sal_Int16 _eHoriOrient,
370 const sal_Int16 _eRelOrient,
371 const SvxLRSpaceItem& _rLRSpacing,
372 const SvxULSpaceItem& _rULSpacing,
373 const bool _bEvenPage
374 ) const;
375
404 bool DrawAsideFly( const SwFlyFrame* _pFly,
405 const SwRect& _rObjRect,
406 const SwFrame* _pObjContext,
407 const SwNodeOffset _nObjIndex,
408 const bool _bEvenPage,
409 const sal_Int16 _eHoriOrient,
410 const sal_Int16 _eRelOrient
411 ) const;
412
436 static bool Minor_( sal_Int16 _eRelOrient1,
437 sal_Int16 _eRelOrient2,
438 bool _bLeft );
439
440 public:
441 virtual void CalcPosition() = 0;
442 };
443}
444
445#endif
446
447/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
wrapper class for the positioning of Writer fly frames and drawing objects
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:67
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
Defines the horizontal position of a fly frame.
Definition: fmtornt.hxx:73
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer layout elements.
Definition: frame.hxx:315
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwTwips AdjustHoriRelPos(const SwFrame &_rPageAlignLayFrame, const SwTwips _nProposedRelPosX) const
adjust calculated horizontal in order to keep object inside 'page' alignment layout frame for object ...
SwTwips ImplAdjustHoriRelPos(const SwFrame &_rPageAlignLayFrame, const SwTwips _nProposedRelPosX) const
adjust calculated horizontal in order to keep object inside 'page' alignment layout frame.
void GetInfoAboutObj()
determine information about object
SwTwips CalcRelPosX(const SwFrame &_rHoriOrientFrame, const SwEnvironmentOfAnchoredObject &_rEnvOfObj, const SwFormatHoriOrient &_rHoriOrient, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, const bool _bObjWrapThrough, const SwTwips _nRelPosY, SwTwips &_roHoriOffsetToFrameAnchorPos) const
calculate relative horizontal position
static void ToggleHoriOrientAndAlign(const bool _bToggleLeftRight, sal_Int16 &_ioeHoriOrient, sal_Int16 &_iopeRelOrient)
toggle given horizontal orientation and relative alignment
SwTwips AdjustHoriRelPosForDrawAside(const SwFrame &_rHoriOrientFrame, const SwTwips _nProposedRelPosX, const SwTwips _nRelPosY, const sal_Int16 _eHoriOrient, const sal_Int16 _eRelOrient, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, const bool _bEvenPage) const
adjust calculated horizontal position in order to draw object aside other objects with same positioni...
SwTwips AdjustVertRelPos(const SwTwips nTopOfAnch, const bool bVert, const bool bVertL2R, const SwFrame &rPageAlignLayFrame, const SwTwips nProposedRelPosY, const bool bFollowTextFlow, const bool bCheckBottom=true) const
adjust calculated vertical in order to keep object inside 'page' alignment layout frame.
void GetHoriAlignmentValues(const SwFrame &_rHoriOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, const bool _bObjWrapThrough, SwTwips &_orAlignAreaWidth, SwTwips &_orAlignAreaOffset, bool &_obAlignedRelToPage) const
determine alignment values for horizontal position of object
static bool Minor_(sal_Int16 _eRelOrient1, sal_Int16 _eRelOrient2, bool _bLeft)
determine, if object has to draw aside another object
void GetVertAlignmentValues(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, SwTwips &_orAlignAreaHeight, SwTwips &_orAlignAreaOffset) const
bool DrawAsideFly(const SwFlyFrame *_pFly, const SwRect &_rObjRect, const SwFrame *_pObjContext, const SwNodeOffset _nObjIndex, const bool _bEvenPage, const sal_Int16 _eHoriOrient, const sal_Int16 _eRelOrient) const
determine, if object has to draw aside given fly frame
SwTwips GetVertRelPos(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eVertOrient, const sal_Int16 _eRelOrient, const SwTwips _nVertPos, const SvxLRSpaceItem &_rLRSpacing, const SvxULSpaceItem &_rULSpacing, SwTwips &_roVertOffsetToFrameAnchorPos) const
SwTwips ImplAdjustVertRelPos(const SwTwips nTopOfAnch, const bool bVert, const bool bVertL2R, const SwFrame &rPageAlignLayFrame, const SwTwips nProposedRelPosY, const bool bFollowTextFlow, const bool bCheckBottom) const
adjust calculated vertical in order to keep object inside 'page' alignment layout frame.
SwTwips GetTopForObjPos(const SwFrame &_rFrame, const SwRectFn &_fnRect, const bool _bVert) const
helper method to determine top of a frame for the vertical object positioning
tools::Long SwTwips
Definition: swtypes.hxx:51