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 
26 class SdrObject;
27 class SwFlyFrame;
28 class SwContact;
29 class SwFrameFormat;
30 class SwRect;
31 class SvxLRSpaceItem;
32 class SvxULSpaceItem;
33 class SwFormatHoriOrient;
34 class SwAnchoredObject;
35 
37 {
39 
41  {
42  private:
43  // object to be positioned
45 
46  // does the object represents a Writer fly frame
47  bool mbIsObjFly;
48  // #i26791# - anchored object the object belongs to;
50  // frame the object is anchored at
52  // contact object
54  // frame format
56  // #i62875#
58  bool mbLayoutInCell = false;
59  // #i62875#
60  // for compatibility option <DoNotCaptureDrawObjsOnPage>
62 
68  void GetInfoAboutObj();
69 
70  // #i62875#
71  // --> OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
72  SwTwips ImplAdjustVertRelPos( const SwTwips nTopOfAnch,
73  const bool bVert,
74  const bool bVertL2R,
75  const SwFrame& rPageAlignLayFrame,
76  const SwTwips nProposedRelPosY,
77  const bool bFollowTextFlow,
78  const bool bCheckBottom ) const;
79  SwTwips ImplAdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame,
80  const SwTwips _nProposedRelPosX ) const;
81 
82  protected:
83  SwAnchoredObjectPosition( SdrObject& _rDrawObj );
84  virtual ~SwAnchoredObjectPosition();
85 
86  // accessors for object and its corresponding data/information
88  {
89  return mrDrawObj;
90  }
91  bool IsObjFly() const
92  {
93  return mbIsObjFly;
94  }
96  {
97  return *mpAnchoredObj;
98  }
100  {
101  return *mpAnchorFrame;
102  }
104  {
105  return *mpFrameFormat;
106  }
107  // #i62875#
109  {
110  return mbFollowTextFlow;
111  }
112  bool DoesObjLayoutInCell() const
113  {
114  return mbLayoutInCell;
115  }
116 
117  // virtual methods providing data for to character anchored objects.
118  virtual bool IsAnchoredToChar() const;
119  virtual const SwFrame* ToCharOrientFrame() const;
120  virtual const SwRect* ToCharRect() const;
121  // #i22341#
122  virtual SwTwips ToCharTopOfLine() const;
123 
129  SwTwips GetTopForObjPos( const SwFrame& _rFrame,
130  const SwRectFn& _fnRect,
131  const bool _bVert ) const;
132 
133  void GetVertAlignmentValues( const SwFrame& _rVertOrientFrame,
134  const SwFrame& _rPageAlignLayFrame,
135  const sal_Int16 _eRelOrient,
136  SwTwips& _orAlignAreaHeight,
137  SwTwips& _orAlignAreaOffset ) const;
138 
139  // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos>
140  SwTwips GetVertRelPos( const SwFrame& _rVertOrientFrame,
141  const SwFrame& _rPageAlignLayFrame,
142  const sal_Int16 _eVertOrient,
143  const sal_Int16 _eRelOrient,
144  const SwTwips _nVertPos,
145  const SvxLRSpaceItem& _rLRSpacing,
146  const SvxULSpaceItem& _rULSpacing,
147  SwTwips& _roVertOffsetToFrameAnchorPos ) const;
148 
188  SwTwips AdjustVertRelPos( const SwTwips nTopOfAnch,
189  const bool bVert,
190  const bool bVertL2R,
191  const SwFrame& rPageAlignLayFrame,
192  const SwTwips nProposedRelPosY,
193  const bool bFollowTextFlow,
194  const bool bCheckBottom = true ) const
195  {
196  return !mbDoNotCaptureAnchoredObj
197  ? ImplAdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
198  rPageAlignLayFrame,
199  nProposedRelPosY,
200  bFollowTextFlow,
201  bCheckBottom )
202  : nProposedRelPosY;
203  }
204 
241  SwTwips CalcRelPosX( const SwFrame& _rHoriOrientFrame,
242  const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
243  const SwFormatHoriOrient& _rHoriOrient,
244  const SvxLRSpaceItem& _rLRSpacing,
245  const SvxULSpaceItem& _rULSpacing,
246  const bool _bObjWrapThrough,
247  const SwTwips _nRelPosY,
248  SwTwips& _roHoriOffsetToFrameAnchorPos
249  ) const;
250 
268  SwTwips AdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame,
269  const SwTwips _nProposedRelPosX ) const
270  {
271  return !mbDoNotCaptureAnchoredObj
272  ? ImplAdjustHoriRelPos( _rPageAlignLayFrame, _nProposedRelPosX )
273  : _nProposedRelPosX;
274  }
275 
290  static void ToggleHoriOrientAndAlign( const bool _bToggleLeftRight,
291  sal_Int16& _ioeHoriOrient,
292  sal_Int16& _iopeRelOrient
293  );
294 
332  void GetHoriAlignmentValues( const SwFrame& _rHoriOrientFrame,
333  const SwFrame& _rPageAlignLayFrame,
334  const sal_Int16 _eRelOrient,
335  const bool _bObjWrapThrough,
336  SwTwips& _orAlignAreaWidth,
337  SwTwips& _orAlignAreaOffset,
338  bool& _obAlignedRelToPage ) const;
339 
371  SwTwips AdjustHoriRelPosForDrawAside( const SwFrame& _rHoriOrientFrame,
372  const SwTwips _nProposedRelPosX,
373  const SwTwips _nRelPosY,
374  const sal_Int16 _eHoriOrient,
375  const sal_Int16 _eRelOrient,
376  const SvxLRSpaceItem& _rLRSpacing,
377  const SvxULSpaceItem& _rULSpacing,
378  const bool _bEvenPage
379  ) const;
380 
409  bool DrawAsideFly( const SwFlyFrame* _pFly,
410  const SwRect& _rObjRect,
411  const SwFrame* _pObjContext,
412  const sal_uLong _nObjIndex,
413  const bool _bEvenPage,
414  const sal_Int16 _eHoriOrient,
415  const sal_Int16 _eRelOrient
416  ) const;
417 
441  static bool Minor_( sal_Int16 _eRelOrient1,
442  sal_Int16 _eRelOrient2,
443  bool _bLeft );
444 
445  public:
446  virtual void CalcPosition() = 0;
447  };
448 }
449 
450 #endif
451 
452 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwTwips ImplAdjustHoriRelPos(const SwFrame &_rPageAlignLayFrame, const SwTwips _nProposedRelPosX) const
adjust calculated horizontal in order to keep object inside 'page' alignment layout frame...
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:295
void GetInfoAboutObj()
determine information about object
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...
sal_uIntPtr sal_uLong
long SwTwips
Definition: swtypes.hxx:49
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
static void ToggleHoriOrientAndAlign(const bool _bToggleLeftRight, sal_Int16 &_ioeHoriOrient, sal_Int16 &_iopeRelOrient)
toggle given horizontal orientation and relative alignment
wrapper class for the positioning of Writer fly frames and drawing objects
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...
bool DrawAsideFly(const SwFlyFrame *_pFly, const SwRect &_rObjRect, const SwFrame *_pObjContext, const sal_uLong _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 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...
Style of a layout element.
Definition: frmfmt.hxx:57
static bool Minor_(sal_Int16 _eRelOrient1, sal_Int16 _eRelOrient2, bool _bLeft)
determine, if object has to draw aside another 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
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
virtual const SwFrame * ToCharOrientFrame() const
SwTwips AdjustHoriRelPos(const SwFrame &_rPageAlignLayFrame, const SwTwips _nProposedRelPosX) const
adjust calculated horizontal in order to keep object inside 'page' alignment layout frame for object ...
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
void GetVertAlignmentValues(const SwFrame &_rVertOrientFrame, const SwFrame &_rPageAlignLayFrame, const sal_Int16 _eRelOrient, SwTwips &_orAlignAreaHeight, SwTwips &_orAlignAreaOffset) const
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