cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / LayerTabBar.hxx
blob56f9e9cc8997376b04b703fcd8af1e4a3d7fb541
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
26 #include <svtools/tabbar.hxx>
27 #include <vcl/transfer.hxx>
28 #include <sddllapi.h>
30 #include <svx/sdr/overlay/overlayobject.hxx>
32 namespace sd {
34 /**
35 * TabBar for layer administration
37 class DrawViewShell;
39 class SAL_DLLPUBLIC_RTTI LayerTabBar final
40 : public TabBar,
41 public DropTargetHelper
43 public:
44 LayerTabBar (
45 DrawViewShell* pDrViewSh,
46 vcl::Window* pParent);
47 virtual void dispose() override;
48 virtual ~LayerTabBar() override;
50 /** Inform all listeners of this control that the current layer has been
51 activated. Call this method after switching the current layer and is
52 not done elsewhere (like when using ctrl + page up/down keys).
54 void SendActivatePageEvent();
56 /** Inform all listeners of this control that the current layer has been
57 deactivated. Call this method before switching the current layer
58 and is not done elsewhere (like when using ctrl page up/down keys).
60 void SendDeactivatePageEvent();
62 // Expects not-localized, real layer name in rText. Generates a localized layer name
63 // that will be displayed on the tab of the LayerTabBar and writes the real name
64 // to maAuxiliaryText. In case you want no entry in maAuxiliaryText, use method from TabBar.
65 virtual void InsertPage( sal_uInt16 nPageId, const OUString& rText,
66 TabBarPageBits nBits = TabBarPageBits::NONE,
67 sal_uInt16 nPos = TabBar::APPEND ) override;
68 virtual void SetPageText( sal_uInt16 nPageId, const OUString& rText ) override;
70 // Returns the real layer name if exists and empty OUString otherwise.
71 const OUString & GetLayerName(sal_uInt16 nPageId) const;
73 // Used e.g. in DeleteActualLayer() to test whether deleting is allowed.
74 static bool IsRealNameOfStandardLayer(std::u16string_view rName);
76 // Used e.g. in validity test of user entered names
77 static bool IsLocalizedNameOfStandardLayer(std::u16string_view rName);
79 // In case rName is one of the sUNO_LayerName_*, it generates a localized name,
80 // otherwise it returns value of rName.
81 static OUString convertToLocalizedName(const OUString& rName);
83 // TabBar
84 virtual void Select() override;
85 virtual void DoubleClick() override;
87 SD_DLLPUBLIC virtual void MouseMove(const MouseEvent& rMEvt) override;
88 SD_DLLPUBLIC virtual void MouseButtonDown(const MouseEvent& rMEvt) override; // export for unit test
90 virtual void Command(const CommandEvent& rCEvt) override;
92 virtual bool StartRenaming() override;
93 virtual TabBarAllowRenamingReturnCode AllowRenaming() override;
94 virtual void EndRenaming() override;
96 virtual void ActivatePage() override;
98 // DropTargetHelper
99 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
100 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
102 private:
103 DrawViewShell* pDrViewSh;
105 AutoTimer m_aBringLayerObjectsToAttentionDelayTimer;
106 sal_uInt16 m_nBringLayerObjectsToAttentionLastPageId = 0;
107 std::unique_ptr<sdr::overlay::OverlayObject> m_xOverlayObject;
108 void BringLayerObjectsToAttention(const sal_uInt16 nPageId = 0);
109 DECL_LINK(BringLayerObjectsToAttentionDelayTimerHdl, Timer *, void);
111 // Expects not-localized, real layer name in rText and writes it to maAuxiliaryText.
112 void SetLayerName( sal_uInt16 nPageId, const OUString& rText );
115 } // end of namespace sd
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */