summaryrefslogtreecommitdiffstats
path: root/sw/source/uibase/inc/glossary.hxx
blob: b93925f344d1597b8e8acac39c702dadeef5ffda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_GLOSSARY_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_GLOSSARY_HXX

#include <vcl/customweld.hxx>
#include <vcl/textfilter.hxx>
#include <vcl/weld.hxx>

#include <com/sun/star/text/XAutoTextContainer2.hpp>

#include <rtl/ustring.hxx>
#include <sfx2/basedlgs.hxx>

struct GroupUserData;
class SwGlossaryHdl;
class SwNewGlosNameDlg;
class SwWrtShell;
class SfxViewFrame;
class PopupMenu;
class Menu;
class SwOneExampleFrame;

const short RET_EDIT = 100;

class SwGlossaryDropTarget;

class SwGlossaryDlg final : public SfxDialogController
{
    friend class SwNewGlosNameDlg;

    OUString const        m_sReadonlyPath;

    css::uno::Reference< css::text::XAutoTextContainer2 > m_xAutoText;

    SwGlossaryHdl*  m_pGlossaryHdl;

    OUString        m_sResumeGroup;
    OUString        m_sResumeShortName;
    bool            m_bResume;

    const bool      m_bSelection : 1;
    bool            m_bReadOnly : 1;
    bool            m_bIsOld : 1;
    bool            m_bIsDocReadOnly:1;

    SwWrtShell*     m_pShell;

    std::vector<std::unique_ptr<GroupUserData>> m_xGroupData;

    std::unique_ptr<weld::CheckButton> m_xInsertTipCB;
    std::unique_ptr<weld::Entry> m_xNameED;
    std::unique_ptr<weld::Label> m_xShortNameLbl;
    TextFilter      m_aNoSpaceFilter;
    std::unique_ptr<weld::Entry> m_xShortNameEdit;
    std::unique_ptr<weld::TreeView> m_xCategoryBox;
    std::unique_ptr<weld::CheckButton> m_xFileRelCB;
    std::unique_ptr<weld::CheckButton> m_xNetRelCB;
    std::unique_ptr<weld::Button> m_xInsertBtn;
    std::unique_ptr<weld::MenuButton> m_xEditBtn;
    std::unique_ptr<weld::Button> m_xBibBtn;
    std::unique_ptr<weld::Button> m_xPathBtn;
    std::unique_ptr<SwOneExampleFrame> m_xExampleFrame;
    std::unique_ptr<weld::CustomWeld> m_xExampleFrameWin;
    std::unique_ptr<SwGlossaryDropTarget> m_xDropTarget;

    void EnableShortName(bool bOn = true);
    void ShowPreview();

    DECL_LINK( NameModify, weld::Entry&, void );
    DECL_LINK( NameDoubleClick, weld::TreeView&, bool );
    DECL_LINK( GrpSelect, weld::TreeView&, void );
    DECL_LINK( MenuHdl, const OUString&, void );
    DECL_LINK( EnableHdl, weld::Toggleable&, void );
    DECL_LINK( BibHdl, weld::Button&, void );
    DECL_LINK( InsertHdl, weld::Button&, void );
    DECL_LINK( PathHdl, weld::Button&, void );
    DECL_LINK( CheckBoxHdl, weld::Toggleable&, void );
    DECL_LINK( PreviewLoadedHdl, SwOneExampleFrame&, void );
    DECL_LINK( KeyInputHdl, const KeyEvent&, bool );
    DECL_LINK( TextFilterHdl, OUString&, bool );

    void            Apply();
    void            Init();
    std::unique_ptr<weld::TreeIter> DoesBlockExist(std::u16string_view sBlock, std::u16string_view rShort);
    void            ShowAutoText(const OUString& rGroup, const OUString& rShortName);
    void            ResumeShowAutoText();

    bool            GetResumeData(OUString& rGroup, OUString& rShortName)
                        {rGroup = m_sResumeGroup; rShortName = m_sResumeShortName; return m_bResume;}
    void            SetResumeData(const OUString& rGroup, const OUString& rShortName)
                        {m_sResumeGroup = rGroup; m_sResumeShortName = rShortName; m_bResume = true;}

    void            DeleteEntry();
public:
    SwGlossaryDlg(const SfxViewFrame& rViewFrame, SwGlossaryHdl* pGlosHdl, SwWrtShell *pWrtShell);
    virtual short run() override;
    virtual ~SwGlossaryDlg() override;
    OUString GetCurrGrpName() const;
    OUString GetCurrShortName() const
    {
        return m_xShortNameEdit->get_text();
    }
    static OUString GetCurrGroup();
    static void     SetActGroup(const OUString& rNewGroup);
};

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */