1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <curledit.hxx>
25 OConnectionURLEdit::OConnectionURLEdit(std::unique_ptr
<weld::Entry
> xEntry
, std::unique_ptr
<weld::Label
> xForcedPrefix
)
26 : m_pTypeCollection(nullptr)
27 , m_bShowPrefix(false)
28 , m_xEntry(std::move(xEntry
))
29 , m_xForcedPrefix(std::move(xForcedPrefix
))
33 OConnectionURLEdit::~OConnectionURLEdit()
37 void OConnectionURLEdit::SetTextNoPrefix(const OUString
& _rText
)
39 m_xEntry
->set_text(_rText
);
42 OUString
OConnectionURLEdit::GetTextNoPrefix() const
44 return m_xEntry
->get_text();
47 void OConnectionURLEdit::SetText(const OUString
& _rStr
)
49 Selection
aNoSelection(0,0);
50 SetText(_rStr
, aNoSelection
);
53 void OConnectionURLEdit::SetText(const OUString
& _rStr
, const Selection
& /*_rNewSelection*/)
55 m_xForcedPrefix
->set_visible(m_bShowPrefix
);
57 bool bIsEmpty
= _rStr
.isEmpty();
62 // determine the type of the new URL described by the new text
63 sPrefix
= m_pTypeCollection
->getPrefix(_rStr
);
66 // the fixed text gets the prefix
67 m_xForcedPrefix
->set_label(sPrefix
);
69 // do the real SetText
70 OUString
sNewText( _rStr
);
72 sNewText
= m_pTypeCollection
->cutPrefix( _rStr
);
73 m_xEntry
->set_text(sNewText
);
76 OUString
OConnectionURLEdit::GetText() const
78 return m_xForcedPrefix
->strip_mnemonic(m_xForcedPrefix
->get_label()) + m_xEntry
->get_text();
81 void OConnectionURLEdit::ShowPrefix(bool _bShowPrefix
)
83 m_bShowPrefix
= _bShowPrefix
;
84 m_xForcedPrefix
->set_visible(m_bShowPrefix
);
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */