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 INCLUDED_SW_SOURCE_UIBASE_INC_CONDEDIT_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_CONDEDIT_HXX
21 
22 #include <vcl/transfer.hxx>
23 #include <vcl/weld.hxx>
24 #include <swdllapi.h>
25 
26 class ConditionEdit;
27 
28 class SW_DLLPUBLIC ConditionEditDropTarget : public DropTargetHelper
29 {
30 private:
31     ConditionEdit& m_rEdit;
32 
33     SAL_DLLPRIVATE virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) override;
34     SAL_DLLPRIVATE virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override;
35 
36 public:
37     ConditionEditDropTarget(ConditionEdit& rEdit);
38 };
39 
40 class SW_DLLPUBLIC ConditionEdit
41 {
42     std::unique_ptr<weld::Entry> m_xControl;
43     ConditionEditDropTarget m_aDropTargetHelper;
44     bool bBrackets, bEnableDrop;
45 
46 public:
47     ConditionEdit(std::unique_ptr<weld::Entry> xControl);
48 
get_text() const49     OUString get_text() const { return m_xControl->get_text(); }
set_text(const OUString & rText)50     void set_text(const OUString& rText) { m_xControl->set_text(rText); }
set_visible(bool bVisible)51     void set_visible(bool bVisible) { m_xControl->set_visible(bVisible); }
set_accessible_name(const OUString & rName)52     void set_accessible_name(const OUString& rName) { m_xControl->set_accessible_name(rName); }
save_value()53     void save_value() { m_xControl->save_value(); }
get_value_changed_from_saved() const54     bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
set_sensitive(bool bSensitive)55     void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
connect_changed(const Link<weld::Entry &,void> & rLink)56     void connect_changed(const Link<weld::Entry&, void>& rLink)
57     {
58         m_xControl->connect_changed(rLink);
59     }
replace_selection(const OUString & rText)60     void replace_selection(const OUString& rText) { m_xControl->replace_selection(rText); }
hide()61     void hide() { m_xControl->hide(); }
get_widget()62     weld::Entry& get_widget() { return *m_xControl; }
63 
ShowBrackets(bool bShow)64     void ShowBrackets(bool bShow) { bBrackets = bShow; }
GetBrackets() const65     bool GetBrackets() const { return bBrackets; }
SetDropEnable(bool bFlag)66     void SetDropEnable(bool bFlag) { bEnableDrop = bFlag; }
GetDropEnable() const67     bool GetDropEnable() const { return bEnableDrop; }
68 };
69 
70 #endif
71 
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
73