Branch data 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 : : #ifndef _CHART2_SELECTIONHELPER_HXX
20 : : #define _CHART2_SELECTIONHELPER_HXX
21 : :
22 : : #include "DrawViewWrapper.hxx"
23 : : #include "ObjectIdentifier.hxx"
24 : :
25 : : class SdrObject;
26 : : // header for enum SdrDragMode
27 : : #include <svx/svdtypes.hxx>
28 : : #include <com/sun/star/drawing/XShape.hpp>
29 : :
30 : : //.............................................................................
31 : : namespace chart
32 : : {
33 : : //.............................................................................
34 : :
35 : : class ObjectIdentifier;
36 : :
37 : : //-----------------------------------------------------------------------------
38 : :
39 [ + - ][ + - ]: 68 : class Selection
[ + - ][ + - ]
40 : : {
41 : : public: //methods
42 : : bool hasSelection();
43 : :
44 : : rtl::OUString getSelectedCID();
45 : : ::com::sun::star::uno::Reference<
46 : : ::com::sun::star::drawing::XShape > getSelectedAdditionalShape();
47 : : ObjectIdentifier getSelectedOID() const;
48 : :
49 : : bool isResizeableObjectSelected();
50 : : bool isRotateableObjectSelected( const ::com::sun::star::uno::Reference<
51 : : ::com::sun::star::frame::XModel >& xChartModel );
52 : : bool isDragableObjectSelected();
53 : :
54 : : bool isAdditionalShapeSelected() const;
55 : :
56 : : //returns true if selection has changed
57 : : bool setSelection( const ::rtl::OUString& rCID );
58 : : bool setSelection( const ::com::sun::star::uno::Reference<
59 : : ::com::sun::star::drawing::XShape >& xShape );
60 : :
61 : : void clearSelection();
62 : :
63 : : //returns true if the selection has changed
64 : : bool maybeSwitchSelectionAfterSingleClickWasEnsured();
65 : : void resetPossibleSelectionAfterSingleClickWasEnsured();
66 : :
67 : : void remindSelectionBeforeMouseDown();
68 : : bool isSelectionDifferentFromBeforeMouseDown() const;
69 : :
70 : : void adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper* pDrawViewWrapper
71 : : , bool bIsRightMouse, bool bWaitingForDoubleClick );
72 : :
73 : : void applySelection( DrawViewWrapper* pDrawViewWrapper );
74 : :
75 : : private: //member
76 : : //the selection could be given by a CID or by a shape
77 : : //if m_aSelectedObjectCID is not empty this indicates the selection
78 : : //the content of m_xSelectedShape is ignored in that case
79 : : //the strings are used for autogenerated chart specific objects
80 : : //the shape reference is used for additional shapes
81 : : ObjectIdentifier m_aSelectedOID; //only single object selection so far
82 : : ObjectIdentifier m_aSelectedOID_beforeMouseDown;
83 : : ObjectIdentifier m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing;
84 : : };
85 : :
86 : : class SelectionHelper : public MarkHandleProvider
87 : : {
88 : : public:
89 : : static bool findNamedParent( SdrObject*& pInOutObject
90 : : , rtl::OUString& rOutName
91 : : , bool bGivenObjectMayBeResult );
92 : : static bool findNamedParent( SdrObject*& pInOutObject
93 : : , ObjectIdentifier& rOutObject
94 : : , bool bGivenObjectMayBeResult );
95 : : static SdrObject* getMarkHandlesObject( SdrObject* pObj );
96 : : static E3dScene* getSceneToRotate( SdrObject* pObj );
97 : : static bool isDragableObjectHitTwice( const Point& rMPos
98 : : , const rtl::OUString& rNameOfSelectedObject
99 : : , const DrawViewWrapper& rDrawViewWrapper );
100 : :
101 : : static ::rtl::OUString getHitObjectCID(
102 : : const Point& rMPos,
103 : : DrawViewWrapper& rDrawViewWrapper,
104 : : bool bGetDiagramInsteadOf_Wall=false );
105 : :
106 : : static bool isRotateableObject( const ::rtl::OUString& rCID
107 : : , const ::com::sun::star::uno::Reference<
108 : : ::com::sun::star::frame::XModel >& xChartModel );
109 : :
110 : :
111 : : SelectionHelper( SdrObject* pSelectedObj );
112 : : virtual ~SelectionHelper();
113 : :
114 : :
115 : : //MarkHandleProvider:
116 : : virtual bool getMarkHandles( SdrHdlList& rHdlList );
117 : : virtual bool getFrameDragSingles();
118 : :
119 : : SdrObject* getObjectToMark();//sets also internally the mark object
120 : : //-> getMarkHandles will behave different if this method has found a Mark Object different from m_pSelectedObj
121 : :
122 : : private:
123 : : SdrObject* m_pSelectedObj;//hit and logically selected object
124 : : SdrObject* m_pMarkObj;//object that is marked instead to have more pretty handles
125 : : };
126 : :
127 : : //.............................................................................
128 : : } //namespace chart
129 : : //.............................................................................
130 : : #endif
131 : :
132 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|