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"
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2015-02-18 21:58:05 +01:00
|
|
|
|* Constructor / Destructor
|
2009-10-31 00:36:06 +01:00
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SvxHyperlinkMailTp::SvxHyperlinkMailTp ( vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet& rItemSet)
|
2014-06-22 12:24:33 +02:00
|
|
|
: SvxHyperlinkTabPageBase ( pParent, pDlg, "HyperlinkMailPage", "cui/ui/hyperlinkmailpage.ui",
|
|
|
|
rItemSet )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
get(m_pCbbReceiver, "receiver");
|
2015-04-02 18:32:36 +02:00
|
|
|
m_pCbbReceiver->SetSmartProtocol(INetProtocol::Mailto);
|
2014-06-22 12:24:33 +02:00
|
|
|
get(m_pBtAdrBook, "adressbook");
|
|
|
|
m_pBtAdrBook->SetModeImage(Image(CUI_RES(RID_SVXBMP_ADRESSBOOK)));
|
|
|
|
get(m_pFtSubject, "subject_label");
|
|
|
|
get(m_pEdSubject, "subject");
|
|
|
|
|
2010-11-13 00:33:43 -08:00
|
|
|
// Disable display of bitmap names.
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pBtAdrBook->EnableTextDisplay (false);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
InitStdControls();
|
|
|
|
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pCbbReceiver->Show();
|
|
|
|
m_pCbbReceiver->SetHelpId( HID_HYPERDLG_MAIL_PATH );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
SetExchangeSupport ();
|
|
|
|
|
2015-01-08 23:08:34 +01:00
|
|
|
// set handlers
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pBtAdrBook->SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, ClickAdrBookHdl_Impl ) );
|
|
|
|
m_pCbbReceiver->SetModifyHdl ( LINK ( this, SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl) );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2015-04-07 10:59:56 +02:00
|
|
|
if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE ) )
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pBtAdrBook->Hide();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Fill the all dialog-controls except controls in groupbox "more..."
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2013-09-30 11:03:58 +01:00
|
|
|
void SvxHyperlinkMailTp::FillDlgFields(const OUString& rStrURL)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-30 11:03:58 +01:00
|
|
|
OUString aStrScheme = GetSchemeFromURL(rStrURL);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
// set URL-field and additional controls
|
2013-09-30 11:03:58 +01:00
|
|
|
OUString aStrURLc (rStrURL);
|
2009-10-31 00:36:06 +01:00
|
|
|
// set additional controls for EMail:
|
2013-09-09 23:35:25 +02:00
|
|
|
if ( aStrScheme.startsWith( INET_MAILTO_SCHEME ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
// Find mail-subject
|
2013-09-09 23:35:25 +02:00
|
|
|
OUString aStrSubject, aStrTmp( aStrURLc );
|
|
|
|
|
|
|
|
sal_Int32 nPos = aStrTmp.toAsciiLowerCase().indexOf( "subject" );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-09-09 23:35:25 +02:00
|
|
|
if ( nPos != -1 )
|
|
|
|
nPos = aStrTmp.indexOf( '=', nPos );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-09-09 23:35:25 +02:00
|
|
|
if ( nPos != -1 )
|
|
|
|
aStrSubject = aStrURLc.copy( nPos+1 );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-09-09 23:35:25 +02:00
|
|
|
nPos = aStrURLc.indexOf( '?' );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-09-09 23:35:25 +02:00
|
|
|
if ( nPos != -1 )
|
|
|
|
aStrURLc = aStrURLc.copy( 0, nPos );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pEdSubject->SetText ( aStrSubject );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pEdSubject->SetText (aEmptyStr);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pCbbReceiver->SetText ( aStrURLc );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
SetScheme( aStrScheme );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* retrieve and prepare data from dialog-fields
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
void SvxHyperlinkMailTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrName,
|
|
|
|
OUString& aStrIntName, OUString& aStrFrame,
|
2009-10-31 00:36:06 +01:00
|
|
|
SvxLinkInsertMode& eMode )
|
|
|
|
{
|
2013-09-23 07:19:08 +01:00
|
|
|
rStrURL = CreateAbsoluteURL();
|
2009-10-31 00:36:06 +01:00
|
|
|
GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
|
|
|
|
}
|
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString SvxHyperlinkMailTp::CreateAbsoluteURL() const
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
OUString aStrURL = m_pCbbReceiver->GetText();
|
2009-10-31 00:36:06 +01:00
|
|
|
INetURLObject aURL(aStrURL);
|
|
|
|
|
2015-04-02 18:32:36 +02:00
|
|
|
if( aURL.GetProtocol() == INetProtocol::NotValid )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2015-04-01 15:51:04 +03:00
|
|
|
aURL.SetSmartProtocol( INetProtocol::Mailto );
|
2009-10-31 00:36:06 +01:00
|
|
|
aURL.SetSmartURL(aStrURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// subject for EMail-url
|
2015-04-02 18:32:36 +02:00
|
|
|
if( aURL.GetProtocol() == INetProtocol::Mailto )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
if ( m_pEdSubject->GetText() != OUString(aEmptyStr) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aQuery("subject=");
|
2014-06-22 12:24:33 +02:00
|
|
|
aQuery += m_pEdSubject->GetText();
|
2009-10-31 00:36:06 +01:00
|
|
|
aURL.SetParam(aQuery);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 18:32:36 +02:00
|
|
|
if ( aURL.GetProtocol() != INetProtocol::NotValid )
|
2009-10-31 00:36:06 +01:00
|
|
|
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
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
IconChoicePage* SvxHyperlinkMailTp::Create( vcl::Window* pWindow, IconChoiceDialog* pDlg, const SfxItemSet& rItemSet )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2015-02-11 13:20:49 +02:00
|
|
|
return new SvxHyperlinkMailTp( pWindow, pDlg, rItemSet );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Set initial focus
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
|
|
|
void SvxHyperlinkMailTp::SetInitFocus()
|
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pCbbReceiver->GrabFocus();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|************************************************************************/
|
|
|
|
|
2013-09-30 11:03:58 +01:00
|
|
|
void SvxHyperlinkMailTp::SetScheme(const OUString& rScheme)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2015-04-01 15:51:04 +03:00
|
|
|
const bool bMail = true;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
//update target:
|
2013-09-30 11:03:58 +01:00
|
|
|
RemoveImproperProtocol(rScheme);
|
2015-04-01 15:51:04 +03:00
|
|
|
m_pCbbReceiver->SetSmartProtocol( INetProtocol::Mailto );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
//show/hide special fields for MAIL:
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pBtAdrBook->Enable(bMail);
|
|
|
|
m_pEdSubject->Enable(bMail);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Remove protocol if it does not fit to the current button selection
|
|
|
|
|*
|
|
|
|
|************************************************************************/
|
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
void SvxHyperlinkMailTp::RemoveImproperProtocol(const OUString& aProperScheme)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
OUString aStrURL ( m_pCbbReceiver->GetText() );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( aStrURL != aEmptyStr )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aStrScheme = GetSchemeFromURL( aStrURL );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
aStrURL = aStrURL.copy( aStrScheme.getLength() );
|
2014-06-22 12:24:33 +02:00
|
|
|
m_pCbbReceiver->SetText ( aStrURL );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* 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
|
|
|
{
|
2014-06-22 12:24:33 +02:00
|
|
|
OUString aScheme = GetSchemeFromURL( m_pCbbReceiver->GetText() );
|
2013-09-26 08:30:52 +02:00
|
|
|
if(!aScheme.isEmpty())
|
2009-10-31 00:36:06 +01:00
|
|
|
SetScheme( aScheme );
|
|
|
|
|
2015-02-11 13:20:49 +02:00
|
|
|
return 0L;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* 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();
|
2014-10-11 16:01:26 +02:00
|
|
|
SfxRequest aReq(SID_VIEW_DATA_SOURCE_BROWSER, SfxCallMode::SLOT, rPool);
|
2014-03-18 11:23:57 +02:00
|
|
|
pViewFrame->ExecuteSlot( aReq, true );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-11 13:20:49 +02:00
|
|
|
return 0L;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|