Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svl/filenotation.hxx>
21 : #include <svtools/urlcontrol.hxx>
22 : #include <vcl/layout.hxx>
23 : #include <vcl/builderfactory.hxx>
24 :
25 : namespace svt
26 : {
27 : //= OFileURLControl
28 0 : OFileURLControl::OFileURLControl(vcl::Window* _pParent, WinBits nStyle)
29 0 : : SvtURLBox(_pParent, nStyle, INetProtocol::File)
30 : {
31 0 : DisableHistory();
32 0 : }
33 :
34 0 : VCL_BUILDER_DECL_FACTORY(OFileURLControl)
35 : {
36 : (void)rMap;
37 : WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP|
38 0 : WB_DROPDOWN|WB_AUTOSIZE|WB_AUTOHSCROLL;
39 0 : VclPtrInstance<OFileURLControl> pListBox(pParent, nWinBits);
40 0 : pListBox->EnableAutoSize(true);
41 0 : rRet = pListBox;
42 0 : }
43 :
44 0 : bool OFileURLControl::PreNotify( NotifyEvent& _rNEvt )
45 : {
46 0 : if (GetSubEdit() == _rNEvt.GetWindow())
47 0 : if (MouseNotifyEvent::KEYINPUT == _rNEvt.GetType())
48 0 : if (KEY_RETURN == _rNEvt.GetKeyEvent()->GetKeyCode().GetCode())
49 0 : if (IsInDropDown())
50 0 : m_sPreservedText = GetURL();
51 :
52 0 : return SvtURLBox::PreNotify(_rNEvt);
53 : }
54 :
55 0 : bool OFileURLControl::Notify( NotifyEvent& _rNEvt )
56 : {
57 0 : if (GetSubEdit() == _rNEvt.GetWindow())
58 0 : if (MouseNotifyEvent::KEYINPUT == _rNEvt.GetType())
59 0 : if (KEY_RETURN == _rNEvt.GetKeyEvent()->GetKeyCode().GetCode())
60 0 : if (IsInDropDown())
61 : {
62 0 : bool nReturn = SvtURLBox::Notify(_rNEvt);
63 :
64 : // build a system dependent (thus more user readable) file name
65 0 : OFileNotation aTransformer(m_sPreservedText, OFileNotation::N_URL);
66 0 : SetText(aTransformer.get(OFileNotation::N_SYSTEM));
67 0 : Modify();
68 :
69 : // Update the pick list
70 0 : UpdatePickList();
71 :
72 0 : return nReturn;
73 : }
74 :
75 0 : return SvtURLBox::Notify(_rNEvt);
76 : }
77 798 : } // namespace svt
78 :
79 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|