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

Generated by: LCOV version 1.10