Files
libreoffice/cui/source/dialogs/hlmailtp.cxx

249 lines
7.7 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: clarify Option->Language UI option Patch contributed by Herbert Duerr http://svn.apache.org/viewvc?view=revision&revision=1173991 cws mba34issues01: #i117712#: fix several resource errors introduced by IAccessible2 implementation Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1173991 cws mba34issues01: #i117709#: add missing string resource Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1172348 cws mba34issues01: #i117716#: fix missing resources my removing unused code Patch contributed by Mathias Bauer http://svn.apache.org/viewvc?view=revision&revision=1172345 re-add Crystal, Tango, Oxygen icon theme listings. correct method signature Patch contributed by Jean-Louis 'Hans' Fuchs http://svn.apache.org/viewvc?view=revision&revision=1306725 i#119063 - correct serf integration Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1300521 i#119036 - adapt serf integration -- use transfer-encoding 'chunked' on HTTPS -- switch transfer-encoding between 'chunked' and none on 413 HTTP status code -- refactoring -- improve user experience of certification dialog - only shown once Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1299727 118569: Use whole certification chain for verification. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1295493 serf integration: improve credential input handling Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1294557 warning-free ucb/source/ucp/webdav Patch contributed by Pavel Janik http://svn.apache.org/viewvc?view=revision&revision=1294086 some refactoring to PROPPATCH and PROPFIND requests Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1293281 i#118569: Replace neon with serf Patch contributed by Oliver-Rainer Wittmann http://svn.apache.org/viewvc?view=revision&revision=1292832 http://svn.apache.org/viewvc?view=revision&revision=1292794 remove OS/2 conditionals for now. re-enable webdav unit tests.
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;
/*************************************************************************
|*
|* Constructor / Destructor
2009-10-31 00:36:06 +01:00
|*
|************************************************************************/
SvxHyperlinkMailTp::SvxHyperlinkMailTp ( vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet& rItemSet)
: SvxHyperlinkTabPageBase ( pParent, pDlg, "HyperlinkMailPage", "cui/ui/hyperlinkmailpage.ui",
rItemSet )
2009-10-31 00:36:06 +01:00
{
get(m_pCbbReceiver, "receiver");
m_pCbbReceiver->SetSmartProtocol(INetProtocol::Mailto);
get(m_pBtAdrBook, "adressbook");
m_pBtAdrBook->SetModeImage(Image(CUI_RES(RID_SVXBMP_ADRESSBOOK)));
get(m_pFtSubject, "subject_label");
get(m_pEdSubject, "subject");
// Disable display of bitmap names.
m_pBtAdrBook->EnableTextDisplay (false);
2009-10-31 00:36:06 +01:00
InitStdControls();
m_pCbbReceiver->Show();
m_pCbbReceiver->SetHelpId( HID_HYPERDLG_MAIL_PATH );
2009-10-31 00:36:06 +01:00
SetExchangeSupport ();
// set handlers
m_pBtAdrBook->SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, ClickAdrBookHdl_Impl ) );
m_pCbbReceiver->SetModifyHdl ( LINK ( this, SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl) );
2009-10-31 00:36:06 +01:00
if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::DATABASE ) )
m_pBtAdrBook->Hide();
2009-10-31 00:36:06 +01:00
}
/*************************************************************************
|*
|* Fill the all dialog-controls except controls in groupbox "more..."
|*
|************************************************************************/
void SvxHyperlinkMailTp::FillDlgFields(const OUString& rStrURL)
2009-10-31 00:36:06 +01:00
{
OUString aStrScheme = GetSchemeFromURL(rStrURL);
2009-10-31 00:36:06 +01:00
// set URL-field and additional controls
OUString aStrURLc (rStrURL);
2009-10-31 00:36:06 +01:00
// set additional controls for EMail:
if ( aStrScheme.startsWith( INET_MAILTO_SCHEME ) )
2009-10-31 00:36:06 +01:00
{
// Find mail-subject
OUString aStrSubject, aStrTmp( aStrURLc );
sal_Int32 nPos = aStrTmp.toAsciiLowerCase().indexOf( "subject" );
2009-10-31 00:36:06 +01:00
if ( nPos != -1 )
nPos = aStrTmp.indexOf( '=', nPos );
2009-10-31 00:36:06 +01:00
if ( nPos != -1 )
aStrSubject = aStrURLc.copy( nPos+1 );
2009-10-31 00:36:06 +01:00
nPos = aStrURLc.indexOf( '?' );
2009-10-31 00:36:06 +01:00
if ( nPos != -1 )
aStrURLc = aStrURLc.copy( 0, nPos );
2009-10-31 00:36:06 +01:00
m_pEdSubject->SetText ( aStrSubject );
2009-10-31 00:36:06 +01:00
}
else
{
m_pEdSubject->SetText (aEmptyStr);
2009-10-31 00:36:06 +01:00
}
m_pCbbReceiver->SetText ( aStrURLc );
2009-10-31 00:36:06 +01:00
SetScheme( aStrScheme );
}
/*************************************************************************
|*
|* retrieve and prepare data from dialog-fields
|*
|************************************************************************/
void SvxHyperlinkMailTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrName,
OUString& aStrIntName, OUString& aStrFrame,
2009-10-31 00:36:06 +01:00
SvxLinkInsertMode& eMode )
{
rStrURL = CreateAbsoluteURL();
2009-10-31 00:36:06 +01:00
GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
}
OUString SvxHyperlinkMailTp::CreateAbsoluteURL() const
2009-10-31 00:36:06 +01:00
{
OUString aStrURL = m_pCbbReceiver->GetText();
2009-10-31 00:36:06 +01:00
INetURLObject aURL(aStrURL);
if( aURL.GetProtocol() == INetProtocol::NotValid )
2009-10-31 00:36:06 +01:00
{
aURL.SetSmartProtocol( INetProtocol::Mailto );
2009-10-31 00:36:06 +01:00
aURL.SetSmartURL(aStrURL);
}
// subject for EMail-url
if( aURL.GetProtocol() == INetProtocol::Mailto )
2009-10-31 00:36:06 +01:00
{
if ( m_pEdSubject->GetText() != OUString(aEmptyStr) )
2009-10-31 00:36:06 +01:00
{
OUString aQuery("subject=");
aQuery += m_pEdSubject->GetText();
2009-10-31 00:36:06 +01:00
aURL.SetParam(aQuery);
}
}
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
|*
|************************************************************************/
IconChoicePage* SvxHyperlinkMailTp::Create( vcl::Window* pWindow, IconChoiceDialog* pDlg, const SfxItemSet& rItemSet )
2009-10-31 00:36:06 +01:00
{
return new SvxHyperlinkMailTp( pWindow, pDlg, rItemSet );
2009-10-31 00:36:06 +01:00
}
/*************************************************************************
|*
|* Set initial focus
|*
|************************************************************************/
void SvxHyperlinkMailTp::SetInitFocus()
{
m_pCbbReceiver->GrabFocus();
2009-10-31 00:36:06 +01:00
}
/*************************************************************************
|************************************************************************/
void SvxHyperlinkMailTp::SetScheme(const OUString& rScheme)
2009-10-31 00:36:06 +01:00
{
const bool bMail = true;
2009-10-31 00:36:06 +01:00
//update target:
RemoveImproperProtocol(rScheme);
m_pCbbReceiver->SetSmartProtocol( INetProtocol::Mailto );
2009-10-31 00:36:06 +01:00
//show/hide special fields for MAIL:
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
|*
|************************************************************************/
void SvxHyperlinkMailTp::RemoveImproperProtocol(const OUString& aProperScheme)
2009-10-31 00:36:06 +01:00
{
OUString aStrURL ( m_pCbbReceiver->GetText() );
2009-10-31 00:36:06 +01:00
if ( aStrURL != aEmptyStr )
{
OUString aStrScheme = GetSchemeFromURL( aStrURL );
2009-10-31 00:36:06 +01:00
if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme )
{
aStrURL = aStrURL.copy( aStrScheme.getLength() );
m_pCbbReceiver->SetText ( aStrURL );
2009-10-31 00:36:06 +01:00
}
}
}
/*************************************************************************
|*
|* Contens of editfield "receiver" modified
|*
|************************************************************************/
IMPL_LINK_NOARG(SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl)
2009-10-31 00:36:06 +01:00
{
OUString aScheme = GetSchemeFromURL( m_pCbbReceiver->GetText() );
if(!aScheme.isEmpty())
2009-10-31 00:36:06 +01:00
SetScheme( aScheme );
return 0L;
2009-10-31 00:36:06 +01:00
}
/*************************************************************************
|*
|* Click on imagebutton : addressbook
|*
|************************************************************************/
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, SfxCallMode::SLOT, rPool);
pViewFrame->ExecuteSlot( aReq, true );
2009-10-31 00:36:06 +01:00
}
return 0L;
2009-10-31 00:36:06 +01:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */