update dev300-m58
[ooovba.git] / sw / source / ui / fldui / fldwrap.cxx
blob15d21b0c1338b109b1fa483b91c35f6b3b8db157
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fldwrap.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #ifndef _CMDID_H
37 #include <cmdid.h>
38 #endif
39 #include <swtypes.hxx>
40 #include <sfx2/basedlgs.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <svx/htmlmode.hxx>
44 #include <viewopt.hxx>
45 #ifndef _DOCSH_HXX
46 #include <docsh.hxx>
47 #endif
48 #include <fldwrap.hxx>
49 #include <wrtsh.hxx>
50 #include <view.hxx>
51 #include <swmodule.hxx>
53 #ifndef _HELPID_H
54 #include <helpid.h>
55 #endif
56 #ifndef _FLDUI_HRC
57 #include <fldui.hrc>
58 #endif
59 #ifndef _GLOBALS_HRC
60 #include <globals.hrc>
61 #endif
62 #ifndef _FLDTDLG_HRC
63 #include <fldtdlg.hrc>
64 #endif
65 #include "swabstdlg.hxx"
67 SFX_IMPL_CHILDWINDOW(SwFldDlgWrapper, FN_INSERT_FIELD)
69 /*--------------------------------------------------------------------
70 Beschreibung:
71 --------------------------------------------------------------------*/
73 SwChildWinWrapper::SwChildWinWrapper(Window *pParentWindow, USHORT nId) :
74 SfxChildWindow(pParentWindow, nId),
75 m_pDocSh(0)
77 // Flackern der Buttons vermeiden:
78 m_aUpdateTimer.SetTimeout(200);
79 m_aUpdateTimer.SetTimeoutHdl(LINK(this, SwChildWinWrapper, UpdateHdl));
82 /*--------------------------------------------------------------------
83 Beschreibung:
84 --------------------------------------------------------------------*/
86 IMPL_LINK( SwChildWinWrapper, UpdateHdl, void*, EMPTYARG )
88 GetWindow()->Activate(); // Dialog aktualisieren
90 return 0;
93 /*--------------------------------------------------------------------
94 Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
95 --------------------------------------------------------------------*/
97 BOOL SwChildWinWrapper::ReInitDlg(SwDocShell *)
99 BOOL bRet = FALSE;
101 if (m_pDocSh != GetOldDocShell())
103 m_aUpdateTimer.Stop();
104 bRet = TRUE; // Sofortiges Update
106 else
107 m_aUpdateTimer.Start();
109 return bRet;
112 /*--------------------------------------------------------------------
113 Beschreibung:
114 --------------------------------------------------------------------*/
116 SfxChildWinInfo SwFldDlgWrapper::GetInfo() const
118 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
119 aInfo.aPos = GetWindow()->OutputToAbsoluteScreenPixel(aInfo.aPos);
120 return aInfo;
124 /*--------------------------------------------------------------------
125 Beschreibung:
126 --------------------------------------------------------------------*/
128 SwFldDlgWrapper::SwFldDlgWrapper( Window* _pParent, USHORT nId,
129 SfxBindings* pB,
130 SfxChildWinInfo* )
131 : SwChildWinWrapper( _pParent, nId )
133 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
134 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
136 AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
137 DBG_ASSERT(pDlg, "Dialogdiet fail!");
138 pDlgInterface = pDlg;
139 pWindow = pDlg->GetWindow();
140 pDlg->Start();
141 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
144 /*--------------------------------------------------------------------
145 Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
146 --------------------------------------------------------------------*/
148 BOOL SwFldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
150 BOOL bRet;
152 if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == TRUE) // Sofort aktualisieren, Dok-Wechsel
154 pDlgInterface->ReInitDlg();
157 return bRet;
160 /*--------------------------------------------------------------------
161 Beschreibung:
162 --------------------------------------------------------------------*/
164 void SwFldDlgWrapper::ShowPage(USHORT nPage)
166 pDlgInterface->ShowPage(nPage ? nPage : TP_FLD_REF);
169 SFX_IMPL_CHILDWINDOW(SwFldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
171 /* -----------------04.02.2003 14:17-----------------
173 * --------------------------------------------------*/
174 SfxChildWinInfo SwFldDataOnlyDlgWrapper::GetInfo() const
176 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
177 // prevent instatiation of dialog other than by calling
178 // the mail merge dialog
179 aInfo.bVisible = FALSE;
180 return aInfo;
182 /* -----------------04.02.2003 14:17-----------------
184 * --------------------------------------------------*/
185 SwFldDataOnlyDlgWrapper::SwFldDataOnlyDlgWrapper( Window* _pParent, USHORT nId,
186 SfxBindings* pB,
187 SfxChildWinInfo* pInfo )
188 : SwChildWinWrapper( _pParent, nId )
190 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
191 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
193 AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
194 DBG_ASSERT(pDlg, "Dialogdiet fail!");
195 pDlgInterface = pDlg;
197 pWindow = pDlg->GetWindow();
198 pDlg->ActivateDatabasePage();
199 pDlg->Start();
200 pDlg->Initialize( pInfo );
201 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
203 /* -----------------04.02.2003 14:17-----------------
204 * re-init after doc activation
205 * --------------------------------------------------*/
206 BOOL SwFldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
208 BOOL bRet;
209 if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == TRUE) // Sofort aktualisieren, Dok-Wechsel
211 pDlgInterface->ReInitDlg();
214 return bRet;