Lines 243-251
void SfxMailModel_Impl::MakeValueList( A
Link Here
|
243 |
} |
243 |
} |
244 |
} |
244 |
} |
245 |
|
245 |
|
246 |
SfxMailModel_Impl::SaveResult SfxMailModel_Impl::SaveDocument( String& rFileName, String& rType ) |
246 |
SfxMailModel_Impl::SaveResult SfxMailModel_Impl::SaveDocumentAsFormat( String& rFileName, String& rType, const String& rFilter ) |
247 |
{ |
247 |
{ |
248 |
SaveResult eRet = SAVE_CANCELLED; |
248 |
SaveResult eRet = SAVE_CANCELLED; |
|
|
249 |
bool bSaveAs = ( rFilter.Len() > 0 ); |
250 |
|
249 |
SfxViewFrame* pTopViewFrm = mpBindings->GetDispatcher_Impl()->GetFrame()->GetTopViewFrame(); |
251 |
SfxViewFrame* pTopViewFrm = mpBindings->GetDispatcher_Impl()->GetFrame()->GetTopViewFrame(); |
250 |
SfxObjectShellRef xDocShell = pTopViewFrm->GetObjectShell(); |
252 |
SfxObjectShellRef xDocShell = pTopViewFrm->GetObjectShell(); |
251 |
|
253 |
|
Lines 256-262
SfxMailModel_Impl::SaveResult SfxMailMod
Link Here
|
256 |
BOOL bModified = xDocShell->IsModified(); |
258 |
BOOL bModified = xDocShell->IsModified(); |
257 |
|
259 |
|
258 |
// detect filter |
260 |
// detect filter |
259 |
const SfxFilter* pFilter = xDocShell->GetMedium()->GetFilter(); |
261 |
String sFactoryShortName = String::CreateFromAscii(xDocShell->GetFactory().GetShortName()); |
|
|
262 |
String sFactoryLongName = SfxObjectShell::GetServiceNameFromFactory(sFactoryShortName); |
263 |
SfxFilterMatcher aMatcher( sFactoryShortName ); |
264 |
|
265 |
const SfxFilter* pFilter = NULL; |
266 |
if ( bSaveAs ) |
267 |
pFilter = aMatcher.GetFilter4FilterName( rFilter ); |
268 |
else |
269 |
pFilter = xDocShell->GetMedium()->GetFilter(); |
260 |
sal_Bool bHasFilter = pFilter ? sal_True : sal_False; |
270 |
sal_Bool bHasFilter = pFilter ? sal_True : sal_False; |
261 |
if ( !pFilter ) |
271 |
if ( !pFilter ) |
262 |
{ |
272 |
{ |
Lines 280-285
SfxMailModel_Impl::SaveResult SfxMailMod
Link Here
|
280 |
String aName; |
290 |
String aName; |
281 |
if ( aFileObj.hasExtension() ) |
291 |
if ( aFileObj.hasExtension() ) |
282 |
{ |
292 |
{ |
283 |
pExt = new String( String::CreateFromAscii( "." ) + (OUString) aFileObj.getExtension() ); |
293 |
if ( !bSaveAs ) // Only use extension in NOT save in another |
|
|
294 |
// Format |
295 |
pExt = new String( String::CreateFromAscii( "." ) + (OUString) aFileObj.getExtension() ); |
284 |
aFileObj.removeExtension(); |
296 |
aFileObj.removeExtension(); |
285 |
aLeadingStr = aFileObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); |
297 |
aLeadingStr = aFileObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); |
Lines 305-311
SfxMailModel_Impl::SaveResult SfxMailMod
Link Here
|
305 |
|
313 |
|
306 |
rFileName = aTempFile.GetURL(); |
314 |
rFileName = aTempFile.GetURL(); |
307 |
|
315 |
|
308 |
if ( bModified || !xDocShell->HasName() ) |
316 |
if ( bModified || !xDocShell->HasName() || bSaveAs ) |
309 |
{ |
317 |
{ |
310 |
// prepare for mail export |
318 |
// prepare for mail export |
311 |
SfxDispatcher* pDisp = pTopViewFrm->GetDispatcher(); |
319 |
SfxDispatcher* pDisp = pTopViewFrm->GetDispatcher(); |
Lines 488-579
const SfxFilter* impl_getPDFFilterForDoc
Link Here
|
488 |
return 0; |
496 |
return 0; |
489 |
} |
497 |
} |
490 |
|
498 |
|
491 |
SfxMailModel_Impl::SaveResult SfxMailModel_Impl::SaveDocAsPDF( String& rFileName, String& rType ) |
|
|
492 |
{ |
493 |
SaveResult eRet = SAVE_CANCELLED; |
494 |
SfxViewFrame* pTopViewFrm = mpBindings->GetDispatcher_Impl()->GetFrame()->GetTopViewFrame(); |
495 |
SfxObjectShellRef xDocShell = pTopViewFrm->GetObjectShell(); |
496 |
|
497 |
// save the document |
498 |
if ( xDocShell.Is() && xDocShell->GetMedium() ) |
499 |
{ |
500 |
// save old settings |
501 |
BOOL bModified = xDocShell->IsModified(); |
502 |
// prepare for mail export |
503 |
SfxDispatcher* pDisp = pTopViewFrm->GetDispatcher(); |
504 |
pDisp->Execute( SID_MAIL_PREPAREEXPORT, SFX_CALLMODE_SYNCHRON ); |
505 |
|
506 |
// Get PDF Filter from document |
507 |
String sFactoryShortName = String::CreateFromAscii(xDocShell->GetFactory().GetShortName()); |
508 |
String sFactoryLongName = SfxObjectShell::GetServiceNameFromFactory(sFactoryShortName); |
509 |
SfxFilterMatcher aMatcher( sFactoryShortName ); |
510 |
String aPDFExtension = String::CreateFromAscii( "pdf" ); // Extension without dot! |
511 |
|
512 |
const SfxFilter* pFilter = impl_getPDFFilterForDoc( sFactoryLongName, aMatcher); |
513 |
sal_Bool bHasFilter = pFilter ? sal_True : sal_False; |
514 |
|
515 |
// create temp file name with leading chars and extension |
516 |
sal_Bool bHasName = xDocShell->HasName(); |
517 |
String aLeadingStr; |
518 |
String* pExt = NULL; |
519 |
|
520 |
if ( !bHasName ) |
521 |
aLeadingStr = String( DEFINE_CONST_UNICODE("noname") ); |
522 |
else |
523 |
{ |
524 |
INetURLObject aFileObj = xDocShell->GetMedium()->GetURLObject(); |
525 |
String aName; |
526 |
if ( aFileObj.hasExtension() ) |
527 |
{ |
528 |
pExt = new String( String::CreateFromAscii( "." ) + (OUString)aPDFExtension ); |
529 |
aFileObj.removeExtension(); |
530 |
aLeadingStr = aFileObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); |
531 |
aLeadingStr += String::CreateFromAscii( "_" ); |
532 |
} |
533 |
else |
534 |
{ |
535 |
aLeadingStr = aFileObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); |
536 |
aLeadingStr += String::CreateFromAscii( "_" ); |
537 |
} |
538 |
} |
539 |
|
540 |
if ( pFilter && !pExt ) |
541 |
{ |
542 |
pExt = new String( pFilter->GetWildcard()().GetToken(0) ); |
543 |
// erase the '*' from the extension (e.g. "*.sdw") |
544 |
pExt->Erase( 0, 1 ); |
545 |
} |
546 |
|
547 |
::utl::TempFile aTempFile( aLeadingStr, pExt ); |
548 |
delete pExt; |
549 |
|
550 |
rFileName = aTempFile.GetURL(); |
551 |
|
552 |
// save document to temp file |
553 |
SfxStringItem aFileName( SID_FILE_NAME, rFileName ); |
554 |
const SfxBoolItem *pRet = (const SfxBoolItem*)pDisp->Execute( SID_EXPORTDOCASPDF, SFX_CALLMODE_SYNCHRON, &aFileName, 0L ); |
555 |
BOOL bRet = pRet ? pRet->GetValue() : FALSE; |
556 |
eRet = bRet ? SAVE_SUCCESSFULL : SAVE_CANCELLED; |
557 |
|
558 |
if ( pFilter ) |
559 |
{ |
560 |
// detect content type and expand with the file name |
561 |
rType = pFilter->GetMimeType(); |
562 |
rType += DEFINE_CONST_UNICODE("; name =\""); |
563 |
INetURLObject aFileObj = xDocShell->GetMedium()->GetURLObject(); |
564 |
rType += String(aFileObj.getName( INetURLObject::LAST_SEGMENT, |
565 |
true, INetURLObject::DECODE_WITH_CHARSET )); |
566 |
rType += '\"'; |
567 |
} |
568 |
|
569 |
// restore old settings |
570 |
if ( !bModified && xDocShell->IsEnableSetModified() ) |
571 |
xDocShell->SetModified( FALSE ); |
572 |
} |
573 |
|
574 |
return eRet; |
575 |
} |
576 |
|
577 |
IMPL_LINK_INLINE_START( SfxMailModel_Impl, DoneHdl, void*, EMPTYARG ) |
499 |
IMPL_LINK_INLINE_START( SfxMailModel_Impl, DoneHdl, void*, EMPTYARG ) |
578 |
{ |
500 |
{ |
579 |
mbLoadDone = sal_True; |
501 |
mbLoadDone = sal_True; |
Lines 644-660
void SfxMailModel_Impl::AddAddress( cons
Link Here
|
644 |
} |
566 |
} |
645 |
} |
567 |
} |
646 |
|
568 |
|
647 |
SfxMailModel_Impl::SendMailResult SfxMailModel_Impl::Send( MailDocType eMailDocType ) |
569 |
SfxMailModel_Impl::SendMailResult SfxMailModel_Impl::Send( const String& rFilterName ) |
648 |
{ |
570 |
{ |
649 |
SaveResult eSaveResult; |
571 |
SaveResult eSaveResult; |
650 |
SendMailResult eResult = SEND_MAIL_ERROR; |
572 |
SendMailResult eResult = SEND_MAIL_ERROR; |
651 |
String aFileName, aContentType; |
573 |
String aFileName, aContentType; |
652 |
|
574 |
|
653 |
sal_Bool bSuccessfull = sal_False; |
575 |
sal_Bool bSuccessfull = sal_False; |
654 |
if ( eMailDocType == TYPE_SELF ) |
576 |
eSaveResult = SaveDocumentAsFormat( aFileName, aContentType, rFilterName ); |
655 |
eSaveResult = SaveDocument( aFileName, aContentType ); |
|
|
656 |
else |
657 |
eSaveResult = SaveDocAsPDF( aFileName, aContentType ); |
658 |
|
577 |
|
659 |
if ( eSaveResult == SAVE_SUCCESSFULL ) |
578 |
if ( eSaveResult == SAVE_SUCCESSFULL ) |
660 |
{ |
579 |
{ |