lok: impress: show only supported transitions in the side pane
[LibreOffice.git] / sfx2 / source / doc / objserv.cxx
blob5e04a0c09c34891a2512947db895fa256ec5d2ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_features.h>
22 #include <sot/storage.hxx>
23 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
24 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
25 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
26 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
27 #include <com/sun/star/ui/dialogs/XControlAccess.hpp>
28 #include <com/sun/star/util/CloseVetoException.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/beans/XPropertyAccess.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/document/XCmisDocument.hpp>
35 #include <com/sun/star/document/XExporter.hpp>
36 #include <com/sun/star/security/XCertificate.hpp>
37 #include <com/sun/star/task/ErrorCodeIOException.hpp>
38 #include <com/sun/star/task/InteractionHandler.hpp>
39 #include <com/sun/star/task/XStatusIndicator.hpp>
40 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
41 #include <comphelper/processfactory.hxx>
42 #include <comphelper/servicehelper.hxx>
43 #include <com/sun/star/security/CertificateValidity.hpp>
45 #include <com/sun/star/security/DocumentSignatureInformation.hpp>
46 #include <com/sun/star/security/DocumentDigitalSignatures.hpp>
47 #include <tools/diagnose_ex.h>
48 #include <tools/urlobj.hxx>
49 #include <svl/whiter.hxx>
50 #include <svl/intitem.hxx>
51 #include <svl/eitem.hxx>
52 #include <svl/visitem.hxx>
53 #include <vcl/weld.hxx>
54 #include <vcl/wrkwin.hxx>
55 #include <svtools/sfxecode.hxx>
56 #include <svtools/ehdl.hxx>
57 #include <sal/log.hxx>
59 #include <comphelper/string.hxx>
60 #include <basic/sbx.hxx>
61 #include <basic/sberrors.hxx>
62 #include <unotools/pathoptions.hxx>
63 #include <unotools/useroptions.hxx>
64 #include <unotools/saveopt.hxx>
65 #include <svtools/asynclink.hxx>
66 #include <svtools/DocumentToGraphicRenderer.hxx>
67 #include <vcl/gdimtf.hxx>
68 #include <comphelper/fileformat.h>
69 #include <comphelper/documentconstants.hxx>
70 #include <comphelper/propertyvalue.hxx>
71 #include <comphelper/storagehelper.hxx>
72 #include <tools/link.hxx>
74 #include <sfx2/asyncfunc.hxx>
75 #include <sfx2/app.hxx>
76 #include <sfx2/signaturestate.hxx>
77 #include <sfx2/sfxresid.hxx>
78 #include <sfx2/event.hxx>
79 #include <sfx2/request.hxx>
80 #include <sfx2/printer.hxx>
81 #include <sfx2/viewsh.hxx>
82 #include <sfx2/dinfdlg.hxx>
83 #include <sfx2/docfilt.hxx>
84 #include <sfx2/docfile.hxx>
85 #include <sfx2/dispatch.hxx>
86 #include <sfx2/objitem.hxx>
87 #include <sfx2/objsh.hxx>
88 #include <objshimp.hxx>
89 #include <sfxtypes.hxx>
90 #include <sfx2/module.hxx>
91 #include <sfx2/viewfrm.hxx>
92 #include <versdlg.hxx>
93 #include <sfx2/strings.hrc>
94 #include <sfx2/docfac.hxx>
95 #include <sfx2/fcontnr.hxx>
96 #include <sfx2/sfxhelp.hxx>
97 #include <sfx2/msgpool.hxx>
98 #include <sfx2/objface.hxx>
99 #include <sfx2/checkin.hxx>
100 #include <sfx2/infobar.hxx>
101 #include <sfx2/sfxuno.hxx>
102 #include <sfx2/sfxsids.hrc>
103 #include <SfxRedactionHelper.hxx>
105 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
106 #include <com/sun/star/embed/XTransactedObject.hpp>
107 #include <com/sun/star/util/XCloneable.hpp>
108 #include <com/sun/star/util/XCloseable.hpp>
109 #include <com/sun/star/document/XDocumentProperties.hpp>
110 #include <com/sun/star/text/XPageCursor.hpp>
111 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
113 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
114 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
115 #include <com/sun/star/frame/XDesktop2.hpp>
116 #include <com/sun/star/frame/Desktop.hpp>
117 #include <com/sun/star/frame/XLayoutManager.hpp>
119 #include <guisaveas.hxx>
120 #include <saveastemplatedlg.hxx>
121 #include <memory>
122 #include <cppuhelper/implbase.hxx>
123 #include <unotools/ucbstreamhelper.hxx>
124 #include <unotools/streamwrap.hxx>
126 #include <svx/unoshape.hxx>
127 #include <svx/xlineit0.hxx>
128 #include <com/sun/star/util/Color.hpp>
130 #include <autoredactdialog.hxx>
132 using namespace ::com::sun::star;
133 using namespace ::com::sun::star::lang;
134 using namespace ::com::sun::star::uno;
135 using namespace ::com::sun::star::ui::dialogs;
136 using namespace ::com::sun::star::awt;
137 using namespace ::com::sun::star::container;
138 using namespace ::com::sun::star::beans;
139 using namespace ::com::sun::star::document;
140 using namespace ::com::sun::star::security;
141 using namespace ::com::sun::star::task;
142 using namespace ::com::sun::star::graphic;
144 #define ShellClass_SfxObjectShell
145 #include <sfxslots.hxx>
147 SFX_IMPL_SUPERCLASS_INTERFACE(SfxObjectShell, SfxShell)
149 void SfxObjectShell::InitInterface_Impl()
153 class SfxClosePreventer_Impl : public ::cppu::WeakImplHelper< css::util::XCloseListener >
155 bool m_bGotOwnership;
156 bool m_bPreventClose;
158 public:
159 SfxClosePreventer_Impl();
161 bool HasOwnership() const { return m_bGotOwnership; }
163 void SetPreventClose( bool bPrevent ) { m_bPreventClose = bPrevent; }
165 virtual void SAL_CALL queryClosing( const lang::EventObject& aEvent, sal_Bool bDeliverOwnership ) override;
167 virtual void SAL_CALL notifyClosing( const lang::EventObject& aEvent ) override ;
169 virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) override ;
173 SfxClosePreventer_Impl::SfxClosePreventer_Impl()
174 : m_bGotOwnership( false )
175 , m_bPreventClose( true )
179 void SAL_CALL SfxClosePreventer_Impl::queryClosing( const lang::EventObject&, sal_Bool bDeliverOwnership )
181 if ( m_bPreventClose )
183 if ( !m_bGotOwnership )
184 m_bGotOwnership = bDeliverOwnership;
186 throw util::CloseVetoException();
190 void SAL_CALL SfxClosePreventer_Impl::notifyClosing( const lang::EventObject& )
193 void SAL_CALL SfxClosePreventer_Impl::disposing( const lang::EventObject& )
197 class SfxInstanceCloseGuard_Impl
199 rtl::Reference<SfxClosePreventer_Impl> m_xPreventer;
200 uno::Reference< util::XCloseable > m_xCloseable;
202 public:
203 SfxInstanceCloseGuard_Impl() {}
205 ~SfxInstanceCloseGuard_Impl();
207 bool Init_Impl( const uno::Reference< util::XCloseable >& xCloseable );
210 bool SfxInstanceCloseGuard_Impl::Init_Impl( const uno::Reference< util::XCloseable >& xCloseable )
212 bool bResult = false;
214 // do not allow reinit after the successful init
215 if ( xCloseable.is() && !m_xCloseable.is() )
219 m_xPreventer = new SfxClosePreventer_Impl();
220 xCloseable->addCloseListener( m_xPreventer.get() );
221 m_xCloseable = xCloseable;
222 bResult = true;
224 catch( uno::Exception& )
226 OSL_FAIL( "Could not register close listener!" );
230 return bResult;
233 SfxInstanceCloseGuard_Impl::~SfxInstanceCloseGuard_Impl()
235 if ( !m_xCloseable.is() || !m_xPreventer.is() )
236 return;
240 m_xCloseable->removeCloseListener( m_xPreventer.get() );
242 catch( uno::Exception& )
248 if ( m_xPreventer.is() )
250 m_xPreventer->SetPreventClose( false );
252 if ( m_xPreventer->HasOwnership() )
253 m_xCloseable->close( true ); // TODO: do it asynchronously
256 catch( uno::Exception& )
262 void SfxObjectShell::PrintExec_Impl(SfxRequest &rReq)
264 SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
265 if ( pFrame )
267 rReq.SetSlot( SID_PRINTDOC );
268 pFrame->GetViewShell()->ExecuteSlot(rReq);
273 void SfxObjectShell::PrintState_Impl(SfxItemSet &rSet)
275 bool bPrinting = false;
276 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
277 if ( pFrame )
279 SfxPrinter *pPrinter = pFrame->GetViewShell()->GetPrinter();
280 bPrinting = pPrinter && pPrinter->IsPrinting();
282 rSet.Put( SfxBoolItem( SID_PRINTOUT, bPrinting ) );
285 bool SfxObjectShell::APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItemSet)
287 bool bOk = false;
290 if ( GetMedium() )
292 OUString aFilterName;
293 const SfxStringItem* pFilterNameItem = rItemSet.GetItem<SfxStringItem>(SID_FILTER_NAME, false);
294 if( pFilterNameItem )
296 aFilterName = pFilterNameItem->GetValue();
298 else
300 const SfxStringItem* pContentTypeItem = rItemSet.GetItem<SfxStringItem>(SID_CONTENTTYPE, false);
301 if ( pContentTypeItem )
303 std::shared_ptr<const SfxFilter> pFilter = SfxFilterMatcher( GetFactory().GetFactoryName() ).GetFilter4Mime( pContentTypeItem->GetValue(), SfxFilterFlags::EXPORT );
304 if ( pFilter )
305 aFilterName = pFilter->GetName();
309 // in case no filter defined use default one
310 if( aFilterName.isEmpty() )
312 std::shared_ptr<const SfxFilter> pFilt = SfxFilter::GetDefaultFilterFromFactory(GetFactory().GetFactoryName());
314 DBG_ASSERT( pFilt, "No default filter!\n" );
315 if( pFilt )
316 aFilterName = pFilt->GetFilterName();
318 rItemSet.Put(SfxStringItem(SID_FILTER_NAME, aFilterName));
323 SfxObjectShellRef xLock( this ); // ???
325 // use the title that is provided in the media descriptor
326 const SfxStringItem* pDocTitleItem = rItemSet.GetItem<SfxStringItem>(SID_DOCINFO_TITLE, false);
327 if ( pDocTitleItem )
328 getDocProperties()->setTitle( pDocTitleItem->GetValue() );
330 bOk = CommonSaveAs_Impl(INetURLObject(aFileName), aFilterName, rItemSet);
334 return bOk;
337 void SfxObjectShell::CheckOut( )
341 uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW );
342 xCmisDoc->checkOut( );
344 // Remove the info bar
345 SfxViewFrame* pViewFrame = GetFrame();
346 pViewFrame->RemoveInfoBar( "checkout" );
348 catch ( const uno::RuntimeException& e )
350 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(),
351 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
352 xBox->run();
356 void SfxObjectShell::CancelCheckOut( )
360 uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW );
361 xCmisDoc->cancelCheckOut( );
363 uno::Reference< util::XModifiable > xModifiable( GetModel( ), uno::UNO_QUERY );
364 if ( xModifiable.is( ) )
365 xModifiable->setModified( false );
367 catch ( const uno::RuntimeException& e )
369 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(),
370 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
371 xBox->run();
375 void SfxObjectShell::CheckIn( )
379 uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW );
380 // Pop up dialog to ask for comment and major
381 SfxCheckinDialog checkinDlg(GetFrame()->GetWindow().GetFrameWeld());
382 if (checkinDlg.run() == RET_OK)
384 xCmisDoc->checkIn(checkinDlg.IsMajor(), checkinDlg.GetComment());
385 uno::Reference< util::XModifiable > xModifiable( GetModel( ), uno::UNO_QUERY );
386 if ( xModifiable.is( ) )
387 xModifiable->setModified( false );
390 catch ( const uno::RuntimeException& e )
392 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(),
393 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
394 xBox->run();
398 uno::Sequence< document::CmisVersion > SfxObjectShell::GetCmisVersions( ) const
402 uno::Reference< document::XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY_THROW );
403 return xCmisDoc->getAllVersions( );
405 catch ( const uno::RuntimeException& e )
407 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(),
408 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
409 xBox->run();
411 return uno::Sequence< document::CmisVersion > ( );
414 void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
416 weld::Window* pDialogParent = rReq.GetFrameWeld();
417 if (!pDialogParent)
419 SfxViewFrame* pFrame = GetFrame();
420 if (!pFrame)
421 pFrame = SfxViewFrame::GetFirst(this);
422 if (pFrame)
423 pDialogParent = pFrame->GetWindow().GetFrameWeld();
426 sal_uInt16 nId = rReq.GetSlot();
428 if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId )
430 if ( QueryHiddenInformation( HiddenWarningFact::WhenSigning, nullptr ) == RET_YES )
431 ( SID_SIGNATURE == nId ) ? SignDocumentContent(pDialogParent) : SignScriptingContent(pDialogParent);
432 return;
435 if ( !GetMedium() && nId != SID_CLOSEDOC )
437 rReq.Ignore();
438 return;
441 // this guard is created here to have it destruction at the end of the method
442 SfxInstanceCloseGuard_Impl aModelGuard;
444 bool bIsPDFExport = false;
445 bool bIsAutoRedact = false;
446 std::vector<std::pair<RedactionTarget*, OUString>> aRedactionTargets;
447 switch(nId)
449 case SID_VERSION:
451 SfxViewFrame* pFrame = GetFrame();
452 if ( !pFrame )
453 pFrame = SfxViewFrame::GetFirst( this );
454 if ( !pFrame )
455 return;
457 if ( !IsOwnStorageFormat( *GetMedium() ) )
458 return;
460 SfxVersionDialog aDlg(pDialogParent, pFrame, IsSaveVersionOnClose());
461 aDlg.run();
462 SetSaveVersionOnClose(aDlg.IsSaveVersionOnClose());
463 rReq.Done();
464 return;
467 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
468 case SID_DOCINFO:
470 const SfxDocumentInfoItem* pDocInfItem = rReq.GetArg<SfxDocumentInfoItem>(SID_DOCINFO);
471 if ( pDocInfItem )
473 // parameter, e.g. from replayed macro
474 pDocInfItem->UpdateDocumentInfo(getDocProperties(), true);
475 SetUseUserData( pDocInfItem->IsUseUserData() );
476 SetUseThumbnailSave( pDocInfItem->IsUseThumbnailSave() );
478 else
480 // no argument containing DocInfo; check optional arguments
481 bool bReadOnly = IsReadOnly();
482 const SfxBoolItem* pROItem = rReq.GetArg<SfxBoolItem>(SID_DOC_READONLY);
483 if ( pROItem )
484 // override readonly attribute of document
485 // e.g. if a readonly document is saved elsewhere and user asks for editing DocInfo before
486 bReadOnly = pROItem->GetValue();
488 // URL for dialog
489 const OUString aURL( HasName() ? GetMedium()->GetName() : GetFactory().GetFactoryURL() );
491 Reference< XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY );
492 uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties();
494 SfxDocumentInfoItem aDocInfoItem( aURL, getDocProperties(), aCmisProperties,
495 IsUseUserData(), IsUseThumbnailSave() );
496 if ( !GetSlotState( SID_DOCTEMPLATE ) )
497 // templates not supported
498 aDocInfoItem.SetTemplate(false);
500 SfxItemSet aSet(GetPool(), svl::Items<SID_DOCINFO, SID_DOCINFO, SID_DOC_READONLY, SID_DOC_READONLY,
501 SID_EXPLORER_PROPS_START, SID_EXPLORER_PROPS_START, SID_BASEURL, SID_BASEURL>{} );
502 aSet.Put( aDocInfoItem );
503 aSet.Put( SfxBoolItem( SID_DOC_READONLY, bReadOnly ) );
504 aSet.Put( SfxStringItem( SID_EXPLORER_PROPS_START, GetTitle() ) );
505 aSet.Put( SfxStringItem( SID_BASEURL, GetMedium()->GetBaseURL() ) );
507 // creating dialog is done via virtual method; application will
508 // add its own statistics page
509 std::shared_ptr<SfxRequest> pReq = std::make_shared<SfxRequest>(rReq);
510 std::shared_ptr<SfxDocumentInfoDialog> xDlg(CreateDocumentInfoDialog(rReq.GetFrameWeld(), aSet));
511 SfxTabDialogController::runAsync(xDlg, [this, xDlg, xCmisDoc, pReq](sal_Int32 nResult)
513 if (RET_OK == nResult)
515 const SfxDocumentInfoItem* pDocInfoItem = SfxItemSet::GetItem<SfxDocumentInfoItem>(xDlg->GetOutputItemSet(), SID_DOCINFO, false);
516 if ( pDocInfoItem )
518 // user has done some changes to DocumentInfo
519 pDocInfoItem->UpdateDocumentInfo(getDocProperties());
520 const uno::Sequence< document::CmisProperty >& aNewCmisProperties =
521 pDocInfoItem->GetCmisProperties( );
522 if ( aNewCmisProperties.hasElements( ) )
523 xCmisDoc->updateCmisProperties( aNewCmisProperties );
524 SetUseUserData( pDocInfoItem->IsUseUserData() );
525 SetUseThumbnailSave( pDocInfoItem-> IsUseThumbnailSave() );
526 // add data from dialog for possible recording purpose
527 pReq->AppendItem( SfxDocumentInfoItem( GetTitle(),
528 getDocProperties(), aNewCmisProperties, IsUseUserData(), IsUseThumbnailSave() ) );
531 css::uno::Reference< css::uno::XInterface > xInterface;
532 const SfxUnoAnyItem* pUnoAny = pReq->GetArg<SfxUnoAnyItem>(FN_PARAM_2);
533 AsyncFunc* pAsyncFunc = pUnoAny && (pUnoAny->GetValue() >>= xInterface ) ?
534 comphelper::getUnoTunnelImplementation<AsyncFunc>(xInterface) : nullptr;
535 if (pAsyncFunc)
536 pAsyncFunc->Execute();
538 pReq->Done();
540 else
541 // nothing done; no recording
542 pReq->Ignore();
545 rReq.Ignore();
548 return;
551 case SID_AUTOREDACTDOC:
553 SfxAutoRedactDialog aDlg(pDialogParent);
554 sal_Int16 nResult = aDlg.run();
556 if (nResult != RET_OK || !aDlg.hasTargets() || !aDlg.isValidState())
558 //Do nothing
559 return;
562 // else continue with normal redaction
563 bIsAutoRedact = true;
564 aDlg.getTargets(aRedactionTargets);
566 [[fallthrough]];
569 case SID_REDACTDOC:
571 css::uno::Reference<css::frame::XModel> xModel = GetModel();
572 if(!xModel.is())
573 return;
575 uno::Reference< lang::XComponent > xSourceDoc( xModel );
577 DocumentToGraphicRenderer aRenderer(xSourceDoc, false);
579 // Get the page margins of the original doc
580 PageMargins aPageMargins = {-1, -1, -1, -1};
581 if (aRenderer.isWriter())
582 aPageMargins = SfxRedactionHelper::getPageMarginsForWriter(xModel);
583 else if (aRenderer.isCalc())
584 aPageMargins = SfxRedactionHelper::getPageMarginsForCalc(xModel);
586 sal_Int32 nPages = aRenderer.getPageCount();
587 std::vector< GDIMetaFile > aMetaFiles;
588 std::vector< ::Size > aPageSizes;
590 // Convert the pages of the document to gdimetafiles
591 SfxRedactionHelper::getPageMetaFilesFromDoc(aMetaFiles, aPageSizes, nPages, aRenderer);
593 // Create an empty Draw component.
594 uno::Reference<frame::XDesktop2> xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext());
595 uno::Reference<lang::XComponent> xComponent = xDesktop->loadComponentFromURL("private:factory/sdraw", "_default", 0, {});
597 // Add the doc pages to the new draw document
598 SfxRedactionHelper::addPagesToDraw(xComponent, nPages, aMetaFiles, aPageSizes, aPageMargins, aRedactionTargets, bIsAutoRedact);
600 // Show the Redaction toolbar
601 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
602 if (!pViewFrame)
603 return;
604 SfxRedactionHelper::showRedactionToolbar(pViewFrame);
606 return;
609 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
610 case SID_DIRECTEXPORTDOCASPDF:
612 uno::Reference< lang::XComponent > xComponent( GetCurrentComponent(), uno::UNO_QUERY );
613 if (!xComponent.is())
614 return;
616 uno::Reference< lang::XServiceInfo > xServiceInfo( xComponent, uno::UNO_QUERY);
618 // Redaction finalization takes place in Draw
619 if ( xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument")
620 && SfxRedactionHelper::isRedactMode(rReq) )
622 OUString sRedactionStyle(SfxRedactionHelper::getStringParam(rReq, SID_REDACTION_STYLE));
624 // Access the draw pages
625 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
626 uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
628 sal_Int32 nPageCount = xDrawPages->getCount();
629 for (sal_Int32 nPageNum = 0; nPageNum < nPageCount; ++nPageNum)
631 // Get the page
632 uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( nPageNum ), uno::UNO_QUERY );
634 if (!xPage.is())
635 continue;
637 // Go through all shapes
638 sal_Int32 nShapeCount = xPage->getCount();
639 for (sal_Int32 nShapeNum = 0; nShapeNum < nShapeCount; ++nShapeNum)
641 uno::Reference< drawing::XShape > xCurrShape(xPage->getByIndex(nShapeNum), uno::UNO_QUERY);
642 if (!xCurrShape.is())
643 continue;
645 uno::Reference< beans::XPropertySet > xPropSet(xCurrShape, uno::UNO_QUERY);
646 if (!xPropSet.is())
647 continue;
649 uno::Reference< beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
650 if (!xInfo.is())
651 continue;
653 OUString sShapeName;
654 if (xInfo->hasPropertyByName("Name"))
656 uno::Any aAnyShapeName = xPropSet->getPropertyValue("Name");
657 aAnyShapeName >>= sShapeName;
659 else
660 continue;
662 // Rectangle redaction
663 if (sShapeName == "RectangleRedactionShape"
664 && xInfo->hasPropertyByName("FillTransparence") && xInfo->hasPropertyByName("FillColor"))
666 xPropSet->setPropertyValue("FillTransparence", css::uno::makeAny(static_cast<sal_Int16>(0)));
667 if (sRedactionStyle == "White")
669 xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_WHITE));
670 xPropSet->setPropertyValue("LineStyle", css::uno::makeAny(css::drawing::LineStyle::LineStyle_SOLID));
671 xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_BLACK));
673 else
675 xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_BLACK));
676 xPropSet->setPropertyValue("LineStyle", css::uno::makeAny(css::drawing::LineStyle::LineStyle_NONE));
679 // Freeform redaction
680 else if (sShapeName == "FreeformRedactionShape"
681 && xInfo->hasPropertyByName("LineTransparence") && xInfo->hasPropertyByName("LineColor"))
683 xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast<sal_Int16>(0)));
685 if (sRedactionStyle == "White")
687 xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_WHITE));
689 else
691 xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_BLACK));
698 [[fallthrough]];
699 case SID_EXPORTDOCASPDF:
700 bIsPDFExport = true;
701 [[fallthrough]];
702 case SID_EXPORTDOCASEPUB:
703 case SID_DIRECTEXPORTDOCASEPUB:
704 case SID_EXPORTDOC:
705 case SID_SAVEASDOC:
706 case SID_SAVEASREMOTE:
707 case SID_SAVEDOC:
709 // derived class may decide to abort this
710 if( !QuerySlotExecutable( nId ) )
712 rReq.SetReturnValue( SfxBoolItem( 0, false ) );
713 return;
716 //!! detailed analysis of an error code
717 SfxObjectShellRef xLock( this );
719 // the model can not be closed till the end of this method
720 // if somebody tries to close it during this time the model will be closed
721 // at the end of the method
722 aModelGuard.Init_Impl( uno::Reference< util::XCloseable >( GetModel(), uno::UNO_QUERY ) );
724 ErrCode nErrorCode = ERRCODE_NONE;
726 // by default versions should be preserved always except in case of an explicit
727 // SaveAs via GUI, so the flag must be set accordingly
728 pImpl->bPreserveVersions = (nId == SID_SAVEDOC);
731 SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, GetTitle() ); // ???
733 if ( nId == SID_SAVEASDOC || nId == SID_SAVEASREMOTE )
735 // in case of plugin mode the SaveAs operation means SaveTo
736 const SfxBoolItem* pViewOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(GetMedium()->GetItemSet(), SID_VIEWONLY, false);
737 if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
738 rReq.AppendItem( SfxBoolItem( SID_SAVETO, true ) );
741 // TODO/LATER: do the following GUI related actions in standalone method
743 // Introduce a status indicator for GUI operation
744 const SfxUnoAnyItem* pStatusIndicatorItem = rReq.GetArg<SfxUnoAnyItem>(SID_PROGRESS_STATUSBAR_CONTROL);
745 if ( !pStatusIndicatorItem )
747 // get statusindicator
748 uno::Reference< task::XStatusIndicator > xStatusIndicator;
749 uno::Reference < frame::XController > xCtrl( GetModel()->getCurrentController() );
750 if ( xCtrl.is() )
752 uno::Reference< task::XStatusIndicatorFactory > xStatFactory( xCtrl->getFrame(), uno::UNO_QUERY );
753 if( xStatFactory.is() )
754 xStatusIndicator = xStatFactory->createStatusIndicator();
757 OSL_ENSURE( xStatusIndicator.is(), "Can not retrieve default status indicator!" );
759 if ( xStatusIndicator.is() )
761 SfxUnoAnyItem aStatIndItem( SID_PROGRESS_STATUSBAR_CONTROL, uno::makeAny( xStatusIndicator ) );
763 if ( nId == SID_SAVEDOC )
765 // in case of saving it is not possible to transport the parameters from here
766 // but it is not clear here whether the saving will be done or saveAs operation
767 GetMedium()->GetItemSet()->Put( aStatIndItem );
770 rReq.AppendItem( aStatIndItem );
773 else if ( nId == SID_SAVEDOC )
775 // in case of saving it is not possible to transport the parameters from here
776 // but it is not clear here whether the saving will be done or saveAs operation
777 GetMedium()->GetItemSet()->Put( *pStatusIndicatorItem );
780 // Introduce an interaction handler for GUI operation
781 const SfxUnoAnyItem* pInteractionHandlerItem = rReq.GetArg<SfxUnoAnyItem>(SID_INTERACTIONHANDLER);
782 if ( !pInteractionHandlerItem )
784 uno::Reference<css::awt::XWindow> xParentWindow;
785 uno::Reference<frame::XController> xCtrl(GetModel()->getCurrentController());
786 if (xCtrl.is())
787 xParentWindow = xCtrl->getFrame()->getContainerWindow();
789 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
791 uno::Reference< task::XInteractionHandler2 > xInteract(
792 task::InteractionHandler::createWithParent(xContext, xParentWindow) );
794 SfxUnoAnyItem aInteractionItem( SID_INTERACTIONHANDLER, uno::makeAny( xInteract ) );
795 if ( nId == SID_SAVEDOC )
797 // in case of saving it is not possible to transport the parameters from here
798 // but it is not clear here whether the saving will be done or saveAs operation
799 GetMedium()->GetItemSet()->Put( aInteractionItem );
802 rReq.AppendItem( aInteractionItem );
804 else if ( nId == SID_SAVEDOC )
806 // in case of saving it is not possible to transport the parameters from here
807 // but it is not clear here whether the saving will be done or saveAs operation
808 GetMedium()->GetItemSet()->Put( *pInteractionHandlerItem );
812 bool bPreselectPassword = false;
813 const SfxUnoAnyItem* pOldEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
814 const SfxStringItem* pOldPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
815 if ( pOldEncryptionDataItem || pOldPasswordItem )
816 bPreselectPassword = true;
818 uno::Sequence< beans::PropertyValue > aDispatchArgs;
819 if ( rReq.GetArgs() )
820 TransformItems( nId,
821 *rReq.GetArgs(),
822 aDispatchArgs );
824 bool bForceSaveAs = nId == SID_SAVEDOC && IsReadOnlyMedium();
825 const SfxSlot* pSlot = GetModule()->GetSlotPool()->GetSlot( bForceSaveAs ? SID_SAVEASDOC : nId );
826 if ( !pSlot )
827 throw uno::Exception("no slot", nullptr);
829 SfxStoringHelper aHelper;
831 if ( QueryHiddenInformation( bIsPDFExport ? HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving, nullptr ) != RET_YES )
833 // the user has decided not to store the document
834 throw task::ErrorCodeIOException(
835 "SfxObjectShell::ExecFile_Impl: ERRCODE_IO_ABORT",
836 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
839 aHelper.GUIStoreModel( GetModel(),
840 OUString::createFromAscii( pSlot->GetUnoName() ),
841 aDispatchArgs,
842 bPreselectPassword,
843 GetDocumentSignatureState() );
846 // merge aDispatchArgs to the request
847 SfxAllItemSet aResultParams( GetPool() );
848 TransformParameters( nId,
849 aDispatchArgs,
850 aResultParams );
851 rReq.SetArgs( aResultParams );
853 // the StoreAsURL/StoreToURL method have called this method with false
854 // so it has to be restored to true here since it is a call from GUI
855 GetMedium()->SetUpdatePickList( true );
857 // TODO: in future it must be done in following way
858 // if document is opened from GUI, it immediately appears in the picklist
859 // if the document is a new one then it appears in the picklist immediately
860 // after SaveAs operation triggered from GUI
862 catch( const task::ErrorCodeIOException& aErrorEx )
864 TOOLS_WARN_EXCEPTION( "sfx.doc", "Fatal IO error during save");
865 nErrorCode = ErrCode(aErrorEx.ErrCode);
867 catch( Exception& )
869 nErrorCode = ERRCODE_IO_GENERAL;
872 // by default versions should be preserved always except in case of an explicit
873 // SaveAs via GUI, so the flag must be reset to guarantee this
874 pImpl->bPreserveVersions = true;
875 ErrCode lErr=GetErrorCode();
877 if ( !lErr && nErrorCode )
878 lErr = nErrorCode;
880 if ( lErr && nErrorCode == ERRCODE_NONE )
882 const SfxBoolItem* pWarnItem = rReq.GetArg<SfxBoolItem>(SID_FAIL_ON_WARNING);
883 if ( pWarnItem && pWarnItem->GetValue() )
884 nErrorCode = lErr;
887 // may be nErrorCode should be shown in future
888 if ( lErr != ERRCODE_IO_ABORT )
890 SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC,GetTitle());
891 ErrorHandler::HandleError(lErr, pDialogParent);
894 if (nId == SID_DIRECTEXPORTDOCASPDF &&
895 SfxRedactionHelper::isRedactMode(rReq))
897 // Return the finalized redaction shapes back to normal (gray & transparent)
898 uno::Reference< lang::XComponent > xComponent( GetCurrentComponent(), uno::UNO_QUERY );
899 if (!xComponent.is())
900 return;
902 uno::Reference< lang::XServiceInfo > xServiceInfo( xComponent, uno::UNO_QUERY);
904 // Redaction finalization takes place in Draw
905 if ( xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") )
907 // Access the draw pages
908 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
909 uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
911 sal_Int32 nPageCount = xDrawPages->getCount();
912 for (sal_Int32 nPageNum = 0; nPageNum < nPageCount; ++nPageNum)
914 // Get the page
915 uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( nPageNum ), uno::UNO_QUERY );
917 if (!xPage.is())
918 continue;
920 // Go through all shapes
921 sal_Int32 nShapeCount = xPage->getCount();
922 for (sal_Int32 nShapeNum = 0; nShapeNum < nShapeCount; ++nShapeNum)
924 uno::Reference< drawing::XShape > xCurrShape(xPage->getByIndex(nShapeNum), uno::UNO_QUERY);
925 if (!xCurrShape.is())
926 continue;
928 uno::Reference< beans::XPropertySet > xPropSet(xCurrShape, uno::UNO_QUERY);
929 if (!xPropSet.is())
930 continue;
932 uno::Reference< beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
933 if (!xInfo.is())
934 continue;
936 // Not a shape we converted?
937 if (!xInfo->hasPropertyByName("Name"))
938 continue;
940 OUString sShapeName;
941 if (xInfo->hasPropertyByName("Name"))
943 uno::Any aAnyShapeName = xPropSet->getPropertyValue("Name");
944 aAnyShapeName >>= sShapeName;
946 else
947 continue;
949 // Rectangle redaction
950 if (sShapeName == "RectangleRedactionShape"
951 && xInfo->hasPropertyByName("FillTransparence") && xInfo->hasPropertyByName("FillColor"))
953 xPropSet->setPropertyValue("FillTransparence", css::uno::makeAny(static_cast<sal_Int16>(50)));
954 xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_GRAY7));
955 xPropSet->setPropertyValue("LineStyle", css::uno::makeAny(css::drawing::LineStyle::LineStyle_NONE));
958 // Freeform redaction
959 else if (sShapeName == "FreeformRedactionShape")
961 xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast<sal_Int16>(50)));
962 xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_GRAY7));
971 if ( nId == SID_EXPORTDOCASPDF )
973 // This function is used by the SendMail function that needs information if an export
974 // file was written or not. This could be due to cancellation of the export
975 // or due to an error. So IO abort must be handled like an error!
976 nErrorCode = ( lErr != ERRCODE_IO_ABORT ) && ( nErrorCode == ERRCODE_NONE ) ? nErrorCode : lErr;
979 if ( ( nId == SID_SAVEASDOC || nId == SID_SAVEASREMOTE ) && nErrorCode == ERRCODE_NONE )
981 const SfxBoolItem* saveTo = rReq.GetArg<SfxBoolItem>(SID_SAVETO);
982 if (saveTo == nullptr || !saveTo->GetValue())
984 SfxViewFrame *pFrame = GetFrame();
985 if (pFrame)
986 pFrame->RemoveInfoBar("readonly");
987 SetReadOnlyUI(false);
991 rReq.SetReturnValue( SfxBoolItem(0, nErrorCode == ERRCODE_NONE ) );
993 ResetError();
995 Invalidate();
996 break;
999 case SID_SAVEACOPY:
1001 SfxAllItemSet aArgs( GetPool() );
1002 aArgs.Put( SfxBoolItem( SID_SAVEACOPYITEM, true ) );
1003 SfxRequest aSaveACopyReq( SID_EXPORTDOC, SfxCallMode::API, aArgs );
1004 ExecFile_Impl( aSaveACopyReq );
1005 if ( !aSaveACopyReq.IsDone() )
1007 rReq.Ignore();
1008 return;
1010 break;
1013 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1015 case SID_CLOSEDOC:
1017 // Evaluate Parameter
1018 const SfxBoolItem* pSaveItem = rReq.GetArg<SfxBoolItem>(SID_CLOSEDOC_SAVE);
1019 const SfxStringItem* pNameItem = rReq.GetArg<SfxStringItem>(SID_CLOSEDOC_FILENAME);
1020 if ( pSaveItem )
1022 if ( pSaveItem->GetValue() )
1024 if ( !pNameItem )
1026 #if HAVE_FEATURE_SCRIPTING
1027 SbxBase::SetError( ERRCODE_BASIC_WRONG_ARGS );
1028 #endif
1029 rReq.Ignore();
1030 return;
1032 SfxAllItemSet aArgs( GetPool() );
1033 SfxStringItem aTmpItem( SID_FILE_NAME, pNameItem->GetValue() );
1034 aArgs.Put( aTmpItem, aTmpItem.Which() );
1035 SfxRequest aSaveAsReq( SID_SAVEASDOC, SfxCallMode::API, aArgs );
1036 ExecFile_Impl( aSaveAsReq );
1037 if ( !aSaveAsReq.IsDone() )
1039 rReq.Ignore();
1040 return;
1043 else
1044 SetModified(false);
1047 // Cancelled by the user?
1048 if (!PrepareClose())
1050 rReq.SetReturnValue( SfxBoolItem(0, false) );
1051 rReq.Done();
1052 return;
1055 SetModified( false );
1056 ErrCode lErr = GetErrorCode();
1057 ErrorHandler::HandleError(lErr, pDialogParent);
1059 rReq.SetReturnValue( SfxBoolItem(0, true) );
1060 rReq.Done();
1061 rReq.ReleaseArgs(); // because the pool is destroyed in Close
1062 DoClose();
1063 return;
1066 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1067 case SID_DOCTEMPLATE:
1069 // save as document templates
1070 SfxSaveAsTemplateDialog aDlg(pDialogParent, GetModel());
1071 (void)aDlg.run();
1072 break;
1075 case SID_CHECKOUT:
1077 CheckOut( );
1078 break;
1080 case SID_CANCELCHECKOUT:
1082 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
1083 VclMessageType::Question, VclButtonsType::YesNo, SfxResId(STR_QUERY_CANCELCHECKOUT)));
1084 if (xBox->run() == RET_YES)
1086 CancelCheckOut( );
1088 // Reload the document as we may still have local changes
1089 SfxViewFrame *pFrame = GetFrame();
1090 if ( pFrame )
1091 pFrame->GetDispatcher()->Execute(SID_RELOAD);
1093 break;
1095 case SID_CHECKIN:
1097 CheckIn( );
1098 break;
1102 // Prevent entry in the Pick-lists
1103 if ( rReq.IsAPI() )
1104 GetMedium()->SetUpdatePickList( false );
1106 // Ignore()-branches have already returned
1107 rReq.Done();
1111 void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
1113 SfxWhichIter aIter( rSet );
1115 for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
1117 switch ( nWhich )
1119 case SID_DOCTEMPLATE :
1121 if ( !GetFactory().GetTemplateFilter() )
1122 rSet.DisableItem( nWhich );
1123 break;
1126 case SID_CHECKOUT:
1128 bool bShow = false;
1129 Reference< XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY );
1130 const uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties();
1132 if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) )
1134 // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut
1135 bool bIsGoogleFile = false;
1136 bool bCheckedOut = false;
1137 for ( const auto& rCmisProperty : aCmisProperties )
1139 if ( rCmisProperty.Id == "cmis:isVersionSeriesCheckedOut" )
1141 uno::Sequence< sal_Bool > bTmp;
1142 rCmisProperty.Value >>= bTmp;
1143 bCheckedOut = bTmp[0];
1145 // using title to know if it's a Google Drive file
1146 // maybe there's a safer way.
1147 if ( rCmisProperty.Name == "title" )
1148 bIsGoogleFile = true;
1150 bShow = !bCheckedOut && !bIsGoogleFile;
1153 if ( !bShow )
1155 rSet.DisableItem( nWhich );
1156 rSet.Put( SfxVisibilityItem( nWhich, false ) );
1159 break;
1161 case SID_CANCELCHECKOUT:
1162 case SID_CHECKIN:
1164 bool bShow = false;
1165 Reference< XCmisDocument > xCmisDoc( GetModel(), uno::UNO_QUERY );
1166 uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties( );
1168 if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) )
1170 // Loop over the CMIS Properties to find cmis:isVersionSeriesCheckedOut
1171 bool bCheckedOut = false;
1172 auto pProp = std::find_if(aCmisProperties.begin(), aCmisProperties.end(),
1173 [](const document::CmisProperty& rProp) { return rProp.Id == "cmis:isVersionSeriesCheckedOut"; });
1174 if (pProp != aCmisProperties.end())
1176 uno::Sequence< sal_Bool > bTmp;
1177 pProp->Value >>= bTmp;
1178 bCheckedOut = bTmp[0];
1180 bShow = bCheckedOut;
1183 if ( !bShow )
1185 rSet.DisableItem( nWhich );
1186 rSet.Put( SfxVisibilityItem( nWhich, false ) );
1189 break;
1191 case SID_VERSION:
1193 SfxObjectShell *pDoc = this;
1194 SfxViewFrame* pFrame = GetFrame();
1195 if ( !pFrame )
1196 pFrame = SfxViewFrame::GetFirst( this );
1198 if ( !pFrame || !pDoc->HasName() ||
1199 !IsOwnStorageFormat( *pDoc->GetMedium() ) )
1200 rSet.DisableItem( nWhich );
1201 break;
1203 case SID_SAVEDOC:
1205 if ( !IsReadOnly() )
1206 rSet.Put(SfxStringItem(
1207 nWhich, SfxResId(STR_SAVEDOC)));
1208 else
1209 rSet.DisableItem(nWhich);
1211 break;
1213 case SID_DOCINFO:
1214 break;
1216 case SID_CLOSEDOC:
1218 rSet.Put(SfxStringItem(nWhich, SfxResId(STR_CLOSEDOC)));
1219 break;
1222 case SID_SAVEASDOC:
1224 if( !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) )
1226 rSet.DisableItem( nWhich );
1227 break;
1229 if ( /*!pCombinedFilters ||*/ !GetMedium() )
1230 rSet.DisableItem( nWhich );
1231 else
1232 rSet.Put( SfxStringItem( nWhich, SfxResId(STR_SAVEASDOC) ) );
1233 break;
1236 case SID_SAVEACOPY:
1238 if( !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) )
1240 rSet.DisableItem( nWhich );
1241 break;
1243 if ( /*!pCombinedFilters ||*/ !GetMedium() )
1244 rSet.DisableItem( nWhich );
1245 else
1246 rSet.Put( SfxStringItem( nWhich, SfxResId(STR_SAVEACOPY) ) );
1247 break;
1250 case SID_EXPORTDOCASPDF:
1251 case SID_DIRECTEXPORTDOCASPDF:
1252 case SID_EXPORTDOCASEPUB:
1253 case SID_DIRECTEXPORTDOCASEPUB:
1254 case SID_REDACTDOC:
1255 case SID_AUTOREDACTDOC:
1257 break;
1260 case SID_DOC_MODIFIED:
1262 rSet.Put( SfxBoolItem( SID_DOC_MODIFIED, IsModified() ) );
1263 break;
1266 case SID_MODIFIED:
1268 rSet.Put( SfxBoolItem( SID_MODIFIED, IsModified() ) );
1269 break;
1272 case SID_DOCINFO_TITLE:
1274 rSet.Put( SfxStringItem(
1275 SID_DOCINFO_TITLE, getDocProperties()->getTitle() ) );
1276 break;
1278 case SID_FILE_NAME:
1280 if( GetMedium() && HasName() )
1281 rSet.Put( SfxStringItem(
1282 SID_FILE_NAME, GetMedium()->GetName() ) );
1283 break;
1285 case SID_SIGNATURE:
1287 SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
1288 if ( pFrame )
1290 SignatureState eState = GetDocumentSignatureState();
1291 InfoBarType aInfoBarType(InfoBarType::Info);
1292 OUString sMessage("");
1294 switch (eState)
1296 case SignatureState::BROKEN:
1297 sMessage = SfxResId(STR_SIGNATURE_BROKEN);
1298 aInfoBarType = InfoBarType::Danger;
1299 break;
1300 case SignatureState::INVALID:
1301 sMessage = SfxResId(STR_SIGNATURE_INVALID);
1302 // Warning only, I've tried Danger and it looked too scary
1303 aInfoBarType = InfoBarType::Warning;
1304 break;
1305 case SignatureState::NOTVALIDATED:
1306 sMessage = SfxResId(STR_SIGNATURE_NOTVALIDATED);
1307 aInfoBarType = InfoBarType::Warning;
1308 break;
1309 case SignatureState::PARTIAL_OK:
1310 sMessage = SfxResId(STR_SIGNATURE_PARTIAL_OK);
1311 aInfoBarType = InfoBarType::Warning;
1312 break;
1313 case SignatureState::OK:
1314 sMessage = SfxResId(STR_SIGNATURE_OK);
1315 aInfoBarType = InfoBarType::Info;
1316 break;
1317 case SignatureState::NOTVALIDATED_PARTIAL_OK:
1318 sMessage = SfxResId(STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK);
1319 aInfoBarType = InfoBarType::Warning;
1320 break;
1321 //FIXME SignatureState::Unknown, own message?
1322 default:
1323 break;
1326 // new info bar
1327 if ( !pFrame->HasInfoBarWithID("signature") )
1329 if ( !sMessage.isEmpty() )
1331 auto pInfoBar = pFrame->AppendInfoBar("signature", sMessage, aInfoBarType);
1332 if (pInfoBar == nullptr || pInfoBar->IsDisposed())
1333 return;
1334 VclPtrInstance<PushButton> xBtn(&(pFrame->GetWindow()));
1335 xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW));
1336 xBtn->SetSizePixel(xBtn->GetOptimalSize());
1337 xBtn->SetClickHdl(LINK(this, SfxObjectShell, SignDocumentHandler));
1338 pInfoBar->addButton(xBtn);
1341 else // info bar exists already
1343 if ( eState == SignatureState::NOSIGNATURES )
1344 pFrame->RemoveInfoBar("signature");
1345 else
1346 pFrame->UpdateInfoBar("signature", sMessage, aInfoBarType);
1350 rSet.Put( SfxUInt16Item( SID_SIGNATURE, static_cast<sal_uInt16>(GetDocumentSignatureState()) ) );
1351 break;
1353 case SID_MACRO_SIGNATURE:
1355 // the slot makes sense only if there is a macro in the document
1356 if ( pImpl->documentStorageHasMacros() || pImpl->aMacroMode.hasMacroLibrary() )
1357 rSet.Put( SfxUInt16Item( SID_MACRO_SIGNATURE, static_cast<sal_uInt16>(GetScriptingSignatureState()) ) );
1358 else
1359 rSet.DisableItem( nWhich );
1360 break;
1362 case SID_DOC_REPAIR:
1364 SfxUndoManager* pIUndoMgr = GetUndoManager();
1365 if (pIUndoMgr)
1366 rSet.Put( SfxBoolItem(nWhich, pIUndoMgr->IsEmptyActions()) );
1367 else
1368 rSet.DisableItem( nWhich );
1369 break;
1375 IMPL_LINK_NOARG(SfxObjectShell, SignDocumentHandler, Button*, void)
1377 GetDispatcher()->Execute(SID_SIGNATURE);
1380 void SfxObjectShell::ExecProps_Impl(SfxRequest &rReq)
1382 switch ( rReq.GetSlot() )
1384 case SID_MODIFIED:
1386 SetModified( rReq.GetArgs()->Get(SID_MODIFIED).GetValue() );
1387 rReq.Done();
1388 break;
1391 case SID_DOCTITLE:
1392 SetTitle( rReq.GetArgs()->Get(SID_DOCTITLE).GetValue() );
1393 rReq.Done();
1394 break;
1396 case SID_DOCINFO_AUTHOR :
1397 getDocProperties()->setAuthor( static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue() );
1398 break;
1400 case SID_DOCINFO_COMMENTS :
1401 getDocProperties()->setDescription( static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue() );
1402 break;
1404 case SID_DOCINFO_KEYWORDS :
1406 const OUString aStr = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
1407 getDocProperties()->setKeywords(
1408 ::comphelper::string::convertCommaSeparated(aStr) );
1409 break;
1415 void SfxObjectShell::StateProps_Impl(SfxItemSet &rSet)
1417 SfxWhichIter aIter(rSet);
1418 for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
1420 switch ( nSID )
1422 case SID_DOCINFO_AUTHOR :
1424 rSet.Put( SfxStringItem( nSID,
1425 getDocProperties()->getAuthor() ) );
1426 break;
1429 case SID_DOCINFO_COMMENTS :
1431 rSet.Put( SfxStringItem( nSID,
1432 getDocProperties()->getDescription()) );
1433 break;
1436 case SID_DOCINFO_KEYWORDS :
1438 rSet.Put( SfxStringItem( nSID, ::comphelper::string::
1439 convertCommaSeparated(getDocProperties()->getKeywords())) );
1440 break;
1443 case SID_DOCPATH:
1445 OSL_FAIL( "Not supported anymore!" );
1446 break;
1449 case SID_DOCFULLNAME:
1451 rSet.Put( SfxStringItem( SID_DOCFULLNAME, GetTitle(SFX_TITLE_FULLNAME) ) );
1452 break;
1455 case SID_DOCTITLE:
1457 rSet.Put( SfxStringItem( SID_DOCTITLE, GetTitle() ) );
1458 break;
1461 case SID_DOC_READONLY:
1463 rSet.Put( SfxBoolItem( SID_DOC_READONLY, IsReadOnly() ) );
1464 break;
1467 case SID_DOC_SAVED:
1469 rSet.Put( SfxBoolItem( SID_DOC_SAVED, !IsModified() ) );
1470 break;
1473 case SID_CLOSING:
1475 rSet.Put( SfxBoolItem( SID_CLOSING, false ) );
1476 break;
1479 case SID_DOC_LOADING:
1480 rSet.Put( SfxBoolItem( nSID, ! ( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) ) );
1481 break;
1483 case SID_IMG_LOADING:
1484 rSet.Put( SfxBoolItem( nSID, ! ( pImpl->nLoadedFlags & SfxLoadedFlags::IMAGES ) ) );
1485 break;
1491 void SfxObjectShell::ExecView_Impl(SfxRequest &rReq)
1493 switch ( rReq.GetSlot() )
1495 case SID_ACTIVATE:
1497 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this );
1498 if ( pFrame )
1499 pFrame->GetFrame().Appear();
1500 rReq.SetReturnValue( SfxObjectItem( 0, pFrame ) );
1501 rReq.Done();
1502 break;
1508 void SfxObjectShell::StateView_Impl(SfxItemSet& /*rSet*/)
1512 SignatureState SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< security::DocumentSignatureInformation >& aInfos )
1514 bool bCertValid = true;
1515 SignatureState nResult = SignatureState::NOSIGNATURES;
1516 bool bCompleteSignature = true;
1517 if( aInfos.hasElements() )
1519 nResult = SignatureState::OK;
1520 for ( const auto& rInfo : aInfos )
1522 if ( bCertValid )
1524 sal_Int32 nCertStat = rInfo.CertificateStatus;
1525 bCertValid = nCertStat == security::CertificateValidity::VALID;
1528 if ( !rInfo.SignatureIsValid )
1530 nResult = SignatureState::BROKEN;
1531 break; // we know enough
1533 bCompleteSignature &= !rInfo.PartialDocumentSignature;
1537 if (nResult == SignatureState::OK && !bCertValid && !bCompleteSignature)
1538 nResult = SignatureState::NOTVALIDATED_PARTIAL_OK;
1539 else if (nResult == SignatureState::OK && !bCertValid)
1540 nResult = SignatureState::NOTVALIDATED;
1541 else if ( nResult == SignatureState::OK && bCertValid && !bCompleteSignature)
1542 nResult = SignatureState::PARTIAL_OK;
1544 // this code must not check whether the document is modified
1545 // it should only check the provided info
1547 return nResult;
1550 /// Does this ZIP storage have a signature stream?
1551 static bool HasSignatureStream(const uno::Reference<embed::XStorage>& xStorage)
1553 if (!xStorage.is())
1554 return false;
1556 if (xStorage->hasByName("META-INF"))
1558 // ODF case.
1561 uno::Reference<embed::XStorage> xMetaInf
1562 = xStorage->openStorageElement("META-INF", embed::ElementModes::READ);
1563 if (xMetaInf.is())
1565 return xMetaInf->hasByName("documentsignatures.xml")
1566 || xMetaInf->hasByName("macrosignatures.xml")
1567 || xMetaInf->hasByName("packagesignatures.xml");
1570 catch (const css::io::IOException& rException)
1572 SAL_WARN("sfx.doc", "HasSignatureStream: failed to open META-INF: " << rException.Message);
1576 // OOXML case.
1577 return xStorage->hasByName("_xmlsignatures");
1580 uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::GetDocumentSignatureInformation( bool bScriptingContent, const uno::Reference< security::XDocumentDigitalSignatures >& xSigner )
1582 uno::Sequence< security::DocumentSignatureInformation > aResult;
1583 uno::Reference< security::XDocumentDigitalSignatures > xLocSigner = xSigner;
1585 bool bSupportsSigning = GetMedium() && GetMedium()->GetFilter() && GetMedium()->GetFilter()->GetSupportsSigning();
1586 if (GetMedium() && !GetMedium()->GetName().isEmpty() && ((IsOwnStorageFormat(*GetMedium()) && GetMedium()->GetStorage().is()) || bSupportsSigning))
1590 if ( !xLocSigner.is() )
1592 OUString aVersion;
1595 uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW );
1596 xPropSet->getPropertyValue("Version") >>= aVersion;
1598 catch( uno::Exception& )
1602 xLocSigner.set( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion) );
1606 if ( bScriptingContent )
1607 aResult = xLocSigner->verifyScriptingContentSignatures( GetMedium()->GetZipStorageToSign_Impl(),
1608 uno::Reference< io::XInputStream >() );
1609 else
1611 if (GetMedium()->GetStorage().is())
1613 // Something ZIP-based.
1614 // Only call into xmlsecurity if we see a signature stream,
1615 // as libxmlsec init is expensive.
1616 if (HasSignatureStream(GetMedium()->GetZipStorageToSign_Impl()))
1617 aResult = xLocSigner->verifyDocumentContentSignatures( GetMedium()->GetZipStorageToSign_Impl(),
1618 uno::Reference< io::XInputStream >() );
1620 else
1622 // Not ZIP-based, e.g. PDF.
1623 std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(GetMedium()->GetName(), StreamMode::READ));
1624 uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
1625 uno::Reference<io::XInputStream> xInputStream(xStream, uno::UNO_QUERY);
1626 aResult = xLocSigner->verifyDocumentContentSignatures(uno::Reference<embed::XStorage>(), xInputStream);
1630 catch( css::uno::Exception& )
1635 return aResult;
1638 SignatureState SfxObjectShell::ImplGetSignatureState( bool bScriptingContent )
1640 SignatureState* pState = bScriptingContent ? &pImpl->nScriptingSignatureState : &pImpl->nDocumentSignatureState;
1642 if ( *pState == SignatureState::UNKNOWN )
1644 *pState = SignatureState::NOSIGNATURES;
1646 uno::Sequence< security::DocumentSignatureInformation > aInfos = GetDocumentSignatureInformation( bScriptingContent );
1647 *pState = ImplCheckSignaturesInformation( aInfos );
1650 if ( *pState == SignatureState::OK || *pState == SignatureState::NOTVALIDATED
1651 || *pState == SignatureState::PARTIAL_OK)
1653 if ( IsModified() )
1654 *pState = SignatureState::INVALID;
1657 return *pState;
1660 bool SfxObjectShell::PrepareForSigning(weld::Window* pDialogParent)
1662 // check whether the document is signed
1663 ImplGetSignatureState(); // document signature
1664 if (GetMedium() && GetMedium()->GetFilter() && GetMedium()->GetFilter()->IsOwnFormat())
1665 ImplGetSignatureState( true ); // script signature
1666 bool bHasSign = ( pImpl->nScriptingSignatureState != SignatureState::NOSIGNATURES || pImpl->nDocumentSignatureState != SignatureState::NOSIGNATURES );
1668 // the target ODF version on saving (only valid when signing ODF of course)
1669 SvtSaveOptions aSaveOpt;
1670 SvtSaveOptions::ODFDefaultVersion nVersion = aSaveOpt.GetODFDefaultVersion();
1672 // the document is not new and is not modified
1673 OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage()));
1675 if ( IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty()
1676 || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion != ODFVER_012_TEXT && !bHasSign) )
1678 // the document might need saving ( new, modified or in ODF1.1 format without signature )
1680 if ( nVersion >= SvtSaveOptions::ODFVER_012 )
1682 OUString sQuestion(bHasSign ? SfxResId(STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN) : SfxResId(RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN));
1683 std::unique_ptr<weld::MessageDialog> xQuestion(Application::CreateMessageDialog(pDialogParent,
1684 VclMessageType::Question, VclButtonsType::YesNo, sQuestion));
1687 if (xQuestion->run() == RET_YES)
1689 sal_uInt16 nId = SID_SAVEDOC;
1690 if ( !GetMedium() || GetMedium()->GetName().isEmpty() )
1691 nId = SID_SAVEASDOC;
1692 SfxRequest aSaveRequest( nId, SfxCallMode::SLOT, GetPool() );
1693 //ToDo: Review. We needed to call SetModified, otherwise the document would not be saved.
1694 SetModified();
1695 ExecFile_Impl( aSaveRequest );
1697 // Check if it is stored a format which supports signing
1698 if (GetMedium() && GetMedium()->GetFilter() && !GetMedium()->GetName().isEmpty()
1699 && ((!GetMedium()->GetFilter()->IsOwnFormat()
1700 && !GetMedium()->GetFilter()->GetSupportsSigning())
1701 || (GetMedium()->GetFilter()->IsOwnFormat()
1702 && !GetMedium()->HasStorage_Impl())))
1704 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
1705 pDialogParent, VclMessageType::Info, VclButtonsType::Ok,
1706 SfxResId(STR_INFO_WRONGDOCFORMAT)));
1708 xBox->run();
1709 return false;
1712 else
1714 // When the document is modified then we must not show the
1715 // digital signatures dialog
1716 // If we have come here then the user denied to save.
1717 if (!bHasSign)
1718 return false;
1721 else
1723 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pDialogParent,
1724 VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_XMLSEC_ODF12_EXPECTED)));
1725 xBox->run();
1726 return false;
1729 if ( IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty() )
1730 return false;
1733 // the document is not modified currently, so it can not become modified after signing
1734 pImpl->m_bAllowModifiedBackAfterSigning = false;
1735 if ( IsEnableSetModified() )
1737 EnableSetModified( false );
1738 pImpl->m_bAllowModifiedBackAfterSigning = true;
1741 // we have to store to the original document, the original medium should be closed for this time
1742 if ( ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) )
1744 GetMedium()->CloseAndRelease();
1745 return true;
1747 return false;
1750 void SfxObjectShell::RecheckSignature(bool bAlsoRecheckScriptingSignature)
1752 if (bAlsoRecheckScriptingSignature)
1753 pImpl->nScriptingSignatureState = SignatureState::UNKNOWN; // Re-Check
1755 pImpl->nDocumentSignatureState = SignatureState::UNKNOWN; // Re-Check
1757 Invalidate(SID_SIGNATURE);
1758 Invalidate(SID_MACRO_SIGNATURE);
1759 Broadcast(SfxHint(SfxHintId::TitleChanged));
1762 void SfxObjectShell::AfterSigning(bool bSignSuccess, bool bSignScriptingContent)
1764 pImpl->m_bSavingForSigning = true;
1765 DoSaveCompleted( GetMedium() );
1766 pImpl->m_bSavingForSigning = false;
1768 if ( bSignSuccess )
1769 RecheckSignature(bSignScriptingContent);
1771 if ( pImpl->m_bAllowModifiedBackAfterSigning )
1772 EnableSetModified();
1775 bool SfxObjectShell::CheckIsReadonly(bool bSignScriptingContent)
1777 if (GetMedium()->IsOriginallyReadOnly())
1779 // If the file is physically read-only, we just show the existing signatures
1782 OUString aODFVersion(
1783 comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage()));
1784 uno::Reference<security::XDocumentDigitalSignatures> xSigner(
1785 security::DocumentDigitalSignatures::createWithVersionAndValidSignature(
1786 comphelper::getProcessComponentContext(), aODFVersion, HasValidSignatures()));
1787 if (bSignScriptingContent)
1788 xSigner->showScriptingContentSignatures(GetMedium()->GetZipStorageToSign_Impl(),
1789 uno::Reference<io::XInputStream>());
1790 else
1792 uno::Reference<embed::XStorage> xStorage = GetMedium()->GetZipStorageToSign_Impl();
1793 if (xStorage.is())
1794 xSigner->showDocumentContentSignatures(xStorage,
1795 uno::Reference<io::XInputStream>());
1796 else
1798 std::unique_ptr<SvStream> pStream(
1799 utl::UcbStreamHelper::CreateStream(GetName(), StreamMode::READ));
1800 uno::Reference<io::XInputStream> xStream(new utl::OStreamWrapper(*pStream));
1801 xSigner->showDocumentContentSignatures(uno::Reference<embed::XStorage>(),
1802 xStream);
1806 catch (const uno::Exception&)
1808 SAL_WARN("sfx.doc", "Couldn't use signing functionality!");
1810 return true;
1812 return false;
1815 bool SfxObjectShell::HasValidSignatures() const
1817 return pImpl->nDocumentSignatureState == SignatureState::OK
1818 || pImpl->nDocumentSignatureState == SignatureState::NOTVALIDATED
1819 || pImpl->nDocumentSignatureState == SignatureState::PARTIAL_OK;
1822 SignatureState SfxObjectShell::GetDocumentSignatureState()
1824 return ImplGetSignatureState();
1827 void SfxObjectShell::SignDocumentContent(weld::Window* pDialogParent)
1829 if (!PrepareForSigning(pDialogParent))
1830 return;
1832 if (CheckIsReadonly(false))
1833 return;
1835 bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, false, HasValidSignatures());
1837 AfterSigning(bSignSuccess, false);
1840 bool SfxObjectShell::SignDocumentContentUsingCertificate(const Reference<XCertificate>& xCertificate)
1842 // 1. PrepareForSigning
1844 // check whether the document is signed
1845 ImplGetSignatureState(false); // document signature
1846 if (GetMedium() && GetMedium()->GetFilter() && GetMedium()->GetFilter()->IsOwnFormat())
1847 ImplGetSignatureState( true ); // script signature
1848 bool bHasSign = ( pImpl->nScriptingSignatureState != SignatureState::NOSIGNATURES || pImpl->nDocumentSignatureState != SignatureState::NOSIGNATURES );
1850 // the target ODF version on saving (only valid when signing ODF of course)
1851 SvtSaveOptions aSaveOpt;
1852 SvtSaveOptions::ODFDefaultVersion nVersion = aSaveOpt.GetODFDefaultVersion();
1854 // the document is not new and is not modified
1855 OUString aODFVersion(comphelper::OStorageHelper::GetODFVersionFromStorage(GetStorage()));
1857 if (IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty()
1858 || (GetMedium()->GetFilter()->IsOwnFormat() && aODFVersion != ODFVER_012_TEXT && !bHasSign))
1860 if ( nVersion >= SvtSaveOptions::ODFVER_012 )
1862 sal_uInt16 nId = SID_SAVEDOC;
1863 if ( !GetMedium() || GetMedium()->GetName().isEmpty() )
1864 nId = SID_SAVEASDOC;
1865 SfxRequest aSaveRequest( nId, SfxCallMode::SLOT, GetPool() );
1866 //ToDo: Review. We needed to call SetModified, otherwise the document would not be saved.
1867 SetModified();
1868 ExecFile_Impl( aSaveRequest );
1870 // Check if it is stored a format which supports signing
1871 if (GetMedium() && GetMedium()->GetFilter() && !GetMedium()->GetName().isEmpty()
1872 && ((!GetMedium()->GetFilter()->IsOwnFormat()
1873 && !GetMedium()->GetFilter()->GetSupportsSigning())
1874 || (GetMedium()->GetFilter()->IsOwnFormat()
1875 && !GetMedium()->HasStorage_Impl())))
1877 return false;
1880 else
1882 return false;
1885 if ( IsModified() || !GetMedium() || GetMedium()->GetName().isEmpty() )
1886 return false;
1889 // the document is not modified currently, so it can not become modified after signing
1890 pImpl->m_bAllowModifiedBackAfterSigning = false;
1891 if ( IsEnableSetModified() )
1893 EnableSetModified( false );
1894 pImpl->m_bAllowModifiedBackAfterSigning = true;
1897 // we have to store to the original document, the original medium should be closed for this time
1898 bool bResult = ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium);
1900 if (!bResult)
1901 return false;
1903 GetMedium()->CloseAndRelease();
1905 // 2. Check Read-Only
1906 if (GetMedium()->IsOriginallyReadOnly())
1907 return false;
1909 // 3. Sign
1910 bool bSignSuccess = GetMedium()->SignDocumentContentUsingCertificate(HasValidSignatures(), xCertificate);
1912 // 4. AfterSigning
1913 AfterSigning(bSignSuccess, false);
1915 return true;
1918 void SfxObjectShell::SignSignatureLine(weld::Window* pDialogParent,
1919 const OUString& aSignatureLineId,
1920 const Reference<XCertificate>& xCert,
1921 const Reference<XGraphic>& xValidGraphic,
1922 const Reference<XGraphic>& xInvalidGraphic,
1923 const OUString& aComment)
1925 if (!PrepareForSigning(pDialogParent))
1926 return;
1928 if (CheckIsReadonly(false))
1929 return;
1931 bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent,
1932 false, HasValidSignatures(), aSignatureLineId, xCert, xValidGraphic, xInvalidGraphic, aComment);
1934 AfterSigning(bSignSuccess, false);
1936 // Reload the document to get the updated graphic
1937 // FIXME: Update just the signature line graphic instead of reloading the document
1938 SfxViewFrame *pFrame = GetFrame();
1939 if (pFrame)
1940 pFrame->GetDispatcher()->Execute(SID_RELOAD);
1943 SignatureState SfxObjectShell::GetScriptingSignatureState()
1945 return ImplGetSignatureState( true );
1948 void SfxObjectShell::SignScriptingContent(weld::Window* pDialogParent)
1950 if (!PrepareForSigning(pDialogParent))
1951 return;
1953 if (CheckIsReadonly(true))
1954 return;
1956 bool bSignSuccess = GetMedium()->SignContents_Impl(pDialogParent, true, HasValidSignatures());
1958 AfterSigning(bSignSuccess, true);
1961 namespace
1963 class theSfxObjectShellUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSfxObjectShellUnoTunnelId > {};
1966 const uno::Sequence<sal_Int8>& SfxObjectShell::getUnoTunnelId()
1968 return theSfxObjectShellUnoTunnelId::get().getSeq();
1971 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */