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