LCOV - code coverage report
Current view: top level - sw/inc - anchoreddrawobject.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 6 50.0 %
Date: 2012-08-25 Functions: 2 4 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 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                 :            : #ifndef _ANCHOREDDRAWOBJECT_HXX
      29                 :            : #define _ANCHOREDDRAWOBJECT_HXX
      30                 :            : 
      31                 :            : #include <anchoredobject.hxx>
      32                 :            : #include <tools/gen.hxx>
      33                 :            : 
      34                 :            : /** class for the positioning of drawing objects
      35                 :            : 
      36                 :            :     @author OD
      37                 :            : */
      38                 :            : class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject
      39                 :            : {
      40                 :            :     private:
      41                 :            :         // boolean, indicating that the object position has been invalidated
      42                 :            :         // and that a positioning has to be performed.
      43                 :            :         bool mbValidPos;
      44                 :            : 
      45                 :            :         // rectangle, keeping the last object rectangle after the postioning
      46                 :            :         Rectangle* mpLastObjRect;
      47                 :            : 
      48                 :            :         // boolean, indicating that anchored drawing object hasn't been attached
      49                 :            :         // to a anchor frame yet. Once, it is attached to a anchor frame the
      50                 :            :         // boolean changes its state.
      51                 :            :         bool mbNotYetAttachedToAnchorFrame;
      52                 :            : 
      53                 :            :         // boolean, indicating that anchored
      54                 :            :         // drawing object hasn't been positioned yet. Once, it's positioned the
      55                 :            :         // boolean changes its state.
      56                 :            :         bool mbNotYetPositioned;
      57                 :            : 
      58                 :            :         // boolean, indicating that after change of layout direction the
      59                 :            :         // anchored drawing object has to be captured on the page, if it exceeds
      60                 :            :         // the left or right page margin.
      61                 :            :         // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
      62                 :            :         bool mbCaptureAfterLayoutDirChange;
      63                 :            : 
      64                 :            :         /** method for the intrinsic positioning of a at-paragraph|at-character
      65                 :            :             anchored drawing object
      66                 :            : 
      67                 :            :             helper method for method <MakeObjPos>
      68                 :            : 
      69                 :            :             @author OD
      70                 :            :         */
      71                 :            :         void _MakeObjPosAnchoredAtPara();
      72                 :            : 
      73                 :            :         /** method for the intrinsic positioning of a at-page|at-frame anchored
      74                 :            :             drawing object
      75                 :            : 
      76                 :            :             helper method for method <MakeObjPos>
      77                 :            : 
      78                 :            :             @author OD
      79                 :            :         */
      80                 :            :         void _MakeObjPosAnchoredAtLayout();
      81                 :            : 
      82                 :            :             /** method to set positioning attributes (not for as-character anchored)
      83                 :            : 
      84                 :            :             During load the positioning attributes aren't set.
      85                 :            :             Thus, the positioning attributes are set by the current object geometry.
      86                 :            :             This method is also used for the conversion for drawing objects
      87                 :            :             (not anchored as-character) imported from OpenOffice.org file format
      88                 :            :             once and directly before the first positioning.
      89                 :            : 
      90                 :            :             @author OD
      91                 :            :         */
      92                 :            :         void _SetPositioningAttr();
      93                 :            : 
      94                 :            :         /** method to set internal anchor position of <SdrObject> instance
      95                 :            :             of the drawing object
      96                 :            : 
      97                 :            :             For drawing objects the internal anchor position of the <SdrObject>
      98                 :            :             instance has to be set.
      99                 :            :             Note: This adjustment is not be done for as-character anchored
     100                 :            :             drawing object - the positioning code takes care of this.
     101                 :            :             #i31698# - API for drawing objects in Writer has
     102                 :            :             been adjusted. Thus, this method will only set the internal anchor
     103                 :            :             position of the <SdrObject> instance to the anchor position given
     104                 :            :             by its anchor frame.
     105                 :            : 
     106                 :            :             @author OD
     107                 :            :         */
     108                 :            :         void _SetDrawObjAnchor();
     109                 :            : 
     110                 :            :         /** method to invalidate the given page frame
     111                 :            : 
     112                 :            :             @author OD
     113                 :            :         */
     114                 :            :         void _InvalidatePage( SwPageFrm* _pPageFrm );
     115                 :            : 
     116                 :            :     protected:
     117                 :            :         virtual void ObjectAttachedToAnchorFrame();
     118                 :            : 
     119                 :            :         /** method to assure that anchored object is registered at the correct
     120                 :            :             page frame
     121                 :            : 
     122                 :            :             @author OD
     123                 :            :         */
     124                 :            :         virtual void RegisterAtCorrectPage();
     125                 :            : 
     126                 :            :         virtual bool _SetObjTop( const SwTwips _nTop);
     127                 :            :         virtual bool _SetObjLeft( const SwTwips _nLeft);
     128                 :            : 
     129                 :            :         virtual const SwRect GetObjBoundRect() const;
     130                 :            : 
     131                 :            :     public:
     132                 :            :         TYPEINFO();
     133                 :            : 
     134                 :            :         SwAnchoredDrawObject();
     135                 :            :         virtual ~SwAnchoredDrawObject();
     136                 :            : 
     137                 :            :         // declaration of pure virtual methods of base class <SwAnchoredObject>
     138                 :            :         virtual void MakeObjPos();
     139                 :            :         virtual void InvalidateObjPos();
     140                 :          0 :         inline bool IsValidPos() const
     141                 :            :         {
     142                 :          0 :             return mbValidPos;
     143                 :            :         }
     144                 :            : 
     145                 :            :         // accessors to the format
     146                 :            :         virtual SwFrmFmt& GetFrmFmt();
     147                 :            :         virtual const SwFrmFmt& GetFrmFmt() const;
     148                 :            : 
     149                 :            :         // accessors to the object area and its position
     150                 :            :         virtual const SwRect GetObjRect() const;
     151                 :            :         // Return value can be NULL.
     152                 :            :         const Rectangle* GetLastObjRect() const;
     153                 :            : 
     154                 :            :         void SetLastObjRect( const Rectangle& _rNewObjRect );
     155                 :            : 
     156                 :            :         /** adjust positioning and alignment attributes for new anchor frame
     157                 :            : 
     158                 :            :             Set horizontal and vertical position/alignment to manual position
     159                 :            :             relative to anchor frame area using the anchor position of the
     160                 :            :             new anchor frame and the current absolute drawing object position.
     161                 :            :             Note: For correct Undo/Redo method should only be called inside a
     162                 :            :             Undo-/Redo-action.
     163                 :            : 
     164                 :            :             @author OD
     165                 :            : 
     166                 :            :             @param <_pNewAnchorFrm>
     167                 :            :             input parameter - new anchor frame for the anchored object.
     168                 :            : 
     169                 :            :             @param <_pNewObjRect>
     170                 :            :             optional input parameter - proposed new object rectangle. If not
     171                 :            :             provided the current object rectangle is taken.
     172                 :            :         */
     173                 :            :         void AdjustPositioningAttr( const SwFrm* _pNewAnchorFrm,
     174                 :            :                                     const SwRect* _pNewObjRect = 0L );
     175                 :            : 
     176                 :            :         /** method to notify background of drawing object
     177                 :            : 
     178                 :            :             @author OD
     179                 :            :         */
     180                 :            :         virtual void NotifyBackground( SwPageFrm* _pPageFrm,
     181                 :            :                                        const SwRect& _rRect,
     182                 :            :                                        PrepareHint _eHint );
     183                 :            : 
     184                 :        991 :         inline bool NotYetPositioned() const
     185                 :            :         {
     186                 :        991 :             return mbNotYetPositioned;
     187                 :            :         }
     188                 :            : 
     189                 :            :         // change of layout direction needs to be tracked
     190                 :            :         // for setting <mbCaptureAfterLayoutDirChange>.
     191                 :            :         virtual void UpdateLayoutDir();
     192                 :            :         bool IsOutsidePage() const;
     193                 :            : 
     194                 :            :         // new Loop control
     195                 :          0 :         void ValidateThis() { mbValidPos = true; }
     196                 :            : 
     197                 :            :         /** The element name to show in the XML dump.
     198                 :            :           */
     199                 :          3 :         virtual const char* getElementName( ) { return "SwAnchoredDrawObject"; }
     200                 :            : };
     201                 :            : 
     202                 :            : #endif
     203                 :            : 
     204                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10