xref: /aoo41x/main/sw/source/ui/fldui/fldwrap.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 
29 #ifndef _CMDID_H
30 #include <cmdid.h>
31 #endif
32 #include <swtypes.hxx>
33 #include <sfx2/basedlgs.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <svx/htmlmode.hxx>
37 #include <viewopt.hxx>
38 #ifndef _DOCSH_HXX
39 #include <docsh.hxx>
40 #endif
41 #include <fldwrap.hxx>
42 #include <wrtsh.hxx>
43 #include <view.hxx>
44 #include <swmodule.hxx>
45 
46 #ifndef _HELPID_H
47 #include <helpid.h>
48 #endif
49 #ifndef _FLDUI_HRC
50 #include <fldui.hrc>
51 #endif
52 #ifndef _GLOBALS_HRC
53 #include <globals.hrc>
54 #endif
55 #ifndef _FLDTDLG_HRC
56 #include <fldtdlg.hrc>
57 #endif
58 #include "swabstdlg.hxx"
59 
SFX_IMPL_CHILDWINDOW(SwFldDlgWrapper,FN_INSERT_FIELD)60 SFX_IMPL_CHILDWINDOW(SwFldDlgWrapper, FN_INSERT_FIELD)
61 
62 /*--------------------------------------------------------------------
63 	Beschreibung:
64  --------------------------------------------------------------------*/
65 
66 SwChildWinWrapper::SwChildWinWrapper(Window *pParentWindow, sal_uInt16 nId) :
67 		SfxChildWindow(pParentWindow, nId),
68         m_pDocSh(0)
69 {
70 	// Flackern der Buttons vermeiden:
71     m_aUpdateTimer.SetTimeout(200);
72     m_aUpdateTimer.SetTimeoutHdl(LINK(this, SwChildWinWrapper, UpdateHdl));
73 }
74 
75 /*--------------------------------------------------------------------
76 	Beschreibung:
77  --------------------------------------------------------------------*/
78 
IMPL_LINK(SwChildWinWrapper,UpdateHdl,void *,EMPTYARG)79 IMPL_LINK( SwChildWinWrapper, UpdateHdl, void*, EMPTYARG )
80 {
81 	GetWindow()->Activate();	// Dialog aktualisieren
82 
83 	return 0;
84 }
85 
86 /*--------------------------------------------------------------------
87 	Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
88  --------------------------------------------------------------------*/
89 
ReInitDlg(SwDocShell *)90 sal_Bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
91 {
92 	sal_Bool bRet = sal_False;
93 
94     if (m_pDocSh != GetOldDocShell())
95 	{
96         m_aUpdateTimer.Stop();
97 		bRet = sal_True;			// Sofortiges Update
98 	}
99 	else
100         m_aUpdateTimer.Start();
101 
102 	return bRet;
103 }
104 
105 /*--------------------------------------------------------------------
106 	Beschreibung:
107  --------------------------------------------------------------------*/
108 
GetInfo() const109 SfxChildWinInfo SwFldDlgWrapper::GetInfo() const
110 {
111     SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
112     aInfo.aPos = GetWindow()->OutputToAbsoluteScreenPixel(aInfo.aPos);
113     return aInfo;
114 }
115 
116 
117 /*--------------------------------------------------------------------
118 	Beschreibung:
119  --------------------------------------------------------------------*/
120 
SwFldDlgWrapper(Window * _pParent,sal_uInt16 nId,SfxBindings * pB,SfxChildWinInfo *)121 SwFldDlgWrapper::SwFldDlgWrapper( Window* _pParent, sal_uInt16 nId,
122 									SfxBindings* pB,
123                                     SfxChildWinInfo*  )
124     : SwChildWinWrapper( _pParent, nId )
125 {
126     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
127     DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
128 
129 	AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
130     DBG_ASSERT(pDlg, "Dialogdiet fail!");
131 	pDlgInterface = pDlg;
132 	pWindow = pDlg->GetWindow();
133 	pDlg->Start();
134 	eChildAlignment = SFX_ALIGN_NOALIGNMENT;
135 }
136 
137 /*--------------------------------------------------------------------
138 	Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
139  --------------------------------------------------------------------*/
140 
ReInitDlg(SwDocShell * pDocSh)141 sal_Bool SwFldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
142 {
143 	sal_Bool bRet;
144 
145 	if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True)	// Sofort aktualisieren, Dok-Wechsel
146 	{
147         pDlgInterface->ReInitDlg();
148 	}
149 
150 	return bRet;
151 }
152 
153 /*--------------------------------------------------------------------
154 	Beschreibung:
155  --------------------------------------------------------------------*/
156 
ShowPage(sal_uInt16 nPage)157 void SwFldDlgWrapper::ShowPage(sal_uInt16 nPage)
158 {
159     pDlgInterface->ShowPage(nPage ? nPage : TP_FLD_REF);
160 }
161 
SFX_IMPL_CHILDWINDOW(SwFldDataOnlyDlgWrapper,FN_INSERT_FIELD_DATA_ONLY)162 SFX_IMPL_CHILDWINDOW(SwFldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
163 
164 /* -----------------04.02.2003 14:17-----------------
165  *
166  * --------------------------------------------------*/
167 SfxChildWinInfo SwFldDataOnlyDlgWrapper::GetInfo() const
168 {
169     SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
170 // prevent instatiation of dialog other than by calling
171 // the mail merge dialog
172     aInfo.bVisible = sal_False;
173     return aInfo;
174 }
175 /* -----------------04.02.2003 14:17-----------------
176  *
177  * --------------------------------------------------*/
SwFldDataOnlyDlgWrapper(Window * _pParent,sal_uInt16 nId,SfxBindings * pB,SfxChildWinInfo * pInfo)178 SwFldDataOnlyDlgWrapper::SwFldDataOnlyDlgWrapper( Window* _pParent, sal_uInt16 nId,
179                                     SfxBindings* pB,
180                                     SfxChildWinInfo* pInfo )
181     : SwChildWinWrapper( _pParent, nId )
182 {
183     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
184     DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
185 
186 	AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
187     DBG_ASSERT(pDlg, "Dialogdiet fail!");
188     pDlgInterface = pDlg;
189 
190     pWindow = pDlg->GetWindow();
191 	pDlg->ActivateDatabasePage();
192     pDlg->Start();
193     pDlg->Initialize( pInfo );
194     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
195 }
196 /* -----------------04.02.2003 14:17-----------------
197  * re-init after doc activation
198  * --------------------------------------------------*/
ReInitDlg(SwDocShell * pDocSh)199 sal_Bool SwFldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
200 {
201     sal_Bool bRet;
202     if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True)  // Sofort aktualisieren, Dok-Wechsel
203 	{
204         pDlgInterface->ReInitDlg();
205 	}
206 
207     return bRet;
208 }
209