LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/layout - flypos.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 30 86.7 %
Date: 2013-07-09 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             : 
      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          39 : bool SwPosFlyFrmCmp::operator()(const SwPosFlyFrmPtr& rA, const SwPosFlyFrmPtr& rB) const
      35             : {
      36          39 :     if(rA->GetNdIndex() == rB->GetNdIndex())
      37             :     {
      38             :         // In this case, the order number decides!
      39           6 :         return rA->GetOrdNum() < rB->GetOrdNum();
      40             :     }
      41             : 
      42          33 :     return rA->GetNdIndex() < rB->GetNdIndex();
      43             : }
      44             : 
      45          26 : SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
      46             :                             sal_uInt16 nArrPos )
      47          26 :     : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
      48             : {
      49          26 :     bool bFnd = false;
      50          26 :     const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
      51          26 :     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
      52             :     {
      53           0 :         pNdIdx = new SwNodeIndex( rIdx );
      54             :     }
      55          26 :     else if( pFmt->GetDoc()->GetCurrentViewShell() )    //swmod 071108//swmod 071225
      56             :     {
      57          26 :         if( RES_FLYFRMFMT == pFmt->Which() )
      58             :         {
      59             :             // Let's see if we have an SdrObject for this
      60          17 :             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
      61          17 :             if( pFly )
      62             :             {
      63          17 :                 nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
      64          17 :                 bFnd = true;
      65             :             }
      66             :         }
      67           9 :         else if( RES_DRAWFRMFMT == pFmt->Which() )
      68             :         {
      69             :             // Let's see if we have an SdrObject for this
      70           9 :             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
      71           9 :             if( pContact )
      72             :             {
      73           9 :                 nOrdNum = pContact->GetMaster()->GetOrdNum();
      74           9 :                 bFnd = true;
      75             :             }
      76             :         }
      77             :     }
      78             : 
      79          26 :     if( !bFnd )
      80             :     {
      81           0 :         nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->size();
      82           0 :         nOrdNum += nArrPos;
      83             :     }
      84          26 : }
      85             : 
      86          52 : SwPosFlyFrm::~SwPosFlyFrm()
      87             : {
      88          26 :     const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
      89          26 :     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
      90             :     {
      91           0 :         delete pNdIdx;
      92             :     }
      93         151 : }
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10