Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / controller / inc / SelectionHelper.hxx
blobff0e95eee27adc35be73370db0debf6046b91764
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #pragma once
21 #include "DrawViewWrapper.hxx"
22 #include <ObjectIdentifier.hxx>
24 class SdrObject;
26 namespace com::sun::star::drawing { class XShape; }
28 namespace chart
31 class Selection
33 public: //methods
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 isDragableObjectSelected() const;
44 bool isAdditionalShapeSelected() const;
46 //returns true if selection has changed
47 bool setSelection( const OUString& rCID );
48 bool setSelection( const css::uno::Reference< css::drawing::XShape >& xShape );
50 void clearSelection();
52 //returns true if the selection has changed
53 bool maybeSwitchSelectionAfterSingleClickWasEnsured();
54 void resetPossibleSelectionAfterSingleClickWasEnsured();
56 void remindSelectionBeforeMouseDown();
57 bool isSelectionDifferentFromBeforeMouseDown() const;
59 void adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper const * pDrawViewWrapper
60 , bool bIsRightMouse, bool bWaitingForDoubleClick );
62 void applySelection( DrawViewWrapper* pDrawViewWrapper );
64 private: //member
65 //the selection could be given by a CID or by a shape
66 //if m_aSelectedObjectCID is not empty this indicates the selection
67 //the content of m_xSelectedShape is ignored in that case
68 //the strings are used for autogenerated chart specific objects
69 //the shape reference is used for additional shapes
70 ObjectIdentifier m_aSelectedOID; //only single object selection so far
71 ObjectIdentifier m_aSelectedOID_beforeMouseDown;
72 ObjectIdentifier m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing;
75 class SelectionHelper final : public MarkHandleProvider
77 public:
78 static bool findNamedParent( SdrObject*& pInOutObject
79 , OUString& rOutName
80 , bool bGivenObjectMayBeResult );
81 static bool findNamedParent( SdrObject*& pInOutObject
82 , ObjectIdentifier& rOutObject
83 , bool bGivenObjectMayBeResult );
84 static SdrObject* getMarkHandlesObject( SdrObject* pObj );
85 static E3dScene* getSceneToRotate( SdrObject* pObj );
86 static bool isDragableObjectHitTwice( const Point& rMPos
87 , const OUString& rNameOfSelectedObject
88 , const DrawViewWrapper& rDrawViewWrapper );
90 static OUString getHitObjectCID(
91 const Point& rMPos,
92 DrawViewWrapper const & rDrawViewWrapper,
93 bool bGetDiagramInsteadOf_Wall=false );
95 static bool isRotateableObject( std::u16string_view rCID
96 , const rtl::Reference<::chart::ChartModel>& xChartModel );
98 explicit SelectionHelper( SdrObject* pSelectedObj );
99 virtual ~SelectionHelper();
101 //MarkHandleProvider:
102 virtual bool getMarkHandles( SdrHdlList& rHdlList ) override;
103 virtual bool getFrameDragSingles() override;
105 SdrObject* getObjectToMark();//sets also internally the mark object
106 //-> getMarkHandles will behave different if this method has found a Mark Object different from m_pSelectedObj
108 private:
109 SdrObject* m_pSelectedObj;//hit and logically selected object
110 SdrObject* m_pMarkObj;//object that is marked instead to have more pretty handles
113 } //namespace chart
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */