/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if ( rType == PDF_DOCUMENT_TYPE )
{ //add an internal property, used to tell the dialog we want to set a different //string for the ok button //used in filter/source/pdf/impdialog.cxx
uno::Sequence< beans::PropertyValue > aFilterDataValue{
comphelper::makePropertyValue(u"_OkButtonString"_ustr,
SfxResId(STR_PDF_EXPORT_SEND ))
};
//add to the filterdata property, the only one the PDF export filter dialog will care for
uno::Sequence< beans::PropertyValue > aPropsForDialog{
comphelper::makePropertyValue(u"FilterData"_ustr, aFilterDataValue)
};
//when executing the dialog will merge the persistent FilterData properties
xFilterProperties->setPropertyValues( aPropsForDialog );
}
if( xFilterDialog->execute() )
{ //get the filter data const uno::Sequence< beans::PropertyValue > aPropsFromDialog = xFilterProperties->getPropertyValues();
//add them to the args auto pProp = std::find_if(aPropsFromDialog.begin(), aPropsFromDialog.end(),
[](const beans::PropertyValue& rDialogProp) { return rDialogProp.Name == "FilterData"; }); if (pProp != aPropsFromDialog.end())
{ //found the filterdata, add to the storing argument
rArgs.realloc( ++rNumArgs ); auto pArgs = rArgs.getArray();
pArgs[rNumArgs-1].Name = pProp->Name;
pArgs[rNumArgs-1].Value = pProp->Value;
}
eRet = SAVE_SUCCESSFUL;
} else
{ // cancel from dialog, then do not send // If the model is not modified, it could be modified by the dispatch calls. // Therefore set back to modified = false. This should not hurt if we call // on a non-modified model. if ( !bModified )
{ try
{
xModifiable->setModified( false );
} catch( css::beans::PropertyVetoException& )
{
}
}
eRet = SAVE_CANCELLED;
}
} break;
}
}
}
}
} catch( css::uno::RuntimeException& )
{ throw;
} catch( uno::Exception& )
{
}
// We need at least a valid module name and model reference if ( !aModule.isEmpty() && xModel.is() )
{ bool bModified( false ); bool bHasLocation( false ); bool bStoreTo( false );
if ( bStoreTo )
{ // Retrieve filter from type
css::uno::Sequence< css::beans::NamedValue > aQuery( bSendAsPDF ? 3 : 2 ); auto pQuery = aQuery.getArray();
pQuery[0].Name = "Type";
pQuery[0].Value <<= aTypeName;
pQuery[1].Name = "DocumentService";
pQuery[1].Value <<= aModule; if( bSendAsPDF )
{ // #i91419# // FIXME: we want just an export filter. However currently we need // exact flag value as detailed in the filter configuration to get it // this seems to be a bug // without flags we get an import filter here, which is also unwanted
pQuery[2].Name = "Flags";
pQuery[2].Value <<= sal_Int32(0x80042); // SfxFilterFlags: EXPORT ALIEN 3RDPARTY
}
if ( bHasLocation )
{ // Retrieve filter from media descriptor
::comphelper::SequenceAsHashMap aMediaDescrPropsHM( xModel->getArgs() );
OUString aOrgFilterName = aMediaDescrPropsHM.getUnpackedValueOrDefault(
u"FilterName"_ustr,
OUString() ); if ( aOrgFilterName == aFilterName )
{ // We should save the document in the original format. Therefore this // is not a storeTo operation. To support signing in this case, reset // bStoreTo flag.
bStoreTo = false;
}
}
} else
{ if ( bHasLocation )
{ // Retrieve filter from media descriptor
::comphelper::SequenceAsHashMap aMediaDescrPropsHM( xModel->getArgs() );
aFilterName = aMediaDescrPropsHM.getUnpackedValueOrDefault(
u"FilterName"_ustr,
OUString() );
}
// No filter found => error // No type and no location => error if (( aFilterName.isEmpty() ) ||
( aTypeName.isEmpty() && !bHasLocation )) return eRet;
// Use provided save file name. If empty determine file name
aFileName = aSaveFileName; if ( aFileName.isEmpty() )
{ if ( !bHasLocation )
{ // Create a noname file name with the correct extension
aFileName = "noname";
} else
{ // Determine file name from model
INetURLObject aFileObj( xStorable->getLocation() );
aFileName = aFileObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::NONE );
}
}
// No file name => error if ( aFileName.isEmpty() ) return eRet;
// Creates a temporary directory to store a predefined file into it. // This makes it possible to store the file for "send document as e-mail" // with the original file name. We cannot use the original file as // some mail programs need exclusive access.
INetURLObject aFilePathObj( ::utl::CreateTempURL(nullptr, true) );
aFilePathObj.insertName( aFileName );
aFilePathObj.setExtension( aExtension );
if ( bModified || !bHasLocation || bStoreTo || bNeedsPreparation )
{ // Document is modified, is newly created or should be stored in a special format try
{ if( bNeedsPreparation && xPrepareDispatch.is() )
{ try
{
css::uno::Sequence< css::beans::PropertyValue > aDispatchArgs;
xPrepareDispatch->dispatch( aPrepareURL, aDispatchArgs );
} catch ( css::uno::RuntimeException& )
{ throw;
} catch ( css::uno::Exception& )
{
}
}
//check if this is the pdf output filter (i#64555) if( bSendAsPDF )
{
SaveResult eShowPDFFilterDialog = ShowFilterOptionsDialog(
xSMGR, xModel, aFilterName, rType, bModified, nNumArgs, aArgs );
// don't continue on dialog cancel or error if ( eShowPDFFilterDialog != SAVE_SUCCESSFUL ) return eShowPDFFilterDialog;
}
if( !bSendAsPDF )
{
css::util::URL aURL; // #i30432# notify that export is finished - the Writer may want to restore removed content
aURL.Complete = ".uno:MailExportFinished";
xURLTransformer->parseStrict( aURL );
if ( xDispatchProvider.is() )
{
css::uno::Reference< css::frame::XDispatch > xDispatch(
xDispatchProvider->queryDispatch( aURL, OUString(), 0 )); if ( xDispatch.is() )
{ try
{
css::uno::Sequence< css::beans::PropertyValue > aDispatchArgs;
xDispatch->dispatch( aURL, aDispatchArgs );
} catch ( css::uno::RuntimeException& )
{ throw;
} catch ( css::uno::Exception& )
{
}
}
}
} // If the model is not modified, it could be modified by the dispatch calls. // Therefore set back to modified = false. This should not hurt if we call // on a non-modified model. if ( !bModified )
{ try
{
xModifiable->setModified( false );
} catch( css::beans::PropertyVetoException& )
{
}
}
} catch ( css::io::IOException& )
{
eRet = SAVE_ERROR;
}
} else
{ // We need 1:1 copy of the document to preserve an added signature.
aArgs.realloc( ++nNumArgs ); auto pArgs = aArgs.getArray();
pArgs[nNumArgs-1].Name = "CopyStreamIfPossible";
pArgs[nNumArgs-1].Value <<= true;
if ( !xSimpleMailClient.is() )
{ // no mail client support => message box! return SEND_MAIL_ERROR;
}
// we have a simple mail client
css::uno::Reference< XSimpleMailMessage > xSimpleMailMessage = xSimpleMailClient->createSimpleMailMessage(); if ( xSimpleMailMessage.is() )
{
sal_Int32 nSendFlags = SimpleMailClientFlags::DEFAULTS; if ( maFromAddress.isEmpty() )
{ // from address not set, try figure out users e-mail address
CreateFromAddress_Impl( maFromAddress );
}
xSimpleMailMessage->setOriginator( maFromAddress );
// set recipient (only one) for this simple mail server!! if ( nToCount >= 1 )
{
xSimpleMailMessage->setRecipient( mpToList->at( 0 ) );
nSendFlags = SimpleMailClientFlags::NO_USER_INTERFACE;
}
// all other recipient must be handled with CC recipients! if ( nToCount > 1 )
{
Sequence< OUString > aCcRecipientSeq( nToCount - 1 );
std::copy_n(std::next(mpToList->begin()), aCcRecipientSeq.getLength(),
aCcRecipientSeq.getArray());
xSimpleMailMessage->setCcRecipient( aCcRecipientSeq );
}
This function tries to create a From-address with the help of IniManagers. For this the fields 'first name', 'Name' and 'Email' are read from the application-ini-data. If these fields are not set, FALSE is returned.
[Return value]
sal_True: Address could be created. sal_False: Address could not be created.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.