1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fldwrap.cxx,v $
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"
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>
48 #include <fldwrap.hxx>
51 #include <swmodule.hxx>
60 #include <globals.hrc>
63 #include <fldtdlg.hrc>
65 #include "swabstdlg.hxx"
67 SFX_IMPL_CHILDWINDOW(SwFldDlgWrapper
, FN_INSERT_FIELD
)
69 /*--------------------------------------------------------------------
71 --------------------------------------------------------------------*/
73 SwChildWinWrapper::SwChildWinWrapper(Window
*pParentWindow
, USHORT nId
) :
74 SfxChildWindow(pParentWindow
, nId
),
77 // Flackern der Buttons vermeiden:
78 m_aUpdateTimer
.SetTimeout(200);
79 m_aUpdateTimer
.SetTimeoutHdl(LINK(this, SwChildWinWrapper
, UpdateHdl
));
82 /*--------------------------------------------------------------------
84 --------------------------------------------------------------------*/
86 IMPL_LINK( SwChildWinWrapper
, UpdateHdl
, void*, EMPTYARG
)
88 GetWindow()->Activate(); // Dialog aktualisieren
93 /*--------------------------------------------------------------------
94 Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
95 --------------------------------------------------------------------*/
97 BOOL
SwChildWinWrapper::ReInitDlg(SwDocShell
*)
101 if (m_pDocSh
!= GetOldDocShell())
103 m_aUpdateTimer
.Stop();
104 bRet
= TRUE
; // Sofortiges Update
107 m_aUpdateTimer
.Start();
112 /*--------------------------------------------------------------------
114 --------------------------------------------------------------------*/
116 SfxChildWinInfo
SwFldDlgWrapper::GetInfo() const
118 SfxChildWinInfo aInfo
= SfxChildWindow::GetInfo();
119 aInfo
.aPos
= GetWindow()->OutputToAbsoluteScreenPixel(aInfo
.aPos
);
124 /*--------------------------------------------------------------------
126 --------------------------------------------------------------------*/
128 SwFldDlgWrapper::SwFldDlgWrapper( Window
* _pParent
, USHORT nId
,
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();
141 eChildAlignment
= SFX_ALIGN_NOALIGNMENT
;
144 /*--------------------------------------------------------------------
145 Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
146 --------------------------------------------------------------------*/
148 BOOL
SwFldDlgWrapper::ReInitDlg(SwDocShell
*pDocSh
)
152 if ((bRet
= SwChildWinWrapper::ReInitDlg(pDocSh
)) == TRUE
) // Sofort aktualisieren, Dok-Wechsel
154 pDlgInterface
->ReInitDlg();
160 /*--------------------------------------------------------------------
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
;
182 /* -----------------04.02.2003 14:17-----------------
184 * --------------------------------------------------*/
185 SwFldDataOnlyDlgWrapper::SwFldDataOnlyDlgWrapper( Window
* _pParent
, USHORT nId
,
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();
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
)
209 if ((bRet
= SwChildWinWrapper::ReInitDlg(pDocSh
)) == TRUE
) // Sofort aktualisieren, Dok-Wechsel
211 pDlgInterface
->ReInitDlg();