1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "DrawViewWrapper.hxx"
22 #include <ObjectIdentifier.hxx>
26 namespace com::sun::star::drawing
{ class XShape
; }
34 bool hasSelection() const;
36 OUString
const & getSelectedCID() const;
37 css::uno::Reference
< css::drawing::XShape
> const & getSelectedAdditionalShape() const;
38 const ObjectIdentifier
& getSelectedOID() const { return m_aSelectedOID
;}
40 bool isResizeableObjectSelected() const;
41 bool isRotateableObjectSelected( const rtl::Reference
<::chart::ChartModel
>& xChartModel
) const;
42 bool isTitleObjectSelected() const;
43 bool isDragableObjectSelected() const;
45 bool isAdditionalShapeSelected() const;
47 //returns true if selection has changed
48 bool setSelection( const OUString
& rCID
);
49 bool setSelection( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
51 void clearSelection();
53 //returns true if the selection has changed
54 bool maybeSwitchSelectionAfterSingleClickWasEnsured();
55 void resetPossibleSelectionAfterSingleClickWasEnsured();
57 void remindSelectionBeforeMouseDown();
58 bool isSelectionDifferentFromBeforeMouseDown() const;
60 void adaptSelectionToNewPos( const Point
& rMousePos
, DrawViewWrapper
const * pDrawViewWrapper
61 , bool bIsRightMouse
, bool bWaitingForDoubleClick
);
63 void applySelection( DrawViewWrapper
* pDrawViewWrapper
);
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
;
76 class SelectionHelper final
: public MarkHandleProvider
79 static bool findNamedParent( SdrObject
*& pInOutObject
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
);
91 static OUString
getHitObjectCID(
93 DrawViewWrapper
const & rDrawViewWrapper
,
94 bool bGetDiagramInsteadOf_Wall
=false );
96 static bool isRotateableObject( std::u16string_view rCID
97 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
);
99 explicit SelectionHelper( SdrObject
* pSelectedObj
);
100 virtual ~SelectionHelper();
102 //MarkHandleProvider:
103 virtual bool getMarkHandles( SdrHdlList
& rHdlList
) override
;
104 virtual bool getFrameDragSingles() override
;
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
110 SdrObject
* m_pSelectedObj
;//hit and logically selected object
111 SdrObject
* m_pMarkObj
;//object that is marked instead to have more pretty handles
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */