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 <vcl/svapp.hxx>
30 : : #include <osl/mutex.hxx>
31 : : #include <svl/itemprop.hxx>
32 : : #include <svl/urihelper.hxx>
33 : : #include <svx/dataaccessdescriptor.hxx>
34 : : #include <tools/shl.hxx> // GetAppData
35 : : #include <tools/tempfile.hxx>
36 : : #include <sfx2/app.hxx>
37 : : #include <sfx2/docfile.hxx>
38 : : #include <sfx2/docfilt.hxx>
39 : : #include <comphelper/processfactory.hxx>
40 : : #include <comphelper/string.hxx>
41 : : #include <vcl/timer.hxx>
42 : : #include <com/sun/star/sdb/CommandType.hpp>
43 : : #include <com/sun/star/text/MailMergeType.hpp>
44 : : #include <com/sun/star/text/MailMergeEvent.hpp>
45 : : #include <com/sun/star/text/XMailMergeListener.hpp>
46 : : #include <com/sun/star/text/XMailMergeBroadcaster.hpp>
47 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
48 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
49 : : #include <com/sun/star/sdbc/XResultSet.hpp>
50 : : #include <com/sun/star/sdbc/XConnection.hpp>
51 : : #include <com/sun/star/sdbc/XRowSet.hpp>
52 : : #include <com/sun/star/frame/XComponentLoader.hpp>
53 : : #include <com/sun/star/util/XCloseable.hpp>
54 : : #include <com/sun/star/util/CloseVetoException.hpp>
55 : : #include <com/sun/star/sdbcx/XRowLocate.hpp>
56 : : #include <com/sun/star/frame/XStorable.hpp>
57 : : #include "com/sun/star/mail/XSmtpService.hpp"
58 : : #include <sfx2/viewfrm.hxx>
59 : : #include <sfx2/event.hxx>
60 : : #include <swevent.hxx>
61 : : #include <unomailmerge.hxx>
62 : : #include <swdll.hxx>
63 : : #include <swmodule.hxx>
64 : : #include <unoprnms.hxx>
65 : : #include <unomap.hxx>
66 : : #include <swunohelper.hxx>
67 : : #include <docsh.hxx>
68 : : #include <IDocumentDeviceAccess.hxx>
69 : : #include <view.hxx>
70 : : #include <dbmgr.hxx>
71 : : #include <unotxdoc.hxx>
72 : : #include <prtopt.hxx>
73 : : #include <wrtsh.hxx>
74 : : #include <shellio.hxx>
75 : : #include <mmconfigitem.hxx>
76 : : #include <mailmergehelper.hxx>
77 : : #include <memory>
78 : :
79 : : #include <unomid.h>
80 : :
81 : :
82 : : #define SN_MAIL_MERGE "com.sun.star.text.MailMerge"
83 : : #define SN_DATA_ACCESS_DESCRIPTOR "com.sun.star.sdb.DataAccessDescriptor"
84 : :
85 : : using namespace ::com::sun::star;
86 : : using namespace ::com::sun::star::frame;
87 : : using namespace ::com::sun::star::uno;
88 : : using namespace ::com::sun::star::lang;
89 : : using namespace ::com::sun::star::beans;
90 : : using namespace ::com::sun::star::text;
91 : : using ::rtl::OUString;
92 : : using namespace SWUnoHelper;
93 : :
94 : : ////////////////////////////////////////////////////////////
95 : :
96 : : typedef ::utl::SharedUNOComponent< XInterface > SharedComponent;
97 : :
98 : : ////////////////////////////////////////////////////////////
99 : :
100 : 0 : osl::Mutex & GetMailMergeMutex()
101 : : {
102 [ # # ][ # # ]: 0 : static osl::Mutex aMutex;
[ # # ][ # # ]
103 : 0 : return aMutex;
104 : : }
105 : :
106 : : ////////////////////////////////////////////////////////////
107 : :
108 : : enum CloseResult
109 : : {
110 : : eSuccess, // successfully closed
111 : : eVetoed, // vetoed, ownership transfered to the vetoing instance
112 : : eFailed // failed for some unknown reason
113 : : };
114 : 0 : static CloseResult CloseModelAndDocSh(
115 : : Reference< frame::XModel > &rxModel,
116 : : SfxObjectShellRef &rxDocSh )
117 : : {
118 : 0 : CloseResult eResult = eSuccess;
119 : :
120 [ # # ]: 0 : rxDocSh = 0;
121 : :
122 : : //! models/documents should never be disposed (they may still be
123 : : //! used for printing which is called asynchronously for example)
124 : : //! instead call close
125 [ # # ]: 0 : Reference< util::XCloseable > xClose( rxModel, UNO_QUERY );
126 [ # # ]: 0 : if (xClose.is())
127 : : {
128 : : try
129 : : {
130 : : //! 'sal_True' -> transfer ownership to vetoing object if vetoed!
131 : : //! I.e. now that object is responsible for closing the model and doc shell.
132 [ # # ][ # # ]: 0 : xClose->close( sal_True );
133 : : }
134 [ # # ]: 0 : catch (const util::CloseVetoException&)
135 : : {
136 : : //! here we have the problem that the temporary file that is
137 : : //! currently being printed will never be deleted. :-(
138 : 0 : eResult = eVetoed;
139 : : }
140 [ # # ]: 0 : catch (const uno::RuntimeException&)
141 : : {
142 : 0 : eResult = eFailed;
143 : : }
144 : : }
145 [ # # # ]: 0 : return eResult;
146 : : }
147 : :
148 : : ////////////////////////////////////////////////////////////
149 : :
150 : 0 : static sal_Bool LoadFromURL_impl(
151 : : Reference< frame::XModel > &rxModel,
152 : : SfxObjectShellRef &rxDocSh,
153 : : const String &rURL,
154 : : sal_Bool bClose )
155 : : throw (RuntimeException)
156 : : {
157 : : // try to open the document readonly and hidden
158 : 0 : Reference< frame::XModel > xTmpModel;
159 [ # # ]: 0 : Sequence < PropertyValue > aArgs( 1 );
160 [ # # ][ # # ]: 0 : aArgs[0].Name = C2U("Hidden");
161 : 0 : sal_Bool bVal = sal_True;
162 [ # # ][ # # ]: 0 : aArgs[0].Value <<= bVal;
163 : : try
164 : : {
165 [ # # ][ # # ]: 0 : Reference < XComponentLoader > xDesktop( ::comphelper::getProcessServiceFactory()->
166 [ # # ][ # # ]: 0 : createInstance( C2U("com.sun.star.frame.Desktop") ), UNO_QUERY );
[ # # ]
167 [ # # ]: 0 : xTmpModel = Reference < XModel >( xDesktop->loadComponentFromURL(
168 [ # # ][ # # ]: 0 : rURL, C2U("_blank"), 0, aArgs ), UNO_QUERY );
[ # # ][ # # ]
[ # # ][ # # ]
169 : : }
170 [ # # ]: 0 : catch (const Exception&)
171 : : {
172 : 0 : return sal_False;
173 : : }
174 : :
175 : : // try to get the DocShell
176 : 0 : SwDocShell *pTmpDocShell = 0;
177 [ # # ]: 0 : Reference < XUnoTunnel > xTunnel( xTmpModel, UNO_QUERY );
178 [ # # ]: 0 : if (xTunnel.is())
179 : : {
180 : : SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument *>(
181 [ # # ][ # # ]: 0 : xTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ));
[ # # ]
182 [ # # ]: 0 : pTmpDocShell = pTextDoc ? pTextDoc->GetDocShell() : 0;
183 : : }
184 : :
185 : 0 : sal_Bool bRes = sal_False;
186 [ # # ][ # # ]: 0 : if (xTmpModel.is() && pTmpDocShell) // everything available?
[ # # ]
187 : : {
188 [ # # ]: 0 : if (bClose)
189 [ # # ]: 0 : CloseModelAndDocSh( rxModel, rxDocSh );
190 : : // set new stuff
191 [ # # ]: 0 : rxModel = xTmpModel;
192 [ # # ]: 0 : rxDocSh = pTmpDocShell;
193 : 0 : bRes = sal_True;
194 : : }
195 : : else
196 : : {
197 : : // SfxObjectShellRef is ok here, since the document will be explicitly closed
198 : 0 : SfxObjectShellRef xTmpDocSh = pTmpDocShell;
199 [ # # ][ # # ]: 0 : CloseModelAndDocSh( xTmpModel, xTmpDocSh );
200 : : }
201 : :
202 [ # # ]: 0 : return bRes;
203 : : }
204 : :
205 : : //==========================================================
206 : : namespace
207 : : {
208 : : class DelayedFileDeletion : public ::cppu::WeakImplHelper1< util::XCloseListener >
209 : : {
210 : : protected:
211 : : ::osl::Mutex m_aMutex;
212 : : Reference< util::XCloseable > m_xDocument;
213 : : Timer m_aDeleteTimer;
214 : : String m_sTemporaryFile;
215 : : sal_Int32 m_nPendingDeleteAttempts;
216 : :
217 : : public:
218 : : DelayedFileDeletion( const Reference< XModel >& _rxModel,
219 : : const String& _rTemporaryFile );
220 : :
221 : : protected:
222 : : ~DelayedFileDeletion( );
223 : :
224 : : // XCloseListener
225 : : virtual void SAL_CALL queryClosing( const EventObject& _rSource, sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException);
226 : : virtual void SAL_CALL notifyClosing( const EventObject& _rSource ) throw (RuntimeException);
227 : :
228 : : // XEventListener
229 : : virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
230 : :
231 : : private:
232 : : void implTakeOwnership( );
233 : : DECL_LINK( OnTryDeleteFile, void* );
234 : :
235 : : private:
236 : : DelayedFileDeletion( const DelayedFileDeletion& ); // never implemented
237 : : DelayedFileDeletion& operator=( const DelayedFileDeletion& ); // never implemented
238 : : };
239 : :
240 : : //------------------------------------------------------
241 : 0 : DelayedFileDeletion::DelayedFileDeletion( const Reference< XModel >& _rxModel, const String& _rTemporaryFile )
242 : : :
243 : : m_xDocument( _rxModel, UNO_QUERY )
244 : : ,m_sTemporaryFile( _rTemporaryFile )
245 [ # # ][ # # ]: 0 : ,m_nPendingDeleteAttempts( 0 )
[ # # ][ # # ]
246 : : {
247 [ # # ]: 0 : osl_incrementInterlockedCount( &m_refCount );
248 : : try
249 : : {
250 [ # # ]: 0 : if ( m_xDocument.is() )
251 : : {
252 [ # # ][ # # ]: 0 : m_xDocument->addCloseListener( this );
[ # # ][ # # ]
253 : : // successfully added -> keep ourself alive
254 : 0 : acquire();
255 : : }
256 : : else {
257 : : OSL_FAIL("DelayedFileDeletion::DelayedFileDeletion: model is no component!" );
258 : : }
259 : : }
260 [ # # ]: 0 : catch (const Exception&)
261 : : {
262 : : OSL_FAIL("DelayedFileDeletion::DelayedFileDeletion: could not register as event listener at the model!" );
263 : : }
264 [ # # ]: 0 : osl_decrementInterlockedCount( &m_refCount );
265 : 0 : }
266 : :
267 : : //--------------------------------------------------------------------
268 : 0 : IMPL_LINK_NOARG(DelayedFileDeletion, OnTryDeleteFile)
269 : : {
270 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
271 : :
272 : 0 : sal_Bool bSuccess = sal_False;
273 : : try
274 : : {
275 : 0 : sal_Bool bDeliverOwnership = ( 0 == m_nPendingDeleteAttempts );
276 : : // if this is our last attemt, then anybody which vetoes this has to take the consequences
277 : : // (means take the ownership)
278 [ # # ][ # # ]: 0 : m_xDocument->close( bDeliverOwnership );
279 : 0 : bSuccess = sal_True;
280 : : }
281 [ # # # # : 0 : catch (const util::CloseVetoException&)
# ]
282 : : {
283 : : // somebody vetoed -> next try
284 [ # # ]: 0 : if ( m_nPendingDeleteAttempts )
285 : : {
286 : : // next attempt
287 : 0 : --m_nPendingDeleteAttempts;
288 [ # # ]: 0 : m_aDeleteTimer.Start();
289 : : }
290 : : else
291 : 0 : bSuccess = sal_True; // can't do anything here ...
292 : : }
293 [ # # ]: 0 : catch (const Exception&)
294 : : {
295 : : OSL_FAIL("DelayedFileDeletion::OnTryDeleteFile: caught a strange exception!" );
296 : 0 : bSuccess = sal_True;
297 : : // can't do anything here ...
298 : : }
299 : :
300 [ # # ]: 0 : if ( bSuccess )
301 : : {
302 [ # # ]: 0 : SWUnoHelper::UCB_DeleteFile( m_sTemporaryFile );
303 [ # # ]: 0 : aGuard.clear();
304 : 0 : release(); // this should be our last reference, we should be dead after this
305 : : }
306 [ # # ]: 0 : return 0L;
307 : : }
308 : :
309 : : //--------------------------------------------------------------------
310 : 0 : void DelayedFileDeletion::implTakeOwnership( )
311 : : {
312 : : // revoke ourself as listener
313 : : try
314 : : {
315 [ # # ][ # # ]: 0 : m_xDocument->removeCloseListener( this );
[ # # ][ # # ]
316 : : }
317 : 0 : catch (const Exception&)
318 : : {
319 : : OSL_FAIL("DelayedFileDeletion::implTakeOwnership: could not revoke the listener!" );
320 : : }
321 : :
322 : 0 : m_aDeleteTimer.SetTimeout( 3000 ); // 3 seconds
323 : 0 : m_aDeleteTimer.SetTimeoutHdl( LINK( this, DelayedFileDeletion, OnTryDeleteFile ) );
324 : 0 : m_nPendingDeleteAttempts = 3; // try 3 times at most
325 : 0 : m_aDeleteTimer.Start( );
326 : 0 : }
327 : :
328 : : //--------------------------------------------------------------------
329 : 0 : void SAL_CALL DelayedFileDeletion::queryClosing( const EventObject& , sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException)
330 : : {
331 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
332 [ # # ]: 0 : if ( _bGetsOwnership )
333 [ # # ]: 0 : implTakeOwnership( );
334 : :
335 : : // always veto: We want to take the ownership ourself, as this is the only chance to delete
336 : : // the temporary file which the model is based on
337 [ # # ]: 0 : throw util::CloseVetoException( );
338 : : }
339 : :
340 : : //--------------------------------------------------------------------
341 : 0 : void SAL_CALL DelayedFileDeletion::notifyClosing( const EventObject& ) throw (RuntimeException)
342 : : {
343 : : OSL_FAIL("DelayedFileDeletion::notifyClosing: how this?" );
344 : : // this should not happen:
345 : : // Either, a foreign instance closes the document, then we should veto this, and take the ownership
346 : : // Or, we ourself close the document, then we should not be a listener anymore
347 : 0 : }
348 : :
349 : : //------------------------------------------------------
350 : 0 : void SAL_CALL DelayedFileDeletion::disposing( const EventObject& ) throw (RuntimeException)
351 : : {
352 : : OSL_FAIL("DelayedFileDeletion::disposing: how this?" );
353 : : // this should not happen:
354 : : // Either, a foreign instance closes the document, then we should veto this, and take the ownership
355 : : // Or, we ourself close the document, then we should not be a listener anymore
356 : 0 : }
357 : :
358 : : //------------------------------------------------------
359 [ # # ][ # # ]: 0 : DelayedFileDeletion::~DelayedFileDeletion( )
[ # # ]
360 : : {
361 [ # # ]: 0 : }
362 : : }
363 : :
364 : : ////////////////////////////////////////////////////////////
365 : :
366 : 0 : static sal_Bool DeleteTmpFile_Impl(
367 : : Reference< frame::XModel > &rxModel,
368 : : SfxObjectShellRef &rxDocSh,
369 : : const String &rTmpFileURL )
370 : : {
371 : 0 : sal_Bool bRes = sal_False;
372 [ # # ]: 0 : if (rTmpFileURL.Len())
373 : : {
374 : 0 : sal_Bool bDelete = sal_True;
375 [ # # ]: 0 : if ( eVetoed == CloseModelAndDocSh( rxModel, rxDocSh ) )
376 : : {
377 : : // somebody vetoed the closing, and took the ownership of the document
378 : : // -> ensure that the temporary file is deleted later on
379 [ # # ][ # # ]: 0 : Reference< XEventListener > xEnsureDelete( new DelayedFileDeletion( rxModel, rTmpFileURL ) );
[ # # ]
380 : : // note: as soon as #106931# is fixed, the whole DelayedFileDeletion is to be superseeded by
381 : : // a better solution
382 : 0 : bDelete = sal_False;
383 : : }
384 : :
385 : 0 : rxModel = 0;
386 : 0 : rxDocSh = 0; // destroy doc shell
387 : :
388 [ # # ]: 0 : if ( bDelete )
389 : : {
390 [ # # ]: 0 : if ( !SWUnoHelper::UCB_DeleteFile( rTmpFileURL ) )
391 : : {
392 [ # # ][ # # ]: 0 : Reference< XEventListener > xEnsureDelete( new DelayedFileDeletion( rxModel, rTmpFileURL ) );
[ # # ]
393 : : // same not as above: as soon as #106931#, ...
394 : : }
395 : : }
396 : : else
397 : 0 : bRes = sal_True; // file will be deleted delayed
398 : : }
399 : 0 : return bRes;
400 : : }
401 : :
402 : : ////////////////////////////////////////////////////////////
403 : :
404 : 0 : SwXMailMerge::SwXMailMerge() :
405 [ # # ]: 0 : aEvtListeners ( GetMailMergeMutex() ),
406 [ # # ]: 0 : aMergeListeners ( GetMailMergeMutex() ),
407 [ # # ]: 0 : aPropListeners ( GetMailMergeMutex() ),
408 [ # # ]: 0 : pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_MAILMERGE ) ),
409 : : bSendAsHTML(sal_False),
410 : : bSendAsAttachment(sal_False),
411 [ # # ][ # # ]: 0 : bSaveAsSingleFile(sal_False)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
412 : :
413 : : {
414 : : // create empty document
415 : : // like in: SwModule::InsertEnv (appenv.cxx)
416 [ # # ][ # # ]: 0 : SwDocShell *pDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
417 [ # # ]: 0 : xDocSh = pDocShell;
418 [ # # ]: 0 : xDocSh->DoInitNew( 0 );
419 [ # # ]: 0 : SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
420 [ # # ]: 0 : SwView *pView = (SwView*) pFrame->GetViewShell();
421 [ # # ]: 0 : pView->AttrChangedNotify( &pView->GetWrtShell() );//Damit SelectShell gerufen wird.
422 : :
423 [ # # ][ # # ]: 0 : xModel = pDocShell->GetModel();
424 : :
425 : 0 : nDataCommandType = sdb::CommandType::TABLE;
426 : 0 : nOutputType = MailMergeType::PRINTER;
427 : 0 : bEscapeProcessing = sal_True; //!! allow to process properties like "Filter", "Order", ...
428 : 0 : bSinglePrintJobs = sal_False;
429 : 0 : bFileNameFromColumn = sal_False;
430 : :
431 : 0 : bDisposing = sal_False;
432 : 0 : }
433 : :
434 [ # # ][ # # ]: 0 : SwXMailMerge::~SwXMailMerge()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
435 : : {
436 [ # # ]: 0 : if (aTmpFileName.Len())
437 [ # # ]: 0 : DeleteTmpFile_Impl( xModel, xDocSh, aTmpFileName );
438 : : else // there was no temporary file in use
439 : : {
440 : : //! we still need to close the model and doc shell manually
441 : : //! because there is no automatism that will do that later.
442 : : //! #120086#
443 [ # # ]: 0 : if ( eVetoed == CloseModelAndDocSh( xModel, xDocSh ) )
444 : : OSL_FAIL("owner ship transfered to vetoing object!" );
445 : :
446 [ # # ]: 0 : xModel = 0;
447 [ # # ]: 0 : xDocSh = 0; // destroy doc shell
448 : : }
449 [ # # ]: 0 : }
450 : :
451 : 0 : uno::Any SAL_CALL SwXMailMerge::execute(
452 : : const uno::Sequence< beans::NamedValue >& rArguments )
453 : : throw (IllegalArgumentException, Exception, RuntimeException)
454 : : {
455 [ # # ]: 0 : SolarMutexGuard aGuard;
456 : :
457 : : //
458 : : // get property values to be used
459 : : // (use values from the service as default and override them with
460 : : // the values that are provided as arguments)
461 : : //
462 [ # # ]: 0 : uno::Sequence< uno::Any > aCurSelection = aSelection;
463 : 0 : uno::Reference< sdbc::XResultSet > xCurResultSet = xResultSet;
464 : 0 : uno::Reference< sdbc::XConnection > xCurConnection = xConnection;
465 : 0 : uno::Reference< frame::XModel > xCurModel = xModel;
466 : 0 : OUString aCurDataSourceName = aDataSourceName;
467 : 0 : OUString aCurDataCommand = aDataCommand;
468 : 0 : OUString aCurFilter = aFilter;
469 : 0 : OUString aCurDocumentURL = aDocumentURL;
470 : 0 : OUString aCurOutputURL = aOutputURL;
471 : 0 : OUString aCurFileNamePrefix = aFileNamePrefix;
472 : 0 : sal_Int32 nCurDataCommandType = nDataCommandType;
473 : 0 : sal_Int16 nCurOutputType = nOutputType;
474 : 0 : sal_Bool bCurEscapeProcessing = bEscapeProcessing;
475 : 0 : sal_Bool bCurSinglePrintJobs = bSinglePrintJobs;
476 : 0 : sal_Bool bCurFileNameFromColumn = bFileNameFromColumn;
477 : : //
478 : 0 : SfxObjectShellRef xCurDocSh = xDocSh; // the document
479 : : //
480 : 0 : const beans::NamedValue *pArguments = rArguments.getConstArray();
481 : 0 : sal_Int32 nArgs = rArguments.getLength();
482 [ # # ]: 0 : for (sal_Int32 i = 0; i < nArgs; ++i)
483 : : {
484 : 0 : const OUString &rName = pArguments[i].Name;
485 : 0 : const Any &rValue = pArguments[i].Value;
486 : :
487 : 0 : sal_Bool bOK = sal_True;
488 [ # # ][ # # ]: 0 : if (rName.equalsAscii( GetPropName( UNO_NAME_SELECTION ) ))
489 [ # # ]: 0 : bOK = rValue >>= aCurSelection;
490 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_RESULT_SET ) ))
491 [ # # ]: 0 : bOK = rValue >>= xCurResultSet;
492 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_CONNECTION ) ))
493 [ # # ]: 0 : bOK = rValue >>= xCurConnection;
494 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_MODEL ) ))
495 [ # # ][ # # ]: 0 : throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
496 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_DATA_SOURCE_NAME ) ))
497 : 0 : bOK = rValue >>= aCurDataSourceName;
498 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_DAD_COMMAND ) ))
499 : 0 : bOK = rValue >>= aCurDataCommand;
500 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_FILTER ) ))
501 : 0 : bOK = rValue >>= aCurFilter;
502 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_DOCUMENT_URL ) ))
503 : : {
504 : 0 : bOK = rValue >>= aCurDocumentURL;
505 [ # # ][ # # ]: 0 : if (!aCurDocumentURL.isEmpty()
[ # # ]
506 [ # # ][ # # ]: 0 : && !LoadFromURL_impl( xCurModel, xCurDocSh, aCurDocumentURL, sal_False ))
[ # # ][ # # ]
[ # # ]
507 [ # # ][ # # ]: 0 : throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to create document from URL: " ) ) + aCurDocumentURL, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
508 : : }
509 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_OUTPUT_URL ) ))
510 : : {
511 : 0 : bOK = rValue >>= aCurOutputURL;
512 [ # # ]: 0 : if (!aCurOutputURL.isEmpty())
513 : : {
514 [ # # ][ # # ]: 0 : if (!UCB_IsDirectory(aCurOutputURL))
[ # # ][ # # ]
515 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL does not point to a directory: " ) ) + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
516 [ # # ][ # # ]: 0 : if (UCB_IsReadOnlyFileName(aCurOutputURL))
[ # # ][ # # ]
517 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL is read-only: " ) ) + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
518 : : }
519 : : }
520 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_FILE_NAME_PREFIX ) ))
521 : 0 : bOK = rValue >>= aCurFileNamePrefix;
522 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_DAD_COMMAND_TYPE ) ))
523 : 0 : bOK = rValue >>= nCurDataCommandType;
524 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_OUTPUT_TYPE ) ))
525 : 0 : bOK = rValue >>= nCurOutputType;
526 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_ESCAPE_PROCESSING ) ))
527 : 0 : bOK = rValue >>= bCurEscapeProcessing;
528 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SINGLE_PRINT_JOBS ) ))
529 : 0 : bOK = rValue >>= bCurSinglePrintJobs;
530 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_FILE_NAME_FROM_COLUMN ) ))
531 : 0 : bOK = rValue >>= bCurFileNameFromColumn;
532 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SUBJECT ) ))
533 : 0 : bOK = rValue >>= sSubject;
534 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_ADDRESS_FROM_COLUMN ) ))
535 : 0 : bOK = rValue >>= sAddressFromColumn;
536 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SEND_AS_HTML ) ))
537 : 0 : bOK = rValue >>= bSendAsHTML;
538 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_MAIL_BODY ) ))
539 : 0 : bOK = rValue >>= sMailBody;
540 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_ATTACHMENT_NAME ) ))
541 : 0 : bOK = rValue >>= sAttachmentName;
542 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_ATTACHMENT_FILTER ) ))
543 : 0 : bOK = rValue >>= sAttachmentFilter;
544 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_COPIES_TO ) ))
545 [ # # ]: 0 : bOK = rValue >>= aCopiesTo;
546 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_BLIND_COPIES_TO ) ))
547 [ # # ]: 0 : bOK = rValue >>= aBlindCopiesTo;
548 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SEND_AS_ATTACHMENT ) ))
549 : 0 : bOK = rValue >>= bSendAsAttachment;
550 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_PRINT_OPTIONS ) ))
551 [ # # ]: 0 : bOK = rValue >>= aPrintSettings;
552 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_AS_SINGLE_FILE ) ))
553 : 0 : bOK = rValue >>= bSaveAsSingleFile;
554 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_FILTER ) ))
555 : 0 : bOK = rValue >>= sSaveFilter;
556 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_FILTER_OPTIONS ) ))
557 : 0 : bOK = rValue >>= sSaveFilterOptions;
558 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_FILTER_DATA ) ))
559 [ # # ]: 0 : bOK = rValue >>= aSaveFilterData;
560 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_IN_SERVER_PASSWORD ) ))
561 : 0 : bOK = rValue >>= sInServerPassword;
562 [ # # ][ # # ]: 0 : else if (rName.equalsAscii( GetPropName( UNO_NAME_OUT_SERVER_PASSWORD ) ))
563 : 0 : bOK = rValue >>= sOutServerPassword;
564 : : else
565 [ # # ][ # # ]: 0 : throw UnknownPropertyException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is unknown: " ) ) + rName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
566 : :
567 [ # # ]: 0 : if (!bOK)
568 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property type mismatch or property not set: " ) ) + rName, static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
569 : : }
570 : :
571 : : // need to translate the selection: the API here requires a sequence of bookmarks, but the MergeNew
572 : : // method we will call below requires a sequence of indicies.
573 [ # # ]: 0 : if ( aCurSelection.getLength() )
574 : : {
575 [ # # ]: 0 : Sequence< Any > aTranslated( aCurSelection.getLength() );
576 : :
577 : 0 : sal_Bool bValid = sal_False;
578 [ # # ]: 0 : Reference< sdbcx::XRowLocate > xRowLocate( xCurResultSet, UNO_QUERY );
579 [ # # ]: 0 : if ( xRowLocate.is() )
580 : : {
581 : :
582 : 0 : const Any* pBookmarks = aCurSelection.getConstArray();
583 : 0 : const Any* pBookmarksEnd = pBookmarks + aCurSelection.getLength();
584 [ # # ]: 0 : Any* pTranslated = aTranslated.getArray();
585 : :
586 : : try
587 : : {
588 : 0 : sal_Bool bEverythingsFine = sal_True;
589 [ # # ][ # # ]: 0 : for ( ; ( pBookmarks != pBookmarksEnd ) && bEverythingsFine; ++pBookmarks )
[ # # ]
590 : : {
591 [ # # ][ # # ]: 0 : if ( xRowLocate->moveToBookmark( *pBookmarks ) )
[ # # ]
592 [ # # ][ # # ]: 0 : *pTranslated <<= xCurResultSet->getRow();
[ # # ][ # # ]
593 : : else
594 : 0 : bEverythingsFine = sal_False;
595 : : }
596 [ # # ]: 0 : if ( bEverythingsFine )
597 : 0 : bValid = sal_True;
598 : : }
599 [ # # ]: 0 : catch (const Exception&)
600 : : {
601 : 0 : bValid = sal_False;
602 : : }
603 : : }
604 : :
605 [ # # ]: 0 : if ( !bValid )
606 : : {
607 : : throw IllegalArgumentException(
608 : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( "The current 'Selection' does not describe a valid array of bookmarks, relative to the current 'ResultSet'." ) ),
609 : : static_cast < cppu::OWeakObject * > ( this ),
610 : : 0
611 [ # # ][ # # ]: 0 : );
[ # # ]
612 : : }
613 : :
614 [ # # ][ # # ]: 0 : aCurSelection = aTranslated;
615 : : }
616 : :
617 [ # # ]: 0 : SfxViewFrame* pFrame = SfxViewFrame::GetFirst( xCurDocSh, sal_False);
618 [ # # ][ # # ]: 0 : SwView *pView = PTR_CAST( SwView, pFrame->GetViewShell() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
619 [ # # ]: 0 : if (!pView)
620 [ # # ]: 0 : throw RuntimeException();
621 : 0 : SwWrtShell &rSh = *pView->GetWrtShellPtr();
622 : :
623 : : // avoid assertion in 'Update' from Sfx by supplying a shell
624 : : // and thus avoiding the SelectShell call in Writers GetState function
625 : : // while still in Update of Sfx.
626 : : // (GetSelection in Update is not allowed)
627 [ # # ]: 0 : if (!aCurDocumentURL.isEmpty())
628 [ # # ]: 0 : pView->AttrChangedNotify( &pView->GetWrtShell() );//Damit SelectShell gerufen wird.
629 : :
630 [ # # ]: 0 : SharedComponent aRowSetDisposeHelper;
631 [ # # ]: 0 : if (!xCurResultSet.is())
632 : : {
633 [ # # ][ # # ]: 0 : if (aCurDataSourceName.isEmpty() || aCurDataCommand.isEmpty() )
[ # # ]
634 : : {
635 : : OSL_FAIL("PropertyValues missing or unset");
636 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Either the ResultSet or DataSourceName and DataCommand must be set." ) ), static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
637 : : }
638 : :
639 : : //
640 : : // build ResultSet from DataSourceName, DataCommand and DataCommandType
641 : : //
642 [ # # ]: 0 : Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
643 [ # # ]: 0 : if (xMgr.is())
644 : : {
645 [ # # ]: 0 : Reference< XInterface > xInstance = xMgr->createInstance(
646 [ # # ][ # # ]: 0 : C2U( "com.sun.star.sdb.RowSet" ));
647 [ # # ]: 0 : aRowSetDisposeHelper.reset( xInstance, SharedComponent::TakeOwnership );
648 [ # # ]: 0 : Reference< XPropertySet > xRowSetPropSet( xInstance, UNO_QUERY );
649 : : OSL_ENSURE( xRowSetPropSet.is(), "failed to get XPropertySet interface from RowSet" );
650 [ # # ]: 0 : if (xRowSetPropSet.is())
651 : : {
652 [ # # ]: 0 : if (xCurConnection.is())
653 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("ActiveConnection"), makeAny( xCurConnection ) );
[ # # ][ # # ]
654 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("DataSourceName"), makeAny( aCurDataSourceName ) );
[ # # ][ # # ]
655 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("Command"), makeAny( aCurDataCommand ) );
[ # # ][ # # ]
656 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("CommandType"), makeAny( nCurDataCommandType ) );
[ # # ][ # # ]
657 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("EscapeProcessing"), makeAny( bCurEscapeProcessing ) );
[ # # ][ # # ]
658 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("ApplyFilter"), makeAny( sal_True ) );
[ # # ][ # # ]
659 [ # # ][ # # ]: 0 : xRowSetPropSet->setPropertyValue( C2U("Filter"), makeAny( aCurFilter ) );
[ # # ][ # # ]
660 : :
661 [ # # ]: 0 : Reference< sdbc::XRowSet > xRowSet( xInstance, UNO_QUERY );
662 [ # # ]: 0 : if (xRowSet.is())
663 [ # # ][ # # ]: 0 : xRowSet->execute(); // build ResultSet from properties
664 [ # # ]: 0 : if( !xCurConnection.is() )
665 [ # # ][ # # ]: 0 : xCurConnection.set( xRowSetPropSet->getPropertyValue( C2U( "ActiveConnection" )), UNO_QUERY );
[ # # ][ # # ]
666 [ # # ][ # # ]: 0 : xCurResultSet = Reference< sdbc::XResultSet >( xRowSet, UNO_QUERY );
667 : 0 : OSL_ENSURE( xCurResultSet.is(), "failed to build ResultSet" );
668 : 0 : }
669 : 0 : }
670 : : }
671 : :
672 [ # # ]: 0 : svx::ODataAccessDescriptor aDescriptor;
673 [ # # ]: 0 : aDescriptor.setDataSource(aCurDataSourceName);
674 [ # # ][ # # ]: 0 : aDescriptor[ svx::daConnection ] <<= xCurConnection;
675 [ # # ][ # # ]: 0 : aDescriptor[ svx::daCommand ] <<= aCurDataCommand;
676 [ # # ][ # # ]: 0 : aDescriptor[ svx::daCommandType ] <<= nCurDataCommandType;
677 [ # # ][ # # ]: 0 : aDescriptor[ svx::daEscapeProcessing ] <<= bCurEscapeProcessing;
678 [ # # ][ # # ]: 0 : aDescriptor[ svx::daCursor ] <<= xCurResultSet;
679 : : // aDescriptor[ svx::daColumnName ] not used
680 : : // aDescriptor[ svx::daColumnObject ] not used
681 [ # # ][ # # ]: 0 : aDescriptor[ svx::daSelection ] <<= aCurSelection;
682 : :
683 : : sal_uInt16 nMergeType;
684 [ # # # # ]: 0 : switch (nCurOutputType)
685 : : {
686 : 0 : case MailMergeType::PRINTER : nMergeType = DBMGR_MERGE_MAILMERGE; break;
687 : 0 : case MailMergeType::FILE : nMergeType = DBMGR_MERGE_MAILFILES; break;
688 : 0 : case MailMergeType::MAIL : nMergeType = DBMGR_MERGE_MAILING; break;
689 : : default:
690 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Invalid value of property:" ) ) + C2U("OutputType"), static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ][ # # ]
691 : : }
692 : :
693 [ # # ]: 0 : SwNewDBMgr* pMgr = rSh.GetNewDBMgr();
694 : : //force layout creation
695 [ # # ]: 0 : rSh.CalcLayout();
696 : : OSL_ENSURE( pMgr, "database manager missing" );
697 : :
698 [ # # ]: 0 : SwMergeDescriptor aMergeDesc( nMergeType, rSh, aDescriptor );
699 : :
700 : 0 : std::auto_ptr< SwMailMergeConfigItem > pMMConfigItem;
701 : 0 : uno::Reference< mail::XMailService > xInService;
702 [ # # ]: 0 : if (MailMergeType::PRINTER == nCurOutputType)
703 : : {
704 [ # # ]: 0 : IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
705 [ # # ]: 0 : SwPrintData aPrtData( pIDDA->getPrintData() );
706 [ # # ]: 0 : aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs );
707 [ # # ]: 0 : pIDDA->setPrintData( aPrtData );
708 : : // #i25686# printing should not be done asynchronously to prevent dangling offices
709 : : // when mail merge is called as command line macro
710 : 0 : aMergeDesc.bPrintAsync = sal_False;
711 [ # # ]: 0 : aMergeDesc.aPrintOptions = aPrintSettings;
712 : 0 : aMergeDesc.bCreateSingleFile = true;
713 : : }
714 : : else /* FILE and MAIL*/
715 : : {
716 [ # # ]: 0 : INetURLObject aURLObj;
717 : 0 : aURLObj.SetSmartProtocol( INET_PROT_FILE );
718 : :
719 [ # # ]: 0 : if (!aCurDocumentURL.isEmpty())
720 : : {
721 : : // if OutputURL or FileNamePrefix are missing get
722 : : // them from DocumentURL
723 [ # # ]: 0 : aURLObj.SetSmartURL( aCurDocumentURL );
724 [ # # ]: 0 : if (aCurFileNamePrefix.isEmpty())
725 [ # # ]: 0 : aCurFileNamePrefix = aURLObj.GetBase(); // filename without extension
726 [ # # ]: 0 : if (aCurOutputURL.isEmpty())
727 : : {
728 [ # # ]: 0 : aURLObj.removeSegment();
729 [ # # ]: 0 : aCurOutputURL = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
730 : : }
731 : : }
732 : : else // default empty document without URL
733 : : {
734 [ # # ]: 0 : if (aCurOutputURL.isEmpty())
735 [ # # ][ # # ]: 0 : throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "OutputURL is not set and can not be obtained." ) ), static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
736 : : }
737 : :
738 [ # # ]: 0 : aURLObj.SetSmartURL( aCurOutputURL );
739 [ # # ][ # # ]: 0 : String aPath = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
740 : :
741 [ # # ]: 0 : String aDelim = rtl::OUString(INET_PATH_TOKEN);
742 [ # # ][ # # ]: 0 : if (aPath.Len() >= aDelim.Len() &&
[ # # ]
743 [ # # ][ # # ]: 0 : aPath.Copy( aPath.Len()-aDelim.Len() ).CompareTo( aDelim ) != COMPARE_EQUAL)
[ # # ][ # # ]
[ # # ]
744 [ # # ]: 0 : aPath += aDelim;
745 [ # # ]: 0 : if (bCurFileNameFromColumn)
746 [ # # ][ # # ]: 0 : pMgr->SetEMailColumn( aCurFileNamePrefix );
[ # # ]
747 : : else
748 : : {
749 [ # # ][ # # ]: 0 : aPath += String( aCurFileNamePrefix );
[ # # ]
750 [ # # ][ # # ]: 0 : pMgr->SetEMailColumn( String() );
[ # # ]
751 : : }
752 [ # # ]: 0 : pMgr->SetSubject( aPath );
753 [ # # ]: 0 : if(MailMergeType::FILE == nCurOutputType)
754 : : {
755 [ # # ]: 0 : aMergeDesc.sSaveToFilter = sSaveFilter;
756 [ # # ]: 0 : aMergeDesc.sSaveToFilterOptions = sSaveFilterOptions;
757 [ # # ]: 0 : aMergeDesc.aSaveToFilterData = aSaveFilterData;
758 : 0 : aMergeDesc.bCreateSingleFile = bSaveAsSingleFile;
759 : : }
760 : : else
761 : : {
762 [ # # ][ # # ]: 0 : pMgr->SetEMailColumn( sAddressFromColumn );
[ # # ]
763 [ # # ]: 0 : if(sAddressFromColumn.isEmpty())
764 [ # # ][ # # ]: 0 : throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Mail address column not set." ) ), static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
765 [ # # ]: 0 : aMergeDesc.sSaveToFilter = sAttachmentFilter;
766 [ # # ]: 0 : aMergeDesc.sSubject = sSubject;
767 [ # # ]: 0 : aMergeDesc.sMailBody = sMailBody;
768 [ # # ]: 0 : aMergeDesc.sAttachmentName = sAttachmentName;
769 [ # # ]: 0 : aMergeDesc.aCopiesTo = aCopiesTo;
770 [ # # ]: 0 : aMergeDesc.aBlindCopiesTo = aBlindCopiesTo;
771 : 0 : aMergeDesc.bSendAsHTML = bSendAsHTML;
772 : 0 : aMergeDesc.bSendAsAttachment = bSendAsAttachment;
773 : :
774 : 0 : aMergeDesc.bCreateSingleFile = sal_False;
775 [ # # ][ # # ]: 0 : pMMConfigItem = std::auto_ptr< SwMailMergeConfigItem >(new SwMailMergeConfigItem);
[ # # ]
776 : 0 : aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get();
777 : : aMergeDesc.xSmtpServer = SwMailMergeHelper::ConnectToSmtpServer(
778 : 0 : *pMMConfigItem,
779 : : xInService,
780 [ # # # # ]: 0 : sInServerPassword, sOutServerPassword );
[ # # ][ # # ]
[ # # ][ # # ]
781 [ # # ][ # # ]: 0 : if( !aMergeDesc.xSmtpServer.is() || !aMergeDesc.xSmtpServer->isConnected())
[ # # ][ # # ]
[ # # ]
782 [ # # ][ # # ]: 0 : throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to connect to mail server." ) ), static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
783 [ # # ][ # # ]: 0 : }
[ # # ]
784 : : }
785 : :
786 : :
787 : : // save document with temporary filename
788 : : const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
789 : : rtl::OUString( FILTER_XML ),
790 [ # # ][ # # ]: 0 : SwDocShell::Factory().GetFilterContainer() );
[ # # ][ # # ]
[ # # ]
791 [ # # ][ # # ]: 0 : String aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*'));
[ # # ][ # # ]
[ # # ]
792 [ # # ][ # # ]: 0 : TempFile aTempFile( C2U("SwMM"), &aExtension );
[ # # ][ # # ]
793 [ # # ][ # # ]: 0 : aTmpFileName = aTempFile.GetName();
[ # # ]
794 : :
795 [ # # ]: 0 : Reference< XStorable > xStorable( xCurModel, UNO_QUERY );
796 : 0 : sal_Bool bStoredAsTemporary = sal_False;
797 [ # # ]: 0 : if ( xStorable.is() )
798 : : {
799 : : try
800 : : {
801 [ # # ][ # # ]: 0 : xStorable->storeAsURL( aTmpFileName, Sequence< PropertyValue >() );
[ # # ][ # # ]
[ # # # # ]
802 : 0 : bStoredAsTemporary = sal_True;
803 : : }
804 [ # # ]: 0 : catch (const Exception&)
805 : : {
806 : : }
807 : : }
808 [ # # ]: 0 : if ( !bStoredAsTemporary )
809 [ # # ][ # # ]: 0 : throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to save temporary file." ) ), static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
810 : :
811 : 0 : pMgr->SetMergeSilent( sal_True ); // suppress dialogs, message boxes, etc.
812 : 0 : const SwXMailMerge *pOldSrc = pMgr->GetMailMergeEvtSrc();
813 : : OSL_ENSURE( !pOldSrc || pOldSrc == this, "Ooops... different event source already set." );
814 : 0 : pMgr->SetMailMergeEvtSrc( this ); // launch events for listeners
815 : :
816 [ # # ][ # # ]: 0 : SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xCurDocSh));
[ # # ][ # # ]
[ # # ]
817 [ # # ]: 0 : sal_Bool bSucc = pMgr->MergeNew( aMergeDesc );
818 [ # # ][ # # ]: 0 : SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), xCurDocSh));
[ # # ][ # # ]
[ # # ]
819 : :
820 : 0 : pMgr->SetMailMergeEvtSrc( pOldSrc );
821 : :
822 [ # # ][ # # ]: 0 : if ( xCurModel.get() != xModel.get() )
[ # # ]
823 : : { // in case it was a temporary model -> close it, and delete the file
824 [ # # ]: 0 : DeleteTmpFile_Impl( xCurModel, xCurDocSh, aTmpFileName );
825 [ # # ]: 0 : aTmpFileName.Erase();
826 : : }
827 : : // (in case it wasn't a temporary model, it will be closed in the dtor, at the latest)
828 : :
829 [ # # ]: 0 : if (!bSucc)
830 [ # # ][ # # ]: 0 : throw Exception( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Mail merge failed. Sorry, no further information available." ) ), static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
831 : :
832 : : //de-initialize services
833 [ # # ][ # # ]: 0 : if(xInService.is() && xInService->isConnected())
[ # # ][ # # ]
[ # # ]
834 [ # # ][ # # ]: 0 : xInService->disconnect();
835 [ # # ][ # # ]: 0 : if(aMergeDesc.xSmtpServer.is() && aMergeDesc.xSmtpServer->isConnected())
[ # # ][ # # ]
[ # # ]
836 [ # # ][ # # ]: 0 : aMergeDesc.xSmtpServer->disconnect();
837 : :
838 [ # # ][ # # ]: 0 : return makeAny( sal_True );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
839 : : }
840 : :
841 : 0 : void SwXMailMerge::LaunchMailMergeEvent( const MailMergeEvent &rEvt ) const
842 : : {
843 [ # # ]: 0 : cppu::OInterfaceIteratorHelper aIt( ((SwXMailMerge *) this)->aMergeListeners );
844 [ # # ]: 0 : while (aIt.hasMoreElements())
845 : : {
846 [ # # ][ # # ]: 0 : Reference< XMailMergeListener > xRef( aIt.next(), UNO_QUERY );
847 [ # # ]: 0 : if (xRef.is())
848 [ # # ][ # # ]: 0 : xRef->notifyMailMergeEvent( rEvt );
849 [ # # ]: 0 : }
850 : 0 : }
851 : :
852 : 0 : void SwXMailMerge::launchEvent( const PropertyChangeEvent &rEvt ) const
853 : : {
854 : : cppu::OInterfaceContainerHelper *pContainer =
855 : 0 : aPropListeners.getContainer( rEvt.PropertyHandle );
856 [ # # ]: 0 : if (pContainer)
857 : : {
858 [ # # ]: 0 : cppu::OInterfaceIteratorHelper aIt( *pContainer );
859 [ # # ]: 0 : while (aIt.hasMoreElements())
860 : : {
861 [ # # ][ # # ]: 0 : Reference< XPropertyChangeListener > xRef( aIt.next(), UNO_QUERY );
862 [ # # ]: 0 : if (xRef.is())
863 [ # # ][ # # ]: 0 : xRef->propertyChange( rEvt );
864 [ # # ]: 0 : }
865 : : }
866 : 0 : }
867 : :
868 : :
869 : 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXMailMerge::getPropertySetInfo( )
870 : : throw (RuntimeException)
871 : : {
872 [ # # ]: 0 : SolarMutexGuard aGuard;
873 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > aRef = pPropSet->getPropertySetInfo();
[ # # ][ # # ]
874 [ # # ]: 0 : return aRef;
875 : : }
876 : :
877 : 0 : void SAL_CALL SwXMailMerge::setPropertyValue(
878 : : const OUString& rPropertyName, const uno::Any& rValue )
879 : : throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
880 : : {
881 [ # # ]: 0 : SolarMutexGuard aGuard;
882 : :
883 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
884 [ # # ]: 0 : if (!pCur)
885 [ # # ]: 0 : throw UnknownPropertyException();
886 [ # # ]: 0 : else if (pCur->nFlags & PropertyAttribute::READONLY)
887 [ # # ]: 0 : throw PropertyVetoException();
888 : : else
889 : : {
890 : 0 : void *pData = NULL;
891 : 0 : const uno::Type* pType = pCur->pType;
892 [ # # # # : 0 : switch (pCur->nWID)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
893 : : {
894 : 0 : case WID_SELECTION : pData = &aSelection; break;
895 : 0 : case WID_RESULT_SET : pData = &xResultSet; break;
896 : 0 : case WID_CONNECTION : pData = &xConnection; break;
897 : 0 : case WID_MODEL : pData = &xModel; break;
898 : 0 : case WID_DATA_SOURCE_NAME : pData = &aDataSourceName; break;
899 : 0 : case WID_DATA_COMMAND : pData = &aDataCommand; break;
900 : 0 : case WID_FILTER : pData = &aFilter; break;
901 : 0 : case WID_DOCUMENT_URL : pData = &aDocumentURL; break;
902 : 0 : case WID_OUTPUT_URL : pData = &aOutputURL; break;
903 : 0 : case WID_DATA_COMMAND_TYPE : pData = &nDataCommandType; break;
904 : 0 : case WID_OUTPUT_TYPE : pData = &nOutputType; break;
905 : 0 : case WID_ESCAPE_PROCESSING : pData = &bEscapeProcessing; break;
906 : 0 : case WID_SINGLE_PRINT_JOBS : pData = &bSinglePrintJobs; break;
907 : 0 : case WID_FILE_NAME_FROM_COLUMN : pData = &bFileNameFromColumn; break;
908 : 0 : case WID_FILE_NAME_PREFIX : pData = &aFileNamePrefix; break;
909 : 0 : case WID_MAIL_SUBJECT: pData = &sSubject; break;
910 : 0 : case WID_ADDRESS_FROM_COLUMN: pData = &sAddressFromColumn; break;
911 : 0 : case WID_SEND_AS_HTML: pData = &bSendAsHTML; break;
912 : 0 : case WID_SEND_AS_ATTACHMENT: pData = &bSendAsAttachment; break;
913 : 0 : case WID_MAIL_BODY: pData = &sMailBody; break;
914 : 0 : case WID_ATTACHMENT_NAME: pData = &sAttachmentName; break;
915 : 0 : case WID_ATTACHMENT_FILTER: pData = &sAttachmentFilter;break;
916 : 0 : case WID_PRINT_OPTIONS: pData = &aPrintSettings; break;
917 : 0 : case WID_SAVE_AS_SINGLE_FILE: pData = &bSaveAsSingleFile; break;
918 : 0 : case WID_SAVE_FILTER: pData = &sSaveFilter; break;
919 : 0 : case WID_SAVE_FILTER_OPTIONS: pData = &sSaveFilterOptions; break;
920 : 0 : case WID_SAVE_FILTER_DATA: pData = &aSaveFilterData; break;
921 : 0 : case WID_COPIES_TO: pData = &aCopiesTo; break;
922 : 0 : case WID_BLIND_COPIES_TO: pData = &aBlindCopiesTo;break;
923 : 0 : case WID_IN_SERVER_PASSWORD: pData = &sInServerPassword; break;
924 : 0 : case WID_OUT_SERVER_PASSWORD: pData = &sOutServerPassword; break;
925 : : default :
926 : : OSL_FAIL("unknown WID");
927 : : }
928 : 0 : Any aOld( pData, *pType );
929 : :
930 : 0 : sal_Bool bChanged = sal_False;
931 : 0 : sal_Bool bOK = sal_True;
932 [ # # ]: 0 : if (aOld != rValue)
933 : : {
934 [ # # ]: 0 : if (pData == &aSelection)
935 [ # # ]: 0 : bOK = rValue >>= aSelection;
936 [ # # ]: 0 : else if (pData == &xResultSet)
937 [ # # ]: 0 : bOK = rValue >>= xResultSet;
938 [ # # ]: 0 : else if (pData == &xConnection)
939 [ # # ]: 0 : bOK = rValue >>= xConnection;
940 [ # # ]: 0 : else if (pData == &xModel)
941 [ # # ]: 0 : bOK = rValue >>= xModel;
942 [ # # ]: 0 : else if (pData == &aDataSourceName)
943 : 0 : bOK = rValue >>= aDataSourceName;
944 [ # # ]: 0 : else if (pData == &aDataCommand)
945 : 0 : bOK = rValue >>= aDataCommand;
946 [ # # ]: 0 : else if (pData == &aFilter)
947 : 0 : bOK = rValue >>= aFilter;
948 [ # # ]: 0 : else if (pData == &aDocumentURL)
949 : : {
950 : 0 : OUString aText;
951 : 0 : bOK = rValue >>= aText;
952 [ # # ][ # # ]: 0 : if (!aText.isEmpty()
[ # # ]
953 [ # # ][ # # ]: 0 : && !LoadFromURL_impl( xModel, xDocSh, aText, sal_True ))
[ # # ][ # # ]
[ # # ]
954 [ # # ][ # # ]: 0 : throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to create document from URL: " ) ) + aText, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
955 : 0 : aDocumentURL = aText;
956 : : }
957 [ # # ]: 0 : else if (pData == &aOutputURL)
958 : : {
959 : 0 : OUString aText;
960 : 0 : bOK = rValue >>= aText;
961 [ # # ]: 0 : if (!aText.isEmpty())
962 : : {
963 [ # # ][ # # ]: 0 : if (!UCB_IsDirectory(aText))
[ # # ][ # # ]
964 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL does not point to a directory: " ) ) + aText, static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
965 [ # # ][ # # ]: 0 : if (UCB_IsReadOnlyFileName(aText))
[ # # ][ # # ]
966 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL is read-only: " ) ) + aText, static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
967 : : }
968 : 0 : aOutputURL = aText;
969 : : }
970 [ # # ]: 0 : else if (pData == &nDataCommandType)
971 : 0 : bOK = rValue >>= nDataCommandType;
972 [ # # ]: 0 : else if (pData == &nOutputType)
973 : 0 : bOK = rValue >>= nOutputType;
974 [ # # ]: 0 : else if (pData == &bEscapeProcessing)
975 : 0 : bOK = rValue >>= bEscapeProcessing;
976 [ # # ]: 0 : else if (pData == &bSinglePrintJobs)
977 : 0 : bOK = rValue >>= bSinglePrintJobs;
978 [ # # ]: 0 : else if (pData == &bFileNameFromColumn)
979 : 0 : bOK = rValue >>= bFileNameFromColumn;
980 [ # # ]: 0 : else if (pData == &aFileNamePrefix)
981 : 0 : bOK = rValue >>= aFileNamePrefix;
982 [ # # ]: 0 : else if (pData == &sSubject)
983 : 0 : bOK = rValue >>= sSubject;
984 [ # # ]: 0 : else if (pData == &sAddressFromColumn)
985 : 0 : bOK = rValue >>= sAddressFromColumn;
986 [ # # ]: 0 : else if (pData == &bSendAsHTML)
987 : 0 : bOK = rValue >>= bSendAsHTML;
988 [ # # ]: 0 : else if (pData == &bSendAsAttachment)
989 : 0 : bOK = rValue >>= bSendAsAttachment;
990 [ # # ]: 0 : else if (pData == &sMailBody)
991 : 0 : bOK = rValue >>= sMailBody;
992 [ # # ]: 0 : else if (pData == &sAttachmentName)
993 : 0 : bOK = rValue >>= sAttachmentName;
994 [ # # ]: 0 : else if (pData == &sAttachmentFilter)
995 : 0 : bOK = rValue >>= sAttachmentFilter;
996 [ # # ]: 0 : else if (pData == &aPrintSettings)
997 [ # # ]: 0 : bOK = rValue >>= aPrintSettings;
998 [ # # ]: 0 : else if (pData == &bSaveAsSingleFile)
999 : 0 : bOK = rValue >>= bSaveAsSingleFile;
1000 [ # # ]: 0 : else if (pData == &sSaveFilter)
1001 : 0 : bOK = rValue >>= sSaveFilter;
1002 [ # # ]: 0 : else if (pData == &sSaveFilterOptions)
1003 : 0 : bOK = rValue >>= sSaveFilterOptions;
1004 [ # # ]: 0 : else if (pData == &aSaveFilterData)
1005 [ # # ]: 0 : bOK = rValue >>= aSaveFilterData;
1006 [ # # ]: 0 : else if (pData == &aCopiesTo)
1007 [ # # ]: 0 : bOK = rValue >>= aCopiesTo;
1008 [ # # ]: 0 : else if (pData == &aBlindCopiesTo)
1009 [ # # ]: 0 : bOK = rValue >>= aBlindCopiesTo;
1010 [ # # ]: 0 : else if(pData == &sInServerPassword)
1011 : 0 : bOK = rValue >>= sInServerPassword;
1012 [ # # ]: 0 : else if(pData == &sOutServerPassword)
1013 : 0 : bOK = rValue >>= sInServerPassword;
1014 : : else {
1015 : : OSL_FAIL("invalid pointer" );
1016 : : }
1017 : : OSL_ENSURE( bOK, "set value failed" );
1018 : 0 : bChanged = sal_True;
1019 : : }
1020 [ # # ]: 0 : if (!bOK)
1021 [ # # ][ # # ]: 0 : throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property type mismatch or property not set: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 );
[ # # ]
1022 : :
1023 [ # # ]: 0 : if (bChanged)
1024 : : {
1025 : : PropertyChangeEvent aChgEvt( (XPropertySet *) this, rPropertyName,
1026 [ # # ][ # # ]: 0 : sal_False, pCur->nWID, aOld, rValue );
1027 [ # # ][ # # ]: 0 : launchEvent( aChgEvt );
1028 : 0 : }
1029 [ # # ]: 0 : }
1030 : 0 : }
1031 : :
1032 : 0 : uno::Any SAL_CALL SwXMailMerge::getPropertyValue(
1033 : : const OUString& rPropertyName )
1034 : : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1035 : : {
1036 [ # # ]: 0 : SolarMutexGuard aGuard;
1037 : :
1038 : 0 : Any aRet;
1039 : :
1040 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
1041 [ # # ]: 0 : if (!pCur)
1042 [ # # ]: 0 : throw UnknownPropertyException();
1043 : : else
1044 : : {
1045 [ # # # # : 0 : switch (pCur->nWID)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
1046 : : {
1047 [ # # ]: 0 : case WID_SELECTION : aRet <<= aSelection; break;
1048 [ # # ]: 0 : case WID_RESULT_SET : aRet <<= xResultSet; break;
1049 [ # # ]: 0 : case WID_CONNECTION : aRet <<= xConnection; break;
1050 [ # # ]: 0 : case WID_MODEL : aRet <<= xModel; break;
1051 [ # # ]: 0 : case WID_DATA_SOURCE_NAME : aRet <<= aDataSourceName; break;
1052 [ # # ]: 0 : case WID_DATA_COMMAND : aRet <<= aDataCommand; break;
1053 [ # # ]: 0 : case WID_FILTER : aRet <<= aFilter; break;
1054 [ # # ]: 0 : case WID_DOCUMENT_URL : aRet <<= aDocumentURL; break;
1055 [ # # ]: 0 : case WID_OUTPUT_URL : aRet <<= aOutputURL; break;
1056 [ # # ]: 0 : case WID_DATA_COMMAND_TYPE : aRet <<= nDataCommandType; break;
1057 [ # # ]: 0 : case WID_OUTPUT_TYPE : aRet <<= nOutputType; break;
1058 [ # # ]: 0 : case WID_ESCAPE_PROCESSING : aRet <<= bEscapeProcessing; break;
1059 [ # # ]: 0 : case WID_SINGLE_PRINT_JOBS : aRet <<= bSinglePrintJobs; break;
1060 [ # # ]: 0 : case WID_FILE_NAME_FROM_COLUMN : aRet <<= bFileNameFromColumn; break;
1061 [ # # ]: 0 : case WID_FILE_NAME_PREFIX : aRet <<= aFileNamePrefix; break;
1062 [ # # ]: 0 : case WID_MAIL_SUBJECT: aRet <<= sSubject; break;
1063 [ # # ]: 0 : case WID_ADDRESS_FROM_COLUMN: aRet <<= sAddressFromColumn; break;
1064 [ # # ]: 0 : case WID_SEND_AS_HTML: aRet <<= bSendAsHTML; break;
1065 [ # # ]: 0 : case WID_SEND_AS_ATTACHMENT: aRet <<= bSendAsAttachment; break;
1066 [ # # ]: 0 : case WID_MAIL_BODY: aRet <<= sMailBody; break;
1067 [ # # ]: 0 : case WID_ATTACHMENT_NAME: aRet <<= sAttachmentName; break;
1068 [ # # ]: 0 : case WID_ATTACHMENT_FILTER: aRet <<= sAttachmentFilter;break;
1069 [ # # ]: 0 : case WID_PRINT_OPTIONS: aRet <<= aPrintSettings; break;
1070 [ # # ]: 0 : case WID_SAVE_AS_SINGLE_FILE: aRet <<= bSaveAsSingleFile; break;
1071 [ # # ]: 0 : case WID_SAVE_FILTER: aRet <<= sSaveFilter; break;
1072 [ # # ]: 0 : case WID_SAVE_FILTER_OPTIONS: aRet <<= sSaveFilterOptions; break;
1073 [ # # ]: 0 : case WID_SAVE_FILTER_DATA: aRet <<= aSaveFilterData; break;
1074 [ # # ]: 0 : case WID_COPIES_TO: aRet <<= aCopiesTo; break;
1075 [ # # ]: 0 : case WID_BLIND_COPIES_TO: aRet <<= aBlindCopiesTo;break;
1076 [ # # ]: 0 : case WID_IN_SERVER_PASSWORD: aRet <<= sInServerPassword; break;
1077 [ # # ]: 0 : case WID_OUT_SERVER_PASSWORD: aRet <<= sOutServerPassword; break;
1078 : : default :
1079 : : OSL_FAIL("unknown WID");
1080 : : }
1081 : : }
1082 : :
1083 [ # # ]: 0 : return aRet;
1084 : : }
1085 : :
1086 : 0 : void SAL_CALL SwXMailMerge::addPropertyChangeListener(
1087 : : const OUString& rPropertyName,
1088 : : const uno::Reference< beans::XPropertyChangeListener >& rListener )
1089 : : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1090 : : {
1091 [ # # ]: 0 : SolarMutexGuard aGuard;
1092 [ # # ][ # # ]: 0 : if (!bDisposing && rListener.is())
[ # # ]
1093 : : {
1094 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
1095 [ # # ]: 0 : if (pCur)
1096 [ # # ]: 0 : aPropListeners.addInterface( pCur->nWID, rListener );
1097 : : else
1098 [ # # ]: 0 : throw UnknownPropertyException();
1099 [ # # ]: 0 : }
1100 : 0 : }
1101 : :
1102 : 0 : void SAL_CALL SwXMailMerge::removePropertyChangeListener(
1103 : : const OUString& rPropertyName,
1104 : : const uno::Reference< beans::XPropertyChangeListener >& rListener )
1105 : : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1106 : : {
1107 [ # # ]: 0 : SolarMutexGuard aGuard;
1108 [ # # ][ # # ]: 0 : if (!bDisposing && rListener.is())
[ # # ]
1109 : : {
1110 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap().getByName( rPropertyName );
1111 [ # # ]: 0 : if (pCur)
1112 [ # # ]: 0 : aPropListeners.removeInterface( pCur->nWID, rListener );
1113 : : else
1114 [ # # ]: 0 : throw UnknownPropertyException();
1115 [ # # ]: 0 : }
1116 : 0 : }
1117 : :
1118 : 0 : void SAL_CALL SwXMailMerge::addVetoableChangeListener(
1119 : : const OUString& /*rPropertyName*/,
1120 : : const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ )
1121 : : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1122 : : {
1123 : : // no vetoable property, thus no support for vetoable change listeners
1124 : : OSL_FAIL("not implemented");
1125 : 0 : }
1126 : :
1127 : 0 : void SAL_CALL SwXMailMerge::removeVetoableChangeListener(
1128 : : const OUString& /*rPropertyName*/,
1129 : : const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ )
1130 : : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
1131 : : {
1132 : : // no vetoable property, thus no support for vetoable change listeners
1133 : : OSL_FAIL("not implemented");
1134 : 0 : }
1135 : :
1136 : :
1137 : 0 : void SAL_CALL SwXMailMerge::dispose()
1138 : : throw(RuntimeException)
1139 : : {
1140 [ # # ]: 0 : SolarMutexGuard aGuard;
1141 : :
1142 [ # # ]: 0 : if (!bDisposing)
1143 : : {
1144 : 0 : bDisposing = sal_True;
1145 : :
1146 [ # # ][ # # ]: 0 : EventObject aEvtObj( (XPropertySet *) this );
1147 [ # # ]: 0 : aEvtListeners.disposeAndClear( aEvtObj );
1148 [ # # ]: 0 : aMergeListeners.disposeAndClear( aEvtObj );
1149 [ # # ][ # # ]: 0 : aPropListeners.disposeAndClear( aEvtObj );
1150 [ # # ]: 0 : }
1151 : 0 : }
1152 : :
1153 : 0 : void SAL_CALL SwXMailMerge::addEventListener(
1154 : : const Reference< XEventListener >& rxListener )
1155 : : throw(RuntimeException)
1156 : : {
1157 [ # # ]: 0 : SolarMutexGuard aGuard;
1158 [ # # ][ # # ]: 0 : if (!bDisposing && rxListener.is())
[ # # ]
1159 [ # # ][ # # ]: 0 : aEvtListeners.addInterface( rxListener );
1160 : 0 : }
1161 : :
1162 : 0 : void SAL_CALL SwXMailMerge::removeEventListener(
1163 : : const Reference< XEventListener >& rxListener )
1164 : : throw(RuntimeException)
1165 : : {
1166 [ # # ]: 0 : SolarMutexGuard aGuard;
1167 [ # # ][ # # ]: 0 : if (!bDisposing && rxListener.is())
[ # # ]
1168 [ # # ][ # # ]: 0 : aEvtListeners.removeInterface( rxListener );
1169 : 0 : }
1170 : :
1171 : 0 : void SAL_CALL SwXMailMerge::addMailMergeEventListener(
1172 : : const uno::Reference< XMailMergeListener >& rxListener )
1173 : : throw (RuntimeException)
1174 : : {
1175 [ # # ]: 0 : SolarMutexGuard aGuard;
1176 [ # # ][ # # ]: 0 : if (!bDisposing && rxListener.is())
[ # # ]
1177 [ # # ][ # # ]: 0 : aMergeListeners.addInterface( rxListener );
1178 : 0 : }
1179 : :
1180 : 0 : void SAL_CALL SwXMailMerge::removeMailMergeEventListener(
1181 : : const uno::Reference< XMailMergeListener >& rxListener )
1182 : : throw (RuntimeException)
1183 : : {
1184 [ # # ]: 0 : SolarMutexGuard aGuard;
1185 [ # # ][ # # ]: 0 : if (!bDisposing && rxListener.is())
[ # # ]
1186 [ # # ][ # # ]: 0 : aMergeListeners.removeInterface( rxListener );
1187 : 0 : }
1188 : :
1189 : 0 : OUString SAL_CALL SwXMailMerge::getImplementationName()
1190 : : throw(RuntimeException)
1191 : : {
1192 [ # # ]: 0 : SolarMutexGuard aGuard;
1193 [ # # ]: 0 : return SwXMailMerge_getImplementationName();
1194 : : }
1195 : :
1196 : 0 : sal_Bool SAL_CALL SwXMailMerge::supportsService( const OUString& rServiceName )
1197 : : throw(RuntimeException)
1198 : : {
1199 [ # # ]: 0 : SolarMutexGuard aGuard;
1200 [ # # ][ # # ]: 0 : return C2U( SN_MAIL_MERGE ) == rServiceName ||
[ # # ]
1201 [ # # ][ # # ]: 0 : C2U( SN_DATA_ACCESS_DESCRIPTOR ) == rServiceName;
[ # # ][ # # ]
[ # # ][ # # ]
1202 : : }
1203 : :
1204 : 0 : uno::Sequence< OUString > SAL_CALL SwXMailMerge::getSupportedServiceNames()
1205 : : throw(RuntimeException)
1206 : : {
1207 [ # # ]: 0 : SolarMutexGuard aGuard;
1208 [ # # ]: 0 : return SwXMailMerge_getSupportedServiceNames();
1209 : : }
1210 : :
1211 : : ////////////////////////////////////////////////////////////
1212 : :
1213 : 0 : uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames()
1214 : : throw()
1215 : : {
1216 : 0 : uno::Sequence< OUString > aNames(2);
1217 [ # # ]: 0 : OUString *pName = aNames.getArray();
1218 [ # # ]: 0 : pName[0] = C2U( SN_MAIL_MERGE );
1219 [ # # ]: 0 : pName[1] = C2U( SN_DATA_ACCESS_DESCRIPTOR );
1220 : 0 : return aNames;
1221 : : }
1222 : :
1223 : 74 : OUString SAL_CALL SwXMailMerge_getImplementationName()
1224 : : throw()
1225 : : {
1226 : 74 : return OUString( C2U( "SwXMailMerge" ) );
1227 : : }
1228 : :
1229 : 0 : uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(
1230 : : const uno::Reference< XMultiServiceFactory > & /*rSMgr*/)
1231 : : throw( uno::Exception )
1232 : : {
1233 [ # # ]: 0 : SolarMutexGuard aGuard;
1234 : :
1235 : : //the module may not be loaded
1236 [ # # ]: 0 : SwGlobals::ensure();
1237 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface > xRef = (cppu::OWeakObject *) new SwXMailMerge();
1238 [ # # ]: 0 : return xRef;
1239 : : }
1240 : :
1241 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|