summaryrefslogtreecommitdiff
path: root/sw/source/uibase/inc/glossary.hxx
blob: aead0c1e852caf112d1286d575262d561931073f (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* -*- 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_CORE_UIBASE_INC_GLOSSARY_HXX
#define INCLUDED_SW_SOURCE_CORE_UIBASE_INC_GLOSSARY_HXX

#include <vcl/edit.hxx>
#include <svtools/treelistbox.hxx>
#include <svx/stddlg.hxx>

#include <vcl/button.hxx>
#include <vcl/fixed.hxx>

#include <vcl/combobox.hxx>

#include <vcl/menubtn.hxx>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/container/XElementAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/text/XAutoTextContainer2.hpp>

#include <rtl/ustring.hxx>

#include <actctrl.hxx>

class SwGlossaryHdl;
class SwNewGlosNameDlg;
class SwWrtShell;
class SfxViewFrame;
class PopupMenu;
class Menu;

const short RET_EDIT = 100;

class SwGlTreeListBox : public SvTreeListBox
{
    const OUString    sReadonly;

    SvTreeListEntry*  pDragEntry;

    virtual DragDropMode NotifyStartDrag( TransferDataContainer& rContainer,
                                            SvTreeListEntry* ) SAL_OVERRIDE;
    virtual bool         NotifyAcceptDrop( SvTreeListEntry* ) SAL_OVERRIDE;

    virtual TriState     NotifyMoving(   SvTreeListEntry*  pTarget,
                                    SvTreeListEntry*  pEntry,
                                    SvTreeListEntry*& rpNewParent,
                                    sal_uLong&        rNewChildPos
                                ) SAL_OVERRIDE;
    virtual TriState     NotifyCopying(  SvTreeListEntry*  pTarget,
                                    SvTreeListEntry*  pEntry,
                                    SvTreeListEntry*& rpNewParent,
                                    sal_uLong&        rNewChildPos) SAL_OVERRIDE;

    TriState NotifyCopyingOrMoving( SvTreeListEntry*  pTarget,
                                    SvTreeListEntry*  pEntry,
                                    bool              bIsMove);
public:
    SwGlTreeListBox(Window* pParent, WinBits nBits);

    virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
    virtual Size GetOptimalSize() const SAL_OVERRIDE;
    void Clear();
};

class SwOneExampleFrame;
class SwGlossaryDlg : public SvxStandardDialog
{
    friend class SwNewGlosNameDlg;
    friend class SwGlTreeListBox;

    CheckBox*       m_pInsertTipCB;
    Edit*           m_pNameED;
    FixedText*      m_pShortNameLbl;
    NoSpaceEdit*    m_pShortNameEdit;
    SwGlTreeListBox* m_pCategoryBox;
    CheckBox*       m_pFileRelCB;
    CheckBox*       m_pNetRelCB;
    Window*         m_pExampleWIN;
    PushButton*     m_pInsertBtn;
    MenuButton*     m_pEditBtn;
    PushButton*     m_pBibBtn;
    PushButton*     m_pPathBtn;

    OUString        sReadonlyPath;

    ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextContainer2 > m_xAutoText;
    SwOneExampleFrame*  pExampleFrame;

    SwGlossaryHdl*  pGlossaryHdl;

    OUString        sResumeGroup;
    OUString        sResumeShortName;
    bool            bResume;

    const bool      bSelection : 1;
    bool            bReadOnly : 1;
    bool            bIsOld : 1;
    bool            bIsDocReadOnly:1;

    SwWrtShell*     pSh;

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

    DECL_LINK( NameModify, Edit * );
    DECL_LINK( NameDoubleClick, SvTreeListBox * );
    DECL_LINK( GrpSelect, SvTreeListBox * );
    DECL_LINK( MenuHdl, Menu * );
    DECL_LINK( EnableHdl, Menu * );
    DECL_LINK(BibHdl, void *);
    DECL_LINK(EditHdl, void *);
    DECL_LINK(InsertHdl, void *);
    DECL_LINK( PathHdl, Button * );
    DECL_LINK( CheckBoxHdl, CheckBox * );
    DECL_LINK( PreviewLoadedHdl, void * );

    virtual void    Apply() SAL_OVERRIDE;
    void            Init();
    SvTreeListEntry*    DoesBlockExist(const OUString& sBlock, const OUString& rShort);
    void            ShowAutoText(const OUString& rGroup, const OUString& rShortName);
    void            ResumeShowAutoText();

    bool            GetResumeData(OUString& rGroup, OUString& rShortName)
                        {rGroup = sResumeGroup; rShortName = sResumeShortName; return bResume;}
    void            SetResumeData(const OUString& rGroup, const OUString& rShortName)
                        {sResumeGroup = rGroup; sResumeShortName = rShortName; bResume = true;}
    void            ResetResumeData() {bResume = false;}
public:
    SwGlossaryDlg(SfxViewFrame* pViewFrame, SwGlossaryHdl* pGlosHdl, SwWrtShell *pWrtShell);
    virtual ~SwGlossaryDlg();
    OUString GetCurrGrpName() const;
    OUString GetCurrLongName() const
    {
        return m_pNameED->GetText();
    }
    OUString GetCurrShortName() const
    {
        return m_pShortNameEdit->GetText();
    }
    static OUString GetCurrGroup();
    static void     SetActGroup(const OUString& rNewGroup);
    static OUString GetExtension();
};

#endif

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