2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-04 11:25:41 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include <com/sun/star/frame/XDispatchProvider.hpp>
|
|
|
|
#include <com/sun/star/util/XURLTransformer.hpp>
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <unotools/pathoptions.hxx>
|
|
|
|
#include <unotools/moduleoptions.hxx>
|
|
|
|
|
|
|
|
#include "hlmailtp.hxx"
|
|
|
|
#include "hyperdlg.hrc"
|
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Contructor / Destructor
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
SvxHyperlinkMailTp::SvxHyperlinkMailTp ( Window *pParent, const SfxItemSet& rItemSet)
|
2009-11-02 20:49:14 +01:00
|
|
|
: SvxHyperlinkTabPageBase ( pParent, CUI_RES( RID_SVXPAGE_HYPERLINK_MAIL ),
|
2009-10-31 00:36:06 +01:00
|
|
|
rItemSet ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maGrpMailNews ( this, CUI_RES (GRP_MAILNEWS) ),
|
|
|
|
maRbtMail ( this, CUI_RES (RB_LINKTYP_MAIL) ),
|
|
|
|
maRbtNews ( this, CUI_RES (RB_LINKTYP_NEWS) ),
|
|
|
|
maFtReceiver ( this, CUI_RES (FT_RECEIVER) ),
|
2009-10-31 00:36:06 +01:00
|
|
|
maCbbReceiver ( this, INET_PROT_MAILTO ),
|
2009-11-02 20:49:14 +01:00
|
|
|
maBtAdrBook ( this, CUI_RES (BTN_ADRESSBOOK) ),
|
|
|
|
maFtSubject ( this, CUI_RES (FT_SUBJECT) ),
|
|
|
|
maEdSubject ( this, CUI_RES (ED_SUBJECT) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-13 00:33:43 -08:00
|
|
|
// Disable display of bitmap names.
|
2011-01-14 12:41:27 +01:00
|
|
|
maBtAdrBook.EnableTextDisplay (sal_False);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
InitStdControls();
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
// Init URL-Box (pos&size, Open-Handler)
|
|
|
|
maCbbReceiver.SetPosSizePixel ( LogicToPixel( Point( COL_2, 25 ), MAP_APPFONT ),
|
|
|
|
LogicToPixel( Size ( 176 - COL_DIFF, 60), MAP_APPFONT ) );
|
|
|
|
|
|
|
|
maCbbReceiver.Show();
|
|
|
|
maCbbReceiver.SetHelpId( HID_HYPERDLG_MAIL_PATH );
|
|
|
|
|
|
|
|
SetExchangeSupport ();
|
|
|
|
|
|
|
|
// set defaults
|
|
|
|
maRbtMail.Check ();
|
|
|
|
|
|
|
|
// overload handlers
|
|
|
|
maRbtMail.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, Click_SmartProtocol_Impl ) );
|
|
|
|
maRbtNews.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, Click_SmartProtocol_Impl ) );
|
|
|
|
maBtAdrBook.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, ClickAdrBookHdl_Impl ) );
|
|
|
|
maCbbReceiver.SetModifyHdl ( LINK ( this, SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl) );
|
|
|
|
|
|
|
|
if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
|
|
|
|
maBtAdrBook.Hide();
|
2011-01-20 12:21:31 +01:00
|
|
|
|
|
|
|
maBtAdrBook.SetAccessibleRelationMemberOf( &maGrpMailNews );
|
|
|
|
maBtAdrBook.SetAccessibleRelationLabeledBy( &maFtReceiver );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SvxHyperlinkMailTp::~SvxHyperlinkMailTp ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Fill the all dialog-controls except controls in groupbox "more..."
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkMailTp::FillDlgFields ( String& aStrURL )
|
|
|
|
{
|
|
|
|
const sal_Char sMailtoScheme[] = INET_MAILTO_SCHEME;
|
|
|
|
|
|
|
|
INetURLObject aURL( aStrURL );
|
|
|
|
String aStrScheme = GetSchemeFromURL( aStrURL );
|
|
|
|
|
|
|
|
// set URL-field and additional controls
|
|
|
|
String aStrURLc ( aStrURL );
|
|
|
|
// set additional controls for EMail:
|
|
|
|
if ( aStrScheme.SearchAscii( sMailtoScheme ) == 0 )
|
|
|
|
{
|
|
|
|
// Find mail-subject
|
|
|
|
String aStrSubject, aStrTmp ( aStrURLc );
|
|
|
|
|
|
|
|
const sal_Char sSubject[] = "subject";
|
|
|
|
xub_StrLen nPos = aStrTmp.ToLowerAscii().SearchAscii( sSubject, 0 );
|
|
|
|
nPos = aStrTmp.Search( sal_Unicode( '=' ), nPos );
|
|
|
|
|
|
|
|
if ( nPos != STRING_NOTFOUND )
|
|
|
|
aStrSubject = aStrURLc.Copy( nPos+1, aStrURLc.Len() );
|
|
|
|
|
|
|
|
nPos = aStrURLc.Search ( sal_Unicode( '?' ), 0);
|
|
|
|
|
|
|
|
aStrURLc = aStrURLc.Copy( 0, ( nPos == STRING_NOTFOUND ?
|
|
|
|
aStrURLc.Len() : nPos ) );
|
|
|
|
|
|
|
|
maEdSubject.SetText ( aStrSubject );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maEdSubject.SetText (aEmptyStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
maCbbReceiver.SetText ( aStrURLc );
|
|
|
|
|
|
|
|
SetScheme( aStrScheme );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* retrieve and prepare data from dialog-fields
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkMailTp::GetCurentItemData ( String& aStrURL, String& aStrName,
|
|
|
|
String& aStrIntName, String& aStrFrame,
|
|
|
|
SvxLinkInsertMode& eMode )
|
|
|
|
{
|
|
|
|
aStrURL = CreateAbsoluteURL();
|
|
|
|
GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
String SvxHyperlinkMailTp::CreateAbsoluteURL() const
|
|
|
|
{
|
|
|
|
String aStrURL = maCbbReceiver.GetText();
|
|
|
|
INetURLObject aURL(aStrURL);
|
|
|
|
|
|
|
|
if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
|
|
|
|
{
|
|
|
|
aURL.SetSmartProtocol( GetSmartProtocolFromButtons() );
|
|
|
|
aURL.SetSmartURL(aStrURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// subject for EMail-url
|
|
|
|
if( aURL.GetProtocol() == INET_PROT_MAILTO )
|
|
|
|
{
|
2013-01-21 14:32:09 +01:00
|
|
|
if ( maEdSubject.GetText() != OUString(aEmptyStr) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
String aQuery = OUString("subject=");
|
2009-10-31 00:36:06 +01:00
|
|
|
aQuery.Append( maEdSubject.GetText() );
|
|
|
|
aURL.SetParam(aQuery);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
|
|
|
|
return aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
|
|
|
|
else //#105788# always create a URL even if it is not valid
|
|
|
|
return aStrURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* static method to create Tabpage
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
IconChoicePage* SvxHyperlinkMailTp::Create( Window* pWindow, const SfxItemSet& rItemSet )
|
|
|
|
{
|
|
|
|
return( new SvxHyperlinkMailTp( pWindow, rItemSet ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Set initial focus
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkMailTp::SetInitFocus()
|
|
|
|
{
|
|
|
|
maCbbReceiver.GrabFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkMailTp::SetScheme( const String& aScheme )
|
|
|
|
{
|
|
|
|
//if aScheme is empty or unknown the default beaviour is like it where MAIL
|
|
|
|
const sal_Char sNewsScheme[] = INET_NEWS_SCHEME;
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bMail = aScheme.SearchAscii( sNewsScheme ) != 0;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
//update protocol button selection:
|
|
|
|
maRbtMail.Check(bMail);
|
|
|
|
maRbtNews.Check(!bMail);
|
|
|
|
|
|
|
|
//update target:
|
|
|
|
RemoveImproperProtocol(aScheme);
|
|
|
|
maCbbReceiver.SetSmartProtocol( GetSmartProtocolFromButtons() );
|
|
|
|
|
|
|
|
//show/hide special fields for MAIL:
|
|
|
|
maFtSubject.Enable(bMail);
|
|
|
|
maEdSubject.Enable(bMail);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Remove protocol if it does not fit to the current button selection
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkMailTp::RemoveImproperProtocol(const String& aProperScheme)
|
|
|
|
{
|
|
|
|
String aStrURL ( maCbbReceiver.GetText() );
|
|
|
|
if ( aStrURL != aEmptyStr )
|
|
|
|
{
|
|
|
|
String aStrScheme = GetSchemeFromURL( aStrURL );
|
|
|
|
if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme )
|
|
|
|
{
|
|
|
|
aStrURL.Erase ( 0, aStrScheme.Len() );
|
|
|
|
maCbbReceiver.SetText ( aStrURL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String SvxHyperlinkMailTp::GetSchemeFromButtons() const
|
|
|
|
{
|
|
|
|
if( maRbtNews.IsChecked() )
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString(INET_NEWS_SCHEME);
|
|
|
|
return OUString(INET_MAILTO_SCHEME);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
INetProtocol SvxHyperlinkMailTp::GetSmartProtocolFromButtons() const
|
|
|
|
{
|
|
|
|
if( maRbtNews.IsChecked() )
|
|
|
|
{
|
|
|
|
return INET_PROT_NEWS;
|
|
|
|
}
|
|
|
|
return INET_PROT_MAILTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Click on radiobutton : Type EMail
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SvxHyperlinkMailTp, Click_SmartProtocol_Impl)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
String aScheme = GetSchemeFromButtons();
|
|
|
|
SetScheme( aScheme );
|
|
|
|
return( 0L );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Contens of editfield "receiver" modified
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
String aScheme = GetSchemeFromURL( maCbbReceiver.GetText() );
|
|
|
|
if(aScheme.Len()!=0)
|
|
|
|
SetScheme( aScheme );
|
|
|
|
|
|
|
|
return( 0L );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Click on imagebutton : addressbook
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SvxHyperlinkMailTp, ClickAdrBookHdl_Impl)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
|
|
|
|
if( pViewFrame )
|
|
|
|
{
|
|
|
|
SfxItemPool &rPool = pViewFrame->GetPool();
|
|
|
|
SfxRequest aReq(SID_VIEW_DATA_SOURCE_BROWSER, 0, rPool);
|
|
|
|
pViewFrame->ExecuteSlot( aReq, sal_True );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return( 0L );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|