nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / uibase / fldui / fldwrap.cxx
bloba2a41fa3443c323142dd60552d228b05c704775d
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 #include <cmdid.h>
21 #include <sfx2/basedlgs.hxx>
22 #include <docsh.hxx>
23 #include <fldwrap.hxx>
25 #include <swabstdlg.hxx>
27 SFX_IMPL_CHILDWINDOW_WITHID(SwFieldDlgWrapper, FN_INSERT_FIELD)
29 SwChildWinWrapper::SwChildWinWrapper(vcl::Window *pParentWindow, sal_uInt16 nId) :
30 SfxChildWindow(pParentWindow, nId),
31 m_pDocSh(nullptr)
33 // avoid flickering of buttons:
34 m_aUpdateTimer.SetTimeout(200);
35 m_aUpdateTimer.SetInvokeHandler(LINK(this, SwChildWinWrapper, UpdateHdl));
38 IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl, Timer *, void)
40 if (GetController())
41 GetController()->Activate(); // update dialog
44 // newly initialise dialog after Doc switch
45 bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
47 bool bRet = false;
49 if (m_pDocSh != GetOldDocShell())
51 m_aUpdateTimer.Stop();
52 bRet = true; // immediate Update
54 else
55 m_aUpdateTimer.Start();
57 return bRet;
60 SfxChildWinInfo SwFieldDlgWrapper::GetInfo() const
62 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
63 return aInfo;
66 SwFieldDlgWrapper::SwFieldDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
67 SfxBindings* pB,
68 SfxChildWinInfo* )
69 : SwChildWinWrapper( _pParent, nId )
71 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
72 pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld());
73 SetController(pDlgInterface->GetController());
74 pDlgInterface->StartExecuteAsync(nullptr);
77 // newly initialise dialog after Doc switch
78 bool SwFieldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
80 bool bRet = SwChildWinWrapper::ReInitDlg(pDocSh);
81 if (bRet) // update immediately, Doc switch
83 pDlgInterface->ReInitDlg();
86 return bRet;
89 void SwFieldDlgWrapper::ShowReferencePage()
91 pDlgInterface->ShowReferencePage();
94 SFX_IMPL_CHILDWINDOW(SwFieldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
96 SfxChildWinInfo SwFieldDataOnlyDlgWrapper::GetInfo() const
98 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
99 // prevent instantiation of dialog other than by calling
100 // the mail merge dialog
101 aInfo.bVisible = false;
102 return aInfo;
105 SwFieldDataOnlyDlgWrapper::SwFieldDataOnlyDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
106 SfxBindings* pB,
107 SfxChildWinInfo* pInfo )
108 : SwChildWinWrapper( _pParent, nId )
110 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
111 pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld());
113 SetController(pDlgInterface->GetController());
114 pDlgInterface->ActivateDatabasePage();
115 pDlgInterface->StartExecuteAsync(nullptr);
116 pDlgInterface->Initialize( pInfo );
119 // re-init after doc activation
120 bool SwFieldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
122 bool bRet = SwChildWinWrapper::ReInitDlg(pDocSh);
123 if (bRet) // update immediately, Doc switch
125 pDlgInterface->ReInitDlg();
128 return bRet;
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */