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

Generated by: LCOV version 1.11