LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/layout - flypos.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 32 68.8 %
Date: 2012-12-17 Functions: 3 5 60.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             : 
      21             : #include "doc.hxx"
      22             : #include "node.hxx"
      23             : #include <docary.hxx>
      24             : #include <fmtanchr.hxx>
      25             : #include "flypos.hxx"
      26             : #include "frmfmt.hxx"
      27             : #include "dcontact.hxx"
      28             : #include "dview.hxx"
      29             : #include "flyfrm.hxx"
      30             : #include "dflyobj.hxx"
      31             : #include "ndindex.hxx"
      32             : #include "switerator.hxx"
      33             : 
      34          12 : SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
      35             :                             sal_uInt16 nArrPos )
      36          12 :     : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
      37             : {
      38          12 :     bool bFnd = false;
      39          12 :     const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
      40          12 :     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
      41             :     {
      42           0 :         pNdIdx = new SwNodeIndex( rIdx );
      43             :     }
      44          12 :     else if( pFmt->GetDoc()->GetCurrentViewShell() )    //swmod 071108//swmod 071225
      45             :     {
      46          12 :         if( RES_FLYFRMFMT == pFmt->Which() )
      47             :         {
      48             :             // Let's see if we have an SdrObject for this
      49           8 :             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
      50           8 :             if( pFly )
      51             :             {
      52           8 :                 nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
      53           8 :                 bFnd = true;
      54             :             }
      55             :         }
      56           4 :         else if( RES_DRAWFRMFMT == pFmt->Which() )
      57             :         {
      58             :             // Let's see if we have an SdrObject for this
      59           4 :             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
      60           4 :             if( pContact )
      61             :             {
      62           4 :                 nOrdNum = pContact->GetMaster()->GetOrdNum();
      63           4 :                 bFnd = true;
      64             :             }
      65             :         }
      66             :     }
      67             : 
      68          12 :     if( !bFnd )
      69             :     {
      70           0 :         nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->size();
      71           0 :         nOrdNum += nArrPos;
      72             :     }
      73          12 : }
      74             : 
      75          24 : SwPosFlyFrm::~SwPosFlyFrm()
      76             : {
      77          12 :     const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
      78          12 :     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
      79             :     {
      80           0 :         delete pNdIdx;
      81             :     }
      82          24 : }
      83             : 
      84           0 : sal_Bool SwPosFlyFrm::operator==( const SwPosFlyFrm& )
      85             : {
      86           0 :     return sal_False;   // FlyFrames can sit at the same position
      87             : }
      88             : 
      89           0 : sal_Bool SwPosFlyFrm::operator<( const SwPosFlyFrm& rPosFly )
      90             : {
      91           0 :     if( pNdIdx->GetIndex() == rPosFly.pNdIdx->GetIndex() )
      92             :     {
      93             :         // In this case, the order number decides!
      94           0 :         return nOrdNum < rPosFly.nOrdNum;
      95             :     }
      96           0 :     return pNdIdx->GetIndex() < rPosFly.pNdIdx->GetIndex();
      97             : }
      98             : 
      99             : 
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10