LCOV - code coverage report
Current view: top level - sw/source/core/layout - flypos.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 28 30 93.3 %
Date: 2014-04-11 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             : #include "doc.hxx"
      21             : #include <docary.hxx>
      22             : #include "dcontact.hxx"
      23             : #include "flyfrm.hxx"
      24             : #include "dflyobj.hxx"
      25             : #include "switerator.hxx"
      26             : 
      27        1153 : bool SwPosFlyFrmCmp::operator()(const SwPosFlyFrmPtr& rA, const SwPosFlyFrmPtr& rB) const
      28             : {
      29        1153 :     if(rA->GetNdIndex() == rB->GetNdIndex())
      30             :     {
      31             :         // In this case, the order number decides!
      32         969 :         return rA->GetOrdNum() < rB->GetOrdNum();
      33             :     }
      34             : 
      35         184 :     return rA->GetNdIndex() < rB->GetNdIndex();
      36             : }
      37             : 
      38         265 : SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
      39             :                             sal_uInt16 nArrPos )
      40         265 :     : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
      41             : {
      42         265 :     bool bFnd = false;
      43         265 :     const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
      44         265 :     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
      45             :     {
      46           0 :         pNdIdx = new SwNodeIndex( rIdx );
      47             :     }
      48         265 :     else if( pFmt->GetDoc()->GetCurrentViewShell() )
      49             :     {
      50         258 :         if( RES_FLYFRMFMT == pFmt->Which() )
      51             :         {
      52             :             // Let's see if we have an SdrObject for this
      53         130 :             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
      54         130 :             if( pFly )
      55             :             {
      56         128 :                 nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
      57         128 :                 bFnd = true;
      58             :             }
      59             :         }
      60         128 :         else if( RES_DRAWFRMFMT == pFmt->Which() )
      61             :         {
      62             :             // Let's see if we have an SdrObject for this
      63         128 :             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
      64         128 :             if( pContact )
      65             :             {
      66         128 :                 nOrdNum = pContact->GetMaster()->GetOrdNum();
      67         128 :                 bFnd = true;
      68             :             }
      69             :         }
      70             :     }
      71             : 
      72         265 :     if( !bFnd )
      73             :     {
      74           9 :         nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->size();
      75           9 :         nOrdNum += nArrPos;
      76             :     }
      77         265 : }
      78             : 
      79         530 : SwPosFlyFrm::~SwPosFlyFrm()
      80             : {
      81         265 :     const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
      82         265 :     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
      83             :     {
      84           0 :         delete pNdIdx;
      85             :     }
      86         530 : }
      87             : 
      88             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10