/src/libreoffice/sw/source/uibase/fldui/fldwrap.cxx
Line | Count | Source |
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 | | |
20 | | #include <cmdid.h> |
21 | | #include <sfx2/basedlgs.hxx> |
22 | | #include <docsh.hxx> |
23 | | #include <fldwrap.hxx> |
24 | | |
25 | | #include <swabstdlg.hxx> |
26 | | |
27 | | SFX_IMPL_CHILDWINDOW_WITHID(SwFieldDlgWrapper, FN_INSERT_FIELD) |
28 | | |
29 | | SwChildWinWrapper::SwChildWinWrapper(vcl::Window *pParentWindow, sal_uInt16 nId) : |
30 | 0 | SfxChildWindow(pParentWindow, nId), |
31 | 0 | m_aUpdateTimer("SwChildWinWrapper m_aUpdateTimer"), |
32 | 0 | m_pDocSh(nullptr) |
33 | 0 | { |
34 | | // avoid flickering of buttons: |
35 | 0 | m_aUpdateTimer.SetTimeout(200); |
36 | 0 | m_aUpdateTimer.SetInvokeHandler(LINK(this, SwChildWinWrapper, UpdateHdl)); |
37 | 0 | } |
38 | | |
39 | | IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl, Timer *, void) |
40 | 0 | { |
41 | 0 | if (GetController()) |
42 | 0 | GetController()->Activate(); // update dialog |
43 | 0 | } |
44 | | |
45 | | // newly initialise dialog after Doc switch |
46 | | void SwChildWinWrapper::ReInitDlg() |
47 | 0 | { |
48 | 0 | m_aUpdateTimer.Start(); |
49 | 0 | } |
50 | | |
51 | | SfxChildWinInfo SwFieldDlgWrapper::GetInfo() const |
52 | 0 | { |
53 | 0 | SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); |
54 | 0 | return aInfo; |
55 | 0 | } |
56 | | |
57 | | SwFieldDlgWrapper::SwFieldDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId, |
58 | | SfxBindings* pB, |
59 | | SfxChildWinInfo* ) |
60 | 0 | : SwChildWinWrapper( _pParent, nId ) |
61 | 0 | { |
62 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
63 | 0 | m_pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld()); |
64 | 0 | SetController(m_pDlgInterface->GetController()); |
65 | 0 | m_pDlgInterface->StartExecuteAsync(nullptr); |
66 | 0 | } |
67 | | |
68 | | void SwFieldDlgWrapper::ShowReferencePage() |
69 | 0 | { |
70 | 0 | m_pDlgInterface->ShowReferencePage(); |
71 | 0 | } |
72 | | |
73 | | SFX_IMPL_CHILDWINDOW(SwFieldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY) |
74 | | |
75 | | SfxChildWinInfo SwFieldDataOnlyDlgWrapper::GetInfo() const |
76 | 0 | { |
77 | 0 | SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); |
78 | | // prevent instantiation of dialog other than by calling |
79 | | // the mail merge dialog |
80 | 0 | aInfo.bVisible = false; |
81 | 0 | return aInfo; |
82 | 0 | } |
83 | | |
84 | | SwFieldDataOnlyDlgWrapper::SwFieldDataOnlyDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId, |
85 | | SfxBindings* pB, |
86 | | SfxChildWinInfo* pInfo ) |
87 | 0 | : SwChildWinWrapper( _pParent, nId ) |
88 | 0 | { |
89 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
90 | 0 | m_pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld()); |
91 | |
|
92 | 0 | SetController(m_pDlgInterface->GetController()); |
93 | 0 | m_pDlgInterface->ActivateDatabasePage(); |
94 | 0 | m_pDlgInterface->StartExecuteAsync(nullptr); |
95 | 0 | m_pDlgInterface->Initialize( pInfo ); |
96 | 0 | } |
97 | | |
98 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |