LCOV - code coverage report
Current view: top level - sw/source/core/inc - ascharanchoredobjectposition.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4 4 100.0 %
Date: 2014-11-03 Functions: 4 4 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_ASCHARANCHOREDOBJECTPOSITION_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_ASCHARANCHOREDOBJECTPOSITION_HXX
      22             : 
      23             : #include <anchoredobjectposition.hxx>
      24             : #include <sal/types.h>
      25             : #include <swtypes.hxx>
      26             : #include <swrect.hxx>
      27             : 
      28             : class SwTxtFrm;
      29             : class SwFmtVertOrient;
      30             : 
      31             : namespace objectpositioning
      32             : {
      33             :     // flags for positioning algorithm of as-character-anchored objects
      34             :     typedef sal_uInt8 AsCharFlags;
      35             :     #define AS_CHAR_NOFLAG  0
      36             :     #define AS_CHAR_QUICK   1
      37             :     #define AS_CHAR_ULSPACE 2
      38             :     #define AS_CHAR_INIT    4
      39             :     #define AS_CHAR_ROTATE  8
      40             :     #define AS_CHAR_REVERSE 16
      41             :     #define AS_CHAR_BIDI    32
      42             : 
      43             :     class SwAsCharAnchoredObjectPosition : public SwAnchoredObjectPosition
      44             :     {
      45             :     private:
      46             :         // data to calculate object position
      47             :         // Proposed anchor position, starting point for the calculation
      48             :         // of the object position.
      49             :         const Point& mrProposedAnchorPos;
      50             :         // flags that influences the calculation of the anchor position
      51             :         // AS_CHAR_QUICK   : quick formatting - calculated position not set at object
      52             :         // AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
      53             :         // AS_CHAR_INIT    : initial calculation
      54             :         // AS_CHAR_ROTATE  : object is rotated by 90 degrees
      55             :         // AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
      56             :         // AS_CHAR_BIDI    : object belongs to a BIDI-multi-portion
      57             :         const AsCharFlags mnFlags;
      58             :         // needed line values for the different alignments.
      59             :         const SwTwips mnLineAscent;
      60             :         const SwTwips mnLineDescent;
      61             :         const SwTwips mnLineAscentInclObjs;
      62             :         const SwTwips mnLineDescentInclObjs;
      63             : 
      64             :         // calculated data for object position
      65             :         Point       maAnchorPos;
      66             :         SwTwips     mnRelPos;
      67             :         SwRect      maObjBoundRect;
      68             :         // line alignment relative to line height; gives feedback for line formatting
      69             :         // 0 - no line alignment, 1 - at top, 2 - at center, 3 - at bottom
      70             :         sal_uInt8   mnLineAlignment;
      71             : 
      72             :         // method to cast <SwAnchoredObjectPosition::GetAnchorFrm()>
      73             :         const SwTxtFrm& GetAnchorTxtFrm() const;
      74             : 
      75             :         /** determine the relative position to base line for object position
      76             : 
      77             :             @param _ObjBoundHeight
      78             :             height including corresponding spacing of the object, for which
      79             :             the Y-position has to be calculated.
      80             : 
      81             :             @param _rVert
      82             :             given vertical positioning and alignment
      83             : 
      84             :             @return relative position to the base line
      85             :         */
      86             :         SwTwips _GetRelPosToBase( const SwTwips          _nObjBoundHeight,
      87             :                                   const SwFmtVertOrient& _rVert );
      88             : 
      89             :     public:
      90             :         /** construtor; provided object to be positioned and needed data
      91             :             for calculation of the object position
      92             : 
      93             :             @param _rDrawObj
      94             :             input parameter - object, that is be positioned.
      95             : 
      96             :             @param _rProposedAnchorPos
      97             :             proposed anchor position; starting point for the calculation
      98             :             of the anchor position
      99             : 
     100             :             @param _nFlags
     101             :             flags that influences the calculation of the anchor position
     102             :             AS_CHAR_QUICK   : quick formatting - calculated position not set at object
     103             :             AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
     104             :             AS_CHAR_INIT    : initial calculation
     105             :             AS_CHAR_ROTATE  : object is rotated by 90 degrees
     106             :             AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
     107             :             AS_CHAR_BIDI    : object belongs to a BIDI-multi-portion
     108             : 
     109             :             @param _nLineAscent, _nLineDescent, _nLineAscentInclObjs,
     110             :             _nLineDescentInclObjs - needed line values for the different
     111             :             alignments.
     112             :         */
     113             :         SwAsCharAnchoredObjectPosition( SdrObject&      _rDrawObj,
     114             :                                         const Point&    _rProposedAnchorPos,
     115             :                                         const AsCharFlags _nFlags,
     116             :                                         const SwTwips     _nLineAscent,
     117             :                                         const SwTwips     _nLineDescent,
     118             :                                         const SwTwips     _nLineAscentInclObjs,
     119             :                                         const SwTwips     _nLineDescentInclObjs );
     120             :         virtual ~SwAsCharAnchoredObjectPosition();
     121             : 
     122             :         /** calculate position for object position
     123             : 
     124             :             members <maAnchorPos>, <mnRelPos>, <maObjBoundRect> and
     125             :             <mnLineAlignment> are calculated.
     126             :             calculated position is set at the given object.
     127             :         */
     128             :         virtual void CalcPosition() SAL_OVERRIDE;
     129             : 
     130             :         // calculated anchored position for object position type AS_CHAR
     131       13361 :         const Point& GetAnchorPos() const { return maAnchorPos;}
     132             : 
     133             :         // calculated relative position to base line for object position type AS_CHAR
     134       13361 :         SwTwips GetRelPosY() const { return mnRelPos;}
     135             : 
     136             :         // determined object rectangle including spacing for object position type AS_CHAR
     137       13361 :         const SwRect& GetObjBoundRectInclSpacing() const { return maObjBoundRect;}
     138             : 
     139             :         // determined line alignment relative to line height
     140       13361 :         sal_uInt8 GetLineAlignment() const { return mnLineAlignment;}
     141             :     };
     142             : }
     143             : 
     144             : #endif
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10