summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorRadek Doulik <rodo@novell.com>2012-12-04 15:54:24 +0100
committerRadek Doulik <rodo@novell.com>2012-12-04 16:00:44 +0100
commit8e3282344a19932e6dd3f919d2ff1be67adce9ed (patch)
tree974534ab8ad31ef7429fabb571898d90d1a4e832 /sd
parent44ee3ce747058eaf7ca241fe482f4aab54c9bc92 (diff)
refactored GetEmptyPresentationObject, added GetSelectedSingleObject
- also extracted part of GetEmptyPresentationObject into new GetPage() method Change-Id: I3002c3fae8236db1e443f0f454158e7298b56d70
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/inc/View.hxx4
-rw-r--r--sd/source/ui/view/sdview5.cxx90
2 files changed, 57 insertions, 37 deletions
diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index 92878afa8ce6..47556132cc44 100644
--- a/sd/source/ui/inc/View.hxx
+++ b/sd/source/ui/inc/View.hxx
@@ -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 * );
diff --git a/sd/source/ui/view/sdview5.cxx b/sd/source/ui/view/sdview5.cxx
index 735aaa202c67..9023d028ad49 100644
--- a/sd/source/ui/view/sdview5.cxx
+++ b/sd/source/ui/view/sdview5.cxx
@@ -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;
}
}
}