1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 #include <sot/storage.hxx>
31 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
32 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
33 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
34 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
35 #include <com/sun/star/ui/dialogs/XControlAccess.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/beans/XPropertyAccess.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/beans/PropertyValue.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <com/sun/star/document/XExporter.hpp>
42 #include <com/sun/star/task/XInteractionHandler.hpp>
43 #include <com/sun/star/task/XStatusIndicator.hpp>
44 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
45 #include <com/sun/star/frame/DocumentTemplates.hpp>
46 #include <com/sun/star/frame/XDocumentTemplates.hpp>
47 #include <com/sun/star/frame/XStorable.hpp>
48 #include <comphelper/processfactory.hxx>
49 #include <comphelper/servicehelper.hxx>
50 #include <com/sun/star/security/CertificateValidity.hpp>
52 #include <com/sun/star/security/DocumentSignatureInformation.hpp>
53 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
54 #include <tools/urlobj.hxx>
55 #include <svl/whiter.hxx>
56 #include <vcl/msgbox.hxx>
57 #include <svl/intitem.hxx>
58 #include <svl/eitem.hxx>
59 #include <vcl/wrkwin.hxx>
60 #include <svtools/sfxecode.hxx>
61 #include <svtools/ehdl.hxx>
63 #include <comphelper/string.hxx>
64 #include <basic/sbx.hxx>
65 #include <unotools/pathoptions.hxx>
66 #include <unotools/useroptions.hxx>
67 #include <unotools/saveopt.hxx>
68 #include <svtools/asynclink.hxx>
69 #include <svtools/miscopt.hxx>
70 #include <comphelper/documentconstants.hxx>
72 #include <sfx2/app.hxx>
73 #include <sfx2/signaturestate.hxx>
74 #include "sfx2/sfxresid.hxx"
75 #include <sfx2/event.hxx>
76 #include <sfx2/request.hxx>
77 #include <sfx2/printer.hxx>
78 #include <sfx2/viewsh.hxx>
79 #include <sfx2/doctdlg.hxx>
80 #include <sfx2/docfilt.hxx>
81 #include <sfx2/docfile.hxx>
82 #include <sfx2/dispatch.hxx>
83 #include <sfx2/dinfdlg.hxx>
84 #include <sfx2/objitem.hxx>
85 #include <sfx2/objsh.hxx>
86 #include "objshimp.hxx"
87 #include "sfxtypes.hxx"
88 #include <sfx2/module.hxx>
89 #include <sfx2/viewfrm.hxx>
90 #include "versdlg.hxx"
92 #include <sfx2/docfac.hxx>
93 #include <sfx2/fcontnr.hxx>
94 #include "sfx2/sfxhelp.hxx"
95 #include <sfx2/msgpool.hxx>
96 #include <sfx2/objface.hxx>
98 #include "../appl/app.hrc"
99 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
100 #include <com/sun/star/embed/XTransactedObject.hpp>
101 #include <com/sun/star/util/XCloneable.hpp>
102 #include <com/sun/star/document/XDocumentProperties.hpp>
104 #include "helpid.hrc"
106 #include "guisaveas.hxx"
108 using namespace ::com::sun::star
;
109 using namespace ::com::sun::star::lang
;
110 using namespace ::com::sun::star::uno
;
111 using namespace ::com::sun::star::ui::dialogs
;
112 using namespace ::com::sun::star::awt
;
113 using namespace ::com::sun::star::container
;
114 using namespace ::com::sun::star::beans
;
115 using namespace ::com::sun::star::document
;
116 using namespace ::com::sun::star::task
;
118 //====================================================================
120 class SfxSaveAsContext_Impl
122 String
& _rNewNameVar
;
126 SfxSaveAsContext_Impl( String
&rNewNameVar
,
127 const String
&rNewName
)
128 : _rNewNameVar( rNewNameVar
),
129 _aNewName( rNewName
)
130 { rNewNameVar
= rNewName
; }
131 ~SfxSaveAsContext_Impl()
132 { _rNewNameVar
.Erase(); }
135 //====================================================================
137 #define SfxObjectShell
138 #include "sfxslots.hxx"
140 //=========================================================================
144 SFX_IMPL_INTERFACE(SfxObjectShell
,SfxShell
,SfxResId(0))
148 //=========================================================================
150 class SfxClosePreventer_Impl
: public ::cppu::WeakImplHelper1
< ::com::sun::star::util::XCloseListener
>
152 sal_Bool m_bGotOwnership
;
153 sal_Bool m_bPreventClose
;
156 SfxClosePreventer_Impl();
158 sal_Bool
HasOwnership() { return m_bGotOwnership
; }
160 void SetPreventClose( sal_Bool bPrevent
) { m_bPreventClose
= bPrevent
; }
162 virtual void SAL_CALL
queryClosing( const lang::EventObject
& aEvent
, sal_Bool bDeliverOwnership
)
163 throw ( uno::RuntimeException
, util::CloseVetoException
);
165 virtual void SAL_CALL
notifyClosing( const lang::EventObject
& aEvent
) throw ( uno::RuntimeException
) ;
167 virtual void SAL_CALL
disposing( const lang::EventObject
& aEvent
) throw ( uno::RuntimeException
) ;
171 SfxClosePreventer_Impl::SfxClosePreventer_Impl()
172 : m_bGotOwnership( sal_False
)
173 , m_bPreventClose( sal_True
)
177 void SAL_CALL
SfxClosePreventer_Impl::queryClosing( const lang::EventObject
&, sal_Bool bDeliverOwnership
)
178 throw ( uno::RuntimeException
, util::CloseVetoException
)
180 if ( m_bPreventClose
)
182 if ( !m_bGotOwnership
)
183 m_bGotOwnership
= bDeliverOwnership
;
185 throw util::CloseVetoException();
189 void SAL_CALL
SfxClosePreventer_Impl::notifyClosing( const lang::EventObject
& ) throw ( uno::RuntimeException
)
192 void SAL_CALL
SfxClosePreventer_Impl::disposing( const lang::EventObject
& ) throw ( uno::RuntimeException
)
195 //=========================================================================
196 class SfxInstanceCloseGuard_Impl
198 SfxClosePreventer_Impl
* m_pPreventer
;
199 uno::Reference
< util::XCloseListener
> m_xPreventer
;
200 uno::Reference
< util::XCloseable
> m_xCloseable
;
203 SfxInstanceCloseGuard_Impl()
204 : m_pPreventer( NULL
)
207 ~SfxInstanceCloseGuard_Impl();
209 sal_Bool
Init_Impl( const uno::Reference
< util::XCloseable
>& xCloseable
);
212 sal_Bool
SfxInstanceCloseGuard_Impl::Init_Impl( const uno::Reference
< util::XCloseable
>& xCloseable
)
214 sal_Bool bResult
= sal_False
;
216 // do not allow reinit after the successful init
217 if ( xCloseable
.is() && !m_xCloseable
.is() )
221 m_pPreventer
= new SfxClosePreventer_Impl();
222 m_xPreventer
= uno::Reference
< util::XCloseListener
>( m_pPreventer
);
223 xCloseable
->addCloseListener( m_xPreventer
);
224 m_xCloseable
= xCloseable
;
227 catch( uno::Exception
& )
229 OSL_FAIL( "Could not register close listener!\n" );
236 SfxInstanceCloseGuard_Impl::~SfxInstanceCloseGuard_Impl()
238 if ( m_xCloseable
.is() && m_xPreventer
.is() )
242 m_xCloseable
->removeCloseListener( m_xPreventer
);
244 catch( uno::Exception
& )
252 m_pPreventer
->SetPreventClose( sal_False
);
254 if ( m_pPreventer
->HasOwnership() )
255 m_xCloseable
->close( sal_True
); // TODO: do it asynchronously
258 catch( uno::Exception
& )
264 //=========================================================================
266 void SfxObjectShell::PrintExec_Impl(SfxRequest
&rReq
)
268 SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst(this);
271 rReq
.SetSlot( SID_PRINTDOC
);
272 pFrame
->GetViewShell()->ExecuteSlot(rReq
);
276 //--------------------------------------------------------------------
278 void SfxObjectShell::PrintState_Impl(SfxItemSet
&rSet
)
280 bool bPrinting
= false;
281 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( this );
284 SfxPrinter
*pPrinter
= pFrame
->GetViewShell()->GetPrinter();
285 bPrinting
= pPrinter
&& pPrinter
->IsPrinting();
287 rSet
.Put( SfxBoolItem( SID_PRINTOUT
, bPrinting
) );
290 //--------------------------------------------------------------------
292 sal_Bool
SfxObjectShell::APISaveAs_Impl
294 const String
& aFileName
,
298 sal_Bool bOk
= sal_False
;
300 {DBG_CHKTHIS(SfxObjectShell
, 0);}
305 SFX_ITEMSET_ARG( aParams
, pFilterNameItem
, SfxStringItem
, SID_FILTER_NAME
, sal_False
);
306 if( pFilterNameItem
)
308 aFilterName
= pFilterNameItem
->GetValue();
312 SFX_ITEMSET_ARG( aParams
, pContentTypeItem
, SfxStringItem
, SID_CONTENTTYPE
, sal_False
);
313 if ( pContentTypeItem
)
315 const SfxFilter
* pFilter
= SfxFilterMatcher( String::CreateFromAscii(GetFactory().GetShortName()) ).GetFilter4Mime( pContentTypeItem
->GetValue(), SFX_FILTER_EXPORT
);
317 aFilterName
= pFilter
->GetName();
321 // in case no filter defined use default one
322 if( !aFilterName
.Len() )
324 const SfxFilter
* pFilt
= SfxFilter::GetDefaultFilterFromFactory(GetFactory().GetFactoryName());
326 DBG_ASSERT( pFilt
, "No default filter!\n" );
328 aFilterName
= pFilt
->GetFilterName();
330 aParams
->Put(SfxStringItem( SID_FILTER_NAME
, aFilterName
));
335 SfxObjectShellRef
xLock( this ); // ???
337 // use the title that is provided in the media descriptor
338 SFX_ITEMSET_ARG( aParams
, pDocTitleItem
, SfxStringItem
, SID_DOCINFO_TITLE
, sal_False
);
340 getDocProperties()->setTitle( pDocTitleItem
->GetValue() );
342 bOk
= CommonSaveAs_Impl( INetURLObject(aFileName
), aFilterName
,
351 //--------------------------------------------------------------------
353 void SfxObjectShell::ExecFile_Impl(SfxRequest
&rReq
)
355 {DBG_CHKTHIS(SfxObjectShell
, 0);}
357 sal_uInt16 nId
= rReq
.GetSlot();
359 if( SID_SIGNATURE
== nId
|| SID_MACRO_SIGNATURE
== nId
)
361 if ( QueryHiddenInformation( WhenSigning
, NULL
) == RET_YES
)
362 ( SID_SIGNATURE
== nId
) ? SignDocumentContent() : SignScriptingContent();
366 if ( !GetMedium() && nId
!= SID_CLOSEDOC
)
372 // this guard is created here to have it destruction at the end of the method
373 SfxInstanceCloseGuard_Impl aModelGuard
;
375 sal_Bool bIsPDFExport
= sal_False
;
380 SfxViewFrame
* pFrame
= GetFrame();
382 pFrame
= SfxViewFrame::GetFirst( this );
386 if ( pFrame
->GetFrame().GetParentFrame() )
388 pFrame
->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq
);
392 if ( !IsOwnStorageFormat_Impl( *GetMedium() ) )
395 SfxVersionDialog
*pDlg
= new SfxVersionDialog( pFrame
, IsSaveVersionOnClose() );
397 SetSaveVersionOnClose( pDlg
->IsSaveVersionOnClose() );
403 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
406 SFX_REQUEST_ARG(rReq
, pDocInfItem
, SfxDocumentInfoItem
, SID_DOCINFO
, sal_False
);
409 // parameter, e.g. from replayed macro
410 pDocInfItem
->UpdateDocumentInfo(getDocProperties(), true);
411 SetUseUserData( pDocInfItem
->IsUseUserData() );
415 // no argument containing DocInfo; check optional arguments
416 sal_Bool bReadOnly
= IsReadOnly();
417 SFX_REQUEST_ARG(rReq
, pROItem
, SfxBoolItem
, SID_DOC_READONLY
, sal_False
);
419 // override readonly attribute of document
420 // e.g. if a readonly document is saved elsewhere and user asks for editing DocInfo before
421 bReadOnly
= pROItem
->GetValue();
423 // collect data for dialog
427 aURL
= GetMedium()->GetName();
432 aURL
= DEFINE_CONST_UNICODE( "private:factory/" );
433 aURL
+= String::CreateFromAscii( GetFactory().GetShortName() );
438 SfxDocumentInfoItem
aDocInfoItem( aURL
, getDocProperties(),
440 if ( !GetSlotState( SID_DOCTEMPLATE
) )
441 // templates not supported
442 aDocInfoItem
.SetTemplate(sal_False
);
444 SfxItemSet
aSet(GetPool(), SID_DOCINFO
, SID_DOCINFO
, SID_DOC_READONLY
, SID_DOC_READONLY
,
445 SID_EXPLORER_PROPS_START
, SID_EXPLORER_PROPS_START
, SID_BASEURL
, SID_BASEURL
,
447 aSet
.Put( aDocInfoItem
);
448 aSet
.Put( SfxBoolItem( SID_DOC_READONLY
, bReadOnly
) );
449 aSet
.Put( SfxStringItem( SID_EXPLORER_PROPS_START
, aTitle
) );
450 aSet
.Put( SfxStringItem( SID_BASEURL
, GetMedium()->GetBaseURL() ) );
452 // creating dialog is done via virtual method; application will
453 // add its own statistics page
454 SfxDocumentInfoDialog
*pDlg
= CreateDocumentInfoDialog(0, aSet
);
455 if ( RET_OK
== pDlg
->Execute() )
457 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pDocInfoItem
, SfxDocumentInfoItem
, SID_DOCINFO
, sal_False
);
460 // user has done some changes to DocumentInfo
461 pDocInfoItem
->UpdateDocumentInfo(getDocProperties());
462 SetUseUserData( ((const SfxDocumentInfoItem
*)pDocInfoItem
)->IsUseUserData() );
464 // add data from dialog for possible recording purposes
465 rReq
.AppendItem( SfxDocumentInfoItem( GetTitle(),
466 getDocProperties(), IsUseUserData() ) );
472 // nothing done; no recording
481 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
483 case SID_EXPORTDOCASPDF
:
484 case SID_DIRECTEXPORTDOCASPDF
:
485 bIsPDFExport
= sal_True
;
490 // derived class may decide to abort this
491 if( !QuerySlotExecutable( nId
) )
493 rReq
.SetReturnValue( SfxBoolItem( 0, sal_False
) );
497 //!! detailed analysis of an error code
498 SfxObjectShellRef
xLock( this );
500 // the model can not be closed till the end of this method
501 // if somebody tries to close it during this time the model will be closed
502 // at the end of the method
503 aModelGuard
.Init_Impl( uno::Reference
< util::XCloseable
>( GetModel(), uno::UNO_QUERY
) );
505 sal_Bool bDialogUsed
= sal_False
;
506 sal_uInt32 nErrorCode
= ERRCODE_NONE
;
508 // by default versions should be preserved always except in case of an explicit
509 // SaveAs via GUI, so the flag must be set accordingly
510 pImp
->bPreserveVersions
= (nId
== SID_SAVEDOC
);
513 SfxErrorContext
aEc( ERRCTX_SFX_SAVEASDOC
, GetTitle() ); // ???
515 if ( nId
== SID_SAVEASDOC
)
517 // in case of plugin mode the SaveAs operation means SaveTo
518 SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pViewOnlyItem
, SfxBoolItem
, SID_VIEWONLY
, sal_False
);
519 if ( pViewOnlyItem
&& pViewOnlyItem
->GetValue() )
520 rReq
.AppendItem( SfxBoolItem( SID_SAVETO
, sal_True
) );
523 // TODO/LATER: do the following GUI related actions in standalown method
524 // ========================================================================================================
525 // Introduce a status indicator for GUI operation
526 SFX_REQUEST_ARG( rReq
, pStatusIndicatorItem
, SfxUnoAnyItem
, SID_PROGRESS_STATUSBAR_CONTROL
, sal_False
);
527 if ( !pStatusIndicatorItem
)
529 // get statusindicator
530 uno::Reference
< task::XStatusIndicator
> xStatusIndicator
;
531 SfxViewFrame
*pFrame
= GetFrame();
534 uno::Reference
< task::XStatusIndicatorFactory
> xStatFactory(
535 pFrame
->GetFrame().GetFrameInterface(),
537 if( xStatFactory
.is() )
538 xStatusIndicator
= xStatFactory
->createStatusIndicator();
542 OSL_ENSURE( xStatusIndicator
.is(), "Can not retrieve default status indicator!\n" );
543 if ( xStatusIndicator
.is() )
545 SfxUnoAnyItem
aStatIndItem( SID_PROGRESS_STATUSBAR_CONTROL
, uno::makeAny( xStatusIndicator
) );
547 if ( nId
== SID_SAVEDOC
)
549 // in case of saving it is not possible to transport the parameters from here
550 // but it is not clear here whether the saving will be done or saveAs operation
551 GetMedium()->GetItemSet()->Put( aStatIndItem
);
554 rReq
.AppendItem( aStatIndItem
);
557 else if ( nId
== SID_SAVEDOC
)
559 // in case of saving it is not possible to transport the parameters from here
560 // but it is not clear here whether the saving will be done or saveAs operation
561 GetMedium()->GetItemSet()->Put( *pStatusIndicatorItem
);
564 // Introduce an interaction handler for GUI operation
565 SFX_REQUEST_ARG( rReq
, pInteractionHandlerItem
, SfxUnoAnyItem
, SID_INTERACTIONHANDLER
, sal_False
);
566 if ( !pInteractionHandlerItem
)
568 uno::Reference
< task::XInteractionHandler
> xInteract
;
569 uno::Reference
< lang::XMultiServiceFactory
> xServiceManager
= ::comphelper::getProcessServiceFactory();
570 if( xServiceManager
.is() )
572 xInteract
= Reference
< XInteractionHandler
>(
573 xServiceManager
->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
577 OSL_ENSURE( xInteract
.is(), "Can not retrieve default status indicator!\n" );
578 if ( xInteract
.is() )
580 SfxUnoAnyItem
aInteractionItem( SID_INTERACTIONHANDLER
, uno::makeAny( xInteract
) );
581 if ( nId
== SID_SAVEDOC
)
583 // in case of saving it is not possible to transport the parameters from here
584 // but it is not clear here whether the saving will be done or saveAs operation
585 GetMedium()->GetItemSet()->Put( aInteractionItem
);
588 rReq
.AppendItem( aInteractionItem
);
591 else if ( nId
== SID_SAVEDOC
)
593 // in case of saving it is not possible to transport the parameters from here
594 // but it is not clear here whether the saving will be done or saveAs operation
595 GetMedium()->GetItemSet()->Put( *pInteractionHandlerItem
);
597 // ========================================================================================================
599 sal_Bool bPreselectPassword
= sal_False
;
600 SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pOldEncryptionDataItem
, SfxUnoAnyItem
, SID_ENCRYPTIONDATA
, sal_False
);
601 SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pOldPasswordItem
, SfxStringItem
, SID_PASSWORD
, sal_False
);
602 if ( pOldEncryptionDataItem
|| pOldPasswordItem
)
603 bPreselectPassword
= sal_True
;
605 uno::Sequence
< beans::PropertyValue
> aDispatchArgs
;
606 if ( rReq
.GetArgs() )
612 const SfxSlot
* pSlot
= GetModule()->GetSlotPool()->GetSlot( nId
);
614 throw uno::Exception();
616 uno::Reference
< lang::XMultiServiceFactory
> xEmptyFactory
;
617 SfxStoringHelper
aHelper( xEmptyFactory
);
619 if ( QueryHiddenInformation( bIsPDFExport
? WhenCreatingPDF
: WhenSaving
, NULL
) == RET_YES
)
621 bDialogUsed
= aHelper
.GUIStoreModel( GetModel(),
622 ::rtl::OUString::createFromAscii( pSlot
->GetUnoName() ),
626 GetDocumentSignatureState() );
630 // the user has decided not to store the document
631 throw task::ErrorCodeIOException( ::rtl::OUString(),
632 uno::Reference
< uno::XInterface
>(),
636 // merge aDispatchArgs to the request
637 SfxAllItemSet
aResultParams( GetPool() );
638 TransformParameters( nId
,
642 rReq
.SetArgs( aResultParams
);
644 SFX_REQUEST_ARG( rReq
, pFilterNameItem
, SfxStringItem
, SID_FILTER_NAME
, sal_False
);
645 ::rtl::OUString aFilterName
= pFilterNameItem
? ::rtl::OUString( pFilterNameItem
->GetValue() )
647 const SfxFilter
* pFilt
= GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName
);
649 OSL_ENSURE( nId
== SID_SAVEDOC
|| pFilt
, "The filter can not be zero since it was used for storing!\n" );
650 if ( bDialogUsed
&& pFilt
651 && pFilt
->IsOwnFormat()
652 && pFilt
->UsesStorage()
653 && pFilt
->GetVersion() >= SOFFICE_FILEFORMAT_60
)
655 SfxViewFrame
* pDocViewFrame
= SfxViewFrame::GetFirst( this );
657 SfxHelp::OpenHelpAgent( &pDocViewFrame
->GetFrame(), HID_DID_SAVE_PACKED_XML
);
660 // the StoreAsURL/StoreToURL method have called this method with false
661 // so it has to be restored to true here since it is a call from GUI
662 GetMedium()->SetUpdatePickList( sal_True
);
664 // TODO: in future it must be done in followind way
665 // if document is opened from GUI it is immediatelly appeares in the picklist
666 // if the document is a new one then it appeares in the picklist immediatelly
667 // after SaveAs operation triggered from GUI
669 catch( const task::ErrorCodeIOException
& aErrorEx
)
671 nErrorCode
= (sal_uInt32
)aErrorEx
.ErrCode
;
675 nErrorCode
= ERRCODE_IO_GENERAL
;
678 // by default versions should be preserved always except in case of an explicit
679 // SaveAs via GUI, so the flag must be reset to guarantee this
680 pImp
->bPreserveVersions
= sal_True
;
681 sal_uIntPtr lErr
=GetErrorCode();
683 if ( !lErr
&& nErrorCode
)
686 if ( lErr
&& nErrorCode
== ERRCODE_NONE
)
688 SFX_REQUEST_ARG( rReq
, pWarnItem
, SfxBoolItem
, SID_FAIL_ON_WARNING
, sal_False
);
689 if ( pWarnItem
&& pWarnItem
->GetValue() )
693 // may be nErrorCode should be shown in future
694 if ( lErr
!= ERRCODE_IO_ABORT
)
696 SfxErrorContext
aEc(ERRCTX_SFX_SAVEASDOC
,GetTitle());
697 ErrorHandler::HandleError( lErr
);
700 if ( nId
== SID_EXPORTDOCASPDF
)
702 // This function is used by the SendMail function that needs information if a export
703 // file was written or not. This could be due to cancellation of the export
704 // or due to an error. So IO abort must be handled like an error!
705 nErrorCode
= ( lErr
!= ERRCODE_IO_ABORT
) && ( nErrorCode
== ERRCODE_NONE
) ? nErrorCode
: lErr
;
708 rReq
.SetReturnValue( SfxBoolItem(0, nErrorCode
== ERRCODE_NONE
) );
716 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
720 SfxViewFrame
*pFrame
= GetFrame();
721 if ( pFrame
&& pFrame
->GetFrame().GetParentFrame() )
723 // If SID_CLOSEDOC is excecuted through menu and so on, but
724 // the current document is in a frame, then the
725 // FrameSetDocument should actually be closed.
726 pFrame
->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq
);
731 sal_Bool bInFrameSet
= sal_False
;
732 sal_uInt16 nFrames
=0;
733 pFrame
= SfxViewFrame::GetFirst( this );
736 if ( pFrame
->GetFrame().GetParentFrame() )
738 // In this document there still exists a view that is
739 // in a FrameSet , which of course may not be closed
741 bInFrameSet
= sal_True
;
746 pFrame
= SfxViewFrame::GetNext( *pFrame
, this );
751 // Close all views that are not in a FrameSet.
752 pFrame
= SfxViewFrame::GetFirst( this );
755 if ( !pFrame
->GetFrame().GetParentFrame() )
756 pFrame
->GetFrame().DoClose();
757 pFrame
= SfxViewFrame::GetNext( *pFrame
, this );
761 // Evaluate Parameter
762 SFX_REQUEST_ARG(rReq
, pSaveItem
, SfxBoolItem
, SID_CLOSEDOC_SAVE
, sal_False
);
763 SFX_REQUEST_ARG(rReq
, pNameItem
, SfxStringItem
, SID_CLOSEDOC_FILENAME
, sal_False
);
766 if ( pSaveItem
->GetValue() )
770 #ifndef DISABLE_SCRIPTING
771 SbxBase::SetError( SbxERR_WRONG_ARGS
);
776 SfxAllItemSet
aArgs( GetPool() );
777 SfxStringItem
aTmpItem( SID_FILE_NAME
, pNameItem
->GetValue() );
778 aArgs
.Put( aTmpItem
, aTmpItem
.Which() );
779 SfxRequest
aSaveAsReq( SID_SAVEASDOC
, SFX_CALLMODE_API
, aArgs
);
780 ExecFile_Impl( aSaveAsReq
);
781 if ( !aSaveAsReq
.IsDone() )
788 SetModified(sal_False
);
791 // Cancelled by the user?
792 if ( !PrepareClose( 2 ) )
794 rReq
.SetReturnValue( SfxBoolItem(0, sal_False
) );
799 SetModified( sal_False
);
800 sal_uIntPtr lErr
= GetErrorCode();
801 ErrorHandler::HandleError(lErr
);
803 rReq
.SetReturnValue( SfxBoolItem(0, sal_True
) );
805 rReq
.ReleaseArgs(); // because the pool is destroyed in Close
810 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
811 case SID_DOCTEMPLATE
:
813 // save as document templates
814 SfxDocumentTemplateDlg
*pDlg
= 0;
815 SfxErrorContext
aEc(ERRCTX_SFX_DOCTEMPLATE
,GetTitle());
816 SfxDocumentTemplates
*pTemplates
= new SfxDocumentTemplates
;
818 if ( !rReq
.GetArgs() )
820 pDlg
= new SfxDocumentTemplateDlg(0, pTemplates
);
821 if ( RET_OK
== pDlg
->Execute() && pDlg
->GetTemplateName().Len())
823 rReq
.AppendItem(SfxStringItem(
824 SID_TEMPLATE_NAME
, pDlg
->GetTemplateName()));
825 rReq
.AppendItem(SfxStringItem(
826 SID_TEMPLATE_REGIONNAME
, pDlg
->GetRegionName()));
836 SFX_REQUEST_ARG(rReq
, pRegionItem
, SfxStringItem
, SID_TEMPLATE_REGIONNAME
, sal_False
);
837 SFX_REQUEST_ARG(rReq
, pNameItem
, SfxStringItem
, SID_TEMPLATE_NAME
, sal_False
);
838 SFX_REQUEST_ARG(rReq
, pRegionNrItem
, SfxUInt16Item
, SID_TEMPLATE_REGION
, sal_False
);
839 if ( (!pRegionItem
&& !pRegionNrItem
) || !pNameItem
)
841 DBG_ASSERT( rReq
.IsAPI(), "non-API call without Arguments" );
842 #ifndef DISABLE_SCRIPTING
843 SbxBase::SetError( SbxERR_WRONG_ARGS
);
849 ::rtl::OUString aTemplateName
= pNameItem
->GetValue();
850 ::rtl::OUString aTemplateGroup
;
852 aTemplateGroup
= pRegionItem
->GetValue();
854 // pRegionNrItem must not be NULL, it was just checked
855 aTemplateGroup
= pTemplates
->GetFullRegionName( pRegionNrItem
->GetValue() );
856 // check Group and Name
859 sal_Bool bOk
= sal_False
;
862 uno::Reference
< frame::XStorable
> xStorable( GetModel(), uno::UNO_QUERY_THROW
);
863 uno::Reference
< frame::XDocumentTemplates
> xTemplates(
864 frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) );
866 bOk
= xTemplates
->storeTemplate( aTemplateGroup
, aTemplateName
, xStorable
);
868 catch( uno::Exception
& )
874 rReq
.SetReturnValue( SfxBoolItem( 0, bOk
) );
877 // update the Organizer runtime cache from the template
878 // component if the cache has already been created
879 // TODO/LATER: get rid of this cache duplication
880 SfxDocumentTemplates aTemplates
;
881 aTemplates
.ReInitFromComponent();
885 ErrorHandler::HandleError( ERRCODE_IO_GENERAL
);
893 // Prevent entry in the Pick-lists
895 GetMedium()->SetUpdatePickList( sal_False
);
896 else if ( rReq
.GetArgs() )
898 SFX_ITEMSET_GET( *rReq
.GetArgs(), pPicklistItem
, SfxBoolItem
, SID_PICKLIST
, sal_False
);
900 GetMedium()->SetUpdatePickList( pPicklistItem
->GetValue() );
903 // Ignore()-branches have already returned
907 //-------------------------------------------------------------------------
909 void SfxObjectShell::GetState_Impl(SfxItemSet
&rSet
)
911 DBG_CHKTHIS(SfxObjectShell
, 0);
912 SfxWhichIter
aIter( rSet
);
914 for ( sal_uInt16 nWhich
= aIter
.FirstWhich(); nWhich
; nWhich
= aIter
.NextWhich() )
918 case SID_DOCTEMPLATE
:
920 if ( !GetFactory().GetTemplateFilter() )
921 rSet
.DisableItem( nWhich
);
927 SfxObjectShell
*pDoc
= this;
928 SfxViewFrame
* pFrame
= GetFrame();
930 pFrame
= SfxViewFrame::GetFirst( this );
933 if ( pFrame
->GetFrame().GetParentFrame() )
935 pFrame
= pFrame
->GetTopViewFrame();
936 pDoc
= pFrame
->GetObjectShell();
940 if ( !pFrame
|| !pDoc
->HasName() ||
941 !IsOwnStorageFormat_Impl( *pDoc
->GetMedium() ) )
942 rSet
.DisableItem( nWhich
);
947 SvtMiscOptions aMiscOptions
;
948 bool bAlwaysAllowSave
= aMiscOptions
.IsSaveAlwaysAllowed();
949 bool bAllowSave
= (bAlwaysAllowSave
|| IsModified());
950 bool bMediumRO
= IsReadOnlyMedium();
951 if ( !bMediumRO
&& GetMedium() && bAllowSave
)
952 rSet
.Put(SfxStringItem(
953 nWhich
, String(SfxResId(STR_SAVEDOC
))));
955 rSet
.DisableItem(nWhich
);
960 if ( 0 != ( pImp
->eFlags
& SFXOBJECTSHELL_NODOCINFO
) )
961 rSet
.DisableItem( nWhich
);
966 SfxObjectShell
*pDoc
= this;
967 SfxViewFrame
*pFrame
= GetFrame();
968 if ( pFrame
&& pFrame
->GetFrame().GetParentFrame() )
971 // If SID_CLOSEDOC is excecuted through menu and so on, but
972 // the current document is in a frame, then the
973 // FrameSetDocument should actually be closed.
974 pDoc
= pFrame
->GetTopViewFrame()->GetObjectShell();
977 if ( pDoc
->GetFlags() & SFXOBJECTSHELL_DONTCLOSE
)
978 rSet
.DisableItem(nWhich
);
980 rSet
.Put(SfxStringItem(nWhich
, String(SfxResId(STR_CLOSEDOC
))));
986 if( ( pImp
->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
) != SFX_LOADED_MAINDOCUMENT
)
988 rSet
.DisableItem( nWhich
);
991 if ( /*!pCombinedFilters ||*/ !GetMedium() )
992 rSet
.DisableItem( nWhich
);
994 rSet
.Put( SfxStringItem( nWhich
, String( SfxResId( STR_SAVEASDOC
) ) ) );
998 case SID_EXPORTDOCASPDF
:
999 case SID_DIRECTEXPORTDOCASPDF
:
1004 case SID_DOC_MODIFIED
:
1006 rSet
.Put( SfxBoolItem( SID_DOC_MODIFIED
, IsModified() ) );
1012 rSet
.Put( SfxBoolItem( SID_MODIFIED
, IsModified() ) );
1016 case SID_DOCINFO_TITLE
:
1018 rSet
.Put( SfxStringItem(
1019 SID_DOCINFO_TITLE
, getDocProperties()->getTitle() ) );
1024 if( GetMedium() && HasName() )
1025 rSet
.Put( SfxStringItem(
1026 SID_FILE_NAME
, GetMedium()->GetName() ) );
1031 rSet
.Put( SfxUInt16Item( SID_SIGNATURE
, GetDocumentSignatureState() ) );
1034 case SID_MACRO_SIGNATURE
:
1036 // the slot makes sense only if there is a macro in the document
1037 if ( pImp
->documentStorageHasMacros() || pImp
->aMacroMode
.hasMacroLibrary() )
1038 rSet
.Put( SfxUInt16Item( SID_MACRO_SIGNATURE
, GetScriptingSignatureState() ) );
1040 rSet
.DisableItem( nWhich
);
1047 //--------------------------------------------------------------------
1049 void SfxObjectShell::ExecProps_Impl(SfxRequest
&rReq
)
1051 switch ( rReq
.GetSlot() )
1055 SetModified( ( (SfxBoolItem
&) rReq
.GetArgs()->Get(SID_MODIFIED
)).GetValue() );
1061 SetTitle( ( (SfxStringItem
&) rReq
.GetArgs()->Get(SID_DOCTITLE
)).GetValue() );
1065 case SID_DOCINFO_AUTHOR
:
1067 ::rtl::OUString aStr
= ( (SfxStringItem
&)rReq
.GetArgs()->Get(rReq
.GetSlot())).GetValue();
1068 getDocProperties()->setAuthor( aStr
);
1072 case SID_DOCINFO_COMMENTS
:
1074 ::rtl::OUString aStr
= ( (SfxStringItem
&)rReq
.GetArgs()->Get(rReq
.GetSlot())).GetValue();
1075 getDocProperties()->setDescription( aStr
);
1079 case SID_DOCINFO_KEYWORDS
:
1081 ::rtl::OUString aStr
= ( (SfxStringItem
&)rReq
.GetArgs()->Get(rReq
.GetSlot())).GetValue();
1082 getDocProperties()->setKeywords(
1083 ::comphelper::string::convertCommaSeparated(aStr
) );
1089 //--------------------------------------------------------------------
1091 void SfxObjectShell::StateProps_Impl(SfxItemSet
&rSet
)
1093 SfxWhichIter
aIter(rSet
);
1094 for ( sal_uInt16 nSID
= aIter
.FirstWhich(); nSID
; nSID
= aIter
.NextWhich() )
1098 case SID_DOCINFO_AUTHOR
:
1100 rSet
.Put( SfxStringItem( nSID
,
1101 getDocProperties()->getAuthor() ) );
1105 case SID_DOCINFO_COMMENTS
:
1107 rSet
.Put( SfxStringItem( nSID
,
1108 getDocProperties()->getDescription()) );
1112 case SID_DOCINFO_KEYWORDS
:
1114 rSet
.Put( SfxStringItem( nSID
, ::comphelper::string::
1115 convertCommaSeparated(getDocProperties()->getKeywords())) );
1121 OSL_FAIL( "Not supported anymore!" );
1125 case SID_DOCFULLNAME
:
1127 rSet
.Put( SfxStringItem( SID_DOCFULLNAME
, GetTitle(SFX_TITLE_FULLNAME
) ) );
1133 rSet
.Put( SfxStringItem( SID_DOCTITLE
, GetTitle() ) );
1137 case SID_DOC_READONLY
:
1139 rSet
.Put( SfxBoolItem( SID_DOC_READONLY
, IsReadOnly() ) );
1145 rSet
.Put( SfxBoolItem( SID_DOC_SAVED
, !IsModified() ) );
1151 rSet
.Put( SfxBoolItem( SID_CLOSING
, false ) );
1155 case SID_DOC_LOADING
:
1156 rSet
.Put( SfxBoolItem( nSID
, SFX_LOADED_MAINDOCUMENT
!=
1157 ( pImp
->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
) ) );
1160 case SID_IMG_LOADING
:
1161 rSet
.Put( SfxBoolItem( nSID
, SFX_LOADED_IMAGES
!=
1162 ( pImp
->nLoadedFlags
& SFX_LOADED_IMAGES
) ) );
1168 //--------------------------------------------------------------------
1170 void SfxObjectShell::ExecView_Impl(SfxRequest
&rReq
)
1172 switch ( rReq
.GetSlot() )
1176 SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( this, sal_True
);
1178 pFrame
->GetFrame().Appear();
1179 rReq
.SetReturnValue( SfxObjectItem( 0, pFrame
) );
1183 case SID_NEWWINDOWFOREDIT
:
1185 SfxViewFrame
* pFrame
= SfxViewFrame::Current();
1186 if( pFrame
->GetObjectShell() == this &&
1187 ( pFrame
->GetFrameType() & SFXFRAME_HASTITLE
) )
1188 pFrame
->ExecuteSlot( rReq
);
1191 String
aFileName( GetObjectShell()->GetMedium()->GetName() );
1192 if ( aFileName
.Len() )
1194 SfxStringItem
aName( SID_FILE_NAME
, aFileName
);
1195 SfxBoolItem
aCreateView( SID_OPEN_NEW_VIEW
, sal_True
);
1196 SFX_APP()->GetAppDispatcher_Impl()->Execute(
1197 SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
, &aName
,
1205 //--------------------------------------------------------------------
1207 void SfxObjectShell::StateView_Impl(SfxItemSet
& /*rSet*/)
1211 sal_uInt16
SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence
< security::DocumentSignatureInformation
>& aInfos
)
1213 sal_Bool bCertValid
= sal_True
;
1214 sal_uInt16 nResult
= SIGNATURESTATE_NOSIGNATURES
;
1215 int nInfos
= aInfos
.getLength();
1216 bool bCompleteSignature
= true;
1219 nResult
= SIGNATURESTATE_SIGNATURES_OK
;
1220 for ( int n
= 0; n
< nInfos
; n
++ )
1224 sal_Int32 nCertStat
= aInfos
[n
].CertificateStatus
;
1225 bCertValid
= nCertStat
== security::CertificateValidity::VALID
? sal_True
: sal_False
;
1228 if ( !aInfos
[n
].SignatureIsValid
)
1230 nResult
= SIGNATURESTATE_SIGNATURES_BROKEN
;
1231 break; // we know enough
1233 bCompleteSignature
&= !aInfos
[n
].PartialDocumentSignature
;
1237 if ( nResult
== SIGNATURESTATE_SIGNATURES_OK
&& !bCertValid
)
1238 nResult
= SIGNATURESTATE_SIGNATURES_NOTVALIDATED
;
1239 else if ( nResult
== SIGNATURESTATE_SIGNATURES_OK
&& bCertValid
&& !bCompleteSignature
)
1240 nResult
= SIGNATURESTATE_SIGNATURES_PARTIAL_OK
;
1242 // this code must not check whether the document is modified
1243 // it should only check the provided info
1248 uno::Sequence
< security::DocumentSignatureInformation
> SfxObjectShell::ImplAnalyzeSignature( sal_Bool bScriptingContent
, const uno::Reference
< security::XDocumentDigitalSignatures
>& xSigner
)
1250 uno::Sequence
< security::DocumentSignatureInformation
> aResult
;
1251 uno::Reference
< security::XDocumentDigitalSignatures
> xLocSigner
= xSigner
;
1253 if ( GetMedium() && GetMedium()->GetName().Len() && IsOwnStorageFormat_Impl( *GetMedium()) && GetMedium()->GetStorage().is() )
1257 if ( !xLocSigner
.is() )
1259 uno::Sequence
< uno::Any
> aArgs( 1 );
1260 aArgs
[0] <<= ::rtl::OUString();
1263 uno::Reference
< beans::XPropertySet
> xPropSet( GetStorage(), uno::UNO_QUERY_THROW
);
1264 aArgs
[0] = xPropSet
->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) );
1266 catch( uno::Exception
& )
1270 xLocSigner
.set( comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs
), uno::UNO_QUERY_THROW
);
1274 if ( bScriptingContent
)
1275 aResult
= xLocSigner
->verifyScriptingContentSignatures( GetMedium()->GetZipStorageToSign_Impl(),
1276 uno::Reference
< io::XInputStream
>() );
1278 aResult
= xLocSigner
->verifyDocumentContentSignatures( GetMedium()->GetZipStorageToSign_Impl(),
1279 uno::Reference
< io::XInputStream
>() );
1281 catch( com::sun::star::uno::Exception
& )
1289 sal_uInt16
SfxObjectShell::ImplGetSignatureState( sal_Bool bScriptingContent
)
1291 sal_Int16
* pState
= bScriptingContent
? &pImp
->nScriptingSignatureState
: &pImp
->nDocumentSignatureState
;
1293 if ( *pState
== SIGNATURESTATE_UNKNOWN
)
1295 *pState
= SIGNATURESTATE_NOSIGNATURES
;
1297 uno::Sequence
< security::DocumentSignatureInformation
> aInfos
= ImplAnalyzeSignature( bScriptingContent
);
1298 *pState
= ImplCheckSignaturesInformation( aInfos
);
1301 if ( *pState
== SIGNATURESTATE_SIGNATURES_OK
|| *pState
== SIGNATURESTATE_SIGNATURES_NOTVALIDATED
1302 || *pState
== SIGNATURESTATE_SIGNATURES_PARTIAL_OK
)
1305 *pState
= SIGNATURESTATE_SIGNATURES_INVALID
;
1308 return (sal_uInt16
)*pState
;
1311 void SfxObjectShell::ImplSign( sal_Bool bScriptingContent
)
1313 // Check if it is stored in OASIS format...
1315 && GetMedium()->GetFilter()
1316 && GetMedium()->GetName().Len()
1317 && ( !GetMedium()->GetFilter()->IsOwnFormat()
1318 || !GetMedium()->HasStorage_Impl()
1322 // Only OASIS and OOo6.x formats will be handled further
1323 InfoBox( NULL
, SfxResId( RID_XMLSEC_INFO_WRONGDOCFORMAT
) ).Execute();
1327 // check whether the document is signed
1328 ImplGetSignatureState( sal_False
); // document signature
1329 ImplGetSignatureState( sal_True
); // script signature
1330 sal_Bool bHasSign
= ( pImp
->nScriptingSignatureState
!= SIGNATURESTATE_NOSIGNATURES
|| pImp
->nDocumentSignatureState
!= SIGNATURESTATE_NOSIGNATURES
);
1332 // the target ODF version on saving
1333 SvtSaveOptions aSaveOpt
;
1334 SvtSaveOptions::ODFDefaultVersion nVersion
= aSaveOpt
.GetODFDefaultVersion();
1336 // the document is not new and is not modified
1337 ::rtl::OUString aODFVersion
;
1340 // check the version of the document
1341 uno::Reference
< beans::XPropertySet
> xPropSet( GetStorage(), uno::UNO_QUERY_THROW
);
1342 xPropSet
->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) >>= aODFVersion
;
1344 catch( uno::Exception
& )
1347 bool bNoSig
= false;
1349 if ( IsModified() || !GetMedium() || !GetMedium()->GetName().Len()
1350 || (!aODFVersion
.equals( ODFVER_012_TEXT
) && !bHasSign
) )
1352 // the document might need saving ( new, modified or in ODF1.1 format without signature )
1354 if ( nVersion
>= SvtSaveOptions::ODFVER_012
)
1357 if ( (bHasSign
&& QueryBox( NULL
, SfxResId( MSG_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN
) ).Execute() == RET_YES
)
1358 || (!bHasSign
&& QueryBox( NULL
, SfxResId( RID_XMLSEC_QUERY_SAVEBEFORESIGN
) ).Execute() == RET_YES
) )
1360 sal_uInt16 nId
= SID_SAVEDOC
;
1361 if ( !GetMedium() || !GetMedium()->GetName().Len() )
1362 nId
= SID_SAVEASDOC
;
1363 SfxRequest
aSaveRequest( nId
, 0, GetPool() );
1364 //ToDo: Review. We needed to call SetModified, otherwise the document would not be saved.
1365 SetModified(sal_True
);
1366 ExecFile_Impl( aSaveRequest
);
1368 // Check if it is stored in OASIS format...
1369 if ( GetMedium() && GetMedium()->GetFilter()
1370 && ( !GetMedium()->GetFilter()->IsOwnFormat() || !GetMedium()->HasStorage_Impl()
1371 || SotStorage::GetVersion( GetMedium()->GetStorage() ) <= SOFFICE_FILEFORMAT_60
) )
1373 // Only OASIS format will be handled further
1374 InfoBox( NULL
, SfxResId( RID_XMLSEC_INFO_WRONGDOCFORMAT
) ).Execute();
1380 // When the document is modified then we must not show the
1381 // digital signatures dialog
1382 // If we have come here then the user denied to save.
1389 ErrorBox( NULL
, WB_OK
, SfxResId( STR_XMLSEC_ODF12_EXPECTED
) ).Execute();
1393 if ( IsModified() || !GetMedium() || !GetMedium()->GetName().Len() )
1397 // the document is not modified currently, so it can not become modified after signing
1398 sal_Bool bAllowModifiedBack
= sal_False
;
1399 if ( IsEnableSetModified() )
1401 EnableSetModified( sal_False
);
1402 bAllowModifiedBack
= sal_True
;
1405 // we have to store to the original document, the original medium should be closed for this time
1407 && ConnectTmpStorage_Impl( pMedium
->GetStorage(), pMedium
) )
1409 GetMedium()->CloseAndRelease();
1411 // We sign only ODF1.2, that means that if this point has been reached,
1412 // the ODF1.2 signing process should be used.
1413 // This code still might be called to show the signature of ODF1.1 document.
1414 sal_Bool bSigned
= GetMedium()->SignContents_Impl(
1417 pImp
->nDocumentSignatureState
== SIGNATURESTATE_SIGNATURES_OK
1418 || pImp
->nDocumentSignatureState
== SIGNATURESTATE_SIGNATURES_NOTVALIDATED
1419 || pImp
->nDocumentSignatureState
== SIGNATURESTATE_SIGNATURES_PARTIAL_OK
);
1421 DoSaveCompleted( GetMedium() );
1425 if ( bScriptingContent
)
1427 pImp
->nScriptingSignatureState
= SIGNATURESTATE_UNKNOWN
;// Re-Check
1429 // adding of scripting signature removes existing document signature
1430 pImp
->nDocumentSignatureState
= SIGNATURESTATE_UNKNOWN
;// Re-Check
1433 pImp
->nDocumentSignatureState
= SIGNATURESTATE_UNKNOWN
;// Re-Check
1435 pImp
->bSignatureErrorIsShown
= sal_False
;
1437 Invalidate( SID_SIGNATURE
);
1438 Invalidate( SID_MACRO_SIGNATURE
);
1439 Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
1443 if ( bAllowModifiedBack
)
1444 EnableSetModified( sal_True
);
1447 sal_uInt16
SfxObjectShell::GetDocumentSignatureState()
1449 return ImplGetSignatureState( sal_False
);
1452 void SfxObjectShell::SignDocumentContent()
1454 ImplSign( sal_False
);
1457 sal_uInt16
SfxObjectShell::GetScriptingSignatureState()
1459 return ImplGetSignatureState( sal_True
);
1462 void SfxObjectShell::SignScriptingContent()
1464 ImplSign( sal_True
);
1469 class theSfxObjectShellUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSfxObjectShellUnoTunnelId
> {};
1472 const uno::Sequence
<sal_Int8
>& SfxObjectShell::getUnoTunnelId()
1474 return theSfxObjectShellUnoTunnelId::get().getSeq();
1477 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */