1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <sfx2/basedlgs.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_aUpdateTimer("SwChildWinWrapper m_aUpdateTimer"),
34 // avoid flickering of buttons:
35 m_aUpdateTimer
.SetTimeout(200);
36 m_aUpdateTimer
.SetInvokeHandler(LINK(this, SwChildWinWrapper
, UpdateHdl
));
39 IMPL_LINK_NOARG(SwChildWinWrapper
, UpdateHdl
, Timer
*, void)
42 GetController()->Activate(); // update dialog
45 // newly initialise dialog after Doc switch
46 bool SwChildWinWrapper::ReInitDlg(SwDocShell
*)
50 if (m_pDocSh
!= GetOldDocShell())
52 m_aUpdateTimer
.Stop();
53 bRet
= true; // immediate Update
56 m_aUpdateTimer
.Start();
61 SfxChildWinInfo
SwFieldDlgWrapper::GetInfo() const
63 SfxChildWinInfo aInfo
= SfxChildWindow::GetInfo();
67 SwFieldDlgWrapper::SwFieldDlgWrapper( vcl::Window
* _pParent
, sal_uInt16 nId
,
70 : SwChildWinWrapper( _pParent
, nId
)
72 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
73 m_pDlgInterface
= pFact
->CreateSwFieldDlg(pB
, this, _pParent
->GetFrameWeld());
74 SetController(m_pDlgInterface
->GetController());
75 m_pDlgInterface
->StartExecuteAsync(nullptr);
78 // newly initialise dialog after Doc switch
79 bool SwFieldDlgWrapper::ReInitDlg(SwDocShell
*pDocSh
)
81 bool bRet
= SwChildWinWrapper::ReInitDlg(pDocSh
);
82 if (bRet
) // update immediately, Doc switch
84 m_pDlgInterface
->ReInitDlg();
90 void SwFieldDlgWrapper::ShowReferencePage()
92 m_pDlgInterface
->ShowReferencePage();
95 SFX_IMPL_CHILDWINDOW(SwFieldDataOnlyDlgWrapper
, FN_INSERT_FIELD_DATA_ONLY
)
97 SfxChildWinInfo
SwFieldDataOnlyDlgWrapper::GetInfo() const
99 SfxChildWinInfo aInfo
= SfxChildWindow::GetInfo();
100 // prevent instantiation of dialog other than by calling
101 // the mail merge dialog
102 aInfo
.bVisible
= false;
106 SwFieldDataOnlyDlgWrapper::SwFieldDataOnlyDlgWrapper( vcl::Window
* _pParent
, sal_uInt16 nId
,
108 SfxChildWinInfo
* pInfo
)
109 : SwChildWinWrapper( _pParent
, nId
)
111 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
112 m_pDlgInterface
= pFact
->CreateSwFieldDlg(pB
, this, _pParent
->GetFrameWeld());
114 SetController(m_pDlgInterface
->GetController());
115 m_pDlgInterface
->ActivateDatabasePage();
116 m_pDlgInterface
->StartExecuteAsync(nullptr);
117 m_pDlgInterface
->Initialize( pInfo
);
120 // re-init after doc activation
121 bool SwFieldDataOnlyDlgWrapper::ReInitDlg(SwDocShell
*pDocSh
)
123 bool bRet
= SwChildWinWrapper::ReInitDlg(pDocSh
);
124 if (bRet
) // update immediately, Doc switch
126 m_pDlgInterface
->ReInitDlg();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */