xref: /AOO41X/main/sw/source/ui/app/apphdl.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <hintids.hxx>
32*cdf0e10cSrcweir #include <tools/urlobj.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <tools/debug.hxx>
35*cdf0e10cSrcweir #include <tools/link.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
38*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
39*cdf0e10cSrcweir #include <svl/urihelper.hxx>
40*cdf0e10cSrcweir #include <unotools/undoopt.hxx>
41*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
42*cdf0e10cSrcweir #include <svtools/accessibilityoptions.hxx>
43*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
44*cdf0e10cSrcweir #include <sfx2/event.hxx>
45*cdf0e10cSrcweir #include <sfx2/objitem.hxx>
46*cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx>
47*cdf0e10cSrcweir #include <svl/srchitem.hxx>
48*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
49*cdf0e10cSrcweir #include <svl/eitem.hxx>
50*cdf0e10cSrcweir #include <svl/whiter.hxx>
51*cdf0e10cSrcweir #include <svl/isethint.hxx>
52*cdf0e10cSrcweir #include <svx/hyprlink.hxx>
53*cdf0e10cSrcweir #include <sfx2/request.hxx>
54*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
55*cdf0e10cSrcweir #include <svl/stritem.hxx>
56*cdf0e10cSrcweir #include <svl/ctloptions.hxx>
57*cdf0e10cSrcweir #include <unotools/useroptions.hxx>
58*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
59*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
60*cdf0e10cSrcweir #include <svx/insctrl.hxx>
61*cdf0e10cSrcweir #include <svx/selctrl.hxx>
62*cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp>
63*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
64*cdf0e10cSrcweir #include <svx/xmlsecctrl.hxx>
65*cdf0e10cSrcweir #include <navicfg.hxx>
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir #include <sfx2/objface.hxx>
68*cdf0e10cSrcweir #include <sfx2/app.hxx>
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #include <view.hxx>
71*cdf0e10cSrcweir #include <pview.hxx>
72*cdf0e10cSrcweir #include <srcview.hxx>
73*cdf0e10cSrcweir #include <wrtsh.hxx>
74*cdf0e10cSrcweir #include <docsh.hxx>
75*cdf0e10cSrcweir #include <cmdid.h>		  	// Funktion-Ids
76*cdf0e10cSrcweir #include <initui.hxx>
77*cdf0e10cSrcweir #include <uitool.hxx>
78*cdf0e10cSrcweir #include <swmodule.hxx>
79*cdf0e10cSrcweir #include <wdocsh.hxx>
80*cdf0e10cSrcweir #include <wview.hxx>
81*cdf0e10cSrcweir #include <usrpref.hxx>
82*cdf0e10cSrcweir #include <gloslst.hxx>      // SwGlossaryList
83*cdf0e10cSrcweir #include <glosdoc.hxx>      // SwGlossaryList
84*cdf0e10cSrcweir #include <doc.hxx>
85*cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
86*cdf0e10cSrcweir #include <cfgitems.hxx>
87*cdf0e10cSrcweir #include <prtopt.hxx>
88*cdf0e10cSrcweir #include <modcfg.hxx>
89*cdf0e10cSrcweir #include <globals.h>		// globale Konstanten z.B.
90*cdf0e10cSrcweir #include <app.hrc>
91*cdf0e10cSrcweir #include <fontcfg.hxx>
92*cdf0e10cSrcweir #include <barcfg.hxx>
93*cdf0e10cSrcweir #include <uinums.hxx>
94*cdf0e10cSrcweir #include <dbconfig.hxx>
95*cdf0e10cSrcweir #include <mmconfigitem.hxx>
96*cdf0e10cSrcweir #include <mailmergechildwindow.hxx>
97*cdf0e10cSrcweir #include <linguistic/lngprops.hxx>
98*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
99*cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp>
100*cdf0e10cSrcweir #include <com/sun/star/beans/XFastPropertySet.hpp>
101*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
102*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
103*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
104*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp>
105*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp>
106*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
107*cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
108*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp>
109*cdf0e10cSrcweir #include <swabstdlg.hxx>
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir #include <vcl/status.hxx>
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir #include "salhelper/simplereferenceobject.hxx"
115*cdf0e10cSrcweir #include "rtl/ref.hxx"
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir #include <unomid.h>
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir using namespace ::com::sun::star;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir /*--------------------------------------------------------------------
122*cdf0e10cSrcweir 	Beschreibung: Slotmaps fuer Methoden der Applikation
123*cdf0e10cSrcweir  --------------------------------------------------------------------*/
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir // hier werden die SlotID's included
127*cdf0e10cSrcweir // siehe Idl-File
128*cdf0e10cSrcweir //
129*cdf0e10cSrcweir #define SwModule
130*cdf0e10cSrcweir #define ViewSettings
131*cdf0e10cSrcweir #define WebViewSettings
132*cdf0e10cSrcweir #define PrintSettings
133*cdf0e10cSrcweir #define _ExecAddress ExecOther
134*cdf0e10cSrcweir #define _StateAddress StateOther
135*cdf0e10cSrcweir #include <sfx2/msg.hxx>
136*cdf0e10cSrcweir #include "swslots.hxx"
137*cdf0e10cSrcweir #include <cfgid.h>
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir #include <shells.hrc>
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir SFX_IMPL_INTERFACE( SwModule, SfxModule, SW_RES(RID_SW_NAME) )
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SvxHyperlinkDlgWrapper::GetChildWindowId());
144*cdf0e10cSrcweir 	SFX_STATUSBAR_REGISTRATION(SW_RES(CFG_STATUSBAR));
145*cdf0e10cSrcweir     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION |
146*cdf0e10cSrcweir             SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER,
147*cdf0e10cSrcweir             SW_RES(RID_MODULE_TOOLBOX) );
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir /*--------------------------------------------------------------------
152*cdf0e10cSrcweir 	Beschreibung: Andere States
153*cdf0e10cSrcweir  --------------------------------------------------------------------*/
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir void SwModule::StateOther(SfxItemSet &rSet)
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
159*cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	SwView* pActView = ::GetActiveView();
162*cdf0e10cSrcweir 	sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pActView);
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 	while(nWhich)
165*cdf0e10cSrcweir 	{
166*cdf0e10cSrcweir 		switch(nWhich)
167*cdf0e10cSrcweir 		{
168*cdf0e10cSrcweir 			case FN_BUSINESS_CARD:
169*cdf0e10cSrcweir 			case FN_LABEL:
170*cdf0e10cSrcweir 			case FN_ENVELOP:
171*cdf0e10cSrcweir 			{
172*cdf0e10cSrcweir 				sal_Bool bDisable = sal_False;
173*cdf0e10cSrcweir                 SfxViewShell* pCurrView = SfxViewShell::Current();
174*cdf0e10cSrcweir                 if( !pCurrView || (pCurrView && !pCurrView->ISA(SwView)) )
175*cdf0e10cSrcweir 					bDisable = sal_True;
176*cdf0e10cSrcweir 				SwDocShell *pDocSh = (SwDocShell*) SfxObjectShell::Current();
177*cdf0e10cSrcweir 				if ( bDisable ||
178*cdf0e10cSrcweir 					(pDocSh &&    (pDocSh->IsReadOnly() ||
179*cdf0e10cSrcweir 								  pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)) )
180*cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 			}
183*cdf0e10cSrcweir 			break;
184*cdf0e10cSrcweir             case FN_XFORMS_INIT:
185*cdf0e10cSrcweir                 // slot is always active!
186*cdf0e10cSrcweir                 break;
187*cdf0e10cSrcweir 			case FN_EDIT_FORMULA:
188*cdf0e10cSrcweir 				{
189*cdf0e10cSrcweir 					SwWrtShell* pSh = 0;
190*cdf0e10cSrcweir 					int nSelection = 0;
191*cdf0e10cSrcweir 					if( pActView )
192*cdf0e10cSrcweir 						pSh = &pActView->GetWrtShell();
193*cdf0e10cSrcweir 					if( pSh )
194*cdf0e10cSrcweir 						nSelection = pSh->GetSelectionType();
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 					if( (pSh && pSh->HasSelection()) ||
197*cdf0e10cSrcweir 						!(nSelection & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL)))
198*cdf0e10cSrcweir 						rSet.DisableItem(nWhich);
199*cdf0e10cSrcweir 				}
200*cdf0e10cSrcweir 			break;
201*cdf0e10cSrcweir 			case SID_ATTR_METRIC:
202*cdf0e10cSrcweir                 rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, static_cast< sal_uInt16 >(::GetDfltMetric(bWebView))));
203*cdf0e10cSrcweir 			break;
204*cdf0e10cSrcweir 			case FN_SET_MODOPT_TBLNUMFMT:
205*cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, pModuleConfig->
206*cdf0e10cSrcweir 											IsInsTblFormatNum( bWebView )));
207*cdf0e10cSrcweir 			break;
208*cdf0e10cSrcweir             default:
209*cdf0e10cSrcweir 				DBG_ERROR("::StateOther: default");
210*cdf0e10cSrcweir 		}
211*cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
212*cdf0e10cSrcweir 	}
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir /*-- 06.04.2004 15:21:43---------------------------------------------------
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
218*cdf0e10cSrcweir SwView* lcl_LoadDoc(SwView* pView, const String& rURL)
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir     SwView* pNewView = 0;
221*cdf0e10cSrcweir     if(rURL.Len())
222*cdf0e10cSrcweir     {
223*cdf0e10cSrcweir         SfxStringItem aURL(SID_FILE_NAME, rURL);
224*cdf0e10cSrcweir         SfxStringItem aTargetFrameName( SID_TARGETNAME, String::CreateFromAscii("_blank") );
225*cdf0e10cSrcweir         SfxBoolItem aHidden( SID_HIDDEN, sal_True );
226*cdf0e10cSrcweir         SfxStringItem aReferer(SID_REFERER, pView->GetDocShell()->GetTitle());
227*cdf0e10cSrcweir         SfxObjectItem* pItem = (SfxObjectItem*)pView->GetViewFrame()->GetDispatcher()->
228*cdf0e10cSrcweir                 Execute(SID_OPENDOC, SFX_CALLMODE_SYNCHRON,
229*cdf0e10cSrcweir                             &aURL, &aHidden, &aReferer, &aTargetFrameName, 0L);
230*cdf0e10cSrcweir         SfxShell* pShell = pItem ? pItem->GetShell() : 0;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir         if(pShell)
233*cdf0e10cSrcweir         {
234*cdf0e10cSrcweir             SfxViewShell* pViewShell = pShell->GetViewShell();
235*cdf0e10cSrcweir             if(pViewShell)
236*cdf0e10cSrcweir             {
237*cdf0e10cSrcweir                 if( pViewShell->ISA(SwView) )
238*cdf0e10cSrcweir                 {
239*cdf0e10cSrcweir                     pNewView = PTR_CAST(SwView,pViewShell);
240*cdf0e10cSrcweir                     pNewView->GetViewFrame()->GetFrame().Appear();
241*cdf0e10cSrcweir                 }
242*cdf0e10cSrcweir                 else
243*cdf0e10cSrcweir                 {
244*cdf0e10cSrcweir                     pViewShell->GetViewFrame()->DoClose();
245*cdf0e10cSrcweir                 }
246*cdf0e10cSrcweir             }
247*cdf0e10cSrcweir         }
248*cdf0e10cSrcweir     }
249*cdf0e10cSrcweir     else
250*cdf0e10cSrcweir     {
251*cdf0e10cSrcweir         SfxStringItem aFactory(SID_NEWDOCDIRECT, SwDocShell::Factory().GetFilterContainer()->GetName());
252*cdf0e10cSrcweir         const SfxFrameItem* pItem = (SfxFrameItem*)
253*cdf0e10cSrcweir                             pView->GetViewFrame()->GetDispatcher()->Execute(SID_NEWDOCDIRECT,
254*cdf0e10cSrcweir                                 SFX_CALLMODE_SYNCHRON, &aFactory, 0L);
255*cdf0e10cSrcweir         SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0;
256*cdf0e10cSrcweir         SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0;
257*cdf0e10cSrcweir         pNewView = pFrame ? PTR_CAST(SwView, pFrame->GetViewShell()) : 0;
258*cdf0e10cSrcweir     }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir     return pNewView;
261*cdf0e10cSrcweir }
262*cdf0e10cSrcweir /*--------------------------------------------------------------------
263*cdf0e10cSrcweir 	Beschreibung:	Felddialog starten
264*cdf0e10cSrcweir  --------------------------------------------------------------------*/
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir void NewXForms( SfxRequest& rReq ); // implementation: below
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir namespace
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir class SwMailMergeWizardExecutor : public salhelper::SimpleReferenceObject
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     SwView*                  m_pView;    	// never owner
274*cdf0e10cSrcweir     SwView*                  m_pView2Close; // never owner
275*cdf0e10cSrcweir     SwMailMergeConfigItem*   m_pMMConfig; 	// sometimes owner
276*cdf0e10cSrcweir     AbstractMailMergeWizard* m_pWizard;   	// always owner
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     DECL_LINK( EndDialogHdl, AbstractMailMergeWizard* );
279*cdf0e10cSrcweir     DECL_LINK( DestroyDialogHdl, AbstractMailMergeWizard* );
280*cdf0e10cSrcweir     DECL_LINK( DestroyWizardHdl, AbstractMailMergeWizard* );
281*cdf0e10cSrcweir     DECL_LINK( CancelHdl, AbstractMailMergeWizard* );
282*cdf0e10cSrcweir     DECL_LINK( CloseFrameHdl, AbstractMailMergeWizard* );
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     void ExecutionFinished( bool bDeleteConfigItem );
285*cdf0e10cSrcweir     void ExecuteWizard();
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir public:
288*cdf0e10cSrcweir     SwMailMergeWizardExecutor();
289*cdf0e10cSrcweir     ~SwMailMergeWizardExecutor();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     void ExecuteMailMergeWizard( const SfxItemSet * pArgs );
292*cdf0e10cSrcweir };
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir SwMailMergeWizardExecutor::SwMailMergeWizardExecutor()
295*cdf0e10cSrcweir     : m_pView( 0 ),
296*cdf0e10cSrcweir 	  m_pView2Close( NULL ),
297*cdf0e10cSrcweir       m_pMMConfig( 0 ),
298*cdf0e10cSrcweir       m_pWizard( 0 )
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir SwMailMergeWizardExecutor::~SwMailMergeWizardExecutor()
303*cdf0e10cSrcweir {
304*cdf0e10cSrcweir     DBG_ASSERT( m_pWizard == 0, "SwMailMergeWizardExecutor: m_pWizard must be Null!" );
305*cdf0e10cSrcweir     DBG_ASSERT( m_pMMConfig == 0, "SwMailMergeWizardExecutor: m_pMMConfig must be Null!" );
306*cdf0e10cSrcweir }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs )
309*cdf0e10cSrcweir {
310*cdf0e10cSrcweir     if ( m_pView )
311*cdf0e10cSrcweir     {
312*cdf0e10cSrcweir         DBG_ERROR( "SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already executing the wizard!" );
313*cdf0e10cSrcweir         return;
314*cdf0e10cSrcweir     }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     m_pView = ::GetActiveView(); // not owner!
317*cdf0e10cSrcweir     DBG_ASSERT(m_pView, "no current view?");
318*cdf0e10cSrcweir     if(m_pView)
319*cdf0e10cSrcweir     {
320*cdf0e10cSrcweir         // keep self alive until done.
321*cdf0e10cSrcweir         acquire();
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir         // if called from the child window - get the config item and close the ChildWindow, then restore
324*cdf0e10cSrcweir         // the wizard
325*cdf0e10cSrcweir         SwMailMergeChildWindow* pChildWin =
326*cdf0e10cSrcweir             static_cast<SwMailMergeChildWindow*>(m_pView->GetViewFrame()->GetChildWindow(FN_MAILMERGE_CHILDWINDOW));
327*cdf0e10cSrcweir         bool bRestoreWizard = false;
328*cdf0e10cSrcweir         sal_uInt16 nRestartPage = 0;
329*cdf0e10cSrcweir         if(pChildWin && pChildWin->IsVisible())
330*cdf0e10cSrcweir         {
331*cdf0e10cSrcweir             m_pMMConfig = m_pView->GetMailMergeConfigItem();
332*cdf0e10cSrcweir             nRestartPage = m_pView->GetMailMergeRestartPage();
333*cdf0e10cSrcweir             if(m_pView->IsMailMergeSourceView())
334*cdf0e10cSrcweir                 m_pMMConfig->SetSourceView( m_pView );
335*cdf0e10cSrcweir             m_pView->SetMailMergeConfigItem(0, 0, sal_True);
336*cdf0e10cSrcweir             SfxViewFrame* pViewFrame = m_pView->GetViewFrame();
337*cdf0e10cSrcweir             pViewFrame->ShowChildWindow(FN_MAILMERGE_CHILDWINDOW, sal_False);
338*cdf0e10cSrcweir             DBG_ASSERT(m_pMMConfig, "no MailMergeConfigItem available");
339*cdf0e10cSrcweir             bRestoreWizard = true;
340*cdf0e10cSrcweir         }
341*cdf0e10cSrcweir         // to make it bullet proof ;-)
342*cdf0e10cSrcweir         if(!m_pMMConfig)
343*cdf0e10cSrcweir         {
344*cdf0e10cSrcweir             m_pMMConfig = new SwMailMergeConfigItem;
345*cdf0e10cSrcweir             m_pMMConfig->SetSourceView(m_pView);
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir             //set the first used database as default source on the config item
348*cdf0e10cSrcweir             const SfxPoolItem* pItem = 0;
349*cdf0e10cSrcweir             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(
350*cdf0e10cSrcweir                    FN_PARAM_DATABASE_PROPERTIES, sal_False, &pItem))
351*cdf0e10cSrcweir             {
352*cdf0e10cSrcweir                 //mailmerge has been called from the database beamer
353*cdf0e10cSrcweir                 uno::Sequence< beans::PropertyValue> aDBValues;
354*cdf0e10cSrcweir                 if(static_cast<const SfxUsrAnyItem*>(pItem)->GetValue() >>= aDBValues)
355*cdf0e10cSrcweir                 {
356*cdf0e10cSrcweir                     SwDBData aDBData;
357*cdf0e10cSrcweir                     svx::ODataAccessDescriptor aDescriptor(aDBValues);
358*cdf0e10cSrcweir                     aDescriptor[svx::daDataSource]   >>= aDBData.sDataSource;
359*cdf0e10cSrcweir                     aDescriptor[svx::daCommand]      >>= aDBData.sCommand;
360*cdf0e10cSrcweir                     aDescriptor[svx::daCommandType]  >>= aDBData.nCommandType;
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir                     uno::Sequence< uno::Any >                   aSelection;
363*cdf0e10cSrcweir                     uno::Reference< sdbc::XConnection>          xConnection;
364*cdf0e10cSrcweir                     uno::Reference< sdbc::XDataSource>          xSource;
365*cdf0e10cSrcweir                     uno::Reference< sdbcx::XColumnsSupplier>    xColumnsSupplier;
366*cdf0e10cSrcweir                     if ( aDescriptor.has(svx::daSelection) )
367*cdf0e10cSrcweir                         aDescriptor[svx::daSelection] >>= aSelection;
368*cdf0e10cSrcweir                     if ( aDescriptor.has(svx::daConnection) )
369*cdf0e10cSrcweir                         aDescriptor[svx::daConnection] >>= xConnection;
370*cdf0e10cSrcweir                     uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY);
371*cdf0e10cSrcweir                     if(xChild.is())
372*cdf0e10cSrcweir                         xSource = uno::Reference<sdbc::XDataSource>(
373*cdf0e10cSrcweir                             xChild->getParent(), uno::UNO_QUERY);
374*cdf0e10cSrcweir                     m_pMMConfig->SetCurrentConnection(
375*cdf0e10cSrcweir                         xSource, SharedConnection( xConnection, SharedConnection::NoTakeOwnership ),
376*cdf0e10cSrcweir                         xColumnsSupplier, aDBData);
377*cdf0e10cSrcweir                 }
378*cdf0e10cSrcweir             }
379*cdf0e10cSrcweir             else
380*cdf0e10cSrcweir             {
381*cdf0e10cSrcweir                 SvStringsDtor aDBNameList(5, 1);
382*cdf0e10cSrcweir                 SvStringsDtor aAllDBNames(5, 5);
383*cdf0e10cSrcweir                 m_pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames );
384*cdf0e10cSrcweir                 if(aDBNameList.Count())
385*cdf0e10cSrcweir                 {
386*cdf0e10cSrcweir                     String sDBName = *aDBNameList[0];
387*cdf0e10cSrcweir                     SwDBData aDBData;
388*cdf0e10cSrcweir                     aDBData.sDataSource = sDBName.GetToken(0, DB_DELIM);
389*cdf0e10cSrcweir                     aDBData.sCommand = sDBName.GetToken(1, DB_DELIM);
390*cdf0e10cSrcweir                     aDBData.nCommandType = sDBName.GetToken(2, DB_DELIM ).ToInt32();
391*cdf0e10cSrcweir                     //set the currently used database for the wizard
392*cdf0e10cSrcweir                     m_pMMConfig->SetCurrentDBData( aDBData );
393*cdf0e10cSrcweir                 }
394*cdf0e10cSrcweir             }
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
398*cdf0e10cSrcweir         m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig);
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir         if(bRestoreWizard)
401*cdf0e10cSrcweir         {
402*cdf0e10cSrcweir             m_pWizard->ShowPage( nRestartPage );
403*cdf0e10cSrcweir         }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir         ExecuteWizard();
406*cdf0e10cSrcweir     }
407*cdf0e10cSrcweir }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir void SwMailMergeWizardExecutor::ExecutionFinished( bool bDeleteConfigItem )
410*cdf0e10cSrcweir {
411*cdf0e10cSrcweir     m_pMMConfig->Commit();
412*cdf0e10cSrcweir     if ( bDeleteConfigItem ) // owner?
413*cdf0e10cSrcweir         delete m_pMMConfig;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir     m_pMMConfig = 0;
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     // release/destroy asynchronously
418*cdf0e10cSrcweir     Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) );
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir void SwMailMergeWizardExecutor::ExecuteWizard()
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir     m_pWizard->StartExecuteModal(
424*cdf0e10cSrcweir         LINK( this, SwMailMergeWizardExecutor, EndDialogHdl ) );
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
428*cdf0e10cSrcweir IMPL_LINK( SwMailMergeWizardExecutor, EndDialogHdl, AbstractMailMergeWizard*, pDialog )
429*cdf0e10cSrcweir #else
430*cdf0e10cSrcweir IMPL_LINK( SwMailMergeWizardExecutor, EndDialogHdl, AbstractMailMergeWizard*, EMPTYARG )
431*cdf0e10cSrcweir #endif
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
434*cdf0e10cSrcweir     DBG_ASSERT( pDialog == m_pWizard, "wrong dialog passed to EndDialogHdl!" );
435*cdf0e10cSrcweir     (void) pDialog;
436*cdf0e10cSrcweir #endif
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir     long nRet = m_pWizard->GetResult();
439*cdf0e10cSrcweir     sal_uInt16 nRestartPage = m_pWizard->GetRestartPage();
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     switch ( nRet )
442*cdf0e10cSrcweir     {
443*cdf0e10cSrcweir     case RET_LOAD_DOC:
444*cdf0e10cSrcweir         {
445*cdf0e10cSrcweir             SwView* pNewView = lcl_LoadDoc(m_pView, m_pWizard->GetReloadDocument());
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir             // destroy wizard asynchronously
448*cdf0e10cSrcweir             Application::PostUserEvent(
449*cdf0e10cSrcweir                 LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard );
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
452*cdf0e10cSrcweir             if(pNewView)
453*cdf0e10cSrcweir             {
454*cdf0e10cSrcweir                 m_pView = pNewView;
455*cdf0e10cSrcweir                 m_pMMConfig->DocumentReloaded();
456*cdf0e10cSrcweir                 //new source view!
457*cdf0e10cSrcweir                 m_pMMConfig->SetSourceView( m_pView );
458*cdf0e10cSrcweir                 m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig);
459*cdf0e10cSrcweir                 m_pWizard->ShowPage( nRestartPage );
460*cdf0e10cSrcweir             }
461*cdf0e10cSrcweir             else
462*cdf0e10cSrcweir             {
463*cdf0e10cSrcweir                 m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *m_pMMConfig);
464*cdf0e10cSrcweir             }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir             // execute the wizard again
467*cdf0e10cSrcweir             ExecuteWizard();
468*cdf0e10cSrcweir             break;
469*cdf0e10cSrcweir         }
470*cdf0e10cSrcweir     case RET_TARGET_CREATED:
471*cdf0e10cSrcweir         {
472*cdf0e10cSrcweir             SwView* pTargetView = m_pMMConfig->GetTargetView();
473*cdf0e10cSrcweir             uno::Reference< frame::XFrame > xFrame =
474*cdf0e10cSrcweir                 m_pView->GetViewFrame()->GetFrame().GetFrameInterface();
475*cdf0e10cSrcweir             xFrame->getContainerWindow()->setVisible(sal_False);
476*cdf0e10cSrcweir             DBG_ASSERT(pTargetView, "No target view has been created");
477*cdf0e10cSrcweir             if(pTargetView)
478*cdf0e10cSrcweir             {
479*cdf0e10cSrcweir                 // destroy wizard asynchronously
480*cdf0e10cSrcweir                 Application::PostUserEvent(
481*cdf0e10cSrcweir                     LINK( this, SwMailMergeWizardExecutor, DestroyWizardHdl ), m_pWizard );
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
484*cdf0e10cSrcweir                 m_pWizard = pFact->CreateMailMergeWizard(*pTargetView, *m_pMMConfig);
485*cdf0e10cSrcweir                 m_pWizard->ShowPage( nRestartPage );
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir                 // execute the wizard again
488*cdf0e10cSrcweir                 ExecuteWizard();
489*cdf0e10cSrcweir             }
490*cdf0e10cSrcweir             else
491*cdf0e10cSrcweir             {
492*cdf0e10cSrcweir                 //should not happen - just in case no target view has been created
493*cdf0e10cSrcweir                 ExecutionFinished( true );
494*cdf0e10cSrcweir             }
495*cdf0e10cSrcweir             break;
496*cdf0e10cSrcweir         }
497*cdf0e10cSrcweir     case RET_EDIT_DOC:
498*cdf0e10cSrcweir     case RET_EDIT_RESULT_DOC:
499*cdf0e10cSrcweir         {
500*cdf0e10cSrcweir             //create a non-modal dialog that allows to return to the wizard
501*cdf0e10cSrcweir             //the ConfigItem ownership moves to this dialog
502*cdf0e10cSrcweir             bool bResult = nRet == RET_EDIT_RESULT_DOC && m_pMMConfig->GetTargetView();
503*cdf0e10cSrcweir             SwView* pTempView = bResult ? m_pMMConfig->GetTargetView() : m_pMMConfig->GetSourceView();
504*cdf0e10cSrcweir             pTempView->SetMailMergeConfigItem(m_pMMConfig, m_pWizard->GetRestartPage(), !bResult);
505*cdf0e10cSrcweir             SfxViewFrame* pViewFrame = pTempView->GetViewFrame();
506*cdf0e10cSrcweir             pViewFrame->GetDispatcher()->Execute(
507*cdf0e10cSrcweir                 FN_MAILMERGE_CHILDWINDOW, SFX_CALLMODE_SYNCHRON);
508*cdf0e10cSrcweir             ExecutionFinished( false );
509*cdf0e10cSrcweir             break;
510*cdf0e10cSrcweir         }
511*cdf0e10cSrcweir     case RET_REMOVE_TARGET:
512*cdf0e10cSrcweir         {
513*cdf0e10cSrcweir             SwView* pTargetView = m_pMMConfig->GetTargetView();
514*cdf0e10cSrcweir             SwView* pSourceView = m_pMMConfig->GetSourceView();
515*cdf0e10cSrcweir             DBG_ASSERT(pTargetView && pSourceView, "source or target view not available" );
516*cdf0e10cSrcweir             if(pTargetView && pSourceView)
517*cdf0e10cSrcweir             {
518*cdf0e10cSrcweir 				m_pView2Close = pTargetView;
519*cdf0e10cSrcweir                 pTargetView->GetViewFrame()->GetTopViewFrame()->GetWindow().Hide();
520*cdf0e10cSrcweir 				pSourceView->GetViewFrame()->GetFrame().AppearWithUpdate();
521*cdf0e10cSrcweir 				// the current view has be be set when the target is destroyed
522*cdf0e10cSrcweir                 m_pView = pSourceView;
523*cdf0e10cSrcweir                 m_pMMConfig->SetTargetView(0);
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir                 // destroy wizard asynchronously
526*cdf0e10cSrcweir                 Application::PostUserEvent(
527*cdf0e10cSrcweir                     LINK( this, SwMailMergeWizardExecutor, CloseFrameHdl ), m_pWizard );
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
530*cdf0e10cSrcweir                 m_pWizard = pFact->CreateMailMergeWizard(*pSourceView, *m_pMMConfig);
531*cdf0e10cSrcweir                 m_pWizard->ShowPage( nRestartPage );
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir                 // execute the wizard again
534*cdf0e10cSrcweir                 ExecuteWizard();
535*cdf0e10cSrcweir             }
536*cdf0e10cSrcweir             else
537*cdf0e10cSrcweir             {
538*cdf0e10cSrcweir                 //should not happen - just in case no target view has been created
539*cdf0e10cSrcweir                 ExecutionFinished( true );
540*cdf0e10cSrcweir             }
541*cdf0e10cSrcweir             break;
542*cdf0e10cSrcweir         }
543*cdf0e10cSrcweir     case RET_CANCEL:
544*cdf0e10cSrcweir         {
545*cdf0e10cSrcweir             // close frame and destroy wizard asynchronously
546*cdf0e10cSrcweir             Application::PostUserEvent(
547*cdf0e10cSrcweir                 LINK( this, SwMailMergeWizardExecutor, CancelHdl ), m_pWizard );
548*cdf0e10cSrcweir             break;
549*cdf0e10cSrcweir         }
550*cdf0e10cSrcweir     default: //finish
551*cdf0e10cSrcweir         {
552*cdf0e10cSrcweir             SwView* pSourceView = m_pMMConfig->GetSourceView();
553*cdf0e10cSrcweir             if(pSourceView)
554*cdf0e10cSrcweir             {
555*cdf0e10cSrcweir                 SwDocShell* pDocShell = pSourceView->GetDocShell();
556*cdf0e10cSrcweir                 if(pDocShell->HasName() && !pDocShell->IsModified())
557*cdf0e10cSrcweir                     m_pMMConfig->GetSourceView()->GetViewFrame()->DoClose();
558*cdf0e10cSrcweir                 else
559*cdf0e10cSrcweir                     m_pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().Appear();
560*cdf0e10cSrcweir             }
561*cdf0e10cSrcweir             ExecutionFinished( true );
562*cdf0e10cSrcweir             break;
563*cdf0e10cSrcweir         }
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir     } // switch
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir     return 0L;
568*cdf0e10cSrcweir }
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir IMPL_LINK( SwMailMergeWizardExecutor, DestroyDialogHdl, AbstractMailMergeWizard*, EMPTYARG )
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir     delete m_pWizard;
573*cdf0e10cSrcweir     m_pWizard = 0;
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir     release();
576*cdf0e10cSrcweir     return 0L;
577*cdf0e10cSrcweir }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir IMPL_LINK( SwMailMergeWizardExecutor, DestroyWizardHdl, AbstractMailMergeWizard*, pDialog )
580*cdf0e10cSrcweir {
581*cdf0e10cSrcweir     delete pDialog;
582*cdf0e10cSrcweir     return 0L;
583*cdf0e10cSrcweir }
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir IMPL_LINK( SwMailMergeWizardExecutor, CancelHdl, AbstractMailMergeWizard*, EMPTYARG )
586*cdf0e10cSrcweir {
587*cdf0e10cSrcweir     if(m_pMMConfig->GetTargetView())
588*cdf0e10cSrcweir     {
589*cdf0e10cSrcweir         m_pMMConfig->GetTargetView()->GetViewFrame()->DoClose();
590*cdf0e10cSrcweir         m_pMMConfig->SetTargetView(0);
591*cdf0e10cSrcweir     }
592*cdf0e10cSrcweir     if(m_pMMConfig->GetSourceView())
593*cdf0e10cSrcweir         m_pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().AppearWithUpdate();
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir     m_pMMConfig->Commit();
596*cdf0e10cSrcweir     delete m_pMMConfig;
597*cdf0e10cSrcweir     m_pMMConfig = 0;
598*cdf0e10cSrcweir     // m_pWizard already deleted by closing the target view
599*cdf0e10cSrcweir     m_pWizard = 0;
600*cdf0e10cSrcweir     release();
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir     return 0L;
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir IMPL_LINK( SwMailMergeWizardExecutor, CloseFrameHdl, AbstractMailMergeWizard*, EMPTYARG )
606*cdf0e10cSrcweir {
607*cdf0e10cSrcweir     if ( m_pView2Close )
608*cdf0e10cSrcweir     {
609*cdf0e10cSrcweir         m_pView2Close->GetViewFrame()->DoClose();
610*cdf0e10cSrcweir 		m_pView2Close = NULL;
611*cdf0e10cSrcweir     }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir     return 0L;
614*cdf0e10cSrcweir }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir } // namespace
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir void SwModule::ExecOther(SfxRequest& rReq)
619*cdf0e10cSrcweir {
620*cdf0e10cSrcweir 	const SfxItemSet *pArgs = rReq.GetArgs();
621*cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir 	sal_uInt16 nWhich = rReq.GetSlot();
624*cdf0e10cSrcweir 	switch (nWhich)
625*cdf0e10cSrcweir 	{
626*cdf0e10cSrcweir 		case FN_ENVELOP:
627*cdf0e10cSrcweir             InsertEnv( rReq );
628*cdf0e10cSrcweir 			break;
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir 		case FN_BUSINESS_CARD:
631*cdf0e10cSrcweir 		case FN_LABEL:
632*cdf0e10cSrcweir 			InsertLab(rReq, nWhich == FN_LABEL);
633*cdf0e10cSrcweir 			break;
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir         case FN_XFORMS_INIT:
636*cdf0e10cSrcweir             NewXForms( rReq );
637*cdf0e10cSrcweir             break;
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir         case SID_ATTR_METRIC:
640*cdf0e10cSrcweir 		if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nWhich, sal_False, &pItem))
641*cdf0e10cSrcweir 		{
642*cdf0e10cSrcweir 			FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue();
643*cdf0e10cSrcweir 			switch( eUnit )
644*cdf0e10cSrcweir 			{
645*cdf0e10cSrcweir 				case FUNIT_MM:
646*cdf0e10cSrcweir 				case FUNIT_CM:
647*cdf0e10cSrcweir 				case FUNIT_INCH:
648*cdf0e10cSrcweir 				case FUNIT_PICA:
649*cdf0e10cSrcweir 				case FUNIT_POINT:
650*cdf0e10cSrcweir 				{
651*cdf0e10cSrcweir 					SwView* pActView = ::GetActiveView();
652*cdf0e10cSrcweir 					sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pActView);
653*cdf0e10cSrcweir 					::SetDfltMetric(eUnit, bWebView);
654*cdf0e10cSrcweir 				}
655*cdf0e10cSrcweir 				break;
656*cdf0e10cSrcweir                 default:;//prevent warning
657*cdf0e10cSrcweir 			}
658*cdf0e10cSrcweir 		}
659*cdf0e10cSrcweir 		break;
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 		case FN_SET_MODOPT_TBLNUMFMT:
662*cdf0e10cSrcweir 			{
663*cdf0e10cSrcweir 				sal_Bool bWebView = 0 != PTR_CAST(SwWebView, ::GetActiveView() ),
664*cdf0e10cSrcweir 					 bSet;
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 				if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(
667*cdf0e10cSrcweir 						nWhich, sal_False, &pItem ))
668*cdf0e10cSrcweir 					bSet = ((SfxBoolItem*)pItem)->GetValue();
669*cdf0e10cSrcweir 				else
670*cdf0e10cSrcweir 					bSet = !pModuleConfig->IsInsTblFormatNum( bWebView );
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir 				pModuleConfig->SetInsTblFormatNum( bWebView, bSet );
673*cdf0e10cSrcweir 			}
674*cdf0e10cSrcweir 			break;
675*cdf0e10cSrcweir         case FN_MAILMERGE_WIZARD:
676*cdf0e10cSrcweir         {
677*cdf0e10cSrcweir             rtl::Reference< SwMailMergeWizardExecutor > xEx( new SwMailMergeWizardExecutor );
678*cdf0e10cSrcweir             xEx->ExecuteMailMergeWizard( pArgs );
679*cdf0e10cSrcweir         }
680*cdf0e10cSrcweir         break;
681*cdf0e10cSrcweir 	}
682*cdf0e10cSrcweir }
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir /*--------------------------------------------------------------------
685*cdf0e10cSrcweir 	Beschreibung: Notifies abfangen
686*cdf0e10cSrcweir  --------------------------------------------------------------------*/
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	// Hint abfangen fuer DocInfo
690*cdf0e10cSrcweir void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
691*cdf0e10cSrcweir {
692*cdf0e10cSrcweir 	if( rHint.ISA( SfxEventHint ) )
693*cdf0e10cSrcweir 	{
694*cdf0e10cSrcweir 		SfxEventHint& rEvHint = (SfxEventHint&) rHint;
695*cdf0e10cSrcweir 		SwDocShell* pDocSh = PTR_CAST( SwDocShell, rEvHint.GetObjShell() );
696*cdf0e10cSrcweir 		if( pDocSh )
697*cdf0e10cSrcweir 		{
698*cdf0e10cSrcweir 			SwWrtShell* pWrtSh = pDocSh ? pDocSh->GetWrtShell() : 0;
699*cdf0e10cSrcweir 			switch( rEvHint.GetEventId() )
700*cdf0e10cSrcweir 			{
701*cdf0e10cSrcweir             case SFX_EVENT_LOADFINISHED:
702*cdf0e10cSrcweir                 OSL_ASSERT(!pWrtSh);
703*cdf0e10cSrcweir                 // if it is a new document created from a template,
704*cdf0e10cSrcweir                 // update fixed fields
705*cdf0e10cSrcweir                 if (pDocSh->GetMedium())
706*cdf0e10cSrcweir                 {
707*cdf0e10cSrcweir                     SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(),
708*cdf0e10cSrcweir                         pTemplateItem, SfxBoolItem,
709*cdf0e10cSrcweir                         SID_TEMPLATE, sal_False);
710*cdf0e10cSrcweir                     if (pTemplateItem && pTemplateItem->GetValue())
711*cdf0e10cSrcweir                     {
712*cdf0e10cSrcweir                         pDocSh->GetDoc()->SetFixFields(false, 0);
713*cdf0e10cSrcweir                     }
714*cdf0e10cSrcweir                 }
715*cdf0e10cSrcweir                 break;
716*cdf0e10cSrcweir 			case SFX_EVENT_CREATEDOC:
717*cdf0e10cSrcweir 				if( pWrtSh )
718*cdf0e10cSrcweir 				{
719*cdf0e10cSrcweir                     SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
720*cdf0e10cSrcweir                     sal_Bool bUpdateFields = sal_True;
721*cdf0e10cSrcweir                     if( pUpdateDocItem &&  pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE)
722*cdf0e10cSrcweir                         bUpdateFields = sal_False;
723*cdf0e10cSrcweir                     if(bUpdateFields)
724*cdf0e10cSrcweir                     {
725*cdf0e10cSrcweir                         pWrtSh->UpdateInputFlds();
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir                         // Sind Datenbankfelder enthalten?
728*cdf0e10cSrcweir                         // Erstmal alle verwendeten Datenbanken holen
729*cdf0e10cSrcweir                         SwDoc *pDoc = pDocSh->GetDoc();
730*cdf0e10cSrcweir                         SvStringsDtor aDBNameList;
731*cdf0e10cSrcweir                         pDoc->GetAllUsedDB( aDBNameList );
732*cdf0e10cSrcweir                         sal_uInt16 nCount = aDBNameList.Count();
733*cdf0e10cSrcweir                         if (nCount)
734*cdf0e10cSrcweir                         {   // Datenbankbeamer oeffnen
735*cdf0e10cSrcweir                             ShowDBObj(pWrtSh->GetView(), pDoc->GetDBData());
736*cdf0e10cSrcweir                         }
737*cdf0e10cSrcweir                     }
738*cdf0e10cSrcweir 				}
739*cdf0e10cSrcweir 				break;
740*cdf0e10cSrcweir 			}
741*cdf0e10cSrcweir 		}
742*cdf0e10cSrcweir 	}
743*cdf0e10cSrcweir 	else if(rHint.ISA(SfxItemSetHint))
744*cdf0e10cSrcweir 	{
745*cdf0e10cSrcweir 		if(	SFX_ITEM_SET == ((SfxItemSetHint&)rHint).GetItemSet().GetItemState(SID_ATTR_PATHNAME))
746*cdf0e10cSrcweir 		{
747*cdf0e10cSrcweir 			::GetGlossaries()->UpdateGlosPath( sal_False );
748*cdf0e10cSrcweir 			SwGlossaryList* pList = ::GetGlossaryList();
749*cdf0e10cSrcweir 			if(pList->IsActive())
750*cdf0e10cSrcweir 				pList->Update();
751*cdf0e10cSrcweir 		}
752*cdf0e10cSrcweir     }
753*cdf0e10cSrcweir     else if(rHint.ISA(SfxSimpleHint))
754*cdf0e10cSrcweir     {
755*cdf0e10cSrcweir 		sal_uInt16 nHintId = ((SfxSimpleHint&)rHint).GetId();
756*cdf0e10cSrcweir         if(SFX_HINT_DEINITIALIZING == nHintId)
757*cdf0e10cSrcweir         {
758*cdf0e10cSrcweir             DELETEZ(pWebUsrPref);
759*cdf0e10cSrcweir             DELETEZ(pUsrPref)   ;
760*cdf0e10cSrcweir             DELETEZ(pModuleConfig);
761*cdf0e10cSrcweir             DELETEZ(pPrtOpt)      ;
762*cdf0e10cSrcweir             DELETEZ(pWebPrtOpt)   ;
763*cdf0e10cSrcweir             DELETEZ(pChapterNumRules);
764*cdf0e10cSrcweir             DELETEZ(pStdFontConfig)     ;
765*cdf0e10cSrcweir             DELETEZ(pNavigationConfig)  ;
766*cdf0e10cSrcweir             DELETEZ(pToolbarConfig)     ;
767*cdf0e10cSrcweir             DELETEZ(pWebToolbarConfig)  ;
768*cdf0e10cSrcweir             DELETEZ(pAuthorNames)       ;
769*cdf0e10cSrcweir             DELETEZ(pDBConfig);
770*cdf0e10cSrcweir 			if( pColorConfig )
771*cdf0e10cSrcweir 			{
772*cdf0e10cSrcweir 				pColorConfig->RemoveListener(this);
773*cdf0e10cSrcweir 				DELETEZ(pColorConfig);
774*cdf0e10cSrcweir 			}
775*cdf0e10cSrcweir 			if( pAccessibilityOptions )
776*cdf0e10cSrcweir 			{
777*cdf0e10cSrcweir 				pAccessibilityOptions->RemoveListener(this);
778*cdf0e10cSrcweir 				DELETEZ(pAccessibilityOptions);
779*cdf0e10cSrcweir 			}
780*cdf0e10cSrcweir 			if( pCTLOptions )
781*cdf0e10cSrcweir 			{
782*cdf0e10cSrcweir 				pCTLOptions->RemoveListener(this);
783*cdf0e10cSrcweir 				DELETEZ(pCTLOptions);
784*cdf0e10cSrcweir 			}
785*cdf0e10cSrcweir 			if( pUserOptions )
786*cdf0e10cSrcweir 			{
787*cdf0e10cSrcweir 				pUserOptions->RemoveListener(this);
788*cdf0e10cSrcweir 				DELETEZ(pUserOptions);
789*cdf0e10cSrcweir 			}
790*cdf0e10cSrcweir 			if( pUndoOptions )
791*cdf0e10cSrcweir 			{
792*cdf0e10cSrcweir 				pUndoOptions->RemoveListener(this);
793*cdf0e10cSrcweir 				DELETEZ(pUndoOptions);
794*cdf0e10cSrcweir 			}
795*cdf0e10cSrcweir         }
796*cdf0e10cSrcweir 	}
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 )
800*cdf0e10cSrcweir {
801*cdf0e10cSrcweir     if( pBrdCst == pUserOptions )
802*cdf0e10cSrcweir     {
803*cdf0e10cSrcweir         bAuthorInitialised = sal_False;
804*cdf0e10cSrcweir     }
805*cdf0e10cSrcweir     else if( pBrdCst == pUndoOptions )
806*cdf0e10cSrcweir     {
807*cdf0e10cSrcweir         sal_Int32 const nNew = GetUndoOptions().GetUndoCount();
808*cdf0e10cSrcweir         bool const bUndo = (nNew != 0);
809*cdf0e10cSrcweir         // switch Undo for all DocShells
810*cdf0e10cSrcweir         TypeId aType(TYPE(SwDocShell));
811*cdf0e10cSrcweir         SwDocShell * pDocShell =
812*cdf0e10cSrcweir             static_cast<SwDocShell *>(SfxObjectShell::GetFirst(&aType));
813*cdf0e10cSrcweir         while (pDocShell)
814*cdf0e10cSrcweir         {
815*cdf0e10cSrcweir             pDocShell->GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo);
816*cdf0e10cSrcweir             pDocShell = static_cast<SwDocShell *>(
817*cdf0e10cSrcweir                     SfxObjectShell::GetNext(*pDocShell, &aType));
818*cdf0e10cSrcweir         }
819*cdf0e10cSrcweir     }
820*cdf0e10cSrcweir 	else if ( pBrdCst == pColorConfig || pBrdCst == pAccessibilityOptions )
821*cdf0e10cSrcweir     {
822*cdf0e10cSrcweir         sal_Bool bAccessibility = sal_False;
823*cdf0e10cSrcweir         if( pBrdCst == pColorConfig )
824*cdf0e10cSrcweir             SwViewOption::ApplyColorConfigValues(*pColorConfig);
825*cdf0e10cSrcweir         else
826*cdf0e10cSrcweir             bAccessibility = sal_True;
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir         //invalidate all edit windows
829*cdf0e10cSrcweir         const TypeId aSwViewTypeId = TYPE(SwView);
830*cdf0e10cSrcweir         const TypeId aSwPreViewTypeId = TYPE(SwPagePreView);
831*cdf0e10cSrcweir         const TypeId aSwSrcViewTypeId = TYPE(SwSrcView);
832*cdf0e10cSrcweir         SfxViewShell* pViewShell = SfxViewShell::GetFirst();
833*cdf0e10cSrcweir         while(pViewShell)
834*cdf0e10cSrcweir         {
835*cdf0e10cSrcweir             if(pViewShell->GetWindow())
836*cdf0e10cSrcweir             {
837*cdf0e10cSrcweir                 if((pViewShell->IsA(aSwViewTypeId) ||
838*cdf0e10cSrcweir                     pViewShell->IsA(aSwPreViewTypeId) ||
839*cdf0e10cSrcweir                     pViewShell->IsA(aSwSrcViewTypeId)))
840*cdf0e10cSrcweir                 {
841*cdf0e10cSrcweir                     if(bAccessibility)
842*cdf0e10cSrcweir                     {
843*cdf0e10cSrcweir                         if(pViewShell->IsA(aSwViewTypeId))
844*cdf0e10cSrcweir                             ((SwView*)pViewShell)->ApplyAccessiblityOptions(*pAccessibilityOptions);
845*cdf0e10cSrcweir                         else if(pViewShell->IsA(aSwPreViewTypeId))
846*cdf0e10cSrcweir                             ((SwPagePreView*)pViewShell)->ApplyAccessiblityOptions(*pAccessibilityOptions);
847*cdf0e10cSrcweir                     }
848*cdf0e10cSrcweir                     pViewShell->GetWindow()->Invalidate();
849*cdf0e10cSrcweir                 }
850*cdf0e10cSrcweir             }
851*cdf0e10cSrcweir             pViewShell = SfxViewShell::GetNext( *pViewShell );
852*cdf0e10cSrcweir         }
853*cdf0e10cSrcweir     }
854*cdf0e10cSrcweir     else if( pBrdCst == pCTLOptions )
855*cdf0e10cSrcweir     {
856*cdf0e10cSrcweir         const SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
857*cdf0e10cSrcweir         while( pObjSh )
858*cdf0e10cSrcweir         {
859*cdf0e10cSrcweir             if( pObjSh->IsA(TYPE(SwDocShell)) )
860*cdf0e10cSrcweir             {
861*cdf0e10cSrcweir                 const SwDoc* pDoc = ((SwDocShell*)pObjSh)->GetDoc();
862*cdf0e10cSrcweir                 ViewShell* pVSh = 0;
863*cdf0e10cSrcweir                 pDoc->GetEditShell( &pVSh );
864*cdf0e10cSrcweir                 if ( pVSh )
865*cdf0e10cSrcweir                     pVSh->ChgNumberDigits();
866*cdf0e10cSrcweir             }
867*cdf0e10cSrcweir             pObjSh = SfxObjectShell::GetNext(*pObjSh);
868*cdf0e10cSrcweir         }
869*cdf0e10cSrcweir     }
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir }
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir /* -----------------------------20.02.01 12:43--------------------------------
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
876*cdf0e10cSrcweir SwDBConfig*	SwModule::GetDBConfig()
877*cdf0e10cSrcweir {
878*cdf0e10cSrcweir 	if(!pDBConfig)
879*cdf0e10cSrcweir 		pDBConfig = new SwDBConfig;
880*cdf0e10cSrcweir 	return pDBConfig;
881*cdf0e10cSrcweir }
882*cdf0e10cSrcweir /* -----------------------------11.04.2002 15:27------------------------------
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
885*cdf0e10cSrcweir svtools::ColorConfig& SwModule::GetColorConfig()
886*cdf0e10cSrcweir {
887*cdf0e10cSrcweir     if(!pColorConfig)
888*cdf0e10cSrcweir 	{
889*cdf0e10cSrcweir         pColorConfig = new svtools::ColorConfig;
890*cdf0e10cSrcweir 	    SwViewOption::ApplyColorConfigValues(*pColorConfig);
891*cdf0e10cSrcweir 		pColorConfig->AddListener(this);
892*cdf0e10cSrcweir     }
893*cdf0e10cSrcweir     return *pColorConfig;
894*cdf0e10cSrcweir }
895*cdf0e10cSrcweir /* -----------------------------06.05.2002 09:42------------------------------
896*cdf0e10cSrcweir 
897*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
898*cdf0e10cSrcweir SvtAccessibilityOptions& SwModule::GetAccessibilityOptions()
899*cdf0e10cSrcweir {
900*cdf0e10cSrcweir     if(!pAccessibilityOptions)
901*cdf0e10cSrcweir     {
902*cdf0e10cSrcweir         pAccessibilityOptions = new SvtAccessibilityOptions;
903*cdf0e10cSrcweir 		pAccessibilityOptions->AddListener(this);
904*cdf0e10cSrcweir     }
905*cdf0e10cSrcweir     return *pAccessibilityOptions;
906*cdf0e10cSrcweir }
907*cdf0e10cSrcweir /* -----------------06.05.2003 14:52-----------------
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir  --------------------------------------------------*/
910*cdf0e10cSrcweir SvtCTLOptions& SwModule::GetCTLOptions()
911*cdf0e10cSrcweir {
912*cdf0e10cSrcweir     if(!pCTLOptions)
913*cdf0e10cSrcweir     {
914*cdf0e10cSrcweir         pCTLOptions = new SvtCTLOptions;
915*cdf0e10cSrcweir 		pCTLOptions->AddListener(this);
916*cdf0e10cSrcweir     }
917*cdf0e10cSrcweir     return *pCTLOptions;
918*cdf0e10cSrcweir }
919*cdf0e10cSrcweir /* -----------------07.07.2003 09:31-----------------
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir  --------------------------------------------------*/
922*cdf0e10cSrcweir SvtUserOptions& SwModule::GetUserOptions()
923*cdf0e10cSrcweir {
924*cdf0e10cSrcweir     if(!pUserOptions)
925*cdf0e10cSrcweir     {
926*cdf0e10cSrcweir         pUserOptions = new SvtUserOptions;
927*cdf0e10cSrcweir         pUserOptions->AddListener(this);
928*cdf0e10cSrcweir     }
929*cdf0e10cSrcweir     return *pUserOptions;
930*cdf0e10cSrcweir }
931*cdf0e10cSrcweir /* -----------------18.07.2003 13:31-----------------
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir  --------------------------------------------------*/
934*cdf0e10cSrcweir SvtUndoOptions& SwModule::GetUndoOptions()
935*cdf0e10cSrcweir {
936*cdf0e10cSrcweir     if(!pUndoOptions)
937*cdf0e10cSrcweir     {
938*cdf0e10cSrcweir         pUndoOptions = new SvtUndoOptions;
939*cdf0e10cSrcweir         pUndoOptions->AddListener(this);
940*cdf0e10cSrcweir     }
941*cdf0e10cSrcweir     return *pUndoOptions;
942*cdf0e10cSrcweir }
943*cdf0e10cSrcweir /*-----------------30.01.97 08.30-------------------
944*cdf0e10cSrcweir 
945*cdf0e10cSrcweir --------------------------------------------------*/
946*cdf0e10cSrcweir const SwMasterUsrPref *SwModule::GetUsrPref(sal_Bool bWeb) const
947*cdf0e10cSrcweir {
948*cdf0e10cSrcweir 	SwModule* pNonConstModule = (SwModule*)this;
949*cdf0e10cSrcweir 	if(bWeb && !pWebUsrPref)
950*cdf0e10cSrcweir 	{
951*cdf0e10cSrcweir 		// im Load der SwMasterUsrPref wird der SpellChecker gebraucht, dort darf
952*cdf0e10cSrcweir 		// er aber nicht angelegt werden #58256#
953*cdf0e10cSrcweir 		pNonConstModule->pWebUsrPref = new SwMasterUsrPref(sal_True);
954*cdf0e10cSrcweir 	}
955*cdf0e10cSrcweir 	else if(!bWeb && !pUsrPref)
956*cdf0e10cSrcweir 	{
957*cdf0e10cSrcweir 		pNonConstModule->pUsrPref = new SwMasterUsrPref(sal_False);
958*cdf0e10cSrcweir 	}
959*cdf0e10cSrcweir 	return  bWeb ? pWebUsrPref : pUsrPref;
960*cdf0e10cSrcweir }
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir void NewXForms( SfxRequest& rReq )
965*cdf0e10cSrcweir {
966*cdf0e10cSrcweir     // copied & excerpted from SwModule::InsertLab(..)
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir     // create new document
969*cdf0e10cSrcweir     SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD) );
970*cdf0e10cSrcweir     xDocSh->DoInitNew( 0 );
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir     // initialize XForms
973*cdf0e10cSrcweir     static_cast<SwDocShell*>( &xDocSh )->GetDoc()->initXForms( true );
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir     // load document into frame
976*cdf0e10cSrcweir     SfxViewFrame::DisplayNewDocument( *xDocSh, rReq );
977*cdf0e10cSrcweir 
978*cdf0e10cSrcweir     // set return value
979*cdf0e10cSrcweir     rReq.SetReturnValue( SfxVoidItem( rReq.GetSlot() ) );
980*cdf0e10cSrcweir }
981