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 :
21 : #include <svl/filenotation.hxx>
22 : #include <svtools/urlcontrol.hxx>
23 : #include <vcl/layout.hxx>
24 :
25 :
26 : namespace svt
27 : {
28 :
29 :
30 :
31 : //= OFileURLControl
32 :
33 :
34 0 : OFileURLControl::OFileURLControl(Window* _pParent, const ResId& _rId)
35 0 : : SvtURLBox(_pParent, _rId, INET_PROT_FILE)
36 : {
37 0 : DisableHistory();
38 0 : }
39 :
40 0 : OFileURLControl::OFileURLControl(Window* _pParent, WinBits nStyle)
41 0 : : SvtURLBox(_pParent, nStyle, INET_PROT_FILE)
42 : {
43 0 : DisableHistory();
44 0 : }
45 :
46 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeOFileURLControl(Window *pParent, VclBuilder::stringmap &)
47 : {
48 : WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP|
49 0 : WB_DROPDOWN|WB_AUTOSIZE|WB_AUTOHSCROLL;
50 0 : OFileURLControl* pListBox = new OFileURLControl(pParent, nWinBits);
51 0 : pListBox->EnableAutoSize(true);
52 0 : return pListBox;
53 : }
54 :
55 :
56 0 : bool OFileURLControl::PreNotify( NotifyEvent& _rNEvt )
57 : {
58 0 : if (GetSubEdit() == _rNEvt.GetWindow())
59 0 : if (EVENT_KEYINPUT == _rNEvt.GetType())
60 0 : if (KEY_RETURN == _rNEvt.GetKeyEvent()->GetKeyCode().GetCode())
61 0 : if (IsInDropDown())
62 0 : m_sPreservedText = GetURL();
63 :
64 0 : return SvtURLBox::PreNotify(_rNEvt);
65 : }
66 :
67 :
68 0 : bool OFileURLControl::Notify( NotifyEvent& _rNEvt )
69 : {
70 0 : if (GetSubEdit() == _rNEvt.GetWindow())
71 0 : if (EVENT_KEYINPUT == _rNEvt.GetType())
72 0 : if (KEY_RETURN == _rNEvt.GetKeyEvent()->GetKeyCode().GetCode())
73 0 : if (IsInDropDown())
74 : {
75 0 : bool nReturn = SvtURLBox::Notify(_rNEvt);
76 :
77 : // build a system dependent (thus more user readable) file name
78 0 : OFileNotation aTransformer(m_sPreservedText, OFileNotation::N_URL);
79 0 : SetText(aTransformer.get(OFileNotation::N_SYSTEM));
80 0 : Modify();
81 :
82 : // Update the pick list
83 0 : UpdatePickList();
84 :
85 0 : return nReturn;
86 : }
87 :
88 0 : return SvtURLBox::Notify(_rNEvt);
89 : }
90 :
91 :
92 3 : } // namespace svt
93 :
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|