LCOV - code coverage report
Current view: top level - cui/source/dialogs - hlmailtp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 115 0.0 %
Date: 2012-08-25 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 290 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      30                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      31                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      32                 :            : #include <sfx2/request.hxx>
      33                 :            : 
      34                 :            : #include <comphelper/processfactory.hxx>
      35                 :            : #include <sfx2/viewfrm.hxx>
      36                 :            : #include <unotools/pathoptions.hxx>
      37                 :            : #include <unotools/moduleoptions.hxx>
      38                 :            : 
      39                 :            : #include "hlmailtp.hxx"
      40                 :            : #include "hyperdlg.hrc"
      41                 :            : 
      42                 :            : using namespace ::rtl;
      43                 :            : using namespace ::com::sun::star;
      44                 :            : 
      45                 :            : /*************************************************************************
      46                 :            : |*
      47                 :            : |* Contructor / Destructor
      48                 :            : |*
      49                 :            : |************************************************************************/
      50                 :            : 
      51                 :          0 : SvxHyperlinkMailTp::SvxHyperlinkMailTp ( Window *pParent, const SfxItemSet& rItemSet)
      52                 :          0 : :   SvxHyperlinkTabPageBase ( pParent, CUI_RES( RID_SVXPAGE_HYPERLINK_MAIL ),
      53                 :            :                               rItemSet ),
      54         [ #  # ]:          0 :     maGrpMailNews   ( this, CUI_RES (GRP_MAILNEWS) ),
      55         [ #  # ]:          0 :     maRbtMail       ( this, CUI_RES (RB_LINKTYP_MAIL) ),
      56         [ #  # ]:          0 :     maRbtNews       ( this, CUI_RES (RB_LINKTYP_NEWS) ),
      57         [ #  # ]:          0 :     maFtReceiver    ( this, CUI_RES (FT_RECEIVER) ),
      58                 :            :     maCbbReceiver   ( this, INET_PROT_MAILTO ),
      59         [ #  # ]:          0 :     maBtAdrBook     ( this, CUI_RES (BTN_ADRESSBOOK) ),
      60         [ #  # ]:          0 :     maFtSubject     ( this, CUI_RES (FT_SUBJECT) ),
      61 [ #  # ][ #  # ]:          0 :     maEdSubject     ( this, CUI_RES (ED_SUBJECT) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      62                 :            : {
      63                 :            :     // Disable display of bitmap names.
      64         [ #  # ]:          0 :     maBtAdrBook.EnableTextDisplay (sal_False);
      65                 :            : 
      66         [ #  # ]:          0 :     InitStdControls();
      67         [ #  # ]:          0 :     FreeResource();
      68                 :            : 
      69                 :            :     // Init URL-Box (pos&size, Open-Handler)
      70 [ #  # ][ #  # ]:          0 :     maCbbReceiver.SetPosSizePixel ( LogicToPixel( Point( COL_2, 25 ), MAP_APPFONT ),
      71         [ #  # ]:          0 :                                     LogicToPixel( Size ( 176 - COL_DIFF, 60), MAP_APPFONT ) );
           [ #  #  #  # ]
         [ #  # ][ #  # ]
      72                 :            : 
      73         [ #  # ]:          0 :     maCbbReceiver.Show();
      74         [ #  # ]:          0 :     maCbbReceiver.SetHelpId( HID_HYPERDLG_MAIL_PATH );
      75                 :            : 
      76                 :          0 :     SetExchangeSupport ();
      77                 :            : 
      78                 :            :     // set defaults
      79         [ #  # ]:          0 :     maRbtMail.Check ();
      80                 :            : 
      81                 :            :     // overload handlers
      82         [ #  # ]:          0 :     maRbtMail.SetClickHdl        ( LINK ( this, SvxHyperlinkMailTp, Click_SmartProtocol_Impl ) );
      83         [ #  # ]:          0 :     maRbtNews.SetClickHdl        ( LINK ( this, SvxHyperlinkMailTp, Click_SmartProtocol_Impl ) );
      84         [ #  # ]:          0 :     maBtAdrBook.SetClickHdl      ( LINK ( this, SvxHyperlinkMailTp, ClickAdrBookHdl_Impl ) );
      85         [ #  # ]:          0 :     maCbbReceiver.SetModifyHdl   ( LINK ( this, SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl) );
      86                 :            : 
      87 [ #  # ][ #  # ]:          0 :     if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
         [ #  # ][ #  # ]
      88         [ #  # ]:          0 :         maBtAdrBook.Hide();
      89                 :            : 
      90         [ #  # ]:          0 :     maBtAdrBook.SetAccessibleRelationMemberOf( &maGrpMailNews );
      91         [ #  # ]:          0 :     maBtAdrBook.SetAccessibleRelationLabeledBy( &maFtReceiver );
      92                 :          0 : }
      93                 :            : 
      94 [ #  # ][ #  # ]:          0 : SvxHyperlinkMailTp::~SvxHyperlinkMailTp ()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      95                 :            : {
      96         [ #  # ]:          0 : }
      97                 :            : 
      98                 :            : /*************************************************************************
      99                 :            : |*
     100                 :            : |* Fill the all dialog-controls except controls in groupbox "more..."
     101                 :            : |*
     102                 :            : |************************************************************************/
     103                 :            : 
     104                 :          0 : void SvxHyperlinkMailTp::FillDlgFields ( String& aStrURL )
     105                 :            : {
     106                 :          0 :     const sal_Char sMailtoScheme[] = INET_MAILTO_SCHEME;
     107                 :            : 
     108 [ #  # ][ #  # ]:          0 :     INetURLObject aURL( aStrURL );
     109 [ #  # ][ #  # ]:          0 :     String aStrScheme = GetSchemeFromURL( aStrURL );
                 [ #  # ]
     110                 :            : 
     111                 :            :     // set URL-field and additional controls
     112         [ #  # ]:          0 :     String aStrURLc ( aStrURL );
     113                 :            :     // set additional controls for EMail:
     114 [ #  # ][ #  # ]:          0 :     if ( aStrScheme.SearchAscii( sMailtoScheme ) == 0 )
     115                 :            :     {
     116                 :            :         // Find mail-subject
     117 [ #  # ][ #  # ]:          0 :         String aStrSubject, aStrTmp ( aStrURLc );
     118                 :            : 
     119                 :          0 :         const sal_Char sSubject[] = "subject";
     120 [ #  # ][ #  # ]:          0 :         xub_StrLen nPos = aStrTmp.ToLowerAscii().SearchAscii( sSubject, 0 );
     121         [ #  # ]:          0 :         nPos = aStrTmp.Search( sal_Unicode( '=' ), nPos );
     122                 :            : 
     123         [ #  # ]:          0 :         if ( nPos != STRING_NOTFOUND )
     124 [ #  # ][ #  # ]:          0 :             aStrSubject = aStrURLc.Copy( nPos+1, aStrURLc.Len() );
                 [ #  # ]
     125                 :            : 
     126         [ #  # ]:          0 :         nPos = aStrURLc.Search ( sal_Unicode( '?' ), 0);
     127                 :            : 
     128                 :            :         aStrURLc = aStrURLc.Copy( 0, ( nPos == STRING_NOTFOUND ?
     129 [ #  # ][ #  # ]:          0 :                                            aStrURLc.Len() : nPos ) );
         [ #  # ][ #  # ]
     130                 :            : 
     131 [ #  # ][ #  # ]:          0 :         maEdSubject.SetText ( aStrSubject );
                 [ #  # ]
     132                 :            :     }
     133                 :            :     else
     134                 :            :     {
     135         [ #  # ]:          0 :         maEdSubject.SetText (aEmptyStr);
     136                 :            :     }
     137                 :            : 
     138         [ #  # ]:          0 :     maCbbReceiver.SetText ( aStrURLc );
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 :     SetScheme( aStrScheme );
         [ #  # ][ #  # ]
     141                 :          0 : }
     142                 :            : 
     143                 :            : /*************************************************************************
     144                 :            : |*
     145                 :            : |* retrieve and prepare data from dialog-fields
     146                 :            : |*
     147                 :            : |************************************************************************/
     148                 :            : 
     149                 :          0 : void SvxHyperlinkMailTp::GetCurentItemData ( String& aStrURL, String& aStrName,
     150                 :            :                                              String& aStrIntName, String& aStrFrame,
     151                 :            :                                              SvxLinkInsertMode& eMode )
     152                 :            : {
     153         [ #  # ]:          0 :     aStrURL = CreateAbsoluteURL();
     154                 :          0 :     GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
     155                 :          0 : }
     156                 :            : 
     157                 :          0 : String SvxHyperlinkMailTp::CreateAbsoluteURL() const
     158                 :            : {
     159         [ #  # ]:          0 :     String aStrURL = maCbbReceiver.GetText();
     160 [ #  # ][ #  # ]:          0 :     INetURLObject aURL(aStrURL);
     161                 :            : 
     162         [ #  # ]:          0 :     if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
     163                 :            :     {
     164                 :          0 :         aURL.SetSmartProtocol( GetSmartProtocolFromButtons() );
     165 [ #  # ][ #  # ]:          0 :         aURL.SetSmartURL(aStrURL);
     166                 :            :     }
     167                 :            : 
     168                 :            :     // subject for EMail-url
     169         [ #  # ]:          0 :     if( aURL.GetProtocol() == INET_PROT_MAILTO )
     170                 :            :     {
     171 [ #  # ][ #  # ]:          0 :         if ( maEdSubject.GetText() != aEmptyStr )
         [ #  # ][ #  # ]
     172                 :            :         {
     173         [ #  # ]:          0 :             String aQuery = rtl::OUString("subject=");
     174 [ #  # ][ #  # ]:          0 :             aQuery.Append( maEdSubject.GetText() );
                 [ #  # ]
     175 [ #  # ][ #  # ]:          0 :             aURL.SetParam(aQuery);
                 [ #  # ]
     176                 :            :         }
     177                 :            :     }
     178                 :            : 
     179         [ #  # ]:          0 :     if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
     180 [ #  # ][ #  # ]:          0 :         return aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
     181                 :            :     else //#105788# always create a URL even if it is not valid
     182 [ #  # ][ #  # ]:          0 :         return aStrURL;
                 [ #  # ]
     183                 :            : }
     184                 :            : 
     185                 :            : /*************************************************************************
     186                 :            : |*
     187                 :            : |* static method to create Tabpage
     188                 :            : |*
     189                 :            : |************************************************************************/
     190                 :            : 
     191                 :          0 : IconChoicePage* SvxHyperlinkMailTp::Create( Window* pWindow, const SfxItemSet& rItemSet )
     192                 :            : {
     193         [ #  # ]:          0 :     return( new SvxHyperlinkMailTp( pWindow, rItemSet ) );
     194                 :            : }
     195                 :            : 
     196                 :            : /*************************************************************************
     197                 :            : |*
     198                 :            : |* Set initial focus
     199                 :            : |*
     200                 :            : |************************************************************************/
     201                 :            : 
     202                 :          0 : void SvxHyperlinkMailTp::SetInitFocus()
     203                 :            : {
     204                 :          0 :     maCbbReceiver.GrabFocus();
     205                 :          0 : }
     206                 :            : 
     207                 :            : /*************************************************************************
     208                 :            : |************************************************************************/
     209                 :            : 
     210                 :          0 : void SvxHyperlinkMailTp::SetScheme( const String& aScheme )
     211                 :            : {
     212                 :            :     //if  aScheme is empty or unknown the default beaviour is like it where MAIL
     213                 :          0 :     const sal_Char sNewsScheme[]   = INET_NEWS_SCHEME;
     214                 :            : 
     215         [ #  # ]:          0 :     sal_Bool bMail = aScheme.SearchAscii( sNewsScheme ) != 0;
     216                 :            : 
     217                 :            :     //update protocol button selection:
     218         [ #  # ]:          0 :     maRbtMail.Check(bMail);
     219         [ #  # ]:          0 :     maRbtNews.Check(!bMail);
     220                 :            : 
     221                 :            :     //update target:
     222         [ #  # ]:          0 :     RemoveImproperProtocol(aScheme);
     223         [ #  # ]:          0 :     maCbbReceiver.SetSmartProtocol( GetSmartProtocolFromButtons() );
     224                 :            : 
     225                 :            :     //show/hide  special fields for MAIL:
     226         [ #  # ]:          0 :     maFtSubject.Enable(bMail);
     227         [ #  # ]:          0 :     maEdSubject.Enable(bMail);
     228                 :          0 : }
     229                 :            : 
     230                 :            : /*************************************************************************
     231                 :            : |*
     232                 :            : |* Remove protocol if it does not fit to the current button selection
     233                 :            : |*
     234                 :            : |************************************************************************/
     235                 :            : 
     236                 :          0 : void SvxHyperlinkMailTp::RemoveImproperProtocol(const String& aProperScheme)
     237                 :            : {
     238         [ #  # ]:          0 :     String aStrURL ( maCbbReceiver.GetText() );
     239 [ #  # ][ #  # ]:          0 :     if ( aStrURL != aEmptyStr )
     240                 :            :     {
     241 [ #  # ][ #  # ]:          0 :         String aStrScheme = GetSchemeFromURL( aStrURL );
                 [ #  # ]
     242 [ #  # ][ #  # ]:          0 :         if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme )
         [ #  # ][ #  # ]
                 [ #  # ]
     243                 :            :         {
     244         [ #  # ]:          0 :             aStrURL.Erase ( 0, aStrScheme.Len() );
     245         [ #  # ]:          0 :             maCbbReceiver.SetText ( aStrURL );
     246         [ #  # ]:          0 :         }
     247         [ #  # ]:          0 :     }
     248                 :          0 : }
     249                 :            : 
     250                 :          0 : String SvxHyperlinkMailTp::GetSchemeFromButtons() const
     251                 :            : {
     252         [ #  # ]:          0 :     if( maRbtNews.IsChecked() )
     253         [ #  # ]:          0 :         return rtl::OUString(INET_NEWS_SCHEME);
     254         [ #  # ]:          0 :     return rtl::OUString(INET_MAILTO_SCHEME);
     255                 :            : }
     256                 :            : 
     257                 :          0 : INetProtocol SvxHyperlinkMailTp::GetSmartProtocolFromButtons() const
     258                 :            : {
     259         [ #  # ]:          0 :     if( maRbtNews.IsChecked() )
     260                 :            :     {
     261                 :          0 :         return INET_PROT_NEWS;
     262                 :            :     }
     263                 :          0 :     return INET_PROT_MAILTO;
     264                 :            : }
     265                 :            : 
     266                 :            : /*************************************************************************
     267                 :            : |*
     268                 :            : |* Click on radiobutton : Type EMail
     269                 :            : |*
     270                 :            : |************************************************************************/
     271                 :            : 
     272                 :          0 : IMPL_LINK_NOARG(SvxHyperlinkMailTp, Click_SmartProtocol_Impl)
     273                 :            : {
     274         [ #  # ]:          0 :     String aScheme = GetSchemeFromButtons();
     275         [ #  # ]:          0 :     SetScheme( aScheme );
     276         [ #  # ]:          0 :     return( 0L );
     277                 :            : }
     278                 :            : 
     279                 :            : /*************************************************************************
     280                 :            : |*
     281                 :            : |* Contens of editfield "receiver" modified
     282                 :            : |*
     283                 :            : |************************************************************************/
     284                 :            : 
     285                 :          0 : IMPL_LINK_NOARG(SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl)
     286                 :            : {
     287 [ #  # ][ #  # ]:          0 :     String aScheme = GetSchemeFromURL( maCbbReceiver.GetText() );
                 [ #  # ]
     288         [ #  # ]:          0 :     if(aScheme.Len()!=0)
     289         [ #  # ]:          0 :         SetScheme( aScheme );
     290                 :            : 
     291         [ #  # ]:          0 :     return( 0L );
     292                 :            : }
     293                 :            : 
     294                 :            : /*************************************************************************
     295                 :            : |*
     296                 :            : |* Click on imagebutton : addressbook
     297                 :            : |*
     298                 :            : |************************************************************************/
     299                 :            : 
     300                 :          0 : IMPL_LINK_NOARG(SvxHyperlinkMailTp, ClickAdrBookHdl_Impl)
     301                 :            : {
     302                 :          0 :     SfxViewFrame* pViewFrame = SfxViewFrame::Current();
     303         [ #  # ]:          0 :     if( pViewFrame )
     304                 :            :     {
     305                 :          0 :         SfxItemPool &rPool = pViewFrame->GetPool();
     306         [ #  # ]:          0 :         SfxRequest aReq(SID_VIEW_DATA_SOURCE_BROWSER, 0, rPool);
     307 [ #  # ][ #  # ]:          0 :         pViewFrame->ExecuteSlot( aReq, sal_True );
     308                 :            :     }
     309                 :            : 
     310                 :            : 
     311                 :          0 :     return( 0L );
     312                 :            : }
     313                 :            : 
     314                 :            : 
     315                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10