LCOV - code coverage report
Current view: top level - chart2/source/controller/main - SelectionHelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 309 1.6 %
Date: 2015-06-13 12:38:46 Functions: 4 33 12.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "SelectionHelper.hxx"
      21             : #include "ObjectIdentifier.hxx"
      22             : #include "macros.hxx"
      23             : #include "DiagramHelper.hxx"
      24             : #include "ChartModelHelper.hxx"
      25             : 
      26             : #include <svx/svdpage.hxx>
      27             : #include <svx/svditer.hxx>
      28             : #include "svx/obj3d.hxx"
      29             : #include <svx/svdopath.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <osl/mutex.hxx>
      32             : #include <basegfx/point/b2dpoint.hxx>
      33             : #include <com/sun/star/beans/XPropertySet.hpp>
      34             : 
      35             : namespace chart
      36             : {
      37             : using namespace ::com::sun::star;
      38             : 
      39             : namespace
      40             : {
      41             : 
      42           0 : OUString lcl_getObjectName( SdrObject* pObj )
      43             : {
      44           0 :     if(pObj)
      45           0 :        return pObj->GetName();
      46           0 :     return OUString();
      47             : }
      48             : 
      49           0 : void impl_selectObject( SdrObject* pObjectToSelect, DrawViewWrapper& rDrawViewWrapper )
      50             : {
      51           0 :     SolarMutexGuard aSolarGuard;
      52             : 
      53           0 :     if(pObjectToSelect)
      54             :     {
      55           0 :         SelectionHelper aSelectionHelper( pObjectToSelect );
      56           0 :         SdrObject* pMarkObj = aSelectionHelper.getObjectToMark();
      57           0 :         rDrawViewWrapper.setMarkHandleProvider(&aSelectionHelper);
      58           0 :         rDrawViewWrapper.MarkObject(pMarkObj);
      59           0 :         rDrawViewWrapper.setMarkHandleProvider(NULL);
      60           0 :     }
      61           0 : }
      62             : 
      63             : }//anonymous namespace
      64             : 
      65        3166 : bool Selection::hasSelection()
      66             : {
      67        3166 :     return m_aSelectedOID.isValid();
      68             : }
      69             : 
      70           0 : OUString Selection::getSelectedCID()
      71             : {
      72           0 :     return m_aSelectedOID.getObjectCID();
      73             : }
      74             : 
      75           0 : uno::Reference< drawing::XShape > Selection::getSelectedAdditionalShape()
      76             : {
      77           0 :     return m_aSelectedOID.getAdditionalShape();
      78             : }
      79             : 
      80           0 : bool Selection::setSelection( const OUString& rCID )
      81             : {
      82           0 :     if ( !rCID.equals( m_aSelectedOID.getObjectCID() ) )
      83             :     {
      84           0 :         m_aSelectedOID = ObjectIdentifier( rCID );
      85           0 :         return true;
      86             :     }
      87           0 :     return false;
      88             : }
      89             : 
      90           0 : bool Selection::setSelection( const uno::Reference< drawing::XShape >& xShape )
      91             : {
      92           0 :     if ( !( xShape == m_aSelectedOID.getAdditionalShape() ) )
      93             :     {
      94           0 :         clearSelection();
      95           0 :         m_aSelectedOID = ObjectIdentifier( xShape );
      96           0 :         return true;
      97             :     }
      98           0 :     return false;
      99             : }
     100             : 
     101           0 : void Selection::clearSelection()
     102             : {
     103           0 :     m_aSelectedOID = ObjectIdentifier();
     104           0 :     m_aSelectedOID_beforeMouseDown = ObjectIdentifier();
     105           0 :     m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
     106           0 : }
     107             : 
     108           0 : bool Selection::maybeSwitchSelectionAfterSingleClickWasEnsured()
     109             : {
     110           0 :     if ( m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid()
     111           0 :          && m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing != m_aSelectedOID )
     112             :     {
     113           0 :         m_aSelectedOID = m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing;
     114           0 :         m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
     115           0 :         return true;
     116             :     }
     117           0 :     return false;
     118             : }
     119             : 
     120           0 : void Selection::resetPossibleSelectionAfterSingleClickWasEnsured()
     121             : {
     122           0 :     if ( m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid() )
     123             :     {
     124           0 :         m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
     125             :     }
     126           0 : }
     127             : 
     128           0 : void Selection::remindSelectionBeforeMouseDown()
     129             : {
     130           0 :     m_aSelectedOID_beforeMouseDown = m_aSelectedOID;
     131           0 : }
     132             : 
     133           0 : bool Selection::isSelectionDifferentFromBeforeMouseDown() const
     134             : {
     135           0 :     return ( m_aSelectedOID != m_aSelectedOID_beforeMouseDown );
     136             : }
     137             : 
     138           0 : void Selection::applySelection( DrawViewWrapper* pDrawViewWrapper )
     139             : {
     140           0 :     if( pDrawViewWrapper )
     141             :     {
     142             :         {
     143           0 :             SolarMutexGuard aSolarGuard;
     144           0 :             pDrawViewWrapper->UnmarkAll();
     145             :         }
     146           0 :         SdrObject* pObjectToSelect = 0;
     147           0 :         if ( m_aSelectedOID.isAutoGeneratedObject() )
     148             :         {
     149           0 :             pObjectToSelect = pDrawViewWrapper->getNamedSdrObject( m_aSelectedOID.getObjectCID() );
     150             :         }
     151           0 :         else if( m_aSelectedOID.isAdditionalShape() )
     152             :         {
     153           0 :             pObjectToSelect = DrawViewWrapper::getSdrObject( m_aSelectedOID.getAdditionalShape() );
     154             :         }
     155             : 
     156           0 :         impl_selectObject( pObjectToSelect, *pDrawViewWrapper );
     157             :     }
     158           0 : }
     159             : 
     160           0 : void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper* pDrawViewWrapper
     161             :                                        , bool bIsRightMouse, bool bWaitingForDoubleClick )
     162             : {
     163           0 :     if( pDrawViewWrapper )
     164             :     {
     165             :         //do not toggel multiclick selection if right clicked on the selected object or waiting for double click
     166           0 :         bool bAllowMultiClickSelectionChange = !bIsRightMouse && !bWaitingForDoubleClick;
     167             : 
     168           0 :         ObjectIdentifier aLastSelectedObject( m_aSelectedOID );
     169             : 
     170           0 :         SolarMutexGuard aSolarGuard;
     171             : 
     172             :         //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point)
     173             : 
     174             :         //get object to select:
     175             :         {
     176           0 :             m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
     177             : 
     178             :             //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree)
     179             :             //further we travel along the grouping hierarchy from child to parent
     180           0 :             SdrObject* pNewObj = pDrawViewWrapper->getHitObject(rMousePos);
     181           0 :             m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );//name of pNewObj
     182             : 
     183             :             //ignore handle only objects for hit test
     184           0 :             while( pNewObj && m_aSelectedOID.getObjectCID().match( "HandlesOnly" ) )
     185             :             {
     186           0 :                 pNewObj->SetMarkProtect(true);
     187           0 :                 pNewObj = pDrawViewWrapper->getHitObject(rMousePos);
     188           0 :                 m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );
     189             :             }
     190             : 
     191             :             //accept only named objects while searching for the object to select
     192             :             //this call may change m_aSelectedOID
     193           0 :             if ( SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, true ) )
     194             :             {
     195             :                 //if the so far found object is a multi click object further steps are necessary
     196           0 :                 while( ObjectIdentifier::isMultiClickObject( m_aSelectedOID.getObjectCID() ) )
     197             :                 {
     198           0 :                     bool bSameObjectAsLastSelected = ( aLastSelectedObject == m_aSelectedOID );
     199           0 :                     if( bSameObjectAsLastSelected )
     200             :                     {
     201             :                         //if the same child is clicked again don't go up further
     202           0 :                         break;
     203             :                     }
     204           0 :                     if ( ObjectIdentifier::areSiblings( aLastSelectedObject.getObjectCID(), m_aSelectedOID.getObjectCID() ) )
     205             :                     {
     206             :                         //if a sibling of the last selected object is clicked don't go up further
     207           0 :                         break;
     208             :                     }
     209           0 :                     ObjectIdentifier aLastChild = m_aSelectedOID;
     210           0 :                     if ( !SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, false ) )
     211             :                     {
     212             :                         //take the one found so far
     213           0 :                         break;
     214             :                     }
     215             :                     //if the last selected object is found don't go up further
     216             :                     //but take the last child if selection change is allowed
     217           0 :                     if ( aLastSelectedObject == m_aSelectedOID )
     218             :                     {
     219           0 :                         if( bAllowMultiClickSelectionChange )
     220             :                         {
     221           0 :                             m_aSelectedOID = aLastChild;
     222             :                         }
     223             :                         else
     224           0 :                             m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = aLastChild;
     225           0 :                         break;
     226             :                     }
     227           0 :                 }
     228             : 
     229             :                 OSL_ENSURE(m_aSelectedOID.isValid(), "somehow lost selected object");
     230             :             }
     231             :             else
     232             :             {
     233             :                 //maybe an additional shape was hit
     234           0 :                 if ( pNewObj )
     235             :                 {
     236           0 :                     m_aSelectedOID = ObjectIdentifier( uno::Reference< drawing::XShape >( pNewObj->getUnoShape(), uno::UNO_QUERY ) );
     237             :                 }
     238             :                 else
     239             :                 {
     240           0 :                     m_aSelectedOID = ObjectIdentifier();
     241             :                 }
     242             :             }
     243             : 
     244           0 :             if ( !m_aSelectedOID.isAdditionalShape() )
     245             :             {
     246           0 :                 OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );//@todo read CID from model
     247             : 
     248           0 :                 if ( !m_aSelectedOID.isAutoGeneratedObject() )
     249             :                 {
     250           0 :                     m_aSelectedOID = ObjectIdentifier( aPageCID );
     251             :                 }
     252             : 
     253             :                 //check whether the diagram was hit but not selected (e.g. because it has no filling):
     254           0 :                 OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) );
     255           0 :                 OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, OUString() ) );//@todo read CID from model
     256           0 :                 bool bBackGroundHit = m_aSelectedOID.getObjectCID().equals( aPageCID ) || m_aSelectedOID.getObjectCID().equals( aWallCID ) || !m_aSelectedOID.isAutoGeneratedObject();
     257           0 :                 if( bBackGroundHit )
     258             :                 {
     259             :                     //todo: if more than one diagram is available in future do check the list of all diagrams here
     260           0 :                     SdrObject* pDiagram = pDrawViewWrapper->getNamedSdrObject( aDiagramCID );
     261           0 :                     if( pDiagram )
     262             :                     {
     263           0 :                         if( DrawViewWrapper::IsObjectHit( pDiagram, rMousePos ) )
     264             :                         {
     265           0 :                             m_aSelectedOID = ObjectIdentifier( aDiagramCID );
     266             :                         }
     267             :                     }
     268             :                 }
     269             :                 //check whether the legend was hit but not selected (e.g. because it has no filling):
     270           0 :                 if( bBackGroundHit || m_aSelectedOID.getObjectCID().equals( aDiagramCID ) )
     271             :                 {
     272           0 :                     OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::createParticleForLegend(0,0) ) );//@todo read CID from model
     273           0 :                     SdrObject* pLegend = pDrawViewWrapper->getNamedSdrObject( aLegendCID );
     274           0 :                     if( pLegend )
     275             :                     {
     276           0 :                         if( DrawViewWrapper::IsObjectHit( pLegend, rMousePos ) )
     277             :                         {
     278           0 :                             m_aSelectedOID = ObjectIdentifier( aLegendCID );
     279             :                         }
     280           0 :                     }
     281           0 :                 }
     282             :             }
     283             :         }
     284             : 
     285           0 :         if ( bIsRightMouse && m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid() )
     286             :         {
     287           0 :             m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
     288           0 :         }
     289             :     }
     290           0 : }
     291             : 
     292           0 : bool Selection::isResizeableObjectSelected()
     293             : {
     294           0 :     ObjectType eObjectType = m_aSelectedOID.getObjectType();
     295           0 :     switch( eObjectType )
     296             :     {
     297             :         case OBJECTTYPE_DIAGRAM:
     298             :         case OBJECTTYPE_DIAGRAM_WALL:
     299             :         case OBJECTTYPE_SHAPE:
     300             :         case OBJECTTYPE_LEGEND:
     301           0 :             return true;
     302             :         default:
     303           0 :             return false;
     304             :     }
     305             : }
     306             : 
     307           0 : bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel )
     308             : {
     309           0 :     return SelectionHelper::isRotateableObject( m_aSelectedOID.getObjectCID(), xChartModel );
     310             : }
     311             : 
     312           0 : bool Selection::isDragableObjectSelected()
     313             : {
     314           0 :     return m_aSelectedOID.isDragableObject();
     315             : }
     316             : 
     317         820 : bool Selection::isAdditionalShapeSelected() const
     318             : {
     319         820 :     return m_aSelectedOID.isAdditionalShape();
     320             : }
     321             : 
     322           0 : bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject
     323             :                                       , OUString& rOutName
     324             :                                       , bool bGivenObjectMayBeResult )
     325             : {
     326           0 :     SolarMutexGuard aSolarGuard;
     327             :     //find the deepest named group
     328           0 :     SdrObject* pObj = pInOutObject;
     329           0 :     OUString aName;
     330           0 :     if( bGivenObjectMayBeResult )
     331           0 :         aName = lcl_getObjectName( pObj );
     332             : 
     333           0 :     while( pObj && !ObjectIdentifier::isCID( aName  )  )
     334             :     {
     335           0 :         SdrObjList* pObjList = pObj->GetObjList();
     336           0 :         if( !pObjList )
     337           0 :             return false;
     338           0 :         SdrObject* pOwner = pObjList->GetOwnerObj();
     339           0 :         if( !pOwner )
     340           0 :             return false;
     341           0 :         pObj = pOwner;
     342           0 :         aName = lcl_getObjectName( pObj );
     343             :     }
     344             : 
     345           0 :     if(!pObj)
     346           0 :         return false;
     347           0 :     if(aName.isEmpty())
     348           0 :         return false;
     349             : 
     350           0 :     pInOutObject = pObj;
     351           0 :     rOutName = aName;
     352           0 :     return true;
     353             : }
     354             : 
     355           0 : bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject
     356             :                                       , ObjectIdentifier& rOutObject
     357             :                                       , bool bGivenObjectMayBeResult )
     358             : {
     359           0 :     OUString aName;
     360           0 :     if ( findNamedParent( pInOutObject, aName, bGivenObjectMayBeResult ) )
     361             :     {
     362           0 :         rOutObject = ObjectIdentifier( aName );
     363           0 :         return true;
     364             :     }
     365           0 :     return false;
     366             : }
     367             : 
     368           0 : bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos
     369             :                     , const OUString& rNameOfSelectedObject
     370             :                     , const DrawViewWrapper& rDrawViewWrapper )
     371             : {
     372           0 :     if(rNameOfSelectedObject.isEmpty())
     373           0 :         return false;
     374           0 :     if( !ObjectIdentifier::isDragableObject(rNameOfSelectedObject) )
     375           0 :         return false;
     376           0 :     SolarMutexGuard aSolarGuard;
     377           0 :     SdrObject* pObj = rDrawViewWrapper.getNamedSdrObject( rNameOfSelectedObject );
     378           0 :     if( !DrawViewWrapper::IsObjectHit( pObj, rMPos ) )
     379           0 :         return false;
     380           0 :     return true;
     381             : }
     382             : 
     383           0 : OUString SelectionHelper::getHitObjectCID(
     384             :     const Point& rMPos,
     385             :     DrawViewWrapper& rDrawViewWrapper,
     386             :     bool bGetDiagramInsteadOf_Wall )
     387             : {
     388             :     // //- solar mutex
     389           0 :     SolarMutexGuard aSolarGuard;
     390           0 :     OUString aRet;
     391             : 
     392           0 :     SdrObject* pNewObj = rDrawViewWrapper.getHitObject(rMPos);
     393           0 :     aRet = lcl_getObjectName( pNewObj );//name of pNewObj
     394             : 
     395             :     //ignore handle only objects for hit test
     396           0 :     while( pNewObj && aRet.match("HandlesOnly") )
     397             :     {
     398           0 :         pNewObj->SetMarkProtect(true);
     399           0 :         pNewObj = rDrawViewWrapper.getHitObject(rMPos);
     400           0 :         aRet = lcl_getObjectName( pNewObj );
     401             :     }
     402             : 
     403             :     //accept only named objects while searching for the object to select
     404           0 :     if( !findNamedParent( pNewObj, aRet, true ) )
     405             :     {
     406           0 :         aRet.clear();
     407             :     }
     408             : 
     409           0 :     OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );//@todo read CID from model
     410             :     //get page when nothing was hit
     411           0 :     if( aRet.isEmpty() && !pNewObj )
     412             :     {
     413           0 :         aRet = aPageCID;
     414             :     }
     415             : 
     416             :     //get diagram instead wall or page if hit inside diagram
     417           0 :     if( !aRet.isEmpty() )
     418             :     {
     419           0 :         if( aRet.equals( aPageCID ) )
     420             :         {
     421           0 :             OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) );
     422             :             //todo: if more than one diagram is available in future do check the list of all diagrams here
     423           0 :             SdrObject* pDiagram = rDrawViewWrapper.getNamedSdrObject( aDiagramCID );
     424           0 :             if( pDiagram )
     425             :             {
     426           0 :                 if( DrawViewWrapper::IsObjectHit( pDiagram, rMPos ) )
     427             :                 {
     428           0 :                     aRet = aDiagramCID;
     429             :                 }
     430           0 :             }
     431             :         }
     432           0 :         else if( bGetDiagramInsteadOf_Wall )
     433             :         {
     434           0 :             OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, OUString() ) );//@todo read CID from model
     435             : 
     436           0 :             if( aRet.equals( aWallCID ) )
     437             :             {
     438           0 :                 OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) );
     439           0 :                 aRet = aDiagramCID;
     440           0 :             }
     441             :         }
     442             :     }
     443             : 
     444           0 :     return aRet;
     445             :     // \\- solar mutex
     446             : }
     447             : 
     448           0 : bool SelectionHelper::isRotateableObject( const OUString& rCID
     449             :                     , const uno::Reference< frame::XModel >& xChartModel )
     450             : {
     451           0 :     if( !ObjectIdentifier::isRotateableObject( rCID ) )
     452           0 :         return false;
     453             : 
     454           0 :     sal_Int32 nDimensionCount = DiagramHelper::getDimension( ChartModelHelper::findDiagram( xChartModel ) );
     455             : 
     456           0 :     if( nDimensionCount == 3 )
     457           0 :         return true;
     458           0 :     return false;
     459             : }
     460             : 
     461           0 : SelectionHelper::SelectionHelper( SdrObject* pSelectedObj )
     462           0 :                       : m_pSelectedObj( pSelectedObj ), m_pMarkObj(NULL)
     463             : {
     464             : 
     465           0 : }
     466           0 : SelectionHelper::~SelectionHelper()
     467             : {
     468           0 : }
     469             : 
     470           0 : bool SelectionHelper::getFrameDragSingles()
     471             : {
     472           0 :     bool bFrameDragSingles = true;//true == green == surrounding handles
     473           0 :     if( m_pSelectedObj && m_pSelectedObj->ISA(E3dObject) )
     474           0 :         bFrameDragSingles = false;
     475           0 :     return bFrameDragSingles;
     476             : }
     477             : 
     478           0 : SdrObject* SelectionHelper::getMarkHandlesObject( SdrObject* pObj )
     479             : {
     480           0 :     if(!pObj)
     481           0 :         return 0;
     482           0 :     OUString aName( lcl_getObjectName( pObj ) );
     483           0 :     if( aName.match("MarkHandles") || aName.match("HandlesOnly") )
     484           0 :         return pObj;
     485           0 :     if( !aName.isEmpty() )//dont't get the markhandles of a different object
     486           0 :         return 0;
     487             : 
     488             :     //search for a child with name "MarkHandles" or "HandlesOnly"
     489           0 :     SolarMutexGuard aSolarGuard;
     490           0 :     SdrObjList* pSubList = pObj->GetSubList();
     491           0 :     if(pSubList)
     492             :     {
     493           0 :         SdrObjListIter aIterator(*pSubList, IM_FLAT);
     494           0 :         while (aIterator.IsMore())
     495             :         {
     496           0 :             SdrObject* pMarkHandles = SelectionHelper::getMarkHandlesObject( aIterator.Next() );
     497           0 :             if( pMarkHandles )
     498           0 :                 return pMarkHandles;
     499           0 :         }
     500             :     }
     501           0 :     return 0;
     502             : }
     503             : 
     504           0 : SdrObject* SelectionHelper::getObjectToMark()
     505             : {
     506             :     //return the selected object itself
     507             :     //or a specific other object if that exsists
     508           0 :     SdrObject* pObj = m_pSelectedObj;
     509           0 :     m_pMarkObj = pObj;
     510             : 
     511             :     //search for a child with name "MarkHandles" or "HandlesOnly"
     512           0 :     if(pObj)
     513             :     {
     514           0 :         SolarMutexGuard aSolarGuard;
     515           0 :         SdrObjList* pSubList = pObj->GetSubList();
     516           0 :         if(pSubList)
     517             :         {
     518           0 :             SdrObjListIter aIterator(*pSubList, IM_FLAT);
     519           0 :             while (aIterator.IsMore())
     520             :             {
     521           0 :                 SdrObject* pMarkHandles = SelectionHelper::getMarkHandlesObject( aIterator.Next() );
     522           0 :                 if( pMarkHandles )
     523             :                 {
     524           0 :                     m_pMarkObj = pMarkHandles;
     525           0 :                     break;
     526             :                 }
     527           0 :             }
     528           0 :         }
     529             :     }
     530           0 :     return m_pMarkObj;
     531             : }
     532             : 
     533           0 : E3dScene* SelectionHelper::getSceneToRotate( SdrObject* pObj )
     534             : {
     535             :     //search whether the object or one of its children is a 3D object
     536             :     //if so, return the accessory 3DScene
     537             : 
     538           0 :     E3dObject* pRotateable = 0;
     539             : 
     540           0 :     if(pObj)
     541             :     {
     542           0 :         pRotateable = dynamic_cast<E3dObject*>(pObj);
     543           0 :         if( !pRotateable )
     544             :         {
     545           0 :             SolarMutexGuard aSolarGuard;
     546           0 :             SdrObjList* pSubList = pObj->GetSubList();
     547           0 :             if(pSubList)
     548             :             {
     549           0 :                 SdrObjListIter aIterator(*pSubList, IM_DEEPWITHGROUPS);
     550           0 :                 while( aIterator.IsMore() && !pRotateable )
     551             :                 {
     552           0 :                     SdrObject* pSubObj = aIterator.Next();
     553           0 :                     pRotateable = dynamic_cast<E3dObject*>(pSubObj);
     554           0 :                 }
     555           0 :             }
     556             :         }
     557             :     }
     558             : 
     559           0 :     E3dScene* pScene = 0;
     560           0 :     if(pRotateable)
     561             :     {
     562           0 :         SolarMutexGuard aSolarGuard;
     563           0 :         pScene = pRotateable->GetScene();
     564             :     }
     565           0 :     return pScene;
     566             : 
     567             : }
     568             : 
     569           0 : bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList )
     570             : {
     571           0 :     SolarMutexGuard aSolarGuard;
     572             : 
     573             :     //@todo -> more flexible handle creation
     574             :     //2 scenarios possible:
     575             :     //1. add an additional invisible shape as a child to the selected object
     576             :     //this child needs to be named somehow and handles need to be generated therefrom ...
     577             :     //or 2. offer a central service per view where renderer and so can register for handle creation for a special shape
     578             :     //.. or 3. feature from drawinglayer to create handles for each shape ... (bad performance ... ?) ?
     579             : 
     580             :     //scenario 1 is now used:
     581             :     //if a child with name MarkHandles exsists
     582             :     //this child is marked instead of the logical selected object
     583             : 
     584             : /*
     585             :     //if a special mark object was found
     586             :     //that object should be used for marking only
     587             :     if( m_pMarkObj != m_pSelectedObj)
     588             :         return false;
     589             : */
     590             :     //if a special mark object was found
     591             :     //that object should be used to create handles from
     592           0 :     if( m_pMarkObj && m_pMarkObj != m_pSelectedObj)
     593             :     {
     594           0 :         rHdlList.Clear();
     595           0 :         if( m_pMarkObj->ISA(SdrPathObj) )
     596             :         {
     597             :             //if th object is a polygon
     598             :             //from each point a handle is generated
     599           0 :             const ::basegfx::B2DPolyPolygon& rPolyPolygon = static_cast<SdrPathObj*>(m_pMarkObj)->GetPathPoly();
     600           0 :             for( sal_uInt32 nN = 0L; nN < rPolyPolygon.count(); nN++)
     601             :             {
     602           0 :                 const ::basegfx::B2DPolygon aPolygon(rPolyPolygon.getB2DPolygon(nN));
     603           0 :                 for( sal_uInt32 nM = 0L; nM < aPolygon.count(); nM++)
     604             :                 {
     605           0 :                     const ::basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(nM));
     606           0 :                     SdrHdl* pHdl = new SdrHdl(Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())), HDL_POLY);
     607           0 :                     rHdlList.AddHdl(pHdl);
     608           0 :                 }
     609           0 :             }
     610           0 :             return true;
     611             :         }
     612             :         else
     613           0 :             return false; //use the special MarkObject for marking
     614             :     }
     615             : 
     616             :     //@todo:
     617             :     //add and document good marking defaults ...
     618             : 
     619           0 :     rHdlList.Clear();
     620             : 
     621           0 :     SdrObject* pObj = m_pSelectedObj;
     622           0 :     if(!pObj)
     623           0 :         return false;
     624           0 :     SdrObjList* pSubList = pObj->GetSubList();
     625           0 :     if( !pSubList )//no group object !pObj->IsGroupObject()
     626           0 :         return false;
     627             : 
     628           0 :     OUString aName( lcl_getObjectName( pObj ) );
     629           0 :     ObjectType eObjectType( ObjectIdentifier::getObjectType( aName ) );
     630           0 :     if( OBJECTTYPE_DATA_POINT == eObjectType
     631           0 :         || OBJECTTYPE_DATA_LABEL == eObjectType
     632           0 :         || OBJECTTYPE_LEGEND_ENTRY == eObjectType
     633           0 :         || OBJECTTYPE_AXIS_UNITLABEL == eObjectType )
     634             :     {
     635           0 :         return false;
     636             :     }
     637             : 
     638           0 :     SdrObjListIter aIterator(*pSubList, IM_FLAT);
     639             : 
     640           0 :     while (aIterator.IsMore())
     641             :     {
     642           0 :         SdrObject* pSubObj = aIterator.Next();
     643           0 :         if( OBJECTTYPE_DATA_SERIES == eObjectType )
     644             :         {
     645           0 :             OUString aSubName( lcl_getObjectName( pSubObj ) );
     646           0 :             ObjectType eSubObjectType( ObjectIdentifier::getObjectType( aSubName ) );
     647           0 :             if( eSubObjectType!=OBJECTTYPE_DATA_POINT  )
     648           0 :                 return false;
     649             :         }
     650             : 
     651           0 :         Point aPos = pSubObj->GetCurrentBoundRect().Center();
     652           0 :         SdrHdl* pHdl = new SdrHdl(aPos,HDL_POLY);
     653           0 :         rHdlList.AddHdl(pHdl);
     654             :     }
     655           0 :     return true;
     656             : }
     657             : 
     658          57 : } //namespace chart
     659             : 
     660             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11