LibreOffice Module dbaccess (master) 1
curledit.cxx
Go to the documentation of this file.
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 <curledit.hxx>
21
22namespace dbaui
23{
24
25OConnectionURLEdit::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))
30{
31}
32
34{
35}
36
37void OConnectionURLEdit::SetTextNoPrefix(const OUString& _rText)
38{
39 m_xEntry->set_text(_rText);
40}
41
43{
44 return m_xEntry->get_text();
45}
46
47void OConnectionURLEdit::SetText(const OUString& _rStr)
48{
49 Selection aNoSelection(0,0);
50 SetText(_rStr, aNoSelection);
51}
52
53void OConnectionURLEdit::SetText(const OUString& _rStr, const Selection& /*_rNewSelection*/)
54{
55 m_xForcedPrefix->set_visible(m_bShowPrefix);
56
57 bool bIsEmpty = _rStr.isEmpty();
58 // calc the prefix
59 OUString sPrefix;
60 if (!bIsEmpty)
61 {
62 // determine the type of the new URL described by the new text
64 }
65
66 // the fixed text gets the prefix
67 m_xForcedPrefix->set_label(sPrefix);
68
69 // do the real SetText
70 OUString sNewText( _rStr );
71 if ( !bIsEmpty )
72 sNewText = m_pTypeCollection->cutPrefix( _rStr );
73 m_xEntry->set_text(sNewText);
74}
75
77{
78 return m_xForcedPrefix->strip_mnemonic(m_xForcedPrefix->get_label()) + m_xEntry->get_text();
79}
80
81void OConnectionURLEdit::ShowPrefix(bool _bShowPrefix)
82{
83 m_bShowPrefix = _bShowPrefix;
84 m_xForcedPrefix->set_visible(m_bShowPrefix);
85}
86
87} // namespace dbaui
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString cutPrefix(std::u16string_view _sURL) const
on a given string, cut the type prefix and return the result
Definition: dsntypes.cxx:84
OUString getPrefix(std::u16string_view _sURL) const
on a given string, return the type prefix
Definition: dsntypes.cxx:110
OUString GetText() const
Definition: curledit.cxx:76
OUString GetTextNoPrefix() const
get the currently set text, excluding the prefix indicating the type
Definition: curledit.cxx:42
std::unique_ptr< weld::Label > m_xForcedPrefix
Definition: curledit.hxx:37
void ShowPrefix(bool _bShowPrefix)
Shows the Prefix.
Definition: curledit.cxx:81
OConnectionURLEdit(std::unique_ptr< weld::Entry > xEntry, std::unique_ptr< weld::Label > xForcedPrefix)
Definition: curledit.cxx:25
void SetText(const OUString &_rStr)
Definition: curledit.cxx:47
std::unique_ptr< weld::Entry > m_xEntry
Definition: curledit.hxx:36
::dbaccess::ODsnTypeCollection * m_pTypeCollection
Definition: curledit.hxx:32
void SetTextNoPrefix(const OUString &_rText)
set a new text, leave the current prefix unchanged
Definition: curledit.cxx:37
OUString sPrefix