Line data Source code
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 <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>
32 :
33 : #include <helpid.h>
34 : #include <fldui.hrc>
35 : #include <globals.hrc>
36 : #include "swabstdlg.hxx"
37 :
38 37231 : SFX_IMPL_CHILDWINDOW_WITHID(SwFieldDlgWrapper, FN_INSERT_FIELD)
39 :
40 0 : SwChildWinWrapper::SwChildWinWrapper(vcl::Window *pParentWindow, sal_uInt16 nId) :
41 : SfxChildWindow(pParentWindow, nId),
42 0 : m_pDocSh(0)
43 : {
44 : // avoid flickering of buttons:
45 0 : m_aUpdateTimer.SetTimeout(200);
46 0 : m_aUpdateTimer.SetTimeoutHdl(LINK(this, SwChildWinWrapper, UpdateHdl));
47 0 : }
48 :
49 0 : IMPL_LINK_NOARG_TYPED(SwChildWinWrapper, UpdateHdl, Timer *, void)
50 : {
51 0 : GetWindow()->Activate(); // update dialog
52 0 : }
53 :
54 : // newly initialise dialog after Doc switch
55 0 : bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
56 : {
57 0 : bool bRet = false;
58 :
59 0 : if (m_pDocSh != GetOldDocShell())
60 : {
61 0 : m_aUpdateTimer.Stop();
62 0 : bRet = true; // immediate Update
63 : }
64 : else
65 0 : m_aUpdateTimer.Start();
66 :
67 0 : return bRet;
68 : }
69 :
70 0 : SfxChildWinInfo SwFieldDlgWrapper::GetInfo() const
71 : {
72 0 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
73 0 : aInfo.aPos = GetWindow()->OutputToAbsoluteScreenPixel(aInfo.aPos);
74 0 : return aInfo;
75 : }
76 :
77 0 : SwFieldDlgWrapper::SwFieldDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
78 : SfxBindings* pB,
79 : SfxChildWinInfo* )
80 0 : : SwChildWinWrapper( _pParent, nId )
81 : {
82 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
83 : assert(pFact && "SwAbstractDialogFactory fail!");
84 0 : AbstractSwFieldDlg* pDlg = pFact->CreateSwFieldDlg(pB, this, _pParent);
85 : assert(pDlg && "Dialog creation failed!");
86 0 : pDlgInterface = pDlg;
87 0 : pWindow = pDlg->GetWindow();
88 0 : pDlg->Start();
89 0 : eChildAlignment = SfxChildAlignment::NOALIGNMENT;
90 0 : }
91 :
92 : // newly initialise dialog after Doc switch
93 0 : bool SwFieldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
94 : {
95 : bool bRet;
96 :
97 0 : if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh))) // update immediately, Doc switch
98 : {
99 0 : pDlgInterface->ReInitDlg();
100 : }
101 :
102 0 : return bRet;
103 : }
104 :
105 0 : void SwFieldDlgWrapper::ShowReferencePage()
106 : {
107 0 : pDlgInterface->ShowReferencePage();
108 0 : }
109 :
110 59 : SFX_IMPL_CHILDWINDOW(SwFieldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
111 :
112 0 : SfxChildWinInfo SwFieldDataOnlyDlgWrapper::GetInfo() const
113 : {
114 0 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
115 : // prevent instatiation of dialog other than by calling
116 : // the mail merge dialog
117 0 : aInfo.bVisible = false;
118 0 : return aInfo;
119 : }
120 :
121 0 : SwFieldDataOnlyDlgWrapper::SwFieldDataOnlyDlgWrapper( vcl::Window* _pParent, sal_uInt16 nId,
122 : SfxBindings* pB,
123 : SfxChildWinInfo* pInfo )
124 0 : : SwChildWinWrapper( _pParent, nId )
125 : {
126 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
127 : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
128 :
129 0 : AbstractSwFieldDlg* pDlg = pFact->CreateSwFieldDlg(pB, this, _pParent);
130 : OSL_ENSURE(pDlg, "Dialog creation failed!");
131 0 : pDlgInterface = pDlg;
132 :
133 0 : pWindow = pDlg->GetWindow();
134 0 : pDlg->ActivateDatabasePage();
135 0 : pDlg->Start();
136 0 : pDlg->Initialize( pInfo );
137 0 : eChildAlignment = SfxChildAlignment::NOALIGNMENT;
138 0 : }
139 :
140 : // re-init after doc activation
141 0 : bool SwFieldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
142 : {
143 : bool bRet;
144 0 : if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh))) // update immediately, Doc switch
145 : {
146 0 : pDlgInterface->ReInitDlg();
147 : }
148 :
149 0 : return bRet;
150 177 : }
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|