Index: sfx2/inc/mailmodelapi.hxx =================================================================== RCS file: /cvs/framework/sfx2/inc/mailmodelapi.hxx,v --- sfx2/inc/mailmodelapi.hxx 19 Jun 2006 22:01:29 -0000 1.5 +++ sfx2/inc/mailmodelapi.hxx 16 Dec 2006 17:44:07 -0000 @@ -99,6 +99,8 @@ private: String maSubject; MailPriority mePriority; + sal_Bool mbIsApiCall; //true if instantiated while serving an API call + sal_Bool mbLoadDone; void ClearList( AddressList_Impl* pList ); @@ -147,6 +149,9 @@ public: sal_Int32 GetCount() const; sal_Bool IsEmpty() const; + + void SetIsApiCall( sal_Bool bIsApiCall ) { mbIsApiCall = bIsApiCall; }; + sal_Bool IsApiCall() { return mbIsApiCall; }; }; BOOL CreateFromAddress_Impl( String& rFrom ); Index: sfx2/source/dialog/mailmodel.cxx =================================================================== RCS file: /cvs/framework/sfx2/source/dialog/mailmodel.cxx,v --- sfx2/source/dialog/mailmodel.cxx 17 Sep 2006 16:33:06 -0000 1.42 +++ sfx2/source/dialog/mailmodel.cxx 16 Dec 2006 17:44:07 -0000 @@ -37,6 +37,16 @@ #include "precompiled_sfx2.hxx" // includes -------------------------------------------------------------- +#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ +#include +#endif + #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include #endif @@ -232,6 +242,7 @@ SfxMailModel::SaveResult SfxMailModel::S rtl::OUString& rFileNamePath ) { SaveResult eRet( SAVE_ERROR ); + bool bSendAsPDF = (rType.compareTo(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf_Portable_Document_Format" ))) == 0); css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); if (!xSMGR.is()) @@ -510,6 +521,107 @@ SfxMailModel::SaveResult SfxMailModel::S } } +//check if not running a script and this is the pdf otput filter + if( !IsApiCall() && bSendAsPDF ) + { + try + { + uno::Sequence < beans::PropertyValue > aProps; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xFilterCFG = + uno::Reference< container::XNameAccess >( + xSMGR->createInstance( + ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" ) ), uno::UNO_QUERY ); + + if ( !xFilterCFG.is() ) + return eRet; + + uno::Any aAny = xFilterCFG->getByName( aFilterName ); + + if ( aAny >>= aProps ) + { + sal_Int32 nPropertyCount = aProps.getLength(); + for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty ) + if( aProps[nProperty].Name.equals( ::rtl::OUString::createFromAscii("UIComponent")) ) + { + ::rtl::OUString aServiceName; + aProps[nProperty].Value >>= aServiceName; + if( aServiceName.getLength() ) + { + uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog( + xSMGR->createInstance( aServiceName ), uno::UNO_QUERY ); + uno::Reference< beans::XPropertyAccess > xFilterProperties( + xFilterDialog, uno::UNO_QUERY ); + + if( xFilterDialog.is() && xFilterProperties.is() ) + { + uno::Reference< document::XExporter > xExporter( xFilterDialog, uno::UNO_QUERY ); + if( xExporter.is() ) + xExporter->setSourceDocument( + uno::Reference< lang::XComponent >( xModel, uno::UNO_QUERY ) ); + + uno::Sequence< beans::PropertyValue > aPropsForDialog(1); + //add an internal property, used to tell the dialog we called it from send mail attachement as pdf + //used in filter/source/pdf/impdialog.cxx + uno::Sequence< beans::PropertyValue > aFilterDataValue(1); + aFilterDataValue[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_DialogCalledFromSendMail" )); + aFilterDataValue[0].Value = css::uno::makeAny( sal_True ); + //add to the filterdata property, the only one the PDF export filter dialog will care for + aPropsForDialog[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterData" )); + aPropsForDialog[0].Value = css::uno::makeAny( aFilterDataValue ); + //when executing the dialog will merge the persistent FilterData properties + xFilterProperties->setPropertyValues( aPropsForDialog ); + + if( xFilterDialog->execute() ) + { + //get the filter data + uno::Sequence< beans::PropertyValue > aPropsFromDialog = xFilterProperties->getPropertyValues(); + //add them to the args + for ( sal_Int32 nInd = 0; nInd < aPropsFromDialog.getLength(); nInd++ ) + { + if( aPropsFromDialog[ nInd ].Name.equals( ::rtl::OUString::createFromAscii( "FilterData" ) ) ) + { + //found the filterdata, add to the storing argument + aArgs.realloc( ++nNumArgs ); + aArgs[nNumArgs-1].Name = aPropsFromDialog[ nInd ].Name; + aArgs[nNumArgs-1].Value = aPropsFromDialog[ nInd ].Value; + break; + } + } + } + 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( sal_False ); + } + catch( com::sun::star::beans::PropertyVetoException& ) + { + } + } + eRet = SAVE_CANCELLED; + return eRet; + } + } + break; + } + } + } + } + catch( css::uno::RuntimeException& ) + { + throw; + } + catch( uno::Exception& ) + { + + } + } + xStorable->storeToURL( aFileURL, aArgs ); rFileNamePath = aFileURL; eRet = SAVE_SUCCESSFULL; @@ -589,6 +701,7 @@ SfxMailModel::SfxMailModel() : mpCcList ( NULL ), mpBccList ( NULL ), mePriority ( PRIO_NORMAL ), + mbIsApiCall ( sal_False ), mbLoadDone ( sal_True ) { } Index: sfx2/source/view/viewsh.cxx =================================================================== RCS file: /cvs/framework/sfx2/source/view/viewsh.cxx,v --- sfx2/source/view/viewsh.cxx 1 Nov 2006 18:29:56 -0000 1.70 +++ sfx2/source/view/viewsh.cxx 16 Dec 2006 17:44:08 -0000 @@ -279,7 +279,12 @@ void SfxViewShell::ExecMisc_Impl( SfxReq eResult = aModel.SaveAndSend( xFrame, rtl::OUString() ); else if ( nId == SID_MAIL_SENDDOCASPDF ) + { + //mode record == from menu or user else if from API, seems that SFX_CALLMODE_RECORD is not set if called from API + //don't know if it is a bug or 'by design' + aModel.SetIsApiCall( !( SFX_CALLMODE_RECORD == ( rReq.GetCallMode() & SFX_CALLMODE_RECORD ) ) ); eResult = aModel.SaveAndSend( xFrame, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf_Portable_Document_Format" ))); + } else if ( nId == SID_MAIL_SENDDOCASMS ) { Index: filter/source/pdf/impdialog.cxx =================================================================== RCS file: /cvs/framework/filter/source/pdf/impdialog.cxx,v --- filter/source/pdf/impdialog.cxx 4 Dec 2006 08:20:58 -0000 1.19 +++ filter/source/pdf/impdialog.cxx 16 Dec 2006 17:44:09 -0000 @@ -243,8 +243,14 @@ ImpPDFTabDialog::ImpPDFTabDialog( Window //last queued is the first to be displayed (or so it seems..) AddTabPage( RID_PDF_TAB_GENER, ImpPDFTabGeneralPage::Create, 0 ); +//get the internal boolean property value (from sfx2/source/dialog/mailmodel.cxx) to select the right text for the Ok button + sal_Bool bUseSendText = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "_DialogCalledFromSendMail" ) ), sal_False ); + //change test on the Ok button: get the relevant string from resources, update it on the button - GetOKButton().SetText( OUString( String( ResId( STR_PDF_EXPORT, &rResMgr ) ) ) ); +//according to the exported pdf file destination + GetOKButton().SetText( ( bUseSendText ) ? OUString( String( ResId( STR_PDF_EXPORT_SEND, &rResMgr ) ) ) + : OUString( String( ResId( STR_PDF_EXPORT, &rResMgr ) ) ) ); + //remove the reset button, not needed in this tabbed dialog RemoveResetButton(); ///////////////// Index: filter/source/pdf/impdialog.hrc =================================================================== RCS file: /cvs/framework/filter/source/pdf/impdialog.hrc,v --- filter/source/pdf/impdialog.hrc 4 Dec 2006 08:21:09 -0000 1.11 +++ filter/source/pdf/impdialog.hrc 16 Dec 2006 17:44:09 -0000 @@ -51,6 +51,7 @@ #define STR_PDF_EXPORT_CB_PERM (RID_PDF_DIALOG_START + 8) #define STR_PDF_EXPORT_OSPWD (RID_PDF_DIALOG_START + 9) #define STR_PDF_EXPORT_ODPWD (RID_PDF_DIALOG_START + 10) +#define STR_PDF_EXPORT_SEND (RID_PDF_DIALOG_START + 11) //ATTENTION: maximum allowed value is( RID_PDF_DIALOG_START + 19) Index: filter/source/pdf/impdialog.src =================================================================== RCS file: /cvs/framework/filter/source/pdf/impdialog.src,v --- filter/source/pdf/impdialog.src 4 Dec 2006 08:21:29 -0000 1.30 +++ filter/source/pdf/impdialog.src 16 Dec 2006 17:44:10 -0000 @@ -43,6 +43,12 @@ String STR_PDF_EXPORT Text[ en-US ] = "E~xport"; }; +//string for TabDialog standard buttons +String STR_PDF_EXPORT_SEND +{ + Text[ en-US ] = "~Send"; +}; + //strings used in encryption UI String STR_PDF_EXPORT_USPWD {