20#include <config_features.h>
22#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
23#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
24#include <com/sun/star/util/CloseVetoException.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/beans/PropertyValue.hpp>
27#include <com/sun/star/beans/PropertyAttribute.hpp>
28#include <com/sun/star/document/XCmisDocument.hpp>
29#include <com/sun/star/drawing/LineStyle.hpp>
30#include <com/sun/star/lang/XServiceInfo.hpp>
31#include <com/sun/star/security/XCertificate.hpp>
32#include <com/sun/star/task/ErrorCodeIOException.hpp>
33#include <com/sun/star/task/InteractionHandler.hpp>
34#include <com/sun/star/task/XStatusIndicator.hpp>
35#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
38#include <com/sun/star/drawing/XDrawView.hpp>
40#include <com/sun/star/security/DocumentSignatureInformation.hpp>
41#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
65#include <LibreOfficeKit/LibreOfficeKitEnums.h>
83#include <sfx2/strings.hrc>
91#include <sfx2/sfxsids.hrc>
94#include <com/sun/star/util/XCloseable.hpp>
95#include <com/sun/star/document/XDocumentProperties.hpp>
97#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
98#include <com/sun/star/frame/XDesktop2.hpp>
99#include <com/sun/star/frame/Desktop.hpp>
112#include <boost/property_tree/json_parser.hpp>
126#define ShellClass_SfxObjectShell
127#include <sfxslots.hxx>
137class SfxClosePreventer_Impl :
public ::cppu::WeakImplHelper< css::util::XCloseListener >
139 bool m_bGotOwnership;
140 bool m_bPreventClose;
143 SfxClosePreventer_Impl();
145 bool HasOwnership()
const {
return m_bGotOwnership; }
147 void SetPreventClose(
bool bPrevent ) { m_bPreventClose = bPrevent; }
149 virtual void SAL_CALL queryClosing(
const lang::EventObject& aEvent,
sal_Bool bDeliverOwnership )
override;
151 virtual void SAL_CALL notifyClosing(
const lang::EventObject& aEvent )
override ;
153 virtual void SAL_CALL disposing(
const lang::EventObject& aEvent )
override ;
159SfxClosePreventer_Impl::SfxClosePreventer_Impl()
160: m_bGotOwnership( false )
161, m_bPreventClose( true )
165void SAL_CALL SfxClosePreventer_Impl::queryClosing(
const lang::EventObject&,
sal_Bool bDeliverOwnership )
167 if ( m_bPreventClose )
169 if ( !m_bGotOwnership )
170 m_bGotOwnership = bDeliverOwnership;
172 throw util::CloseVetoException();
176void SAL_CALL SfxClosePreventer_Impl::notifyClosing(
const lang::EventObject& )
179void SAL_CALL SfxClosePreventer_Impl::disposing(
const lang::EventObject& )
184class SfxInstanceCloseGuard_Impl
187 uno::Reference< util::XCloseable > m_xCloseable;
190 SfxInstanceCloseGuard_Impl() {}
192 ~SfxInstanceCloseGuard_Impl();
194 bool Init_Impl(
const uno::Reference< util::XCloseable >& xCloseable );
199bool SfxInstanceCloseGuard_Impl::Init_Impl(
const uno::Reference< util::XCloseable >& xCloseable )
201 bool bResult =
false;
204 if ( xCloseable.is() && !m_xCloseable.is() )
208 m_xPreventer =
new SfxClosePreventer_Impl();
209 xCloseable->addCloseListener( m_xPreventer );
210 m_xCloseable = xCloseable;
213 catch( uno::Exception& )
215 OSL_FAIL(
"Could not register close listener!" );
222SfxInstanceCloseGuard_Impl::~SfxInstanceCloseGuard_Impl()
224 if ( !m_xCloseable.is() || !m_xPreventer.is() )
229 m_xCloseable->removeCloseListener( m_xPreventer );
231 catch( uno::Exception& )
237 if ( m_xPreventer.is() )
239 m_xPreventer->SetPreventClose(
false );
241 if ( m_xPreventer->HasOwnership() )
242 m_xCloseable->close(
true );
245 catch( uno::Exception& )
264 bool bPrinting =
false;
269 bPrinting = pPrinter && pPrinter->
IsPrinting();
275 const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
281 OUString aFilterName;
283 if( pFilterNameItem )
285 aFilterName = pFilterNameItem->
GetValue();
290 if ( pContentTypeItem )
294 aFilterName = pFilter->GetName();
299 if( aFilterName.isEmpty() )
305 aFilterName = pFilt->GetFilterName();
330 uno::Reference< document::XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY_THROW );
331 xCmisDoc->checkOut( );
337 catch (
const uno::RuntimeException& e )
340 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
349 uno::Reference< document::XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY_THROW );
350 xCmisDoc->cancelCheckOut( );
352 uno::Reference< util::XModifiable > xModifiable(
GetModel( ), uno::UNO_QUERY );
353 if ( xModifiable.is( ) )
354 xModifiable->setModified(
false );
356 catch (
const uno::RuntimeException& e )
359 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
368 uno::Reference< document::XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY_THROW );
374 uno::Reference< util::XModifiable > xModifiable(
GetModel( ), uno::UNO_QUERY );
375 if ( xModifiable.is( ) )
376 xModifiable->setModified(
false );
379 catch (
const uno::RuntimeException& e )
382 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
391 uno::Reference< document::XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY_THROW );
392 return xCmisDoc->getAllVersions( );
394 catch (
const uno::RuntimeException& e )
397 VclMessageType::Warning, VclButtonsType::Ok, e.Message));
400 return uno::Sequence< document::CmisVersion > ( );
408 if (pFilter && pFilter->GetName() ==
"draw_pdf_import")
420 return uno::Reference<security::XCertificate>();
423 uno::Reference<drawing::XShapes> xShapes(
xModel->getCurrentSelection(), uno::UNO_QUERY);
424 if (!xShapes.is() || xShapes->getCount() < 1)
426 return uno::Reference<security::XCertificate>();
429 uno::Reference<beans::XPropertySet> xShapeProps(xShapes->getByIndex(0), uno::UNO_QUERY);
430 if (!xShapeProps.is())
432 return uno::Reference<security::XCertificate>();
435 if (!xShapeProps->getPropertySetInfo()->hasPropertyByName(
"InteropGrabBag"))
437 return uno::Reference<security::XCertificate>();
441 auto it =
aMap.find(
"SignatureCertificate");
442 if (it ==
aMap.end())
444 return uno::Reference<security::XCertificate>();
447 return uno::Reference<security::XCertificate>(it->second, uno::UNO_QUERY);
452 if (error.
GetClass() == ErrCodeClass::NONE)
455 boost::property_tree::ptree aTree;
456 aTree.put(
"code", error);
457 aTree.put(
"kind",
"");
458 aTree.put(
"cmd",
"");
463 aTree.put(
"message", aErr.toUtf8());
465 std::stringstream aStream;
466 boost::property_tree::write_json(aStream, aTree);
473void SetDocProperties(
const uno::Reference<document::XDocumentProperties>& xDP,
474 const uno::Sequence<beans::PropertyValue>& rUpdatedProperties)
477 OUString aNamePrefix;
478 auto it =
aMap.find(
"NamePrefix");
479 if (it !=
aMap.end())
481 it->second >>= aNamePrefix;
484 uno::Sequence<beans::PropertyValue> aUserDefinedProperties;
485 it =
aMap.find(
"UserDefinedProperties");
486 if (it !=
aMap.end())
488 it->second >>= aUserDefinedProperties;
491 uno::Reference<beans::XPropertyContainer> xUDP = xDP->getUserDefinedProperties();
492 if (!aNamePrefix.isEmpty())
494 uno::Reference<beans::XPropertySet> xSet(xUDP, UNO_QUERY);
495 uno::Reference<beans::XPropertySetInfo> xSetInfo = xSet->getPropertySetInfo();
496 const uno::Sequence<beans::Property>
aProperties = xSetInfo->getProperties();
497 for (
const auto& rProperty : aProperties)
499 if (!rProperty.Name.startsWith(aNamePrefix))
504 if (!(rProperty.Attributes & beans::PropertyAttribute::REMOVABLE))
509 xUDP->removeProperty(rProperty.Name);
513 for (
const auto& rUserDefinedProperty : aUserDefinedProperties)
515 xUDP->addProperty(rUserDefinedProperty.Name, beans::PropertyAttribute::REMOVABLE,
516 rUserDefinedProperty.Value);
535 bool bHaveWeSigned =
false;
537 if( SID_SIGNATURE ==
nId || SID_MACRO_SIGNATURE ==
nId )
541 if (SID_SIGNATURE ==
nId)
544 if (xCertificate.is())
558 GetBaseModel()->getCurrentController(), uno::UNO_QUERY);
559 uno::Reference<beans::XPropertySet> xPage(
xController->getCurrentPage(),
562 xPage->getPropertyValue(
"Number") >>= nPage;
586 VclMessageType::Question, VclButtonsType::YesNo,
SfxResId(STR_QUERY_REMEMBERSIGNATURE)));
609 SfxInstanceCloseGuard_Impl aModelGuard;
611 bool bIsPDFExport =
false;
612 bool bIsAutoRedact =
false;
613 bool bIsAsync =
false;
614 std::vector<std::pair<RedactionTarget, OUString>> aRedactionTargets;
638 const SfxDocumentInfoItem* pDocInfItem = rReq.
GetArg<SfxDocumentInfoItem>(SID_DOCINFO);
648 uno::Sequence<beans::PropertyValue> aUpdatedProperties;
649 pItem->GetValue() >>= aUpdatedProperties;
665 Reference< XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY );
666 uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties();
672 aDocInfoItem.SetTemplate(
false);
674 SfxItemSetFixed<SID_DOCINFO, SID_DOCINFO, SID_DOC_READONLY, SID_DOC_READONLY,
675 SID_EXPLORER_PROPS_START, SID_EXPLORER_PROPS_START, SID_BASEURL, SID_BASEURL>
677 aSet.Put( aDocInfoItem );
685 auto aFunc = [
this, xDlg, xCmisDoc](sal_Int32 nResult,
SfxRequest& rRequest)
689 const SfxDocumentInfoItem* pDocInfoItem =
SfxItemSet::GetItem(xDlg->GetOutputItemSet(), SID_DOCINFO,
false);
694 const uno::Sequence< document::CmisProperty >& aNewCmisProperties =
695 pDocInfoItem->GetCmisProperties( );
696 if ( aNewCmisProperties.hasElements( ) )
697 xCmisDoc->updateCmisProperties( aNewCmisProperties );
701 rRequest.AppendItem( SfxDocumentInfoItem(
GetTitle(),
715 std::shared_ptr<SfxRequest> pReq = std::make_shared<SfxRequest>(rReq);
718 aFunc(nResult, *pReq);
724 aFunc(xDlg->run(), rReq);
731 case SID_AUTOREDACTDOC:
737 pDialogParent, VclMessageType::Warning, VclButtonsType::Ok,
738 SfxResId(STR_REDACTION_NO_DRAW_WARNING)));
746 sal_Int16 nResult = aDlg.
run();
755 bIsAutoRedact =
true;
767 uno::Reference< lang::XComponent > xSourceDoc(
xModel );
773 pDialogParent, VclMessageType::Warning, VclButtonsType::Ok,
774 SfxResId(STR_REDACTION_NO_DRAW_WARNING)));
787 else if (aRenderer.
isCalc())
791 std::vector< GDIMetaFile > aMetaFiles;
792 std::vector< ::Size > aPageSizes;
799 uno::Reference<lang::XComponent> xComponent = xDesktop->loadComponentFromURL(
"private:factory/sdraw",
"_default", 0, {});
801 if (!xComponent.is())
803 SAL_WARN(
"sfx.doc",
"SID_REDACTDOC: Failed to load new draw component. loadComponentFromURL returned an empty reference.");
821 case SID_DIRECTEXPORTDOCASPDF:
824 if (!xComponent.is())
827 uno::Reference< lang::XServiceInfo > xServiceInfo( xComponent, uno::UNO_QUERY);
830 if ( xServiceInfo.is() && xServiceInfo->supportsService(
"com.sun.star.drawing.DrawingDocument")
836 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
837 uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
839 sal_Int32 nPageCount = xDrawPages->getCount();
840 for (sal_Int32 nPageNum = 0; nPageNum < nPageCount; ++nPageNum)
843 uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( nPageNum ), uno::UNO_QUERY );
849 sal_Int32 nShapeCount = xPage->getCount();
850 for (sal_Int32 nShapeNum = 0; nShapeNum < nShapeCount; ++nShapeNum)
852 uno::Reference< drawing::XShape > xCurrShape(xPage->getByIndex(nShapeNum), uno::UNO_QUERY);
853 if (!xCurrShape.is())
856 uno::Reference< beans::XPropertySet > xPropSet(xCurrShape, uno::UNO_QUERY);
860 uno::Reference< beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
865 if (xInfo->hasPropertyByName(
"Name"))
867 uno::Any aAnyShapeName = xPropSet->getPropertyValue(
"Name");
868 aAnyShapeName >>= sShapeName;
874 if (sShapeName ==
"RectangleRedactionShape"
875 && xInfo->hasPropertyByName(
"FillTransparence") && xInfo->hasPropertyByName(
"FillColor"))
877 xPropSet->setPropertyValue(
"FillTransparence", css::uno::Any(
static_cast<sal_Int16
>(0)));
878 if (sRedactionStyle ==
"White")
880 xPropSet->setPropertyValue(
"FillColor", css::uno::Any(
COL_WHITE));
881 xPropSet->setPropertyValue(
"LineStyle", css::uno::Any(css::drawing::LineStyle::LineStyle_SOLID));
882 xPropSet->setPropertyValue(
"LineColor", css::uno::Any(
COL_BLACK));
886 xPropSet->setPropertyValue(
"FillColor", css::uno::Any(
COL_BLACK));
887 xPropSet->setPropertyValue(
"LineStyle", css::uno::Any(css::drawing::LineStyle::LineStyle_NONE));
891 else if (sShapeName ==
"FreeformRedactionShape"
892 && xInfo->hasPropertyByName(
"LineTransparence") && xInfo->hasPropertyByName(
"LineColor"))
894 xPropSet->setPropertyValue(
"LineTransparence", css::uno::Any(
static_cast<sal_Int16
>(0)));
896 if (sRedactionStyle ==
"White")
898 xPropSet->setPropertyValue(
"LineColor", css::uno::Any(
COL_WHITE));
902 xPropSet->setPropertyValue(
"LineColor", css::uno::Any(
COL_BLACK));
910 case SID_EXPORTDOCASPDF:
913 case SID_EXPORTDOCASEPUB:
914 case SID_DIRECTEXPORTDOCASEPUB:
917 case SID_SAVEASREMOTE:
922 && (
nId == SID_EXPORTDOCASEPUB ||
nId == SID_EXPORTDOCASPDF))
938 aModelGuard.Init_Impl( uno::Reference< util::XCloseable >(
GetModel(), uno::UNO_QUERY ) );
944 pImpl->bPreserveVersions = (
nId == SID_SAVEDOC);
949 if (
nId == SID_SAVEASDOC ||
nId == SID_SAVEASREMOTE )
953 if ( pViewOnlyItem && pViewOnlyItem->
GetValue() )
961 if ( !pStatusIndicatorItem )
964 uno::Reference< task::XStatusIndicator > xStatusIndicator;
965 uno::Reference < frame::XController > xCtrl(
GetModel()->getCurrentController() );
968 uno::Reference< task::XStatusIndicatorFactory > xStatFactory( xCtrl->getFrame(), uno::UNO_QUERY );
969 if( xStatFactory.is() )
970 xStatusIndicator = xStatFactory->createStatusIndicator();
973 OSL_ENSURE( xStatusIndicator.is(),
"Can not retrieve default status indicator!" );
975 if ( xStatusIndicator.is() )
979 if (
nId == SID_SAVEDOC )
989 else if (
nId == SID_SAVEDOC )
998 if ( !pInteractionHandlerItem )
1000 uno::Reference<css::awt::XWindow> xParentWindow;
1001 uno::Reference<frame::XController> xCtrl(
GetModel()->getCurrentController());
1003 xParentWindow = xCtrl->getFrame()->getContainerWindow();
1005 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1007 uno::Reference< task::XInteractionHandler2 > xInteract(
1008 task::InteractionHandler::createWithParent(xContext, xParentWindow) );
1011 if (
nId == SID_SAVEDOC )
1020 else if (
nId == SID_SAVEDOC )
1030 const bool bPreselectPassword
1031 = pOldPasswordItem || pOldEncryptionDataItem
1035 uno::Sequence< beans::PropertyValue > aDispatchArgs;
1044 throw uno::Exception(
"no slot",
nullptr);
1046 std::shared_ptr<SfxStoringHelper> xHelper = std::make_shared<SfxStoringHelper>();
1053 throw task::ErrorCodeIOException(
1054 "SfxObjectShell::ExecFile_Impl: ERRCODE_IO_ABORT",
1058 const SfxBoolItem *pItem =
nId != SID_DIRECTEXPORTDOCASPDF ? nullptr :
1062 bool bMailPrepareExport = pItem && pItem->
GetValue();
1063 if (bMailPrepareExport)
1070 xHelper->GUIStoreModel(
GetModel(),
1077 if (bMailPrepareExport)
1088 rReq.
SetArgs( aResultParams );
1099 catch(
const task::ErrorCodeIOException& aErrorEx )
1102 nErrorCode =
ErrCode(aErrorEx.ErrCode);
1111 pImpl->bPreserveVersions =
true;
1114 if ( !lErr && nErrorCode )
1120 if ( pWarnItem && pWarnItem->
GetValue() )
1136 if (
nId == SID_DIRECTEXPORTDOCASPDF &&
1141 if (!xComponent.is())
1144 uno::Reference< lang::XServiceInfo > xServiceInfo( xComponent, uno::UNO_QUERY);
1147 if ( xServiceInfo.is() && xServiceInfo->supportsService(
"com.sun.star.drawing.DrawingDocument") )
1150 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
1151 uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
1153 sal_Int32 nPageCount = xDrawPages->getCount();
1154 for (sal_Int32 nPageNum = 0; nPageNum < nPageCount; ++nPageNum)
1157 uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( nPageNum ), uno::UNO_QUERY );
1163 sal_Int32 nShapeCount = xPage->getCount();
1164 for (sal_Int32 nShapeNum = 0; nShapeNum < nShapeCount; ++nShapeNum)
1166 uno::Reference< drawing::XShape > xCurrShape(xPage->getByIndex(nShapeNum), uno::UNO_QUERY);
1167 if (!xCurrShape.is())
1170 uno::Reference< beans::XPropertySet > xPropSet(xCurrShape, uno::UNO_QUERY);
1174 uno::Reference< beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
1179 if (!xInfo->hasPropertyByName(
"Name"))
1182 OUString sShapeName;
1183 if (xInfo->hasPropertyByName(
"Name"))
1185 uno::Any aAnyShapeName = xPropSet->getPropertyValue(
"Name");
1186 aAnyShapeName >>= sShapeName;
1192 if (sShapeName ==
"RectangleRedactionShape"
1193 && xInfo->hasPropertyByName(
"FillTransparence") && xInfo->hasPropertyByName(
"FillColor"))
1195 xPropSet->setPropertyValue(
"FillTransparence", css::uno::Any(
static_cast<sal_Int16
>(50)));
1196 xPropSet->setPropertyValue(
"FillColor", css::uno::Any(
COL_GRAY7));
1197 xPropSet->setPropertyValue(
"LineStyle", css::uno::Any(css::drawing::LineStyle::LineStyle_NONE));
1201 else if (sShapeName ==
"FreeformRedactionShape")
1203 xPropSet->setPropertyValue(
"LineTransparence", css::uno::Any(
static_cast<sal_Int16
>(50)));
1204 xPropSet->setPropertyValue(
"LineColor", css::uno::Any(
COL_GRAY7));
1213 if (
nId == SID_EXPORTDOCASPDF )
1221 if ( (
nId == SID_SAVEASDOC ||
nId == SID_SAVEASREMOTE ) && nErrorCode ==
ERRCODE_NONE )
1224 if (saveTo ==
nullptr || !saveTo->
GetValue())
1250 if ( !aSaveACopyReq.
IsDone() )
1271#if HAVE_FEATURE_SCRIPTING
1278 SfxStringItem aTmpItem( SID_FILE_NAME, pNameItem->GetValue() );
1279 aArgs.
Put( aTmpItem, aTmpItem.
Which() );
1282 if ( !aSaveAsReq.
IsDone() )
1316 case SID_DOCTEMPLATE:
1329 case SID_CANCELCHECKOUT:
1332 VclMessageType::Question, VclButtonsType::YesNo,
SfxResId(STR_QUERY_CANCELCHECKOUT)));
1368 case SID_DOCTEMPLATE :
1378 Reference< XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY );
1379 const uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties();
1381 if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) )
1384 bool bIsGoogleFile =
false;
1385 bool bCheckedOut =
false;
1386 for (
const auto& rCmisProperty : aCmisProperties )
1388 if ( rCmisProperty.Id ==
"cmis:isVersionSeriesCheckedOut" )
1390 uno::Sequence< sal_Bool > bTmp;
1391 rCmisProperty.Value >>= bTmp;
1392 bCheckedOut = bTmp[0];
1396 if ( rCmisProperty.Name ==
"title" )
1397 bIsGoogleFile =
true;
1399 bShow = !bCheckedOut && !bIsGoogleFile;
1410 case SID_CANCELCHECKOUT:
1414 Reference< XCmisDocument > xCmisDoc(
GetModel(), uno::UNO_QUERY );
1415 const uno::Sequence< document::CmisProperty> aCmisProperties = xCmisDoc->getCmisProperties( );
1417 if ( xCmisDoc->isVersionable( ) && aCmisProperties.hasElements( ) )
1420 bool bCheckedOut =
false;
1421 auto pProp = std::find_if(aCmisProperties.begin(), aCmisProperties.end(),
1422 [](
const document::CmisProperty& rProp) { return rProp.Id ==
"cmis:isVersionSeriesCheckedOut"; });
1423 if (pProp != aCmisProperties.end())
1425 uno::Sequence< sal_Bool > bTmp;
1426 pProp->Value >>= bTmp;
1427 bCheckedOut = bTmp[0];
1429 bShow = bCheckedOut;
1447 if ( !pFrame || !pDoc->
HasName() ||
1502 case SID_EXPORTDOCASPDF:
1503 case SID_DIRECTEXPORTDOCASPDF:
1504 case SID_EXPORTDOCASEPUB:
1505 case SID_DIRECTEXPORTDOCASEPUB:
1507 case SID_AUTOREDACTDOC:
1508 case SID_SAVEASREMOTE:
1515 case SID_DOC_MODIFIED:
1527 case SID_DOCINFO_TITLE:
1588 if (pInfoBar ==
nullptr || pInfoBar->isDisposed())
1607 case SID_MACRO_SIGNATURE:
1610 if (
pImpl->documentStorageHasMacros() ||
pImpl->aMacroMode.hasMacroLibrary() )
1616 case SID_DOC_REPAIR:
1634 SAL_WARN(
"sfx.appl",
"There should be some SfxViewFrame associated here");
1657 case SID_DOCINFO_AUTHOR :
1661 case SID_DOCINFO_COMMENTS :
1665 case SID_DOCINFO_KEYWORDS :
1669 ::comphelper::string::convertCommaSeparated(
aStr) );
1683 case SID_DOCINFO_AUTHOR :
1690 case SID_DOCINFO_COMMENTS :
1697 case SID_DOCINFO_KEYWORDS :
1706 OSL_FAIL(
"Not supported anymore!" );
1710 case SID_DOCFULLNAME:
1722 case SID_DOC_READONLY:
1740 case SID_DOC_LOADING:
1744 case SID_IMG_LOADING:
1779 if (xStorage->hasByName(
"META-INF"))
1784 uno::Reference<embed::XStorage> xMetaInf
1785 = xStorage->openStorageElement(
"META-INF", embed::ElementModes::READ);
1788 return xMetaInf->hasByName(
"documentsignatures.xml")
1789 || xMetaInf->hasByName(
"macrosignatures.xml")
1790 || xMetaInf->hasByName(
"packagesignatures.xml");
1793 catch (
const css::io::IOException&)
1800 return xStorage->hasByName(
"_xmlsignatures");
1805 uno::Sequence< security::DocumentSignatureInformation > aResult;
1806 uno::Reference< security::XDocumentDigitalSignatures > xLocSigner = xSigner;
1813 if ( !xLocSigner.is() )
1818 uno::Reference < beans::XPropertySet > xPropSet(
GetStorage(), uno::UNO_QUERY_THROW );
1819 xPropSet->getPropertyValue(
"Version") >>= aVersion;
1821 catch( uno::Exception& )
1829 if ( bScriptingContent )
1830 aResult = xLocSigner->verifyScriptingContentSignatures(
GetMedium()->GetZipStorageToSign_Impl(),
1831 uno::Reference< io::XInputStream >() );
1840 aResult = xLocSigner->verifyDocumentContentSignatures(
GetMedium()->GetZipStorageToSign_Impl(),
1841 uno::Reference< io::XInputStream >() );
1852 uno::Reference<io::XInputStream> xInputStream(
xStream, uno::UNO_QUERY);
1853 aResult = xLocSigner->verifyDocumentContentSignatures(uno::Reference<embed::XStorage>(), xInputStream);
1857 catch( css::uno::Exception& )
1909 OUString sQuestion(bHasSign ?
SfxResId(STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN) :
SfxResId(RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN));
1910 std::unique_ptr<weld::MessageDialog> xQuestion;
1915 VclMessageType::Question, VclButtonsType::YesNo, sQuestion));
1920 sal_uInt16
nId = SID_SAVEDOC;
1922 nId = SID_SAVEASDOC;
1930 && ((!
GetMedium()->GetFilter()->IsOwnFormat()
1931 && !
GetMedium()->GetFilter()->GetSupportsSigning())
1932 || (
GetMedium()->GetFilter()->IsOwnFormat()
1936 pDialogParent, VclMessageType::Info, VclButtonsType::Ok,
1937 SfxResId(STR_INFO_WRONGDOCFORMAT)));
1955 VclMessageType::Warning, VclButtonsType::Ok,
SfxResId(STR_XMLSEC_ODF12_EXPECTED)));
1965 pImpl->m_bAllowModifiedBackAfterSigning =
false;
1969 pImpl->m_bAllowModifiedBackAfterSigning =
true;
1983 if (bAlsoRecheckScriptingSignature)
1995 pImpl->m_bSavingForSigning =
true;
1997 pImpl->m_bSavingForSigning =
false;
2002 if (
pImpl->m_bAllowModifiedBackAfterSigning ||
true )
2014 OUString aODFVersion(
2016 uno::Reference<security::XDocumentDigitalSignatures> xSigner(
2017 security::DocumentDigitalSignatures::createWithVersionAndValidSignature(
2021 xSigner->setParentWindow(pDialogParent->
GetXWindow());
2023 if (bSignScriptingContent)
2024 xSigner->showScriptingContentSignatures(
GetMedium()->GetZipStorageToSign_Impl(),
2025 uno::Reference<io::XInputStream>());
2030 xSigner->showDocumentContentSignatures(xStorage,
2031 uno::Reference<io::XInputStream>());
2034 std::unique_ptr<SvStream> pStream(
2043 SAL_WARN(
"sfx.doc",
"Couldn't use signing functionality!" );
2049 xSigner->showDocumentContentSignatures(uno::Reference<embed::XStorage>(),
2054 catch (
const uno::Exception&)
2056 SAL_WARN(
"sfx.doc",
"Couldn't use signing functionality!");
2087 return bSignSuccess;
2092 bool bSignSuccess =
true;
2095 for (
auto & rInfo : rSignaturesInfo)
2097 auto xCert = rInfo.Signer;
2104 return bSignSuccess;
2128 sal_uInt16
nId = SID_SAVEDOC;
2130 nId = SID_SAVEASDOC;
2138 && ((!
GetMedium()->GetFilter()->IsOwnFormat()
2139 && !
GetMedium()->GetFilter()->GetSupportsSigning())
2140 || (
GetMedium()->GetFilter()->IsOwnFormat()
2156 pImpl->m_bAllowModifiedBackAfterSigning =
false;
2160 pImpl->m_bAllowModifiedBackAfterSigning =
true;
2172 if (
GetMedium()->IsOriginallyReadOnly())
2186 const OUString& aSignatureLineId,
2187 const Reference<XCertificate>& xCert,
2188 const Reference<XGraphic>& xValidGraphic,
2189 const Reference<XGraphic>& xInvalidGraphic,
2190 const OUString& aComment)
2199 false,
HasValidSignatures(), aSignatureLineId, xCert, xValidGraphic, xInvalidGraphic, aComment);
2227 return bSignSuccess;
2233 return theSfxObjectShellUnoTunnelId.
getSeq();
2242 return uno::Sequence< beans::PropertyValue>();
2245 uno::Reference< beans::XPropertySet > xPropSet(
xModel, uno::UNO_QUERY_THROW );
2246 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
2248 if ( xPropSetInfo->hasPropertyByName( aGrabBagName ) )
2250 uno::Sequence< beans::PropertyValue > propList;
2251 xPropSet->getPropertyValue( aGrabBagName ) >>= propList;
2252 for(
const auto& rProp : std::as_const(propList) )
2254 if (rProp.Name ==
"DocumentProtection")
2256 uno::Sequence< beans::PropertyValue > rAttributeList;
2257 rProp.Value >>= rAttributeList;
2258 return rAttributeList;
2263 return uno::Sequence< beans::PropertyValue>();
PropertiesInfo aProperties
SfxApplication * SfxGetpApp()
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
void TransformParameters(sal_uInt16 nSlotId, const uno::Sequence< beans::PropertyValue > &rArgs, SfxAllItemSet &rSet, const SfxSlot *pSlot)
const sal_uInt16 nVersion
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
constexpr ErrCodeClass GetClass() const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static std::unique_ptr< ErrorInfo > GetErrorInfo(ErrCode)
static bool CreateString(const ErrorInfo *, OUString &)
static void SetError(ErrCode)
bool hasTargets() const
Check if the dialog has any valid redaction targets.
bool getTargets(std::vector< std::pair< RedactionTarget, OUString > > &r_aTargets)
Copies targets vector Does a shallow copy.
bool isValidState() const
Check if the dialog is in a valid state.
void Broadcast(const SfxHint &rHint)
OUString GetComment() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
Method to execute a <SfxSlot>s over the Slot-Id.
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
Method to execute a <SfxSlot>s over the Slot-Id.
std::shared_ptr< const SfxFilter > GetFilter4Mime(const OUString &rMime, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
static std::shared_ptr< const SfxFilter > GetDefaultFilterFromFactory(const OUString &rServiceName)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
const std::shared_ptr< const SfxFilter > & GetFilter() const
SfxItemSet & GetItemSet() const
SAL_DLLPRIVATE void SetUpdatePickList(bool)
bool IsOriginallyReadOnly() const
SAL_DLLPRIVATE bool SignDocumentContentUsingCertificate(const css::uno::Reference< css::frame::XModel > &xModel, bool bHasValidDocumentSignature, const css::uno::Reference< css::security::XCertificate > &xCertificate)
void CreateTempFile(bool bReplace=true)
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
SAL_DLLPRIVATE css::uno::Reference< css::embed::XStorage > const & GetZipStorageToSign_Impl(bool bReadOnly=true)
SAL_DLLPRIVATE bool SignContents_Impl(weld::Window *pDialogParent, bool bSignScriptingContent, bool bHasValidDocumentSignature, const OUString &aSignatureLineId=OUString(), const css::uno::Reference< css::security::XCertificate > &xCert=css::uno::Reference< css::security::XCertificate >(), const css::uno::Reference< css::graphic::XGraphic > &xValidGraphic=css::uno::Reference< css::graphic::XGraphic >(), const css::uno::Reference< css::graphic::XGraphic > &xInvalidGraphic=css::uno::Reference< css::graphic::XGraphic >(), const OUString &aComment=OUString())
SfxSlotPool * GetSlotPool() const
void RecheckSignature(bool bAlsoRecheckScriptingSignature)
virtual bool PrepareClose(bool bUI=true)
SAL_DLLPRIVATE bool CommonSaveAs_Impl(const INetURLObject &aURL, const OUString &aFilterName, SfxItemSet &rItemSet, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
SAL_DLLPRIVATE void ExecProps_Impl(SfxRequest &)
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
SAL_DLLPRIVATE void PrintExec_Impl(SfxRequest &)
static SAL_DLLPRIVATE void StateView_Impl(SfxItemSet &)
void SetTitle(const OUString &rTitle)
void AfterSigning(bool bSignSuccess, bool bSignScriptingContent)
void SignSignatureLine(weld::Window *pDialogParent, const OUString &aSignatureLineId, const css::uno::Reference< css::security::XCertificate > &xCert, const css::uno::Reference< css::graphic::XGraphic > &xValidGraphic, const css::uno::Reference< css::graphic::XGraphic > &xInvalidGraphic, const OUString &aComment)
SAL_DLLPRIVATE SignatureState ImplGetSignatureState(bool bScriptingContent=false)
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
ErrCode GetErrorCode() const
bool IsLoadReadonly() const
bool SignDocumentContentUsingCertificate(const css::uno::Reference< css::security::XCertificate > &xCertificate)
bool HasValidSignatures() const
bool isSaveLocked() const
bool IsReadOnlyMedium() const
sal_uInt32 GetModifyPasswordHash() const
virtual std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rItemSet)
bool SignDocumentContent(weld::Window *pDialogParent)
static bool IsOwnStorageFormat(const SfxMedium &)
bool PrepareForSigning(weld::Window *pDialogParent)
Returns true if preparing was successful, else false.
SAL_DLLPRIVATE void CheckIn()
bool IsEnableSetModified() const
SAL_DLLPRIVATE void CancelCheckOut()
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
SAL_DLLPRIVATE void StateProps_Impl(SfxItemSet &)
css::uno::Sequence< css::security::DocumentSignatureInformation > rSignatureInfosRemembered
sal_Int16 QueryHiddenInformation(HiddenWarningFact eFact, weld::Window *pParent)
virtual SfxObjectFactory & GetFactory() const =0
bool isExportLocked() const
bool ResignDocument(css::uno::Sequence< css::security::DocumentSignatureInformation > &rSignaturesInfo)
virtual void Invalidate(sal_uInt16 nId=0) override
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
bool IsUseUserData() const
bool CheckIsReadonly(bool bSignScriptingContent, weld::Window *pDialogParent=nullptr)
SfxModule * GetModule() const
bool IsSignPDF() const
Is this read-only object shell opened via .uno:SignPDF?
SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &)
SAL_DLLPRIVATE void PrintState_Impl(SfxItemSet &)
virtual bool QuerySlotExecutable(sal_uInt16 nSlotId)
SfxMedium * GetMedium() const
void SetReadOnlyUI(bool bReadOnly=true)
SAL_DLLPRIVATE bool APISaveAs_Impl(std::u16string_view aFileName, SfxItemSet &rItemSet, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
css::uno::Reference< css::frame::XModel3 > GetModel() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
css::uno::Reference< css::embed::XStorage > const & GetStorage()
static css::uno::Reference< css::uno::XInterface > GetCurrentComponent()
void SetSaveVersionOnClose(bool bSet)
void EnableSetModified(bool bEnable=true)
void SetUseThumbnailSave(bool _bNew)
void SetUseUserData(bool bNew)
bool IsUseThumbnailSave() const
css::uno::Reference< css::security::XCertificate > GetSignPDFCertificate() const
Gets the certificate that is already picked by the user but not yet used for signing.
bool IsSaveVersionOnClose() const
SAL_DLLPRIVATE void CheckOut()
css::uno::Sequence< css::security::DocumentSignatureInformation > GetDocumentSignatureInformation(bool bScriptingContent, const css::uno::Reference< css::security::XDocumentDigitalSignatures > &xSigner=css::uno::Reference< css::security::XDocumentDigitalSignatures >())
SignatureState GetScriptingSignatureState()
bool SignScriptingContent(weld::Window *pDialogParent)
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
SignatureState GetDocumentSignatureState()
SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &)
SAL_DLLPRIVATE bool ConnectTmpStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xStorage, SfxMedium *pMedium)
SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions() const
SAL_DLLPRIVATE void GetState_Impl(SfxItemSet &)
virtual void SetModified(bool bModified=true)
css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag() const
Gets grab-bagged password info to unprotect change tracking with verification.
static void addPagesToDraw(const uno::Reference< XComponent > &xComponent, sal_Int32 nPages, const std::vector< GDIMetaFile > &aMetaFiles, const std::vector<::Size > &aPageSizes, const PageMargins &aPageMargins, const std::vector< std::pair< RedactionTarget, OUString > > &r_aTableTargets, bool bIsAutoRedact)
static PageMargins getPageMarginsForCalc(const css::uno::Reference< css::frame::XModel > &xModel)
static OUString getStringParam(const SfxRequest &rReq, sal_uInt16 nParamId)
static PageMargins getPageMarginsForWriter(const css::uno::Reference< css::frame::XModel > &xModel)
static void showRedactionToolbar(const SfxViewFrame *pViewFrame)
static bool isRedactMode(const SfxRequest &rReq)
Checks to see if the request has a parameter of IsRedactMode:bool=true.
static void getPageMetaFilesFromDoc(std::vector< GDIMetaFile > &aMetaFiles, std::vector<::Size > &aPageSizes, sal_Int32 nPages, DocumentToGraphicRenderer &aRenderer)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void SetSlot(sal_uInt16 nNewSlot)
const T * GetArg(sal_uInt16 nSlotId) const
Templatized access to the individual parameters of the SfxRequest.
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
SfxCallMode GetCallMode() const
bool IsSynchronCall() const
weld::Window * GetFrameWeld() const
Return the window that should be used as the parent for any dialogs this request creates.
void SetArgs(const SfxAllItemSet &rArgs)
void Done(bool bRemove=false)
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
This method returns the status of the slot with the specified slot ID on the specified interface.
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
const OUString & GetName() const
Returns the name of the Shell object.
SfxViewFrame * GetFrame() const
This method returns a pointer to the <SfxViewFrame> to which this SfxShell instance is associated or ...
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
This method allows you to forward a <SfxRequest> to the specified base <SfxShell>.
virtual SfxUndoManager * GetUndoManager()
Each Subclass of SfxShell can have a <SfxUndoManager>.
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
friend class SfxObjectItem
const SfxSlot * GetSlot(sal_uInt16 nId) const
const OUString & GetUnoName() const
static bool runAsync(const std::shared_ptr< SfxTabDialogController > &rController, const std::function< void(sal_Int32)> &)
bool IsEmptyActions() const
bool IsSaveVersionOnClose() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
void RemoveInfoBar(std::u16string_view sId)
void ExecReload_Impl(SfxRequest &rReq)
SfxDispatcher * GetDispatcher()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxFrame & GetFrame() const
weld::Window * GetFrameWeld() const
bool HasInfoBarWithID(std::u16string_view sId)
VclPtr< SfxInfoBarWindow > AppendInfoBar(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType aInfobarType, bool bShowCloseButton=true)
Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar).
void UpdateInfoBar(std::u16string_view sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType eType)
virtual SfxPrinter * GetPrinter(bool bCreate=false)
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
Invokes the registered callback, if there are any.
void SetStoringHelper(std::shared_ptr< SfxStoringHelper > xHelper)
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
static OUString GetODFVersionFromStorage(const css::uno::Reference< css::embed::XStorage > &xStorage)
const css::uno::Sequence< sal_Int8 > & getSeq() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_GRAY7(0x66, 0x66, 0x66)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_WARN_EXCEPTION_IF(cond, area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
constexpr OUStringLiteral ODFVER_012_TEXT
#define ERRCODE_IO_GENERAL
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
SignatureState getSignatureState(const uno::Sequence< security::DocumentSignatureInformation > &aSigInfo)
OUString convertCommaSeparated(uno::Sequence< OUString > const &i_rSeq)
Reference< XComponentContext > getProcessComponentContext()
std::u16string_view getTitle(std::u16string_view aPath)
HashMap_OWString_Interface aMap
static void sendErrorToLOK(ErrCode error)
IMPL_LINK_NOARG(SfxObjectShell, SignDocumentHandler, weld::Button &, void)
static bool HasSignatureStream(const uno::Reference< embed::XStorage > &xStorage)
Does this ZIP storage have a signature stream?
#define SFX_TITLE_FULLNAME
Sequence< Property > aInfos
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
#define ERRCODE_BASIC_WRONG_ARGS
#define ERRCTX_SFX_SAVEASDOC
OUString SfxResId(TranslateId aId)
#define SFX_IMPL_SUPERCLASS_INTERFACE(Class, SuperClass)
@ NOTVALIDATED_PARTIAL_OK
Certificate could not be validated and the document is only partially signed.
Reference< XController > xController
Reference< XModel > xModel
constexpr OUStringLiteral UNO_NAME_MISC_OBJ_INTEROPGRABBAG