LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - sdview5.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 39 2.6 %
Date: 2013-07-09 Functions: 2 6 33.3 %
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 "sdpage.hxx"
      22             : #include "View.hxx"
      23             : #include "pres.hxx"
      24             : 
      25             : namespace sd {
      26             : 
      27           0 : static bool implIsMultiPresObj( PresObjKind eKind )
      28             : {
      29           0 :     switch( eKind )
      30             :     {
      31             :     case PRESOBJ_OUTLINE:
      32             :     case PRESOBJ_GRAPHIC:
      33             :     case PRESOBJ_OBJECT:
      34             :     case PRESOBJ_CHART:
      35             :     case PRESOBJ_ORGCHART:
      36             :     case PRESOBJ_TABLE:
      37             :     case PRESOBJ_IMAGE:
      38             :     case PRESOBJ_MEDIA:
      39           0 :         return true;
      40             :     default:
      41           0 :         return false;
      42             :     }
      43             : }
      44             : 
      45           0 : SdPage* View::GetPage()
      46             : {
      47           0 :     SdPage* pPage = NULL;
      48           0 :     SdrPageView*    pPV = GetSdrPageView();
      49           0 :     if( pPV )
      50             :     {
      51           0 :         pPage = static_cast< SdPage* >( pPV->GetPage() );
      52             :     }
      53             : 
      54           0 :     return pPage;
      55             : }
      56             : 
      57             : // returns selected object in case there's just one object in the selection
      58           0 : SdrObject* View::GetSelectedSingleObject(SdPage* pPage)
      59             : {
      60           0 :     SdrObject* pRet = NULL;
      61           0 :     if( pPage )
      62             :     {
      63             :         // first try selected shape
      64           0 :         if ( AreObjectsMarked() )
      65             :         {
      66           0 :             const SdrMarkList& rMarkList = GetMarkedObjectList();
      67             : 
      68           0 :             if (rMarkList.GetMarkCount() == 1)
      69             :             {
      70           0 :                 SdrMark* pMark = rMarkList.GetMark(0);
      71           0 :                 pRet = pMark->GetMarkedSdrObj();
      72             :             }
      73             :         }
      74             :     }
      75             : 
      76           0 :     return pRet;
      77             : }
      78             : 
      79           0 : SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
      80             : {
      81           0 :     SdPage* pPage = GetPage();
      82           0 :     SdrObject* pEmptyObj = NULL;
      83             : 
      84           0 :     if ( pPage && !pPage->IsMasterPage() ) {
      85           0 :         SdrObject* pObj = GetSelectedSingleObject( pPage );
      86             : 
      87           0 :         if( pObj && pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
      88           0 :             pEmptyObj = pObj;
      89             : 
      90             :         // try to find empty pres obj of same type
      91           0 :         if( !pEmptyObj )
      92             :         {
      93           0 :             int nIndex = 1;
      94           0 :             do
      95             :             {
      96           0 :                 pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
      97             :             }
      98           0 :             while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
      99             :         }
     100             : 
     101             :         // last try to find empty pres obj of multiple type
     102           0 :         if( !pEmptyObj )
     103             :         {
     104           0 :             const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
     105             : 
     106           0 :             for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter )
     107             :             {
     108           0 :                 if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
     109             :                 {
     110           0 :                     pEmptyObj = (*iter);
     111           0 :                     break;
     112             :                 }
     113             :             }
     114             :         }
     115             :     }
     116             : 
     117           0 :     return pEmptyObj;
     118             : }
     119             : 
     120          33 : }
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10