loplugin:sequenceloop in unoxml..vcl
[LibreOffice.git] / vcl / unx / generic / dtrans / config.cxx
blobf2926ef9ec78d2fb18bc85abf8592ed4342f287d
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 <cstdio>
21 #include <o3tl/any.hxx>
22 #include <unotools/configitem.hxx>
24 #include "X11_selection.hxx"
26 #define SETTINGS_CONFIGNODE "VCL/Settings/Transfer"
27 #define SELECTION_PROPERTY "SelectionTimeout"
29 namespace x11
32 class DtransX11ConfigItem : public ::utl::ConfigItem
34 sal_Int32 m_nSelectionTimeout;
36 virtual void Notify( const css::uno::Sequence< OUString >& rPropertyNames ) override;
37 virtual void ImplCommit() override;
39 public:
40 DtransX11ConfigItem();
42 sal_Int32 getSelectionTimeout() const { return m_nSelectionTimeout; }
47 using namespace com::sun::star::lang;
48 using namespace com::sun::star::uno;
49 using namespace x11;
51 sal_Int32 SelectionManager::getSelectionTimeout()
53 if( m_nSelectionTimeout < 1 )
55 DtransX11ConfigItem aCfg;
56 m_nSelectionTimeout = aCfg.getSelectionTimeout();
57 #if OSL_DEBUG_LEVEL > 1
58 fprintf( stderr, "initialized selection timeout to %" SAL_PRIdINT32 " seconds\n", m_nSelectionTimeout );
59 #endif
61 return m_nSelectionTimeout;
65 * DtransX11ConfigItem constructor
68 DtransX11ConfigItem::DtransX11ConfigItem() :
69 ConfigItem( SETTINGS_CONFIGNODE,
70 ConfigItemMode::NONE ),
71 m_nSelectionTimeout( 3 )
73 Sequence<OUString> aKeys { SELECTION_PROPERTY };
74 const Sequence< Any > aValues = GetProperties( aKeys );
75 #if OSL_DEBUG_LEVEL > 1
76 fprintf( stderr, "found %" SAL_PRIdINT32 " properties for %s\n", aValues.getLength(), SELECTION_PROPERTY );
77 #endif
78 for( Any const & value : aValues )
80 if( auto pLine = o3tl::tryAccess<OUString>(value) )
82 if( !pLine->isEmpty() )
84 m_nSelectionTimeout = pLine->toInt32();
85 if( m_nSelectionTimeout < 1 )
86 m_nSelectionTimeout = 1;
88 #if OSL_DEBUG_LEVEL > 1
89 fprintf( stderr, "found SelectionTimeout \"%s\"\n",
90 OUStringToOString( *pLine, osl_getThreadTextEncoding() ).getStr() );
91 #endif
93 #if OSL_DEBUG_LEVEL > 1
94 else
95 fprintf( stderr, "found SelectionTimeout of type \"%s\"\n",
96 OUStringToOString( value.getValueType().getTypeName(), osl_getThreadTextEncoding() ).getStr() );
97 #endif
101 void DtransX11ConfigItem::ImplCommit()
103 // for the clipboard service this is readonly, so
104 // there is nothing to commit
108 * DtransX11ConfigItem::Notify
111 void DtransX11ConfigItem::Notify( const Sequence< OUString >& /*rPropertyNames*/ )
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */