1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
24 #include <svx/svdpagv.hxx>
28 static bool implIsMultiPresObj( PresObjKind eKind
)
32 case PresObjKind::Outline
:
33 case PresObjKind::Graphic
:
34 case PresObjKind::Object
:
35 case PresObjKind::Chart
:
36 case PresObjKind::OrgChart
:
37 case PresObjKind::Table
:
38 case PresObjKind::Media
:
45 SdPage
* View::GetPage()
47 SdPage
* pPage
= nullptr;
48 SdrPageView
* pPV
= GetSdrPageView();
51 pPage
= static_cast< SdPage
* >( pPV
->GetPage() );
57 // returns selected object in case there's just one object in the selection
58 SdrObject
* View::GetSelectedSingleObject(SdPage
const * pPage
)
60 SdrObject
* pRet
= nullptr;
63 const SdrMarkList
& rMarkList
= GetMarkedObjectList();
65 // first try selected shape
66 if ( rMarkList
.GetMarkCount() != 0 )
68 if (rMarkList
.GetMarkCount() == 1)
70 SdrMark
* pMark
= rMarkList
.GetMark(0);
71 pRet
= pMark
->GetMarkedSdrObj();
79 SdrObject
* View::GetEmptyPresentationObject( PresObjKind eKind
)
81 SdPage
* pPage
= GetPage();
82 SdrObject
* pEmptyObj
= nullptr;
84 if ( pPage
&& !pPage
->IsMasterPage() ) {
85 SdrObject
* pObj
= GetSelectedSingleObject( pPage
);
87 if( pObj
&& pObj
->IsEmptyPresObj() && implIsMultiPresObj( pPage
->GetPresObjKind(pObj
) ) )
90 // try to find empty pres obj of same type
96 pEmptyObj
= pPage
->GetPresObj(eKind
, nIndex
++ );
98 while( (pEmptyObj
!= nullptr) && (!pEmptyObj
->IsEmptyPresObj()) );
101 // last try to find empty pres obj of multiple type
104 const std::list
< SdrObject
* >& rShapes
= pPage
->GetPresentationShapeList().getList();
106 auto iter
= std::find_if(rShapes
.begin(), rShapes
.end(),
107 [&pPage
](SdrObject
* pShape
) { return pShape
->IsEmptyPresObj() && implIsMultiPresObj(pPage
->GetPresObjKind(pShape
)); });
108 if (iter
!= rShapes
.end())
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */