office-gobmx/sd/source/ui/view/sdview5.cxx

115 lines
3.6 KiB
C++
Raw Normal View History

2000-09-18 11:07:07 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 11:07:07 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 11:07:07 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 11:07:07 -05:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 11:07:07 -05:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#include "sdpage.hxx"
#include "View.hxx"
#include "pres.hxx"
namespace sd {
static bool implIsMultiPresObj( PresObjKind eKind )
{
switch( eKind )
{
case PRESOBJ_OUTLINE:
case PRESOBJ_GRAPHIC:
case PRESOBJ_OBJECT:
case PRESOBJ_CHART:
case PRESOBJ_ORGCHART:
case PRESOBJ_TABLE:
case PRESOBJ_IMAGE:
2010-02-22 17:23:09 -06:00
case PRESOBJ_MEDIA:
return true;
default:
return false;
}
}
SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
{
SdrObject* pEmptyObj = 0;
SdrPageView* pPV = GetSdrPageView();
if( pPV )
{
SdPage* pPage = static_cast< SdPage* >( pPV->GetPage() );
if( pPage )
{
// first try selected shape
if ( AreObjectsMarked() )
{
/**********************************************************
* Is an empty graphic object available?
**********************************************************/
const SdrMarkList& rMarkList = GetMarkedObjectList();
if (rMarkList.GetMarkCount() == 1)
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObj = pMark->GetMarkedSdrObj();
if( pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
pEmptyObj = pObj;
}
}
// try to find empty pres obj of same type
if( !pEmptyObj )
{
int nIndex = 1;
do
{
pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
}
while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
}
// last try to find empty pres obj of multiple type
if( !pEmptyObj )
{
const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); iter++ )
{
if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
{
pEmptyObj = (*iter);
break;
}
}
}
}
}
return pEmptyObj;
}
2010-02-08 06:05:08 -06:00
}