1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svtools.hxx" 26 #include <svtools/fileurlbox.hxx> 27 #include <osl/file.h> 28 #include "svl/filenotation.hxx" 29 30 //......................................................................... 31 namespace svt 32 { 33 //......................................................................... 34 35 //===================================================================== 36 //= FileURLBox 37 //===================================================================== 38 //--------------------------------------------------------------------- FileURLBox(Window * _pParent)39 FileURLBox::FileURLBox(Window* _pParent) 40 :SvtURLBox(_pParent, INET_PROT_FILE) 41 { 42 DisableHistory(); 43 } 44 45 //--------------------------------------------------------------------- FileURLBox(Window * _pParent,WinBits _nStyle)46 FileURLBox::FileURLBox( Window* _pParent, WinBits _nStyle ) 47 :SvtURLBox( _pParent, _nStyle, INET_PROT_FILE ) 48 { 49 DisableHistory(); 50 } 51 52 //--------------------------------------------------------------------- FileURLBox(Window * _pParent,const ResId & _rId)53 FileURLBox::FileURLBox(Window* _pParent, const ResId& _rId) 54 :SvtURLBox(_pParent, _rId, INET_PROT_FILE) 55 { 56 DisableHistory(); 57 } 58 59 //--------------------------------------------------------------------- DisplayURL(const String & _rURL)60 void FileURLBox::DisplayURL( const String& _rURL ) 61 { 62 String sOldText = GetText(); 63 64 OFileNotation aTransformer( _rURL, OFileNotation::N_URL ); 65 String sNewText = aTransformer.get( OFileNotation::N_SYSTEM ); 66 SetText( sNewText ); 67 68 if ( sOldText != sNewText ) 69 Modify(); 70 71 UpdatePickList(); 72 } 73 74 //--------------------------------------------------------------------- PreNotify(NotifyEvent & _rNEvt)75 long FileURLBox::PreNotify( NotifyEvent& _rNEvt ) 76 { 77 switch ( _rNEvt.GetType() ) 78 { 79 case EVENT_KEYINPUT: 80 if ( ( GetSubEdit() == _rNEvt.GetWindow() ) 81 && ( KEY_RETURN == _rNEvt.GetKeyEvent()->GetKeyCode().GetCode() ) 82 && ( IsInDropDown() ) 83 ) 84 m_sPreservedText = GetURL(); 85 break; 86 87 case EVENT_LOSEFOCUS: 88 if ( IsWindowOrChild( _rNEvt.GetWindow() ) ) 89 DisplayURL( GetText() ); 90 break; 91 } 92 93 return SvtURLBox::PreNotify(_rNEvt); 94 } 95 96 //--------------------------------------------------------------------- Notify(NotifyEvent & _rNEvt)97 long FileURLBox::Notify( NotifyEvent& _rNEvt ) 98 { 99 switch ( _rNEvt.GetType() ) 100 { 101 case EVENT_KEYINPUT: 102 if ( ( GetSubEdit() == _rNEvt.GetWindow() ) 103 && ( KEY_RETURN == _rNEvt.GetKeyEvent()->GetKeyCode().GetCode() ) 104 && ( IsInDropDown() ) 105 ) 106 { 107 long nReturn = SvtURLBox::Notify(_rNEvt); 108 DisplayURL( m_sPreservedText ); 109 return nReturn; 110 } 111 break; 112 } 113 114 return SvtURLBox::Notify(_rNEvt); 115 } 116 117 //......................................................................... 118 } // namespace svt 119 //......................................................................... 120 121