Kaydet (Commit) 8e328234 authored tarafından Radek Doulik's avatar Radek Doulik

refactored GetEmptyPresentationObject, added GetSelectedSingleObject

 - also extracted part of GetEmptyPresentationObject into new GetPage() method

Change-Id: I3002c3fae8236db1e443f0f454158e7298b56d70
üst 44ee3ce7
......@@ -33,6 +33,7 @@
#include "smarttag.hxx"
class SdDrawDocument;
class SdPage;
class SdrOle2Obj;
class SdrGrafObj;
class SdrMediaObj;
......@@ -208,6 +209,9 @@ public:
void SetMarkedSegmentsKindPossible( bool bSet ) { bSetMarkedSegmentsKindPossible = bSet; }
SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
SdPage* GetPage();
SdrObject* GetSelectedSingleObject(SdPage* pPage);
protected:
DECL_LINK( OnParagraphInsertedHdl, ::Outliner * );
DECL_LINK( OnParagraphRemovingHdl, ::Outliner * );
......
......@@ -42,57 +42,73 @@ static bool implIsMultiPresObj( PresObjKind eKind )
}
}
SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
SdPage* View::GetPage()
{
SdrObject* pEmptyObj = 0;
SdPage* pPage = NULL;
SdrPageView* pPV = GetSdrPageView();
if( pPV )
{
SdPage* pPage = static_cast< SdPage* >( pPV->GetPage() );
if( pPage && !pPage->IsMasterPage() )
pPage = static_cast< SdPage* >( pPV->GetPage() );
}
return pPage;
}
// returns selected object in case there's just one object in the selection
SdrObject* View::GetSelectedSingleObject(SdPage* pPage)
{
SdrObject* pRet = NULL;
if( pPage )
{
// first try selected shape
if ( AreObjectsMarked() )
{
// first try selected shape
if ( AreObjectsMarked() )
const SdrMarkList& rMarkList = GetMarkedObjectList();
if (rMarkList.GetMarkCount() == 1)
{
/**********************************************************
* Is an empty graphic object available?
**********************************************************/
const SdrMarkList& rMarkList = GetMarkedObjectList();
SdrMark* pMark = rMarkList.GetMark(0);
pRet = pMark->GetMarkedSdrObj();
}
}
}
if (rMarkList.GetMarkCount() == 1)
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObj = pMark->GetMarkedSdrObj();
return pRet;
}
if( pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
pEmptyObj = pObj;
}
}
SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
{
SdPage* pPage = GetPage();
SdrObject* pEmptyObj = NULL;
// try to find empty pres obj of same type
if( !pEmptyObj )
if ( pPage && !pPage->IsMasterPage() ) {
SdrObject* pObj = GetSelectedSingleObject( pPage );
if( pObj && pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
pEmptyObj = pObj;
// try to find empty pres obj of same type
if( !pEmptyObj )
{
int nIndex = 1;
do
{
int nIndex = 1;
do
{
pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
}
while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
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();
// 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 )
for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter )
{
if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
{
if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
{
pEmptyObj = (*iter);
break;
}
pEmptyObj = (*iter);
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment