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