tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / vcl / unx / generic / dtrans / config.cxx
blobc9ece3c8d98850f11078c2b26eb893bf6978b453
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <o3tl/any.hxx>
21 #include <sal/log.hxx>
22 #include <unotools/configitem.hxx>
24 #include "X11_selection.hxx"
26 constexpr OUStringLiteral SETTINGS_CONFIGNODE = u"VCL/Settings/Transfer";
27 constexpr OUString SELECTION_PROPERTY = u"SelectionTimeout"_ustr;
29 namespace x11
32 namespace {
34 class DtransX11ConfigItem : public ::utl::ConfigItem
36 sal_Int32 m_nSelectionTimeout;
38 virtual void Notify( const css::uno::Sequence< OUString >& rPropertyNames ) override;
39 virtual void ImplCommit() override;
41 public:
42 DtransX11ConfigItem();
44 sal_Int32 getSelectionTimeout() const { return m_nSelectionTimeout; }
51 using namespace com::sun::star::uno;
52 using namespace x11;
54 sal_Int32 SelectionManager::getSelectionTimeout()
56 if( m_nSelectionTimeout < 1 )
58 DtransX11ConfigItem aCfg;
59 m_nSelectionTimeout = aCfg.getSelectionTimeout();
60 #if OSL_DEBUG_LEVEL > 1
61 SAL_INFO("vcl.unx.dtrans", "initialized selection timeout to "
62 << m_nSelectionTimeout
63 << " seconds.");
64 #endif
66 return m_nSelectionTimeout;
70 * DtransX11ConfigItem constructor
73 DtransX11ConfigItem::DtransX11ConfigItem() :
74 ConfigItem( SETTINGS_CONFIGNODE,
75 ConfigItemMode::NONE ),
76 m_nSelectionTimeout( 3 )
78 Sequence<OUString> aKeys { SELECTION_PROPERTY };
79 const Sequence< Any > aValues = GetProperties( aKeys );
80 #if OSL_DEBUG_LEVEL > 1
81 SAL_INFO("vcl.unx.dtrans", "found "
82 << aValues.getLength()
83 << " properties for "
84 << SELECTION_PROPERTY);
85 #endif
86 for( Any const & value : aValues )
88 if( auto pLine = o3tl::tryAccess<OUString>(value) )
90 if( !pLine->isEmpty() )
92 m_nSelectionTimeout = pLine->toInt32();
93 if( m_nSelectionTimeout < 1 )
94 m_nSelectionTimeout = 1;
96 #if OSL_DEBUG_LEVEL > 1
97 SAL_INFO("vcl.unx.dtrans", "found SelectionTimeout \"" << *pLine << "\".");
98 #endif
100 #if OSL_DEBUG_LEVEL > 1
101 else
102 SAL_INFO("vcl.unx.dtrans", "found SelectionTimeout of type \""
103 << value.getValueTypeName() << "\".");
104 #endif
108 void DtransX11ConfigItem::ImplCommit()
110 // for the clipboard service this is readonly, so
111 // there is nothing to commit
115 * DtransX11ConfigItem::Notify
118 void DtransX11ConfigItem::Notify( const Sequence< OUString >& /*rPropertyNames*/ )
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */