bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / fldui / fldwrap.cxx
blobc1c5f77aa6a831b40816e4a04f5c24eb452cd4a2
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 <swtypes.hxx>
22 #include <sfx2/basedlgs.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <vcl/msgbox.hxx>
25 #include <sfx2/htmlmode.hxx>
26 #include <viewopt.hxx>
27 #include <docsh.hxx>
28 #include <fldwrap.hxx>
29 #include <wrtsh.hxx>
30 #include <view.hxx>
31 #include <swmodule.hxx>
33 #include <helpid.h>
34 #include <fldui.hrc>
35 #include <globals.hrc>
36 #include <fldtdlg.hrc>
37 #include "swabstdlg.hxx"
39 SFX_IMPL_CHILDWINDOW_WITHID(SwFldDlgWrapper, FN_INSERT_FIELD)
41 SwChildWinWrapper::SwChildWinWrapper(Window *pParentWindow, sal_uInt16 nId) :
42 SfxChildWindow(pParentWindow, nId),
43 m_pDocSh(0)
45 // avoid flickering of buttons:
46 m_aUpdateTimer.SetTimeout(200);
47 m_aUpdateTimer.SetTimeoutHdl(LINK(this, SwChildWinWrapper, UpdateHdl));
50 IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl)
52 GetWindow()->Activate(); // update dialog
54 return 0;
57 /*--------------------------------------------------------------------
58 Description: newly initialise dialog after Doc switch
59 --------------------------------------------------------------------*/
60 sal_Bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
62 sal_Bool bRet = sal_False;
64 if (m_pDocSh != GetOldDocShell())
66 m_aUpdateTimer.Stop();
67 bRet = sal_True; // immediate Update
69 else
70 m_aUpdateTimer.Start();
72 return bRet;
75 SfxChildWinInfo SwFldDlgWrapper::GetInfo() const
77 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
78 aInfo.aPos = GetWindow()->OutputToAbsoluteScreenPixel(aInfo.aPos);
79 return aInfo;
82 SwFldDlgWrapper::SwFldDlgWrapper( Window* _pParent, sal_uInt16 nId,
83 SfxBindings* pB,
84 SfxChildWinInfo* )
85 : SwChildWinWrapper( _pParent, nId )
87 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
88 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
90 AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
91 OSL_ENSURE(pDlg, "Dialogdiet fail!");
92 pDlgInterface = pDlg;
93 pWindow = pDlg->GetWindow();
94 pDlg->Start();
95 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
98 /*--------------------------------------------------------------------
99 Description: newly initialise dialog after Doc switch
100 --------------------------------------------------------------------*/
101 sal_Bool SwFldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
103 sal_Bool bRet;
105 if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, Doc switch
107 pDlgInterface->ReInitDlg();
110 return bRet;
113 void SwFldDlgWrapper::ShowPage(sal_uInt16 nPage)
115 pDlgInterface->ShowPage(nPage ? nPage : TP_FLD_REF);
118 SFX_IMPL_CHILDWINDOW(SwFldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
120 SfxChildWinInfo SwFldDataOnlyDlgWrapper::GetInfo() const
122 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
123 // prevent instatiation of dialog other than by calling
124 // the mail merge dialog
125 aInfo.bVisible = sal_False;
126 return aInfo;
129 SwFldDataOnlyDlgWrapper::SwFldDataOnlyDlgWrapper( Window* _pParent, sal_uInt16 nId,
130 SfxBindings* pB,
131 SfxChildWinInfo* pInfo )
132 : SwChildWinWrapper( _pParent, nId )
134 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
135 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
137 AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
138 OSL_ENSURE(pDlg, "Dialogdiet fail!");
139 pDlgInterface = pDlg;
141 pWindow = pDlg->GetWindow();
142 pDlg->ActivateDatabasePage();
143 pDlg->Start();
144 pDlg->Initialize( pInfo );
145 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
148 /* --------------------------------------------------
149 * re-init after doc activation
150 * --------------------------------------------------*/
151 sal_Bool SwFldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
153 sal_Bool bRet;
154 if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, Doc switch
156 pDlgInterface->ReInitDlg();
159 return bRet;
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */