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