LCOV - code coverage report
Current view: top level - sw/source/core/inc - anchoredobjectposition.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 21 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : // #i11860#
      25             : #include <frame.hxx>
      26             : 
      27             : class SdrObject;
      28             : class SwFrm;
      29             : class SwFlyFrm;
      30             : class SwContact;
      31             : class SwFrmFmt;
      32             : class SwRect;
      33             : class SvxLRSpaceItem;
      34             : class SvxULSpaceItem;
      35             : class SwFmtHoriOrient;
      36             : // #i26701#
      37             : class SwAnchoredObject;
      38             : 
      39             : namespace objectpositioning
      40             : {
      41             :     class SwEnvironmentOfAnchoredObject;
      42             : 
      43             :     class SwAnchoredObjectPosition
      44             :     {
      45             :     private:
      46             :         // object to be positioned
      47             :         SdrObject& mrDrawObj;
      48             : 
      49             :         // does the object represents a Writer fly frame
      50             :         bool mbIsObjFly;
      51             :         // #i26791# - anchored object the object belongs to;
      52             :         SwAnchoredObject* mpAnchoredObj;
      53             :         // frame the object is anchored at
      54             :         SwFrm* mpAnchorFrm;
      55             :         // contact object
      56             :         SwContact* mpContact;
      57             :         // frame format
      58             :         const SwFrmFmt* mpFrmFmt;
      59             :         // #i62875#
      60             :         bool mbFollowTextFlow;
      61             :         // #i62875#
      62             :         // for compatibility option <DoNotCaptureDrawObjsOnPage>
      63             :         bool mbDoNotCaptureAnchoredObj;
      64             : 
      65             :         /** determine information about object
      66             : 
      67             :             member <mbIsObjFly>, <mpAnchoredObj>, <mpAnchorFrm>, <mpContact>
      68             :             and <mpFrmFmt> are set
      69             :         */
      70             :         void _GetInfoAboutObj();
      71             : 
      72             :         // #i62875#
      73             :         // --> OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
      74             :         SwTwips _ImplAdjustVertRelPos( const SwTwips nTopOfAnch,
      75             :                                        const bool bVert,
      76             :                                        const bool bVertL2R,
      77             :                                        const SwFrm&  rPageAlignLayFrm,
      78             :                                        const SwTwips nProposedRelPosY,
      79             :                                        const bool bFollowTextFlow,
      80             :                                        const bool bCheckBottom = true ) const;
      81             :         SwTwips _ImplAdjustHoriRelPos( const SwFrm&  _rPageAlignLayFrm,
      82             :                                        const SwTwips _nProposedRelPosX ) const;
      83             : 
      84             :     protected:
      85             :         SwAnchoredObjectPosition( SdrObject& _rDrawObj );
      86             :         virtual ~SwAnchoredObjectPosition();
      87             : 
      88             :         // accessors for object and its corresponding data/information
      89           0 :         inline SdrObject& GetObject() const
      90             :         {
      91           0 :             return mrDrawObj;
      92             :         }
      93           0 :         inline bool IsObjFly() const
      94             :         {
      95           0 :             return mbIsObjFly;
      96             :         }
      97           0 :         inline SwAnchoredObject& GetAnchoredObj() const
      98             :         {
      99           0 :             return *mpAnchoredObj;
     100             :         }
     101           0 :         inline SwFrm& GetAnchorFrm() const
     102             :         {
     103           0 :             return *mpAnchorFrm;
     104             :         }
     105           0 :         inline SwContact& GetContact() const
     106             :         {
     107           0 :             return *mpContact;
     108             :         }
     109           0 :         inline const SwFrmFmt& GetFrmFmt() const
     110             :         {
     111           0 :             return *mpFrmFmt;
     112             :         }
     113             :         // #i62875#
     114           0 :         inline bool DoesObjFollowsTextFlow() const
     115             :         {
     116           0 :             return mbFollowTextFlow;
     117             :         }
     118             : 
     119             :         // virtual methods providing data for to character anchored objects.
     120             :         virtual bool IsAnchoredToChar() const;
     121             :         virtual const SwFrm* ToCharOrientFrm() const;
     122             :         virtual const SwRect* ToCharRect() const;
     123             :         // #i22341#
     124             :         virtual SwTwips ToCharTopOfLine() const;
     125             : 
     126             :         /** helper method to determine top of a frame for the vertical object
     127             :             positioning
     128             : 
     129             :             #i11860#
     130             :         */
     131             :         SwTwips _GetTopForObjPos( const SwFrm& _rFrm,
     132             :                                   const SwRectFn& _fnRect,
     133             :                                   const bool _bVert ) const;
     134             : 
     135             :         void _GetVertAlignmentValues( const SwFrm& _rVertOrientFrm,
     136             :                                       const SwFrm& _rPageAlignLayFrm,
     137             :                                       const sal_Int16 _eRelOrient,
     138             :                                       SwTwips&      _orAlignAreaHeight,
     139             :                                       SwTwips&      _orAlignAreaOffset ) const;
     140             : 
     141             :         // #i26791# - add output parameter <_roVertOffsetToFrmAnchorPos>
     142             :         SwTwips _GetVertRelPos( const SwFrm& _rVertOrientFrm,
     143             :                                 const SwFrm& _rPageAlignLayFrm,
     144             :                                 const sal_Int16 _eVertOrient,
     145             :                                 const sal_Int16 _eRelOrient,
     146             :                                 const SwTwips          _nVertPos,
     147             :                                 const SvxLRSpaceItem& _rLRSpacing,
     148             :                                 const SvxULSpaceItem& _rULSpacing,
     149             :                                 SwTwips& _roVertOffsetToFrmAnchorPos ) const;
     150             : 
     151             :         /** adjust calculated vertical in order to keep object inside
     152             :             'page' alignment layout frame.
     153             : 
     154             :             #i31805# - add parameter <_bCheckBottom>
     155             :             #i26945# - add parameter <_bFollowTextFlow>
     156             :             #i62875# - made inline, intrinsic actions moved
     157             :             to private method <_ImplAdjustVertRelPos>, which is only
     158             :             called, if <mbDoNotCaptureAnchoredObj> not set.
     159             :             OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
     160             : 
     161             :             @param nTopOfAnch
     162             :             input parameter - 'vertical' position, at which the relative
     163             :             position of the object is calculated from.
     164             : 
     165             :             @param bVert
     166             :             input parameter - boolean, indicating, if object is in vertical
     167             :             layout.
     168             : 
     169             :             @param bVertL2R
     170             :             input parameter - boolean, indicating, if object is in mongolian
     171             :             layout (vertical left-to-right layout).
     172             : 
     173             :             @param rPageAlignLayFrm
     174             :             input parameter - layout frame, which determines the 'page area'
     175             :             the object has to be vertical positioned in.
     176             : 
     177             :             @param nProposedRelPosY
     178             :             input parameter - proposed relative vertical position, which
     179             :             will be adjusted.
     180             : 
     181             :             @param bFollowTextFlow
     182             :             input parameter - value of attribute 'Follow text flow' of the
     183             :             anchored object.
     184             : 
     185             :             @param bCheckBottom
     186             :             input parameter - boolean indicating, if bottom of anchored
     187             :             object has to be checked and thus, (if needed) the proposed
     188             :             relative position has to be adjusted. default value <true>
     189             :         */
     190           0 :         inline SwTwips _AdjustVertRelPos( const SwTwips nTopOfAnch,
     191             :                                           const bool bVert,
     192             :                                           const bool bVertL2R,
     193             :                                           const SwFrm& rPageAlignLayFrm,
     194             :                                           const SwTwips nProposedRelPosY,
     195             :                                           const bool bFollowTextFlow,
     196             :                                           const bool bCheckBottom = true ) const
     197             :         {
     198           0 :             return !mbDoNotCaptureAnchoredObj
     199             :                    ? _ImplAdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
     200             :                                             rPageAlignLayFrm,
     201             :                                             nProposedRelPosY,
     202             :                                             bFollowTextFlow,
     203           0 :                                             bCheckBottom )
     204           0 :                    : nProposedRelPosY;
     205             :         }
     206             : 
     207             :         /** calculate relative horizontal position
     208             : 
     209             :             #i26791# - add output parameter
     210             :             <_roHoriOffsetToFrmAnchorPos>
     211             : 
     212             :             @param _rHoriOrientFrm
     213             :             input parameter - frame the horizontal position of the object
     214             :             is oriented at.
     215             : 
     216             :             @param _rEnvOfObj
     217             :             input parameter - object instance to retrieve environment
     218             :             information about the object
     219             : 
     220             :             @param _rHoriOrient
     221             :             input parameter - horizontal positioning and alignment, for which
     222             :             the relative position is calculated.
     223             : 
     224             :             @param _rLRSpacing
     225             :             input parameter - left and right spacing of the object to the text
     226             : 
     227             :             @param _rULSpacing
     228             :             input parameter - upper and lower spacing of the object to the text
     229             : 
     230             :             @param _bObjWrapThrough
     231             :             input parameter - boolean indicating, if object has wrap mode
     232             :             'wrap through'.
     233             : 
     234             :             @param _nRelPosY
     235             :             input parameter - relative vertical position
     236             : 
     237             :             @param _roHoriOffsetToFrmAnchorPos
     238             :             output parameter - 'horizontal' offset to frame anchor position
     239             :             according to the alignment
     240             : 
     241             :             @return relative horizontal position in SwTwips
     242             :         */
     243             :         SwTwips _CalcRelPosX( const SwFrm& _rHoriOrientFrm,
     244             :                               const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
     245             :                               const SwFmtHoriOrient& _rHoriOrient,
     246             :                               const SvxLRSpaceItem& _rLRSpacing,
     247             :                               const SvxULSpaceItem& _rULSpacing,
     248             :                               const bool _bObjWrapThrough,
     249             :                               const SwTwips _nRelPosY,
     250             :                               SwTwips& _roHoriOffsetToFrmAnchorPos
     251             :                             ) const;
     252             : 
     253             :         /** adjust calculated horizontal in order to keep object inside
     254             :             'page' alignment layout frame for object type position TO_CNTNT
     255             : 
     256             :             #i62875# - made inline, intrinsic actions moved
     257             :             to private method <_ImplAdjustHoriRelPos>, which is only
     258             :             called, if <mbDoNotCaptureAnchoredObj> not set.
     259             : 
     260             :             @param _rPageAlignLayFrm
     261             :             input paramter - layout frame, which determines the 'page area'
     262             :             the object has to be horizontal positioned in.
     263             : 
     264             :             @param _nProposedRelPosX
     265             :             input parameter - proposed relative horizontal position, which
     266             :             will be adjusted.
     267             : 
     268             :             @return adjusted relative horizontal position in SwTwips.
     269             :         */
     270           0 :         inline SwTwips _AdjustHoriRelPos( const SwFrm&  _rPageAlignLayFrm,
     271             :                                           const SwTwips _nProposedRelPosX ) const
     272             :         {
     273           0 :             return !mbDoNotCaptureAnchoredObj
     274             :                    ? _ImplAdjustHoriRelPos( _rPageAlignLayFrm, _nProposedRelPosX )
     275           0 :                    : _nProposedRelPosX;
     276             :         }
     277             : 
     278             :         /** toggle given horizontal orientation and relative alignment
     279             : 
     280             :             @param _bToggleLeftRight
     281             :             input parameter - boolean indicating, if horizontal orientation
     282             :             and relative alignment has to be toggled.
     283             : 
     284             :             @param _ioeHoriOrient
     285             :             input/output parameter - horizontal orientation, that is toggled,
     286             :             if needed.
     287             : 
     288             :             @param _iopeRelOrient
     289             :             optional input/output parameter (default value NULL)
     290             :             - if set, relative alignment, that is toggled, if needed.
     291             :         */
     292             :         void _ToggleHoriOrientAndAlign( const bool _bToggleLeftRight,
     293             :                                         sal_Int16& _ioeHoriOrient,
     294             :                                         sal_Int16& _iopeRelOrient
     295             :                                       ) const;
     296             : 
     297             :         /** determine alignment values for horizontal position of object
     298             : 
     299             :             @param _rHoriOrientFrm
     300             :             input parameter - frame the horizontal position of the object
     301             :             is oriented at.
     302             : 
     303             :             @param _rPageAlignLayFrm
     304             :             input paramter - layout frame, which determines the 'page area'
     305             :             the object has to be horizontal positioned in.
     306             : 
     307             :             @param _eRelOrient
     308             :             input parameter - horizontal relative alignment, for which
     309             :             the relative position is calculated.
     310             : 
     311             :             @param _bToggleLeftRight
     312             :             input parameter - boolean indicating, if left/right alignments
     313             :             have to be toggled.
     314             : 
     315             :             @param _bObjWrapThrough
     316             :             input parameter - boolean indicating, if object has wrap mode
     317             :             'wrap through'.
     318             :             important note: value is only relevant, if _rHoriOrientFrm is
     319             :                             a text frame.
     320             : 
     321             :             @param _orAlignAreaWidth
     322             :             output parameter - width in SwTwips of the area the horizontal
     323             :             position is aligned to.
     324             : 
     325             :             @param _orAlignAreaOffset
     326             :             output parameter - offset in SwTwips of the area the horizontal
     327             :             position is aligned to. offset is given to the 'left' of the
     328             :             anchor position.
     329             : 
     330             :             @param _obAlignedRelToPage
     331             :             output parameter - boolean indicating, that object is aligned
     332             :             to 'page area'.
     333             :         */
     334             :         void _GetHoriAlignmentValues( const SwFrm&  _rHoriOrientFrm,
     335             :                                       const SwFrm&  _rPageAlignLayFrm,
     336             :                                       const sal_Int16 _eRelOrient,
     337             :                                       const bool    _bObjWrapThrough,
     338             :                                       SwTwips&      _orAlignAreaWidth,
     339             :                                       SwTwips&      _orAlignAreaOffset,
     340             :                                       bool&         _obAlignedRelToPage ) const;
     341             : 
     342             :         /** adjust calculated horizontal position in order to draw object
     343             :             aside other objects with same positioning
     344             : 
     345             :             @param _rHoriOrientFrm
     346             :             input parameter - frame the horizontal position of the object
     347             :             is oriented at.
     348             : 
     349             :             @param _nProposedRelPosX
     350             :             input parameter - proposed relative horizontal position, which
     351             :             will be adjusted.
     352             : 
     353             :             @param _nRelPosY
     354             :             input parameter - relative vertical position
     355             : 
     356             :             @param _eHoriOrient
     357             :             input parameter - horizontal position of object
     358             : 
     359             :             @param _eRelOrient
     360             :             inpt parameter - alignment of object
     361             : 
     362             :             @param _rLRSpacing
     363             :             input parameter - left and right spacing of the object to the text
     364             : 
     365             :             @param _rULSpacing
     366             :             input parameter - upper and lower spacing of the object to the text
     367             : 
     368             :             @param _bEvenPage
     369             :             input parameter - boolean indicating, if object is on an even page.
     370             : 
     371             :             @return adjusted relative horizontal position in SwTwips
     372             :         */
     373             :         SwTwips _AdjustHoriRelPosForDrawAside( const SwFrm&  _rHoriOrientFrm,
     374             :                                                const SwTwips _nProposedRelPosX,
     375             :                                                const SwTwips _nRelPosY,
     376             :                                                const sal_Int16 _eHoriOrient,
     377             :                                                const sal_Int16 _eRelOrient,
     378             :                                                const SvxLRSpaceItem& _rLRSpacing,
     379             :                                                const SvxULSpaceItem& _rULSpacing,
     380             :                                                const bool _bEvenPage
     381             :                                              ) const;
     382             : 
     383             :         /** detemine, if object has to draw aside given fly frame
     384             : 
     385             :             method used by <_AdjustHoriRelPosForDrawAside(..)>
     386             : 
     387             :             @param _pFly
     388             :             input parameter - fly frame the draw aside check is done for.
     389             : 
     390             :             @param _rObjRect
     391             :             input parameter - proposed object rectangle
     392             : 
     393             :             @param _pObjContext
     394             :             input parameter - context of the object
     395             : 
     396             :             @param _nObjIndex
     397             :             input parameter - index of the anchor frame of the object
     398             : 
     399             :             @param _bEvenPage
     400             :             input parameter - boolean indicating, if object is on an even page.
     401             : 
     402             :             @param _eHoriOrient
     403             :             input parameter - horizontal position of object
     404             : 
     405             :             @param _eRelOrient
     406             :             inpt parameter - alignment of object
     407             : 
     408             :             @return boolean indicating, if object has to be drawn aside
     409             :             given fly frame.
     410             :         */
     411             :         bool _DrawAsideFly( const SwFlyFrm* _pFly,
     412             :                             const SwRect&   _rObjRect,
     413             :                             const SwFrm*    _pObjContext,
     414             :                             const sal_uLong     _nObjIndex,
     415             :                             const bool      _bEvenPage,
     416             :                             const sal_Int16 _eHoriOrient,
     417             :                             const sal_Int16 _eRelOrient
     418             :                           ) const;
     419             : 
     420             :         /** determine, if object has to draw aside another object
     421             : 
     422             :             the different alignments of the objects determines, if one has
     423             :             to draw aside another one. Thus, the given alignment are checked
     424             :             against each other, which one has to be drawn aside the other one.
     425             :             depending on parameter _bLeft check is done for left or right
     426             :             positioning.
     427             :             method used by <_DrawAsideFly(..)>
     428             : 
     429             :             @param _eRelOrient1
     430             :             input parameter - alignment 1
     431             : 
     432             :             @param _eRelOrient2
     433             :             input parameter - alignment 2
     434             : 
     435             :             @param _bLeft
     436             :             input parameter - boolean indicating, if check is done for left
     437             :             or for right positioning.
     438             : 
     439             :             @return boolean indicating, if an object with an alignment
     440             :             <_eRelOrient1> has to be drawn aside an object with an
     441             :             alignment <_eRelOrient2>
     442             :         */
     443             :         bool _Minor( sal_Int16 _eRelOrient1,
     444             :                      sal_Int16 _eRelOrient2,
     445             :                      bool             _bLeft ) const;
     446             : 
     447             :     public:
     448             :         virtual void CalcPosition() = 0;
     449             :     };
     450             : }
     451             : 
     452             : #endif
     453             : 
     454             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10