Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / fldui / fldwrap.cxx
blob7ee3078a23fa15b8c282f1fe26381a46a47394df
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_aUpdateTimer("SwChildWinWrapper m_aUpdateTimer"),
32 m_pDocSh(nullptr)
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)
41 if (GetController())
42 GetController()->Activate(); // update dialog
45 // newly initialise dialog after Doc switch
46 bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
48 bool bRet = false;
50 if (m_pDocSh != GetOldDocShell())
52 m_aUpdateTimer.Stop();
53 bRet = true; // immediate Update
55 else
56 m_aUpdateTimer.Start();
58 return bRet;
61 SfxChildWinInfo SwFieldDlgWrapper::GetInfo() const
63 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
64 return aInfo;
67 SwFieldDlgWrapper::SwFieldDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
68 SfxBindings* pB,
69 SfxChildWinInfo* )
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();
87 return bRet;
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;
103 return aInfo;
106 SwFieldDataOnlyDlgWrapper::SwFieldDataOnlyDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
107 SfxBindings* pB,
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();
129 return bRet;
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */