fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / sdview5.cxx
blob9023d028ad495018dd468fb84779220be119d5ad
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 .
21 #include "sdpage.hxx"
22 #include "View.hxx"
23 #include "pres.hxx"
25 namespace sd {
27 static bool implIsMultiPresObj( PresObjKind eKind )
29 switch( eKind )
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 return true;
40 default:
41 return false;
45 SdPage* View::GetPage()
47 SdPage* pPage = NULL;
48 SdrPageView* pPV = GetSdrPageView();
49 if( pPV )
51 pPage = static_cast< SdPage* >( pPV->GetPage() );
54 return pPage;
57 // returns selected object in case there's just one object in the selection
58 SdrObject* View::GetSelectedSingleObject(SdPage* pPage)
60 SdrObject* pRet = NULL;
61 if( pPage )
63 // first try selected shape
64 if ( AreObjectsMarked() )
66 const SdrMarkList& rMarkList = GetMarkedObjectList();
68 if (rMarkList.GetMarkCount() == 1)
70 SdrMark* pMark = rMarkList.GetMark(0);
71 pRet = pMark->GetMarkedSdrObj();
76 return pRet;
79 SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
81 SdPage* pPage = GetPage();
82 SdrObject* pEmptyObj = NULL;
84 if ( pPage && !pPage->IsMasterPage() ) {
85 SdrObject* pObj = GetSelectedSingleObject( pPage );
87 if( pObj && pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
88 pEmptyObj = pObj;
90 // try to find empty pres obj of same type
91 if( !pEmptyObj )
93 int nIndex = 1;
96 pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
98 while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
101 // last try to find empty pres obj of multiple type
102 if( !pEmptyObj )
104 const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
106 for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter )
108 if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
110 pEmptyObj = (*iter);
111 break;
117 return pEmptyObj;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */