bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / view / sdview5.cxx
blob0554de6177613844024ba7810b0e650548288670
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "sdpage.hxx"
21 #include "View.hxx"
22 #include "pres.hxx"
24 namespace sd {
26 static bool implIsMultiPresObj( PresObjKind eKind )
28 switch( eKind )
30 case PRESOBJ_OUTLINE:
31 case PRESOBJ_GRAPHIC:
32 case PRESOBJ_OBJECT:
33 case PRESOBJ_CHART:
34 case PRESOBJ_ORGCHART:
35 case PRESOBJ_TABLE:
36 case PRESOBJ_IMAGE:
37 case PRESOBJ_MEDIA:
38 return true;
39 default:
40 return false;
44 SdPage* View::GetPage()
46 SdPage* pPage = NULL;
47 SdrPageView* pPV = GetSdrPageView();
48 if( pPV )
50 pPage = static_cast< SdPage* >( pPV->GetPage() );
53 return pPage;
56 // returns selected object in case there's just one object in the selection
57 SdrObject* View::GetSelectedSingleObject(SdPage* pPage)
59 SdrObject* pRet = NULL;
60 if( pPage )
62 // first try selected shape
63 if ( AreObjectsMarked() )
65 const SdrMarkList& rMarkList = GetMarkedObjectList();
67 if (rMarkList.GetMarkCount() == 1)
69 SdrMark* pMark = rMarkList.GetMark(0);
70 pRet = pMark->GetMarkedSdrObj();
75 return pRet;
78 SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
80 SdPage* pPage = GetPage();
81 SdrObject* pEmptyObj = NULL;
83 if ( pPage && !pPage->IsMasterPage() ) {
84 SdrObject* pObj = GetSelectedSingleObject( pPage );
86 if( pObj && pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
87 pEmptyObj = pObj;
89 // try to find empty pres obj of same type
90 if( !pEmptyObj )
92 int nIndex = 1;
95 pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
97 while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
100 // last try to find empty pres obj of multiple type
101 if( !pEmptyObj )
103 const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
105 for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter )
107 if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
109 pEmptyObj = (*iter);
110 break;
116 return pEmptyObj;
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */