Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <sot/storage.hxx>
21 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
22 : : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
23 : : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
24 : : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
25 : : #include <com/sun/star/ui/dialogs/XControlAccess.hpp>
26 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 : : #include <com/sun/star/beans/XPropertyAccess.hpp>
28 : : #include <com/sun/star/beans/XPropertySet.hpp>
29 : : #include <com/sun/star/beans/PropertyValue.hpp>
30 : : #include <com/sun/star/container/XNameAccess.hpp>
31 : : #include <com/sun/star/document/XExporter.hpp>
32 : : #include <com/sun/star/task/XInteractionHandler.hpp>
33 : : #include <com/sun/star/task/XStatusIndicator.hpp>
34 : : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
35 : : #include <com/sun/star/frame/DocumentTemplates.hpp>
36 : : #include <com/sun/star/frame/XDocumentTemplates.hpp>
37 : : #include <com/sun/star/frame/XStorable.hpp>
38 : : #include <comphelper/processfactory.hxx>
39 : : #include <comphelper/servicehelper.hxx>
40 : : #include <com/sun/star/security/CertificateValidity.hpp>
41 : :
42 : : #include <com/sun/star/security/DocumentSignatureInformation.hpp>
43 : : #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
44 : : #include <tools/urlobj.hxx>
45 : : #include <svl/whiter.hxx>
46 : : #include <vcl/msgbox.hxx>
47 : : #include <svl/intitem.hxx>
48 : : #include <svl/eitem.hxx>
49 : : #include <vcl/wrkwin.hxx>
50 : : #include <svtools/sfxecode.hxx>
51 : : #include <svtools/ehdl.hxx>
52 : :
53 : : #include <comphelper/string.hxx>
54 : : #include <basic/sbx.hxx>
55 : : #include <unotools/pathoptions.hxx>
56 : : #include <unotools/useroptions.hxx>
57 : : #include <unotools/saveopt.hxx>
58 : : #include <svtools/asynclink.hxx>
59 : : #include <svtools/miscopt.hxx>
60 : : #include <comphelper/documentconstants.hxx>
61 : :
62 : : #include <sfx2/app.hxx>
63 : : #include <sfx2/signaturestate.hxx>
64 : : #include "sfx2/sfxresid.hxx"
65 : : #include <sfx2/event.hxx>
66 : : #include <sfx2/request.hxx>
67 : : #include <sfx2/printer.hxx>
68 : : #include <sfx2/viewsh.hxx>
69 : : #include <sfx2/doctdlg.hxx>
70 : : #include <sfx2/docfilt.hxx>
71 : : #include <sfx2/docfile.hxx>
72 : : #include <sfx2/dispatch.hxx>
73 : : #include <sfx2/dinfdlg.hxx>
74 : : #include <sfx2/objitem.hxx>
75 : : #include <sfx2/objsh.hxx>
76 : : #include "objshimp.hxx"
77 : : #include "sfxtypes.hxx"
78 : : #include <sfx2/module.hxx>
79 : : #include <sfx2/viewfrm.hxx>
80 : : #include "versdlg.hxx"
81 : : #include "doc.hrc"
82 : : #include <sfx2/docfac.hxx>
83 : : #include <sfx2/fcontnr.hxx>
84 : : #include "sfx2/sfxhelp.hxx"
85 : : #include <sfx2/msgpool.hxx>
86 : : #include <sfx2/objface.hxx>
87 : :
88 : : #include "../appl/app.hrc"
89 : : #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
90 : : #include <com/sun/star/embed/XTransactedObject.hpp>
91 : : #include <com/sun/star/util/XCloneable.hpp>
92 : : #include <com/sun/star/document/XDocumentProperties.hpp>
93 : :
94 : : #include "helpid.hrc"
95 : :
96 : : #include "guisaveas.hxx"
97 : : #include "templatedlg.hxx"
98 : :
99 : : using namespace ::com::sun::star;
100 : : using namespace ::com::sun::star::lang;
101 : : using namespace ::com::sun::star::uno;
102 : : using namespace ::com::sun::star::ui::dialogs;
103 : : using namespace ::com::sun::star::awt;
104 : : using namespace ::com::sun::star::container;
105 : : using namespace ::com::sun::star::beans;
106 : : using namespace ::com::sun::star::document;
107 : : using namespace ::com::sun::star::task;
108 : :
109 : : //====================================================================
110 : :
111 : : class SfxSaveAsContext_Impl
112 : : {
113 : : String& _rNewNameVar;
114 : : String _aNewName;
115 : :
116 : : public:
117 : : SfxSaveAsContext_Impl( String &rNewNameVar,
118 : : const String &rNewName )
119 : : : _rNewNameVar( rNewNameVar ),
120 : : _aNewName( rNewName )
121 : : { rNewNameVar = rNewName; }
122 : : ~SfxSaveAsContext_Impl()
123 : : { _rNewNameVar.Erase(); }
124 : : };
125 : :
126 : : //====================================================================
127 : :
128 : : #define SfxObjectShell
129 : : #include "sfxslots.hxx"
130 : :
131 : : //=========================================================================
132 : :
133 : :
134 : :
135 [ + + ][ + - ]: 723 : SFX_IMPL_INTERFACE(SfxObjectShell,SfxShell,SfxResId(0))
[ + - ]
136 : : {
137 : 233 : }
138 : :
139 : : //=========================================================================
140 : :
141 [ # # ]: 0 : class SfxClosePreventer_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XCloseListener >
142 : : {
143 : : sal_Bool m_bGotOwnership;
144 : : sal_Bool m_bPreventClose;
145 : :
146 : : public:
147 : : SfxClosePreventer_Impl();
148 : :
149 : 0 : sal_Bool HasOwnership() { return m_bGotOwnership; }
150 : :
151 : 0 : void SetPreventClose( sal_Bool bPrevent ) { m_bPreventClose = bPrevent; }
152 : :
153 : : virtual void SAL_CALL queryClosing( const lang::EventObject& aEvent, sal_Bool bDeliverOwnership )
154 : : throw ( uno::RuntimeException, util::CloseVetoException );
155 : :
156 : : virtual void SAL_CALL notifyClosing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException ) ;
157 : :
158 : : virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException ) ;
159 : :
160 : : } ;
161 : :
162 : 0 : SfxClosePreventer_Impl::SfxClosePreventer_Impl()
163 : : : m_bGotOwnership( sal_False )
164 : 0 : , m_bPreventClose( sal_True )
165 : : {
166 : 0 : }
167 : :
168 : 0 : void SAL_CALL SfxClosePreventer_Impl::queryClosing( const lang::EventObject&, sal_Bool bDeliverOwnership )
169 : : throw ( uno::RuntimeException, util::CloseVetoException )
170 : : {
171 [ # # ]: 0 : if ( m_bPreventClose )
172 : : {
173 [ # # ]: 0 : if ( !m_bGotOwnership )
174 : 0 : m_bGotOwnership = bDeliverOwnership;
175 : :
176 [ # # ]: 0 : throw util::CloseVetoException();
177 : : }
178 : 0 : }
179 : :
180 : 0 : void SAL_CALL SfxClosePreventer_Impl::notifyClosing( const lang::EventObject& ) throw ( uno::RuntimeException )
181 : 0 : {}
182 : :
183 : 0 : void SAL_CALL SfxClosePreventer_Impl::disposing( const lang::EventObject& ) throw ( uno::RuntimeException )
184 : 0 : {}
185 : :
186 : : //=========================================================================
187 : : class SfxInstanceCloseGuard_Impl
188 : : {
189 : : SfxClosePreventer_Impl* m_pPreventer;
190 : : uno::Reference< util::XCloseListener > m_xPreventer;
191 : : uno::Reference< util::XCloseable > m_xCloseable;
192 : :
193 : : public:
194 : 0 : SfxInstanceCloseGuard_Impl()
195 : 0 : : m_pPreventer( NULL )
196 : 0 : {}
197 : :
198 : : ~SfxInstanceCloseGuard_Impl();
199 : :
200 : : sal_Bool Init_Impl( const uno::Reference< util::XCloseable >& xCloseable );
201 : : };
202 : :
203 : 0 : sal_Bool SfxInstanceCloseGuard_Impl::Init_Impl( const uno::Reference< util::XCloseable >& xCloseable )
204 : : {
205 : 0 : sal_Bool bResult = sal_False;
206 : :
207 : : // do not allow reinit after the successful init
208 [ # # ][ # # ]: 0 : if ( xCloseable.is() && !m_xCloseable.is() )
[ # # ]
209 : : {
210 : : try
211 : : {
212 [ # # ]: 0 : m_pPreventer = new SfxClosePreventer_Impl();
213 [ # # ][ # # ]: 0 : m_xPreventer = uno::Reference< util::XCloseListener >( m_pPreventer );
[ # # ][ # # ]
214 [ # # ][ # # ]: 0 : xCloseable->addCloseListener( m_xPreventer );
215 [ # # ]: 0 : m_xCloseable = xCloseable;
216 : 0 : bResult = sal_True;
217 : : }
218 : 0 : catch( uno::Exception& )
219 : : {
220 : : OSL_FAIL( "Could not register close listener!\n" );
221 : : }
222 : : }
223 : :
224 : 0 : return bResult;
225 : : }
226 : :
227 : 0 : SfxInstanceCloseGuard_Impl::~SfxInstanceCloseGuard_Impl()
228 : : {
229 [ # # ][ # # ]: 0 : if ( m_xCloseable.is() && m_xPreventer.is() )
[ # # ]
230 : : {
231 : : try
232 : : {
233 [ # # ][ # # ]: 0 : m_xCloseable->removeCloseListener( m_xPreventer );
234 : : }
235 [ # # # # ]: 0 : catch( uno::Exception& )
236 : : {
237 : : }
238 : :
239 : : try
240 : : {
241 [ # # ]: 0 : if ( m_pPreventer )
242 : : {
243 : 0 : m_pPreventer->SetPreventClose( sal_False );
244 : :
245 [ # # ]: 0 : if ( m_pPreventer->HasOwnership() )
246 [ # # ][ # # ]: 0 : m_xCloseable->close( sal_True ); // TODO: do it asynchronously
247 : : }
248 : : }
249 [ # # ]: 0 : catch( uno::Exception& )
250 : : {
251 : : }
252 : : }
253 [ # # ]: 0 : }
254 : :
255 : : //=========================================================================
256 : :
257 : 0 : void SfxObjectShell::PrintExec_Impl(SfxRequest &rReq)
258 : : {
259 : 0 : SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
260 [ # # ]: 0 : if ( pFrame )
261 : : {
262 : 0 : rReq.SetSlot( SID_PRINTDOC );
263 : 0 : pFrame->GetViewShell()->ExecuteSlot(rReq);
264 : : }
265 : 0 : }
266 : :
267 : : //--------------------------------------------------------------------
268 : :
269 : 0 : void SfxObjectShell::PrintState_Impl(SfxItemSet &rSet)
270 : : {
271 : 0 : bool bPrinting = false;
272 : 0 : SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
273 [ # # ]: 0 : if ( pFrame )
274 : : {
275 : 0 : SfxPrinter *pPrinter = pFrame->GetViewShell()->GetPrinter();
276 [ # # ][ # # ]: 0 : bPrinting = pPrinter && pPrinter->IsPrinting();
277 : : }
278 [ # # ]: 0 : rSet.Put( SfxBoolItem( SID_PRINTOUT, bPrinting ) );
279 : 0 : }
280 : :
281 : : //--------------------------------------------------------------------
282 : :
283 : 177 : sal_Bool SfxObjectShell::APISaveAs_Impl
284 : : (
285 : : const String& aFileName,
286 : : SfxItemSet* aParams
287 : : )
288 : : {
289 : 177 : sal_Bool bOk = sal_False;
290 : :
291 : : {DBG_CHKTHIS(SfxObjectShell, 0);}
292 : :
293 [ + - ]: 177 : if ( GetMedium() )
294 : : {
295 [ + - ]: 177 : String aFilterName;
296 [ + - ][ + - ]: 177 : SFX_ITEMSET_ARG( aParams, pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False );
297 [ + + ]: 177 : if( pFilterNameItem )
298 : : {
299 [ + - ]: 167 : aFilterName = pFilterNameItem->GetValue();
300 : : }
301 : : else
302 : : {
303 [ + - ][ + - ]: 10 : SFX_ITEMSET_ARG( aParams, pContentTypeItem, SfxStringItem, SID_CONTENTTYPE, sal_False );
304 [ - + ]: 10 : if ( pContentTypeItem )
305 : : {
306 [ # # ][ # # ]: 0 : const SfxFilter* pFilter = SfxFilterMatcher( rtl::OUString::createFromAscii(GetFactory().GetShortName()) ).GetFilter4Mime( pContentTypeItem->GetValue(), SFX_FILTER_EXPORT );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
307 [ # # ]: 0 : if ( pFilter )
308 [ # # ]: 0 : aFilterName = pFilter->GetName();
309 : : }
310 : : }
311 : :
312 : : // in case no filter defined use default one
313 [ + + ]: 177 : if( !aFilterName.Len() )
314 : : {
315 [ + - ][ + - ]: 10 : const SfxFilter* pFilt = SfxFilter::GetDefaultFilterFromFactory(GetFactory().GetFactoryName());
[ + - ][ + - ]
316 : :
317 : : DBG_ASSERT( pFilt, "No default filter!\n" );
318 [ + - ]: 10 : if( pFilt )
319 [ + - ]: 10 : aFilterName = pFilt->GetFilterName();
320 : :
321 [ + - ][ + - ]: 10 : aParams->Put(SfxStringItem( SID_FILTER_NAME, aFilterName));
[ + - ]
322 : : }
323 : :
324 : :
325 : : {
326 : 177 : SfxObjectShellRef xLock( this ); // ???
327 : :
328 : : // use the title that is provided in the media descriptor
329 [ + - ][ + - ]: 177 : SFX_ITEMSET_ARG( aParams, pDocTitleItem, SfxStringItem, SID_DOCINFO_TITLE, sal_False );
330 [ - + ]: 177 : if ( pDocTitleItem )
331 [ # # ][ # # ]: 0 : getDocProperties()->setTitle( pDocTitleItem->GetValue() );
[ # # ][ # # ]
332 : :
333 : : bOk = CommonSaveAs_Impl( INetURLObject(aFileName), aFilterName,
334 [ + - ][ + - ]: 177 : aParams );
[ + - ][ + - ]
[ + - ]
335 : :
336 [ + - ]: 177 : }
337 : : }
338 : :
339 : 177 : return bOk;
340 : : }
341 : :
342 : : //--------------------------------------------------------------------
343 : :
344 : 0 : void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
345 : : {
346 : : {DBG_CHKTHIS(SfxObjectShell, 0);}
347 : :
348 : 0 : sal_uInt16 nId = rReq.GetSlot();
349 : :
350 [ # # ][ # # ]: 0 : if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId )
351 : : {
352 [ # # ][ # # ]: 0 : if ( QueryHiddenInformation( WhenSigning, NULL ) == RET_YES )
353 [ # # ][ # # ]: 0 : ( SID_SIGNATURE == nId ) ? SignDocumentContent() : SignScriptingContent();
[ # # ]
354 : : return;
355 : : }
356 : :
357 [ # # ][ # # ]: 0 : if ( !GetMedium() && nId != SID_CLOSEDOC )
[ # # ]
358 : : {
359 [ # # ]: 0 : rReq.Ignore();
360 : : return;
361 : : }
362 : :
363 : : // this guard is created here to have it destruction at the end of the method
364 [ # # ]: 0 : SfxInstanceCloseGuard_Impl aModelGuard;
365 : :
366 : 0 : sal_Bool bIsPDFExport = sal_False;
367 [ # # # # : 0 : switch(nId)
# # # ]
368 : : {
369 : : case SID_VERSION:
370 : : {
371 [ # # ]: 0 : SfxViewFrame* pFrame = GetFrame();
372 [ # # ]: 0 : if ( !pFrame )
373 [ # # ]: 0 : pFrame = SfxViewFrame::GetFirst( this );
374 [ # # ]: 0 : if ( !pFrame )
375 : : return;
376 : :
377 [ # # ][ # # ]: 0 : if ( pFrame->GetFrame().GetParentFrame() )
378 : : {
379 [ # # ][ # # ]: 0 : pFrame->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq );
[ # # ]
380 : : return;
381 : : }
382 : :
383 [ # # ][ # # ]: 0 : if ( !IsOwnStorageFormat_Impl( *GetMedium() ) )
384 : : return;
385 : :
386 [ # # ][ # # ]: 0 : SfxVersionDialog *pDlg = new SfxVersionDialog( pFrame, IsSaveVersionOnClose() );
[ # # ]
387 [ # # ]: 0 : pDlg->Execute();
388 [ # # ]: 0 : SetSaveVersionOnClose( pDlg->IsSaveVersionOnClose() );
389 [ # # ][ # # ]: 0 : delete pDlg;
390 [ # # ]: 0 : rReq.Done();
391 : : return;
392 : : }
393 : :
394 : : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
395 : : case SID_DOCINFO:
396 : : {
397 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pDocInfItem, SfxDocumentInfoItem, SID_DOCINFO, sal_False);
398 [ # # ]: 0 : if ( pDocInfItem )
399 : : {
400 : : // parameter, e.g. from replayed macro
401 [ # # ][ # # ]: 0 : pDocInfItem->UpdateDocumentInfo(getDocProperties(), true);
402 [ # # ][ # # ]: 0 : SetUseUserData( pDocInfItem->IsUseUserData() );
403 : : }
404 : : else
405 : : {
406 : : // no argument containing DocInfo; check optional arguments
407 [ # # ]: 0 : sal_Bool bReadOnly = IsReadOnly();
408 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pROItem, SfxBoolItem, SID_DOC_READONLY, sal_False);
409 [ # # ]: 0 : if ( pROItem )
410 : : // override readonly attribute of document
411 : : // e.g. if a readonly document is saved elsewhere and user asks for editing DocInfo before
412 : 0 : bReadOnly = pROItem->GetValue();
413 : :
414 : : // collect data for dialog
415 [ # # ][ # # ]: 0 : String aURL, aTitle;
416 [ # # ]: 0 : if ( HasName() )
417 : : {
418 [ # # ][ # # ]: 0 : aURL = GetMedium()->GetName();
419 [ # # ][ # # ]: 0 : aTitle = GetTitle();
[ # # ]
420 : : }
421 : : else
422 : : {
423 [ # # ][ # # ]: 0 : aURL = DEFINE_CONST_UNICODE( "private:factory/" );
[ # # ]
424 [ # # ][ # # ]: 0 : aURL += rtl::OUString::createFromAscii( GetFactory().GetShortName() );
425 : :
426 [ # # ][ # # ]: 0 : aTitle = GetTitle();
[ # # ]
427 : : }
428 : :
429 : : SfxDocumentInfoItem aDocInfoItem( aURL, getDocProperties(),
430 [ # # ][ # # ]: 0 : IsUseUserData() );
[ # # ]
431 [ # # ][ # # ]: 0 : if ( !GetSlotState( SID_DOCTEMPLATE ) )
432 : : // templates not supported
433 : 0 : aDocInfoItem.SetTemplate(sal_False);
434 : :
435 : 0 : SfxItemSet aSet(GetPool(), SID_DOCINFO, SID_DOCINFO, SID_DOC_READONLY, SID_DOC_READONLY,
436 : : SID_EXPLORER_PROPS_START, SID_EXPLORER_PROPS_START, SID_BASEURL, SID_BASEURL,
437 [ # # ]: 0 : 0L );
438 [ # # ]: 0 : aSet.Put( aDocInfoItem );
439 [ # # ][ # # ]: 0 : aSet.Put( SfxBoolItem( SID_DOC_READONLY, bReadOnly ) );
[ # # ]
440 [ # # ][ # # ]: 0 : aSet.Put( SfxStringItem( SID_EXPLORER_PROPS_START, aTitle ) );
[ # # ]
441 [ # # ][ # # ]: 0 : aSet.Put( SfxStringItem( SID_BASEURL, GetMedium()->GetBaseURL() ) );
[ # # ][ # # ]
[ # # ][ # # ]
442 : :
443 : : // creating dialog is done via virtual method; application will
444 : : // add its own statistics page
445 [ # # ]: 0 : SfxDocumentInfoDialog *pDlg = CreateDocumentInfoDialog(0, aSet);
446 [ # # ][ # # ]: 0 : if ( RET_OK == pDlg->Execute() )
447 : : {
448 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pDocInfoItem, SfxDocumentInfoItem, SID_DOCINFO, sal_False);
449 [ # # ]: 0 : if ( pDocInfoItem )
450 : : {
451 : : // user has done some changes to DocumentInfo
452 [ # # ][ # # ]: 0 : pDocInfoItem->UpdateDocumentInfo(getDocProperties());
453 [ # # ][ # # ]: 0 : SetUseUserData( ((const SfxDocumentInfoItem *)pDocInfoItem)->IsUseUserData() );
454 : :
455 : : // add data from dialog for possible recording purposes
456 : : rReq.AppendItem( SfxDocumentInfoItem( GetTitle(),
457 [ # # ][ # # ]: 0 : getDocProperties(), IsUseUserData() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
458 : : }
459 : :
460 [ # # ]: 0 : rReq.Done();
461 : : }
462 : : else
463 : : // nothing done; no recording
464 [ # # ]: 0 : rReq.Ignore();
465 : :
466 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
[ # # ][ # # ]
467 : : }
468 : :
469 : : return;
470 : : }
471 : :
472 : : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
473 : :
474 : : case SID_EXPORTDOCASPDF:
475 : : case SID_DIRECTEXPORTDOCASPDF:
476 : 0 : bIsPDFExport = sal_True;
477 : : case SID_EXPORTDOC:
478 : : case SID_SAVEASDOC:
479 : : case SID_SAVEDOC:
480 : : {
481 : : // derived class may decide to abort this
482 [ # # ][ # # ]: 0 : if( !QuerySlotExecutable( nId ) )
483 : : {
484 [ # # ][ # # ]: 0 : rReq.SetReturnValue( SfxBoolItem( 0, sal_False ) );
[ # # ]
485 : : return;
486 : : }
487 : :
488 : : //!! detailed analysis of an error code
489 : 0 : SfxObjectShellRef xLock( this );
490 : :
491 : : // the model can not be closed till the end of this method
492 : : // if somebody tries to close it during this time the model will be closed
493 : : // at the end of the method
494 [ # # ][ # # ]: 0 : aModelGuard.Init_Impl( uno::Reference< util::XCloseable >( GetModel(), uno::UNO_QUERY ) );
[ # # ]
495 : :
496 : 0 : sal_Bool bDialogUsed = sal_False;
497 : 0 : sal_uInt32 nErrorCode = ERRCODE_NONE;
498 : :
499 : : // by default versions should be preserved always except in case of an explicit
500 : : // SaveAs via GUI, so the flag must be set accordingly
501 : 0 : pImp->bPreserveVersions = (nId == SID_SAVEDOC);
502 : : try
503 : : {
504 [ # # ][ # # ]: 0 : SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, GetTitle() ); // ???
[ # # ]
505 : :
506 [ # # ]: 0 : if ( nId == SID_SAVEASDOC )
507 : : {
508 : : // in case of plugin mode the SaveAs operation means SaveTo
509 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pViewOnlyItem, SfxBoolItem, SID_VIEWONLY, sal_False );
[ # # ]
510 [ # # ][ # # ]: 0 : if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
[ # # ]
511 [ # # ][ # # ]: 0 : rReq.AppendItem( SfxBoolItem( SID_SAVETO, sal_True ) );
[ # # ]
512 : : }
513 : :
514 : : // TODO/LATER: do the following GUI related actions in standalown method
515 : : // ========================================================================================================
516 : : // Introduce a status indicator for GUI operation
517 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pStatusIndicatorItem, SfxUnoAnyItem, SID_PROGRESS_STATUSBAR_CONTROL, sal_False );
518 [ # # ]: 0 : if ( !pStatusIndicatorItem )
519 : : {
520 : : // get statusindicator
521 : 0 : uno::Reference< task::XStatusIndicator > xStatusIndicator;
522 [ # # ][ # # ]: 0 : uno::Reference < frame::XController > xCtrl( GetModel()->getCurrentController() );
[ # # ]
523 [ # # ]: 0 : if ( xCtrl.is() )
524 : : {
525 [ # # ][ # # ]: 0 : uno::Reference< task::XStatusIndicatorFactory > xStatFactory( xCtrl->getFrame(), uno::UNO_QUERY );
[ # # ]
526 [ # # ]: 0 : if( xStatFactory.is() )
527 [ # # ][ # # ]: 0 : xStatusIndicator = xStatFactory->createStatusIndicator();
[ # # ]
528 : : }
529 : :
530 : : OSL_ENSURE( xStatusIndicator.is(), "Can not retrieve default status indicator!\n" );
531 : :
532 [ # # ]: 0 : if ( xStatusIndicator.is() )
533 : : {
534 [ # # ][ # # ]: 0 : SfxUnoAnyItem aStatIndItem( SID_PROGRESS_STATUSBAR_CONTROL, uno::makeAny( xStatusIndicator ) );
535 : :
536 [ # # ]: 0 : if ( nId == SID_SAVEDOC )
537 : : {
538 : : // in case of saving it is not possible to transport the parameters from here
539 : : // but it is not clear here whether the saving will be done or saveAs operation
540 [ # # ][ # # ]: 0 : GetMedium()->GetItemSet()->Put( aStatIndItem );
541 : : }
542 : :
543 [ # # ][ # # ]: 0 : rReq.AppendItem( aStatIndItem );
544 : 0 : }
545 : : }
546 [ # # ]: 0 : else if ( nId == SID_SAVEDOC )
547 : : {
548 : : // in case of saving it is not possible to transport the parameters from here
549 : : // but it is not clear here whether the saving will be done or saveAs operation
550 [ # # ][ # # ]: 0 : GetMedium()->GetItemSet()->Put( *pStatusIndicatorItem );
551 : : }
552 : :
553 : : // Introduce an interaction handler for GUI operation
554 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pInteractionHandlerItem, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False );
555 [ # # ]: 0 : if ( !pInteractionHandlerItem )
556 : : {
557 : 0 : uno::Reference< task::XInteractionHandler > xInteract;
558 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
559 [ # # ]: 0 : if( xServiceManager.is() )
560 : : {
561 : : xInteract = Reference< XInteractionHandler >(
562 [ # # ]: 0 : xServiceManager->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
563 [ # # ][ # # ]: 0 : UNO_QUERY );
[ # # ][ # # ]
[ # # ][ # # ]
564 : : }
565 : :
566 : : OSL_ENSURE( xInteract.is(), "Can not retrieve default status indicator!\n" );
567 [ # # ]: 0 : if ( xInteract.is() )
568 : : {
569 [ # # ][ # # ]: 0 : SfxUnoAnyItem aInteractionItem( SID_INTERACTIONHANDLER, uno::makeAny( xInteract ) );
570 [ # # ]: 0 : if ( nId == SID_SAVEDOC )
571 : : {
572 : : // in case of saving it is not possible to transport the parameters from here
573 : : // but it is not clear here whether the saving will be done or saveAs operation
574 [ # # ][ # # ]: 0 : GetMedium()->GetItemSet()->Put( aInteractionItem );
575 : : }
576 : :
577 [ # # ][ # # ]: 0 : rReq.AppendItem( aInteractionItem );
578 : 0 : }
579 : : }
580 [ # # ]: 0 : else if ( nId == SID_SAVEDOC )
581 : : {
582 : : // in case of saving it is not possible to transport the parameters from here
583 : : // but it is not clear here whether the saving will be done or saveAs operation
584 [ # # ][ # # ]: 0 : GetMedium()->GetItemSet()->Put( *pInteractionHandlerItem );
585 : : }
586 : : // ========================================================================================================
587 : :
588 : 0 : sal_Bool bPreselectPassword = sal_False;
589 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pOldEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False );
[ # # ]
590 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pOldPasswordItem, SfxStringItem, SID_PASSWORD, sal_False );
[ # # ]
591 [ # # ][ # # ]: 0 : if ( pOldEncryptionDataItem || pOldPasswordItem )
592 : 0 : bPreselectPassword = sal_True;
593 : :
594 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aDispatchArgs;
595 [ # # ]: 0 : if ( rReq.GetArgs() )
596 : : TransformItems( nId,
597 : 0 : *rReq.GetArgs(),
598 : : aDispatchArgs,
599 [ # # ]: 0 : NULL );
600 : :
601 [ # # ][ # # ]: 0 : const SfxSlot* pSlot = GetModule()->GetSlotPool()->GetSlot( nId );
[ # # ]
602 [ # # ]: 0 : if ( !pSlot )
603 [ # # ]: 0 : throw uno::Exception();
604 : :
605 : 0 : uno::Reference< lang::XMultiServiceFactory > xEmptyFactory;
606 [ # # ]: 0 : SfxStoringHelper aHelper( xEmptyFactory );
607 : :
608 [ # # ][ # # ]: 0 : if ( QueryHiddenInformation( bIsPDFExport ? WhenCreatingPDF : WhenSaving, NULL ) == RET_YES )
[ # # ]
609 : : {
610 : : bDialogUsed = aHelper.GUIStoreModel( GetModel(),
611 : : ::rtl::OUString::createFromAscii( pSlot->GetUnoName() ),
612 : : aDispatchArgs,
613 : : bPreselectPassword,
614 : : GetSharedFileURL(),
615 [ # # ][ # # ]: 0 : GetDocumentSignatureState() );
[ # # ][ # # ]
616 : : }
617 : : else
618 : : {
619 : : // the user has decided not to store the document
620 : : throw task::ErrorCodeIOException( ::rtl::OUString(),
621 : : uno::Reference< uno::XInterface >(),
622 [ # # ]: 0 : ERRCODE_IO_ABORT );
623 : : }
624 : :
625 : : // merge aDispatchArgs to the request
626 [ # # ]: 0 : SfxAllItemSet aResultParams( GetPool() );
627 : : TransformParameters( nId,
628 : : aDispatchArgs,
629 : : aResultParams,
630 [ # # ]: 0 : NULL );
631 [ # # ]: 0 : rReq.SetArgs( aResultParams );
632 : :
633 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False );
634 : 0 : ::rtl::OUString aFilterName = pFilterNameItem ? ::rtl::OUString( pFilterNameItem->GetValue() )
635 [ # # # # ]: 0 : : ::rtl::OUString();
636 [ # # ][ # # ]: 0 : const SfxFilter* pFilt = GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
[ # # ][ # # ]
[ # # ]
637 : :
638 : : OSL_ENSURE( nId == SID_SAVEDOC || pFilt, "The filter can not be zero since it was used for storing!\n" );
639 [ # # ][ # # : 0 : if ( bDialogUsed && pFilt
# # # # #
# ][ # # ]
640 : 0 : && pFilt->IsOwnFormat()
641 : 0 : && pFilt->UsesStorage()
642 : 0 : && pFilt->GetVersion() >= SOFFICE_FILEFORMAT_60 )
643 : : {
644 [ # # ]: 0 : SfxViewFrame* pDocViewFrame = SfxViewFrame::GetFirst( this );
645 [ # # ]: 0 : if ( pDocViewFrame )
646 [ # # ][ # # ]: 0 : SfxHelp::OpenHelpAgent( &pDocViewFrame->GetFrame(), HID_DID_SAVE_PACKED_XML );
647 : : }
648 : :
649 : : // the StoreAsURL/StoreToURL method have called this method with false
650 : : // so it has to be restored to true here since it is a call from GUI
651 [ # # ][ # # ]: 0 : GetMedium()->SetUpdatePickList( sal_True );
[ # # ][ # # ]
[ # # ]
[ # # # ]
652 : :
653 : : // TODO: in future it must be done in followind way
654 : : // if document is opened from GUI it is immediatelly appeares in the picklist
655 : : // if the document is a new one then it appeares in the picklist immediatelly
656 : : // after SaveAs operation triggered from GUI
657 : : }
658 [ # # ]: 0 : catch( const task::ErrorCodeIOException& aErrorEx )
659 : : {
660 : 0 : nErrorCode = (sal_uInt32)aErrorEx.ErrCode;
661 : : }
662 [ # # ]: 0 : catch( Exception& )
663 : : {
664 : 0 : nErrorCode = ERRCODE_IO_GENERAL;
665 : : }
666 : :
667 : : // by default versions should be preserved always except in case of an explicit
668 : : // SaveAs via GUI, so the flag must be reset to guarantee this
669 : 0 : pImp->bPreserveVersions = sal_True;
670 [ # # ]: 0 : sal_uIntPtr lErr=GetErrorCode();
671 : :
672 [ # # ][ # # ]: 0 : if ( !lErr && nErrorCode )
673 : 0 : lErr = nErrorCode;
674 : :
675 [ # # ][ # # ]: 0 : if ( lErr && nErrorCode == ERRCODE_NONE )
676 : : {
677 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pWarnItem, SfxBoolItem, SID_FAIL_ON_WARNING, sal_False );
678 [ # # ][ # # ]: 0 : if ( pWarnItem && pWarnItem->GetValue() )
[ # # ]
679 : 0 : nErrorCode = lErr;
680 : : }
681 : :
682 : : // may be nErrorCode should be shown in future
683 [ # # ]: 0 : if ( lErr != ERRCODE_IO_ABORT )
684 : : {
685 [ # # ][ # # ]: 0 : SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC,GetTitle());
[ # # ]
686 [ # # ][ # # ]: 0 : ErrorHandler::HandleError( lErr );
687 : : }
688 : :
689 [ # # ]: 0 : if ( nId == SID_EXPORTDOCASPDF )
690 : : {
691 : : // This function is used by the SendMail function that needs information if a export
692 : : // file was written or not. This could be due to cancellation of the export
693 : : // or due to an error. So IO abort must be handled like an error!
694 [ # # ][ # # ]: 0 : nErrorCode = ( lErr != ERRCODE_IO_ABORT ) && ( nErrorCode == ERRCODE_NONE ) ? nErrorCode : lErr;
695 : : }
696 : :
697 [ # # ][ # # ]: 0 : if (nId == SID_SAVEASDOC && nErrorCode == ERRCODE_NONE)
698 : : {
699 [ # # ]: 0 : SetReadOnlyUI(false);
700 : : }
701 : :
702 [ # # ][ # # ]: 0 : rReq.SetReturnValue( SfxBoolItem(0, nErrorCode == ERRCODE_NONE ) );
[ # # ]
703 : :
704 [ # # ]: 0 : ResetError();
705 : :
706 [ # # ]: 0 : Invalidate();
707 [ # # ]: 0 : break;
708 : : }
709 : :
710 : : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
711 : :
712 : : case SID_CLOSEDOC:
713 : : {
714 [ # # ]: 0 : SfxViewFrame *pFrame = GetFrame();
715 [ # # ][ # # ]: 0 : if ( pFrame && pFrame->GetFrame().GetParentFrame() )
[ # # ][ # # ]
716 : : {
717 : : // If SID_CLOSEDOC is excecuted through menu and so on, but
718 : : // the current document is in a frame, then the
719 : : // FrameSetDocument should actually be closed.
720 [ # # ][ # # ]: 0 : pFrame->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq );
[ # # ]
721 [ # # ]: 0 : rReq.Done();
722 : : return;
723 : : }
724 : :
725 : 0 : sal_Bool bInFrameSet = sal_False;
726 : 0 : sal_uInt16 nFrames=0;
727 [ # # ]: 0 : pFrame = SfxViewFrame::GetFirst( this );
728 [ # # ]: 0 : while ( pFrame )
729 : : {
730 [ # # ][ # # ]: 0 : if ( pFrame->GetFrame().GetParentFrame() )
731 : : {
732 : : // In this document there still exists a view that is
733 : : // in a FrameSet , which of course may not be closed
734 : : // geclosed werden
735 : 0 : bInFrameSet = sal_True;
736 : : }
737 : : else
738 : 0 : nFrames++;
739 : :
740 [ # # ]: 0 : pFrame = SfxViewFrame::GetNext( *pFrame, this );
741 : : }
742 : :
743 [ # # ]: 0 : if ( bInFrameSet )
744 : : {
745 : : // Close all views that are not in a FrameSet.
746 [ # # ]: 0 : pFrame = SfxViewFrame::GetFirst( this );
747 [ # # ]: 0 : while ( pFrame )
748 : : {
749 [ # # ][ # # ]: 0 : if ( !pFrame->GetFrame().GetParentFrame() )
750 [ # # ][ # # ]: 0 : pFrame->GetFrame().DoClose();
751 [ # # ]: 0 : pFrame = SfxViewFrame::GetNext( *pFrame, this );
752 : : }
753 : : }
754 : :
755 : : // Evaluate Parameter
756 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pSaveItem, SfxBoolItem, SID_CLOSEDOC_SAVE, sal_False);
757 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pNameItem, SfxStringItem, SID_CLOSEDOC_FILENAME, sal_False);
758 [ # # ]: 0 : if ( pSaveItem )
759 : : {
760 [ # # ]: 0 : if ( pSaveItem->GetValue() )
761 : : {
762 [ # # ]: 0 : if ( !pNameItem )
763 : : {
764 : : #ifndef DISABLE_SCRIPTING
765 [ # # ]: 0 : SbxBase::SetError( SbxERR_WRONG_ARGS );
766 : : #endif
767 [ # # ]: 0 : rReq.Ignore();
768 : : return;
769 : : }
770 [ # # ]: 0 : SfxAllItemSet aArgs( GetPool() );
771 [ # # ]: 0 : SfxStringItem aTmpItem( SID_FILE_NAME, pNameItem->GetValue() );
772 [ # # ]: 0 : aArgs.Put( aTmpItem, aTmpItem.Which() );
773 [ # # ]: 0 : SfxRequest aSaveAsReq( SID_SAVEASDOC, SFX_CALLMODE_API, aArgs );
774 [ # # ]: 0 : ExecFile_Impl( aSaveAsReq );
775 [ # # ][ # # ]: 0 : if ( !aSaveAsReq.IsDone() )
776 : : {
777 [ # # ]: 0 : rReq.Ignore();
778 : : return;
779 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
780 : : }
781 : : else
782 [ # # ]: 0 : SetModified(sal_False);
783 : : }
784 : :
785 : : // Cancelled by the user?
786 [ # # ][ # # ]: 0 : if ( !PrepareClose( 2 ) )
787 : : {
788 [ # # ][ # # ]: 0 : rReq.SetReturnValue( SfxBoolItem(0, sal_False) );
[ # # ]
789 [ # # ]: 0 : rReq.Done();
790 : : return;
791 : : }
792 : :
793 [ # # ]: 0 : SetModified( sal_False );
794 [ # # ]: 0 : sal_uIntPtr lErr = GetErrorCode();
795 [ # # ]: 0 : ErrorHandler::HandleError(lErr);
796 : :
797 [ # # ][ # # ]: 0 : rReq.SetReturnValue( SfxBoolItem(0, sal_True) );
[ # # ]
798 [ # # ]: 0 : rReq.Done();
799 [ # # ]: 0 : rReq.ReleaseArgs(); // because the pool is destroyed in Close
800 [ # # ]: 0 : DoClose();
801 : : return;
802 : : }
803 : :
804 : : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
805 : : case SID_DOCTEMPLATE:
806 : : {
807 : : // save as document templates
808 [ # # ]: 0 : SvtMiscOptions aMiscOptions;
809 [ # # ][ # # ]: 0 : if ( aMiscOptions.IsExperimentalMode() )
810 : : {
811 [ # # ]: 0 : SfxTemplateManagerDlg aDlg(NULL);
812 [ # # ][ # # ]: 0 : aDlg.setDocumentModel(GetModel());
813 [ # # ]: 0 : aDlg.setSaveMode(true);
814 [ # # ][ # # ]: 0 : aDlg.Execute();
815 : : }
816 : : else
817 : : {
818 : 0 : SfxDocumentTemplateDlg *pDlg = 0;
819 [ # # ][ # # ]: 0 : SfxErrorContext aEc(ERRCTX_SFX_DOCTEMPLATE,GetTitle());
[ # # ]
820 [ # # ][ # # ]: 0 : SfxDocumentTemplates *pTemplates = new SfxDocumentTemplates;
821 : :
822 [ # # ]: 0 : if ( !rReq.GetArgs() )
823 : : {
824 [ # # ][ # # ]: 0 : pDlg = new SfxDocumentTemplateDlg(0, pTemplates);
825 [ # # ][ # # ]: 0 : if ( RET_OK == pDlg->Execute() && pDlg->GetTemplateName().Len())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
826 : : {
827 : : rReq.AppendItem(SfxStringItem(
828 [ # # ][ # # ]: 0 : SID_TEMPLATE_NAME, pDlg->GetTemplateName()));
[ # # ][ # # ]
[ # # ]
829 : : rReq.AppendItem(SfxStringItem(
830 [ # # ][ # # ]: 0 : SID_TEMPLATE_REGIONNAME, pDlg->GetRegionName()));
[ # # ][ # # ]
[ # # ]
831 : : }
832 : : else
833 : : {
834 [ # # ][ # # ]: 0 : delete pDlg;
835 [ # # ]: 0 : rReq.Ignore();
836 : : return;
837 : : }
838 : : }
839 : :
840 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pRegionItem, SfxStringItem, SID_TEMPLATE_REGIONNAME, sal_False);
841 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pNameItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False);
842 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG(rReq, pRegionNrItem, SfxUInt16Item, SID_TEMPLATE_REGION, sal_False);
843 [ # # ][ # # ]: 0 : if ( (!pRegionItem && !pRegionNrItem ) || !pNameItem )
[ # # ]
844 : : {
845 : : DBG_ASSERT( rReq.IsAPI(), "non-API call without Arguments" );
846 : : #ifndef DISABLE_SCRIPTING
847 [ # # ]: 0 : SbxBase::SetError( SbxERR_WRONG_ARGS );
848 : : #endif
849 [ # # ]: 0 : rReq.Ignore();
850 : : return;
851 : : }
852 : :
853 [ # # ]: 0 : ::rtl::OUString aTemplateName = pNameItem->GetValue();
854 : 0 : ::rtl::OUString aTemplateGroup;
855 [ # # ]: 0 : if ( pRegionItem )
856 [ # # ]: 0 : aTemplateGroup = pRegionItem->GetValue();
857 : : else
858 : : // pRegionNrItem must not be NULL, it was just checked
859 [ # # ][ # # ]: 0 : aTemplateGroup = pTemplates->GetFullRegionName( pRegionNrItem->GetValue() );
[ # # ]
860 : : // check Group and Name
861 [ # # ][ # # ]: 0 : delete pTemplates;
862 : :
863 : 0 : sal_Bool bOk = sal_False;
864 : : try
865 : : {
866 [ # # ][ # # ]: 0 : uno::Reference< frame::XStorable > xStorable( GetModel(), uno::UNO_QUERY_THROW );
867 : : uno::Reference< frame::XDocumentTemplates > xTemplates(
868 [ # # ][ # # ]: 0 : frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) );
869 : :
870 [ # # ][ # # ]: 0 : bOk = xTemplates->storeTemplate( aTemplateGroup, aTemplateName, xStorable );
[ # # ]
871 : : }
872 [ # # ]: 0 : catch( uno::Exception& )
873 : : {
874 : : }
875 : :
876 [ # # ][ # # ]: 0 : DELETEX(pDlg);
877 : :
878 [ # # ][ # # ]: 0 : rReq.SetReturnValue( SfxBoolItem( 0, bOk ) );
[ # # ]
879 [ # # ]: 0 : if ( bOk )
880 : : {
881 : : // update the Organizer runtime cache from the template
882 : : // component if the cache has already been created
883 : : // TODO/LATER: get rid of this cache duplication
884 [ # # ]: 0 : SfxDocumentTemplates aTemplates;
885 [ # # ][ # # ]: 0 : aTemplates.ReInitFromComponent();
886 : : }
887 : : else
888 : : {
889 [ # # ]: 0 : ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
890 : : return;
891 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
892 : : }
893 : :
894 [ # # ][ # # ]: 0 : break;
895 : : }
896 : : }
897 : :
898 : : // Prevent entry in the Pick-lists
899 [ # # ][ # # ]: 0 : if ( rReq.IsAPI() )
900 [ # # ]: 0 : GetMedium()->SetUpdatePickList( sal_False );
901 [ # # ]: 0 : else if ( rReq.GetArgs() )
902 : : {
903 [ # # ][ # # ]: 0 : SFX_ITEMSET_GET( *rReq.GetArgs(), pPicklistItem, SfxBoolItem, SID_PICKLIST, sal_False );
904 [ # # ]: 0 : if ( pPicklistItem )
905 [ # # ]: 0 : GetMedium()->SetUpdatePickList( pPicklistItem->GetValue() );
906 : : }
907 : :
908 : : // Ignore()-branches have already returned
909 [ # # ][ # # ]: 0 : rReq.Done();
[ # # ]
910 : : }
911 : :
912 : : //-------------------------------------------------------------------------
913 : :
914 : 8104 : void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
915 : : {
916 : : DBG_CHKTHIS(SfxObjectShell, 0);
917 [ + - ]: 8104 : SfxWhichIter aIter( rSet );
918 : :
919 [ + - ][ + - ]: 25075 : for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
[ + + ]
920 : : {
921 [ - - + - : 16971 : switch ( nWhich )
- + + + -
- - + -
- ]
922 : : {
923 : : case SID_DOCTEMPLATE :
924 : : {
925 [ # # ][ # # ]: 0 : if ( !GetFactory().GetTemplateFilter() )
[ # # ]
926 [ # # ]: 0 : rSet.DisableItem( nWhich );
927 : 0 : break;
928 : : }
929 : :
930 : : case SID_VERSION:
931 : : {
932 : 0 : SfxObjectShell *pDoc = this;
933 [ # # ]: 0 : SfxViewFrame* pFrame = GetFrame();
934 [ # # ]: 0 : if ( !pFrame )
935 [ # # ]: 0 : pFrame = SfxViewFrame::GetFirst( this );
936 [ # # ]: 0 : if ( pFrame )
937 : : {
938 [ # # ][ # # ]: 0 : if ( pFrame->GetFrame().GetParentFrame() )
939 : : {
940 [ # # ]: 0 : pFrame = pFrame->GetTopViewFrame();
941 [ # # ]: 0 : pDoc = pFrame->GetObjectShell();
942 : : }
943 : : }
944 : :
945 [ # # ][ # # ]: 0 : if ( !pFrame || !pDoc->HasName() ||
[ # # ][ # # ]
946 [ # # ]: 0 : !IsOwnStorageFormat_Impl( *pDoc->GetMedium() ) )
947 [ # # ]: 0 : rSet.DisableItem( nWhich );
948 : 0 : break;
949 : : }
950 : : case SID_SAVEDOC:
951 : : {
952 [ + - ]: 3358 : SvtMiscOptions aMiscOptions;
953 [ + - ]: 3358 : bool bAlwaysAllowSave = aMiscOptions.IsSaveAlwaysAllowed();
954 [ + - ][ + - ]: 3358 : bool bAllowSave = (bAlwaysAllowSave || IsModified());
[ + + ]
955 [ + - ]: 3358 : bool bMediumRO = IsReadOnlyMedium();
956 [ + - ][ + - ]: 3358 : if ( !bMediumRO && GetMedium() && bAllowSave )
[ + + ][ + + ]
957 : : rSet.Put(SfxStringItem(
958 [ + - ][ + - ]: 2429 : nWhich, SfxResId(STR_SAVEDOC).toString()));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
959 : : else
960 [ + - ][ + - ]: 3358 : rSet.DisableItem(nWhich);
961 : : }
962 : 3358 : break;
963 : :
964 : : case SID_DOCINFO:
965 [ # # ]: 0 : if ( 0 != ( pImp->eFlags & SFXOBJECTSHELL_NODOCINFO ) )
966 [ # # ]: 0 : rSet.DisableItem( nWhich );
967 : 0 : break;
968 : :
969 : : case SID_CLOSEDOC:
970 : : {
971 : 0 : SfxObjectShell *pDoc = this;
972 [ # # ]: 0 : SfxViewFrame *pFrame = GetFrame();
973 [ # # ][ # # ]: 0 : if ( pFrame && pFrame->GetFrame().GetParentFrame() )
[ # # ][ # # ]
974 : : {
975 : :
976 : : // If SID_CLOSEDOC is excecuted through menu and so on, but
977 : : // the current document is in a frame, then the
978 : : // FrameSetDocument should actually be closed.
979 [ # # ][ # # ]: 0 : pDoc = pFrame->GetTopViewFrame()->GetObjectShell();
980 : : }
981 : :
982 [ # # ][ # # ]: 0 : if ( pDoc->GetFlags() & SFXOBJECTSHELL_DONTCLOSE )
983 [ # # ]: 0 : rSet.DisableItem(nWhich);
984 : : else
985 [ # # ][ # # ]: 0 : rSet.Put(SfxStringItem(nWhich, SfxResId(STR_CLOSEDOC).toString()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
986 : 0 : break;
987 : : }
988 : :
989 : : case SID_SAVEASDOC:
990 : : {
991 [ - + ]: 3357 : if( ( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) != SFX_LOADED_MAINDOCUMENT )
992 : : {
993 [ # # ]: 0 : rSet.DisableItem( nWhich );
994 : 0 : break;
995 : : }
996 [ - + ]: 3357 : if ( /*!pCombinedFilters ||*/ !GetMedium() )
997 [ # # ]: 0 : rSet.DisableItem( nWhich );
998 : : else
999 [ + - ][ + - ]: 3357 : rSet.Put( SfxStringItem( nWhich, SfxResId(STR_SAVEASDOC).toString() ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1000 : 3357 : break;
1001 : : }
1002 : :
1003 : : case SID_EXPORTDOCASPDF:
1004 : : case SID_DIRECTEXPORTDOCASPDF:
1005 : : {
1006 : 3384 : break;
1007 : : }
1008 : :
1009 : : case SID_DOC_MODIFIED:
1010 : : {
1011 [ + - ][ + - ]: 3436 : rSet.Put( SfxBoolItem( SID_DOC_MODIFIED, IsModified() ) );
[ + - ][ + - ]
1012 : 3436 : break;
1013 : : }
1014 : :
1015 : : case SID_MODIFIED:
1016 : : {
1017 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( SID_MODIFIED, IsModified() ) );
[ # # ][ # # ]
1018 : 0 : break;
1019 : : }
1020 : :
1021 : : case SID_DOCINFO_TITLE:
1022 : : {
1023 : : rSet.Put( SfxStringItem(
1024 [ # # ][ # # ]: 0 : SID_DOCINFO_TITLE, getDocProperties()->getTitle() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1025 : 0 : break;
1026 : : }
1027 : : case SID_FILE_NAME:
1028 : : {
1029 [ # # ][ # # ]: 0 : if( GetMedium() && HasName() )
[ # # ]
1030 : : rSet.Put( SfxStringItem(
1031 [ # # ][ # # ]: 0 : SID_FILE_NAME, GetMedium()->GetName() ) );
[ # # ][ # # ]
[ # # ][ # # ]
1032 : 0 : break;
1033 : : }
1034 : : case SID_SIGNATURE:
1035 : : {
1036 [ + - ][ + - ]: 3436 : rSet.Put( SfxUInt16Item( SID_SIGNATURE, GetDocumentSignatureState() ) );
[ + - ][ + - ]
1037 : 3436 : break;
1038 : : }
1039 : : case SID_MACRO_SIGNATURE:
1040 : : {
1041 : : // the slot makes sense only if there is a macro in the document
1042 [ # # ][ # # ]: 0 : if ( pImp->documentStorageHasMacros() || pImp->aMacroMode.hasMacroLibrary() )
[ # # ][ # # ]
[ # # ]
1043 [ # # ][ # # ]: 0 : rSet.Put( SfxUInt16Item( SID_MACRO_SIGNATURE, GetScriptingSignatureState() ) );
[ # # ][ # # ]
1044 : : else
1045 [ # # ]: 0 : rSet.DisableItem( nWhich );
1046 : 0 : break;
1047 : : }
1048 : : }
1049 [ + - ]: 8104 : }
1050 : 8104 : }
1051 : :
1052 : : //--------------------------------------------------------------------
1053 : :
1054 : 0 : void SfxObjectShell::ExecProps_Impl(SfxRequest &rReq)
1055 : : {
1056 [ # # # # : 0 : switch ( rReq.GetSlot() )
# # ]
1057 : : {
1058 : : case SID_MODIFIED:
1059 : : {
1060 : 0 : SetModified( ( (SfxBoolItem&) rReq.GetArgs()->Get(SID_MODIFIED)).GetValue() );
1061 : 0 : rReq.Done();
1062 : 0 : break;
1063 : : }
1064 : :
1065 : : case SID_DOCTITLE:
1066 : 0 : SetTitle( ( (SfxStringItem&) rReq.GetArgs()->Get(SID_DOCTITLE)).GetValue() );
1067 : 0 : rReq.Done();
1068 : 0 : break;
1069 : :
1070 : : case SID_DOCINFO_AUTHOR :
1071 : : {
1072 [ # # ][ # # ]: 0 : ::rtl::OUString aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
1073 [ # # ][ # # ]: 0 : getDocProperties()->setAuthor( aStr );
[ # # ]
1074 : 0 : break;
1075 : : }
1076 : :
1077 : : case SID_DOCINFO_COMMENTS :
1078 : : {
1079 [ # # ][ # # ]: 0 : ::rtl::OUString aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
1080 [ # # ][ # # ]: 0 : getDocProperties()->setDescription( aStr );
[ # # ]
1081 : 0 : break;
1082 : : }
1083 : :
1084 : : case SID_DOCINFO_KEYWORDS :
1085 : : {
1086 [ # # ][ # # ]: 0 : ::rtl::OUString aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
1087 [ # # ][ # # ]: 0 : getDocProperties()->setKeywords(
1088 [ # # ][ # # ]: 0 : ::comphelper::string::convertCommaSeparated(aStr) );
[ # # ]
1089 : 0 : break;
1090 : : }
1091 : : }
1092 : 0 : }
1093 : :
1094 : : //--------------------------------------------------------------------
1095 : :
1096 : 0 : void SfxObjectShell::StateProps_Impl(SfxItemSet &rSet)
1097 : : {
1098 [ # # ]: 0 : SfxWhichIter aIter(rSet);
1099 [ # # ][ # # ]: 0 : for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
[ # # ]
1100 : : {
1101 [ # # # # : 0 : switch ( nSID )
# # # # #
# # # ]
1102 : : {
1103 : : case SID_DOCINFO_AUTHOR :
1104 : : {
1105 : : rSet.Put( SfxStringItem( nSID,
1106 [ # # ][ # # ]: 0 : getDocProperties()->getAuthor() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1107 : 0 : break;
1108 : : }
1109 : :
1110 : : case SID_DOCINFO_COMMENTS :
1111 : : {
1112 : : rSet.Put( SfxStringItem( nSID,
1113 [ # # ][ # # ]: 0 : getDocProperties()->getDescription()) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1114 : 0 : break;
1115 : : }
1116 : :
1117 : : case SID_DOCINFO_KEYWORDS :
1118 : : {
1119 : : rSet.Put( SfxStringItem( nSID, ::comphelper::string::
1120 [ # # ][ # # ]: 0 : convertCommaSeparated(getDocProperties()->getKeywords())) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1121 : 0 : break;
1122 : : }
1123 : :
1124 : : case SID_DOCPATH:
1125 : : {
1126 : : OSL_FAIL( "Not supported anymore!" );
1127 : 0 : break;
1128 : : }
1129 : :
1130 : : case SID_DOCFULLNAME:
1131 : : {
1132 [ # # ][ # # ]: 0 : rSet.Put( SfxStringItem( SID_DOCFULLNAME, GetTitle(SFX_TITLE_FULLNAME) ) );
[ # # ][ # # ]
[ # # ]
1133 : 0 : break;
1134 : : }
1135 : :
1136 : : case SID_DOCTITLE:
1137 : : {
1138 [ # # ][ # # ]: 0 : rSet.Put( SfxStringItem( SID_DOCTITLE, GetTitle() ) );
[ # # ][ # # ]
[ # # ]
1139 : 0 : break;
1140 : : }
1141 : :
1142 : : case SID_DOC_READONLY:
1143 : : {
1144 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( SID_DOC_READONLY, IsReadOnly() ) );
[ # # ][ # # ]
1145 : 0 : break;
1146 : : }
1147 : :
1148 : : case SID_DOC_SAVED:
1149 : : {
1150 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( SID_DOC_SAVED, !IsModified() ) );
[ # # ][ # # ]
1151 : 0 : break;
1152 : : }
1153 : :
1154 : : case SID_CLOSING:
1155 : : {
1156 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( SID_CLOSING, false ) );
[ # # ]
1157 : 0 : break;
1158 : : }
1159 : :
1160 : : case SID_DOC_LOADING:
1161 : : rSet.Put( SfxBoolItem( nSID, SFX_LOADED_MAINDOCUMENT !=
1162 [ # # ][ # # ]: 0 : ( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) ) );
[ # # ]
1163 : 0 : break;
1164 : :
1165 : : case SID_IMG_LOADING:
1166 : : rSet.Put( SfxBoolItem( nSID, SFX_LOADED_IMAGES !=
1167 [ # # ][ # # ]: 0 : ( pImp->nLoadedFlags & SFX_LOADED_IMAGES ) ) );
[ # # ]
1168 : 0 : break;
1169 : : }
1170 [ # # ]: 0 : }
1171 : 0 : }
1172 : :
1173 : : //--------------------------------------------------------------------
1174 : :
1175 : 0 : void SfxObjectShell::ExecView_Impl(SfxRequest &rReq)
1176 : : {
1177 [ # # # ]: 0 : switch ( rReq.GetSlot() )
1178 : : {
1179 : : case SID_ACTIVATE:
1180 : : {
1181 : 0 : SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this, sal_True );
1182 [ # # ]: 0 : if ( pFrame )
1183 : 0 : pFrame->GetFrame().Appear();
1184 [ # # ]: 0 : rReq.SetReturnValue( SfxObjectItem( 0, pFrame ) );
1185 : 0 : rReq.Done();
1186 : 0 : break;
1187 : : }
1188 : : case SID_NEWWINDOWFOREDIT:
1189 : : {
1190 : 0 : SfxViewFrame* pFrame = SfxViewFrame::Current();
1191 [ # # ]: 0 : if( pFrame->GetObjectShell() == this &&
[ # # # # ]
1192 : 0 : ( pFrame->GetFrameType() & SFXFRAME_HASTITLE ) )
1193 : 0 : pFrame->ExecuteSlot( rReq );
1194 : : else
1195 : : {
1196 [ # # ][ # # ]: 0 : String aFileName( GetObjectShell()->GetMedium()->GetName() );
[ # # ]
1197 [ # # ]: 0 : if ( aFileName.Len() )
1198 : : {
1199 [ # # ]: 0 : SfxStringItem aName( SID_FILE_NAME, aFileName );
1200 [ # # ]: 0 : SfxBoolItem aCreateView( SID_OPEN_NEW_VIEW, sal_True );
1201 : : SFX_APP()->GetAppDispatcher_Impl()->Execute(
1202 : : SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aName,
1203 [ # # ][ # # ]: 0 : &aCreateView, 0L);
[ # # ][ # # ]
[ # # ]
1204 [ # # ]: 0 : }
1205 : : }
1206 : : }
1207 : : }
1208 : 0 : }
1209 : :
1210 : : //--------------------------------------------------------------------
1211 : :
1212 : 0 : void SfxObjectShell::StateView_Impl(SfxItemSet& /*rSet*/)
1213 : : {
1214 : 0 : }
1215 : :
1216 : 1988 : sal_uInt16 SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< security::DocumentSignatureInformation >& aInfos )
1217 : : {
1218 : 1988 : sal_Bool bCertValid = sal_True;
1219 : 1988 : sal_uInt16 nResult = SIGNATURESTATE_NOSIGNATURES;
1220 : 1988 : int nInfos = aInfos.getLength();
1221 : 1988 : bool bCompleteSignature = true;
1222 [ - + ]: 1988 : if( nInfos )
1223 : : {
1224 : 0 : nResult = SIGNATURESTATE_SIGNATURES_OK;
1225 [ # # ]: 0 : for ( int n = 0; n < nInfos; n++ )
1226 : : {
1227 [ # # ]: 0 : if ( bCertValid )
1228 : : {
1229 : 0 : sal_Int32 nCertStat = aInfos[n].CertificateStatus;
1230 [ # # ]: 0 : bCertValid = nCertStat == security::CertificateValidity::VALID ? sal_True : sal_False;
1231 : : }
1232 : :
1233 [ # # ]: 0 : if ( !aInfos[n].SignatureIsValid )
1234 : : {
1235 : 0 : nResult = SIGNATURESTATE_SIGNATURES_BROKEN;
1236 : 0 : break; // we know enough
1237 : : }
1238 : 0 : bCompleteSignature &= !aInfos[n].PartialDocumentSignature;
1239 : : }
1240 : : }
1241 : :
1242 [ - + ][ # # ]: 1988 : if ( nResult == SIGNATURESTATE_SIGNATURES_OK && !bCertValid )
1243 : 0 : nResult = SIGNATURESTATE_SIGNATURES_NOTVALIDATED;
1244 [ - + ][ # # ]: 1988 : else if ( nResult == SIGNATURESTATE_SIGNATURES_OK && bCertValid && !bCompleteSignature)
[ # # ]
1245 : 0 : nResult = SIGNATURESTATE_SIGNATURES_PARTIAL_OK;
1246 : :
1247 : : // this code must not check whether the document is modified
1248 : : // it should only check the provided info
1249 : :
1250 : 1988 : return nResult;
1251 : : }
1252 : :
1253 : 1988 : uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::ImplAnalyzeSignature( sal_Bool bScriptingContent, const uno::Reference< security::XDocumentDigitalSignatures >& xSigner )
1254 : : {
1255 [ + - ]: 1988 : uno::Sequence< security::DocumentSignatureInformation > aResult;
1256 : 1988 : uno::Reference< security::XDocumentDigitalSignatures > xLocSigner = xSigner;
1257 : :
1258 [ + - ][ + + ]: 1988 : if ( GetMedium() && !GetMedium()->GetName().isEmpty() && IsOwnStorageFormat_Impl( *GetMedium()) && GetMedium()->GetStorage().is() )
[ + - ][ + + ]
[ + - ][ + - ]
[ + + ]
[ + + # # ]
[ + - ]
1259 : : {
1260 : : try
1261 : : {
1262 [ + - ]: 167 : if ( !xLocSigner.is() )
1263 : : {
1264 [ + - ]: 167 : uno::Sequence< uno::Any > aArgs( 1 );
1265 [ + - ][ + - ]: 167 : aArgs[0] <<= ::rtl::OUString();
1266 : : try
1267 : : {
1268 [ + - ][ + - ]: 167 : uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW );
1269 [ + - ][ + - ]: 167 : aArgs[0] = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) );
[ + - ][ # # ]
[ + - ]
1270 : : }
1271 [ # # ]: 0 : catch( uno::Exception& )
1272 : : {
1273 : : }
1274 : :
1275 [ + - ][ + - ]: 167 : xLocSigner.set( comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs ), uno::UNO_QUERY_THROW );
[ + - ][ + - ]
[ + + ][ + - ]
1276 : :
1277 : : }
1278 : :
1279 [ - + ]: 108 : if ( bScriptingContent )
1280 [ # # ]: 0 : aResult = xLocSigner->verifyScriptingContentSignatures( GetMedium()->GetZipStorageToSign_Impl(),
1281 [ # # ][ # # ]: 0 : uno::Reference< io::XInputStream >() );
[ # # ][ # # ]
1282 : : else
1283 [ + - ]: 108 : aResult = xLocSigner->verifyDocumentContentSignatures( GetMedium()->GetZipStorageToSign_Impl(),
1284 [ + - ][ + - ]: 167 : uno::Reference< io::XInputStream >() );
[ + - ][ + - ]
[ - + ]
1285 : : }
1286 [ + - ]: 59 : catch( com::sun::star::uno::Exception& )
1287 : : {
1288 : : }
1289 : : }
1290 : :
1291 : 1988 : return aResult;
1292 : : }
1293 : :
1294 : 12805 : sal_uInt16 SfxObjectShell::ImplGetSignatureState( sal_Bool bScriptingContent )
1295 : : {
1296 [ - + ]: 12805 : sal_Int16* pState = bScriptingContent ? &pImp->nScriptingSignatureState : &pImp->nDocumentSignatureState;
1297 : :
1298 [ + + ]: 12805 : if ( *pState == SIGNATURESTATE_UNKNOWN )
1299 : : {
1300 : 1988 : *pState = SIGNATURESTATE_NOSIGNATURES;
1301 : :
1302 [ + - ]: 1988 : uno::Sequence< security::DocumentSignatureInformation > aInfos = ImplAnalyzeSignature( bScriptingContent );
1303 [ + - ][ + - ]: 1988 : *pState = ImplCheckSignaturesInformation( aInfos );
1304 : : }
1305 : :
1306 [ + - ][ + - ]: 12805 : if ( *pState == SIGNATURESTATE_SIGNATURES_OK || *pState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
[ - + ]
1307 : : || *pState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK)
1308 : : {
1309 [ # # ]: 0 : if ( IsModified() )
1310 : 0 : *pState = SIGNATURESTATE_SIGNATURES_INVALID;
1311 : : }
1312 : :
1313 : 12805 : return (sal_uInt16)*pState;
1314 : : }
1315 : :
1316 : 0 : void SfxObjectShell::ImplSign( sal_Bool bScriptingContent )
1317 : : {
1318 : : // Check if it is stored in OASIS format...
1319 [ # # ][ # # : 0 : if ( GetMedium()
# # # # ]
[ # # ][ # # ]
1320 [ # # ]: 0 : && GetMedium()->GetFilter()
1321 [ # # ]: 0 : && !GetMedium()->GetName().isEmpty()
1322 [ # # ]: 0 : && ( !GetMedium()->GetFilter()->IsOwnFormat()
1323 [ # # ]: 0 : || !GetMedium()->HasStorage_Impl()
1324 : : )
1325 : : )
1326 : : {
1327 : : // Only OASIS and OOo6.x formats will be handled further
1328 [ # # ][ # # ]: 0 : InfoBox( NULL, SfxResId( RID_XMLSEC_INFO_WRONGDOCFORMAT ) ).Execute();
[ # # ][ # # ]
1329 : : return;
1330 : : }
1331 : :
1332 : : // check whether the document is signed
1333 [ # # ]: 0 : ImplGetSignatureState( sal_False ); // document signature
1334 [ # # ]: 0 : ImplGetSignatureState( sal_True ); // script signature
1335 [ # # ][ # # ]: 0 : sal_Bool bHasSign = ( pImp->nScriptingSignatureState != SIGNATURESTATE_NOSIGNATURES || pImp->nDocumentSignatureState != SIGNATURESTATE_NOSIGNATURES );
1336 : :
1337 : : // the target ODF version on saving
1338 [ # # ]: 0 : SvtSaveOptions aSaveOpt;
1339 [ # # ]: 0 : SvtSaveOptions::ODFDefaultVersion nVersion = aSaveOpt.GetODFDefaultVersion();
1340 : :
1341 : : // the document is not new and is not modified
1342 : 0 : ::rtl::OUString aODFVersion;
1343 : : try
1344 : : {
1345 : : // check the version of the document
1346 [ # # ][ # # ]: 0 : uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW );
1347 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) >>= aODFVersion;
[ # # ][ # # ]
1348 : : }
1349 [ # # ]: 0 : catch( uno::Exception& )
1350 : : {}
1351 : :
1352 : 0 : bool bNoSig = false;
1353 : :
1354 [ # # ][ # # ]: 0 : if ( IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty()
[ # # ][ # # ]
[ # # # # ]
[ # # ][ # # ]
1355 [ # # ][ # # ]: 0 : || (!aODFVersion.equals( ODFVER_012_TEXT ) && !bHasSign) )
[ # # ]
1356 : : {
1357 : : // the document might need saving ( new, modified or in ODF1.1 format without signature )
1358 : :
1359 [ # # ]: 0 : if ( nVersion >= SvtSaveOptions::ODFVER_012 )
1360 : : {
1361 : :
1362 [ # # ][ # # ]: 0 : if ( (bHasSign && QueryBox( NULL, SfxResId( MSG_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN ) ).Execute() == RET_YES)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
1363 [ # # ][ # # ]: 0 : || (!bHasSign && QueryBox( NULL, SfxResId( RID_XMLSEC_QUERY_SAVEBEFORESIGN ) ).Execute() == RET_YES) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1364 : : {
1365 : 0 : sal_uInt16 nId = SID_SAVEDOC;
1366 [ # # ][ # # ]: 0 : if ( !GetMedium() || GetMedium()->GetName().isEmpty() )
[ # # ][ # # ]
1367 : 0 : nId = SID_SAVEASDOC;
1368 [ # # ]: 0 : SfxRequest aSaveRequest( nId, 0, GetPool() );
1369 : : //ToDo: Review. We needed to call SetModified, otherwise the document would not be saved.
1370 [ # # ]: 0 : SetModified(sal_True);
1371 [ # # ]: 0 : ExecFile_Impl( aSaveRequest );
1372 : :
1373 : : // Check if it is stored in OASIS format...
1374 [ # # ][ # # ]: 0 : if ( GetMedium() && GetMedium()->GetFilter()
[ # # # # ]
[ # # ][ # # ]
[ # # ]
1375 [ # # ][ # # ]: 0 : && ( !GetMedium()->GetFilter()->IsOwnFormat() || !GetMedium()->HasStorage_Impl()
1376 [ # # ][ # # ]: 0 : || SotStorage::GetVersion( GetMedium()->GetStorage() ) <= SOFFICE_FILEFORMAT_60 ) )
[ # # ][ # # ]
1377 : : {
1378 : : // Only OASIS format will be handled further
1379 [ # # ][ # # ]: 0 : InfoBox( NULL, SfxResId( RID_XMLSEC_INFO_WRONGDOCFORMAT ) ).Execute();
[ # # ][ # # ]
1380 : : return;
1381 [ # # ][ # # ]: 0 : }
1382 : : }
1383 : : else
1384 : : {
1385 : : // When the document is modified then we must not show the
1386 : : // digital signatures dialog
1387 : : // If we have come here then the user denied to save.
1388 [ # # ]: 0 : if (!bHasSign)
1389 : 0 : bNoSig = true;
1390 : : }
1391 : : }
1392 : : else
1393 : : {
1394 [ # # ][ # # ]: 0 : ErrorBox( NULL, WB_OK, SfxResId(STR_XMLSEC_ODF12_EXPECTED).toString() ).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1395 : : return;
1396 : : }
1397 : :
1398 [ # # ][ # # ]: 0 : if ( IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty() )
[ # # ][ # # ]
[ # # ][ # # ]
1399 : : return;
1400 : : }
1401 : :
1402 : : // the document is not modified currently, so it can not become modified after signing
1403 : 0 : sal_Bool bAllowModifiedBack = sal_False;
1404 [ # # ][ # # ]: 0 : if ( IsEnableSetModified() )
1405 : : {
1406 [ # # ]: 0 : EnableSetModified( sal_False );
1407 : 0 : bAllowModifiedBack = sal_True;
1408 : : }
1409 : :
1410 : : // we have to store to the original document, the original medium should be closed for this time
1411 [ # # ][ # # ]: 0 : if ( !bNoSig
[ # # ]
1412 [ # # ][ # # ]: 0 : && ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) )
[ # # ][ # # ]
1413 : : {
1414 [ # # ]: 0 : GetMedium()->CloseAndRelease();
1415 : :
1416 : : // We sign only ODF1.2, that means that if this point has been reached,
1417 : : // the ODF1.2 signing process should be used.
1418 : : // This code still might be called to show the signature of ODF1.1 document.
1419 : : sal_Bool bSigned = GetMedium()->SignContents_Impl(
1420 : : bScriptingContent,
1421 : : aODFVersion,
1422 : : pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_OK
1423 : : || pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
1424 [ # # ][ # # ]: 0 : || pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK);
[ # # ][ # # ]
1425 : :
1426 [ # # ]: 0 : DoSaveCompleted( GetMedium() );
1427 : :
1428 [ # # ]: 0 : if ( bSigned )
1429 : : {
1430 [ # # ]: 0 : if ( bScriptingContent )
1431 : : {
1432 : 0 : pImp->nScriptingSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check
1433 : :
1434 : : // adding of scripting signature removes existing document signature
1435 : 0 : pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check
1436 : : }
1437 : : else
1438 : 0 : pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check
1439 : :
1440 : 0 : pImp->bSignatureErrorIsShown = sal_False;
1441 : :
1442 [ # # ]: 0 : Invalidate( SID_SIGNATURE );
1443 [ # # ]: 0 : Invalidate( SID_MACRO_SIGNATURE );
1444 [ # # ][ # # ]: 0 : Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
[ # # ]
1445 : : }
1446 : : }
1447 : :
1448 [ # # ]: 0 : if ( bAllowModifiedBack )
1449 [ # # ][ # # ]: 0 : EnableSetModified( sal_True );
[ # # ][ # # ]
1450 : : }
1451 : :
1452 : 12805 : sal_uInt16 SfxObjectShell::GetDocumentSignatureState()
1453 : : {
1454 : 12805 : return ImplGetSignatureState( sal_False );
1455 : : }
1456 : :
1457 : 0 : void SfxObjectShell::SignDocumentContent()
1458 : : {
1459 : 0 : ImplSign( sal_False );
1460 : 0 : }
1461 : :
1462 : 0 : sal_uInt16 SfxObjectShell::GetScriptingSignatureState()
1463 : : {
1464 : 0 : return ImplGetSignatureState( sal_True );
1465 : : }
1466 : :
1467 : 0 : void SfxObjectShell::SignScriptingContent()
1468 : : {
1469 : 0 : ImplSign( sal_True );
1470 : 0 : }
1471 : :
1472 : : namespace
1473 : : {
1474 : : class theSfxObjectShellUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSfxObjectShellUnoTunnelId > {};
1475 : : }
1476 : :
1477 : 77301 : const uno::Sequence<sal_Int8>& SfxObjectShell::getUnoTunnelId()
1478 : : {
1479 : 77301 : return theSfxObjectShellUnoTunnelId::get().getSeq();
1480 : : }
1481 : :
1482 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|