1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CHART2_SELECTIONHELPER_HXX 24 #define _CHART2_SELECTIONHELPER_HXX 25 26 #include "DrawViewWrapper.hxx" 27 #include "ObjectIdentifier.hxx" 28 29 class SdrObject; 30 // header for enum SdrDragMode 31 #include <svx/svdtypes.hxx> 32 #include <com/sun/star/drawing/XShape.hpp> 33 34 //............................................................................. 35 namespace chart 36 { 37 //............................................................................. 38 39 class ObjectIdentifier; 40 41 //----------------------------------------------------------------------------- 42 /** 43 */ 44 class Selection 45 { 46 public: //methods 47 bool hasSelection(); 48 49 rtl::OUString getSelectedCID(); 50 ::com::sun::star::uno::Reference< 51 ::com::sun::star::drawing::XShape > getSelectedAdditionalShape(); 52 ObjectIdentifier getSelectedOID() const; 53 54 bool isResizeableObjectSelected(); 55 bool isRotateableObjectSelected( const ::com::sun::star::uno::Reference< 56 ::com::sun::star::frame::XModel >& xChartModel ); 57 bool isDragableObjectSelected(); 58 59 bool isAdditionalShapeSelected() const; 60 61 //returns true if selection has changed 62 bool setSelection( const ::rtl::OUString& rCID ); 63 bool setSelection( const ::com::sun::star::uno::Reference< 64 ::com::sun::star::drawing::XShape >& xShape ); 65 66 void clearSelection(); 67 68 //returns true if the selection has changed 69 bool maybeSwitchSelectionAfterSingleClickWasEnsured(); 70 void resetPossibleSelectionAfterSingleClickWasEnsured(); 71 72 void remindSelectionBeforeMouseDown(); 73 bool isSelectionDifferentFromBeforeMouseDown(); 74 75 void adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper* pDrawViewWrapper 76 , bool bIsRightMouse, bool bWaitingForDoubleClick ); 77 78 void applySelection( DrawViewWrapper* pDrawViewWrapper ); 79 80 private: //member 81 //the selection could be given by a CID or by a shape 82 //if m_aSelectedObjectCID is not empty this indicates the selection 83 //the content of m_xSelectedShape is ignored in that case 84 //the strings are used for autogenerated chart specific objects 85 //the shape reference is used for additional shapes 86 ObjectIdentifier m_aSelectedOID; //only single object selection so far 87 ObjectIdentifier m_aSelectedOID_beforeMouseDown; 88 ObjectIdentifier m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing; 89 }; 90 91 class SelectionHelper : public MarkHandleProvider 92 { 93 public: 94 static bool findNamedParent( SdrObject*& pInOutObject 95 , rtl::OUString& rOutName 96 , bool bGivenObjectMayBeResult ); 97 static bool findNamedParent( SdrObject*& pInOutObject 98 , ObjectIdentifier& rOutObject 99 , bool bGivenObjectMayBeResult ); 100 static SdrObject* getMarkHandlesObject( SdrObject* pObj ); 101 static E3dScene* getSceneToRotate( SdrObject* pObj ); 102 static bool isDragableObjectHitTwice( const Point& rMPos 103 , const rtl::OUString& rNameOfSelectedObject 104 , const DrawViewWrapper& rDrawViewWrapper ); 105 106 static ::rtl::OUString getHitObjectCID( 107 const Point& rMPos, 108 DrawViewWrapper& rDrawViewWrapper, 109 bool bGetDiagramInsteadOf_Wall=false ); 110 111 static bool isRotateableObject( const ::rtl::OUString& rCID 112 , const ::com::sun::star::uno::Reference< 113 ::com::sun::star::frame::XModel >& xChartModel ); 114 115 116 SelectionHelper( SdrObject* pSelectedObj ); 117 virtual ~SelectionHelper(); 118 119 120 //MarkHandleProvider: 121 virtual bool getMarkHandles( SdrHdlList& rHdlList ); 122 virtual bool getFrameDragSingles(); 123 124 SdrObject* getObjectToMark();//sets also internally the mark object 125 //-> getMarkHandles will behave different if this method has found a Mark Object different from m_pSelectedObj 126 127 private: 128 SdrObject* m_pSelectedObj;//hit and logically selected object 129 SdrObject* m_pMarkObj;//object that is marked instead to have more pretty handles 130 }; 131 132 //............................................................................. 133 } //namespace chart 134 //............................................................................. 135 #endif 136