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  // #i26791# - anchored object the object belongs to;
47  // frame the object is anchored at
49  // contact object
51  // frame format
53  // does the object represents a Writer fly frame
54  bool mbIsObjFly;
55  // #i62875#
57  // #i62875#
58  // for compatibility option <DoNotCaptureDrawObjsOnPage>
60 
66  void GetInfoAboutObj();
67 
68  // #i62875#
69  // --> OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
70  SwTwips ImplAdjustVertRelPos( const SwTwips nTopOfAnch,
71  const bool bVert,
72  const bool bVertL2R,
73  const SwFrame& rPageAlignLayFrame,
74  const SwTwips nProposedRelPosY,
75  const bool bFollowTextFlow,
76  const bool bCheckBottom ) const;
77  SwTwips ImplAdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame,
78  const SwTwips _nProposedRelPosX ) const;
79 
80  protected:
81  SwAnchoredObjectPosition( SdrObject& _rDrawObj );
82  virtual ~SwAnchoredObjectPosition();
83 
84  // accessors for object and its corresponding data/information
86  {
87  return mrDrawObj;
88  }
89  bool IsObjFly() const
90  {
91  return mbIsObjFly;
92  }
94  {
95  return *mpAnchoredObj;
96  }
98  {
99  return *mpAnchorFrame;
100  }
102  {
103  return *mpFrameFormat;
104  }
105  // #i62875#
107  {
108  return mbFollowTextFlow;
109  }
110 
111  // virtual methods providing data for to character anchored objects.
112  virtual bool IsAnchoredToChar() const;
113  virtual const SwFrame* ToCharOrientFrame() const;
114  virtual const SwRect* ToCharRect() const;
115  // #i22341#
116  virtual SwTwips ToCharTopOfLine() const;
117 
123  SwTwips GetTopForObjPos( const SwFrame& _rFrame,
124  const SwRectFn& _fnRect,
125  const bool _bVert ) const;
126 
127  void GetVertAlignmentValues( const SwFrame& _rVertOrientFrame,
128  const SwFrame& _rPageAlignLayFrame,
129  const sal_Int16 _eRelOrient,
130  SwTwips& _orAlignAreaHeight,
131  SwTwips& _orAlignAreaOffset ) const;
132 
133  // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos>
134  SwTwips GetVertRelPos( const SwFrame& _rVertOrientFrame,
135  const SwFrame& _rPageAlignLayFrame,
136  const sal_Int16 _eVertOrient,
137  const sal_Int16 _eRelOrient,
138  const SwTwips _nVertPos,
139  const SvxLRSpaceItem& _rLRSpacing,
140  const SvxULSpaceItem& _rULSpacing,
141  SwTwips& _roVertOffsetToFrameAnchorPos ) const;
142 
182  SwTwips AdjustVertRelPos( const SwTwips nTopOfAnch,
183  const bool bVert,
184  const bool bVertL2R,
185  const SwFrame& rPageAlignLayFrame,
186  const SwTwips nProposedRelPosY,
187  const bool bFollowTextFlow,
188  const bool bCheckBottom = true ) const
189  {
190  return !mbDoNotCaptureAnchoredObj
191  ? ImplAdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
192  rPageAlignLayFrame,
193  nProposedRelPosY,
194  bFollowTextFlow,
195  bCheckBottom )
196  : nProposedRelPosY;
197  }
198 
235  SwTwips CalcRelPosX( const SwFrame& _rHoriOrientFrame,
236  const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
237  const SwFormatHoriOrient& _rHoriOrient,
238  const SvxLRSpaceItem& _rLRSpacing,
239  const SvxULSpaceItem& _rULSpacing,
240  const bool _bObjWrapThrough,
241  const SwTwips _nRelPosY,
242  SwTwips& _roHoriOffsetToFrameAnchorPos
243  ) const;
244 
262  SwTwips AdjustHoriRelPos( const SwFrame& _rPageAlignLayFrame,
263  const SwTwips _nProposedRelPosX ) const
264  {
265  return !mbDoNotCaptureAnchoredObj
266  ? ImplAdjustHoriRelPos( _rPageAlignLayFrame, _nProposedRelPosX )
267  : _nProposedRelPosX;
268  }
269 
284  static void ToggleHoriOrientAndAlign( const bool _bToggleLeftRight,
285  sal_Int16& _ioeHoriOrient,
286  sal_Int16& _iopeRelOrient
287  );
288 
326  void GetHoriAlignmentValues( const SwFrame& _rHoriOrientFrame,
327  const SwFrame& _rPageAlignLayFrame,
328  const sal_Int16 _eRelOrient,
329  const bool _bObjWrapThrough,
330  SwTwips& _orAlignAreaWidth,
331  SwTwips& _orAlignAreaOffset,
332  bool& _obAlignedRelToPage ) const;
333 
365  SwTwips AdjustHoriRelPosForDrawAside( const SwFrame& _rHoriOrientFrame,
366  const SwTwips _nProposedRelPosX,
367  const SwTwips _nRelPosY,
368  const sal_Int16 _eHoriOrient,
369  const sal_Int16 _eRelOrient,
370  const SvxLRSpaceItem& _rLRSpacing,
371  const SvxULSpaceItem& _rULSpacing,
372  const bool _bEvenPage
373  ) const;
374 
403  bool DrawAsideFly( const SwFlyFrame* _pFly,
404  const SwRect& _rObjRect,
405  const SwFrame* _pObjContext,
406  const sal_uLong _nObjIndex,
407  const bool _bEvenPage,
408  const sal_Int16 _eHoriOrient,
409  const sal_Int16 _eRelOrient
410  ) const;
411 
435  static bool Minor_( sal_Int16 _eRelOrient1,
436  sal_Int16 _eRelOrient2,
437  bool _bLeft );
438 
439  public:
440  virtual void CalcPosition() = 0;
441  };
442 }
443 
444 #endif
445 
446 /* 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:298
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
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
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:58
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
tools::Long SwTwips
Definition: swtypes.hxx:49
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