LCOV - code coverage report
Current view: top level - sw/source/core/inc - anchoredobjectposition.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 21 100.0 %
Date: 2012-08-25 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

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

Generated by: LCOV version 1.10