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