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 <cstdio>
22 : #include <unotools/configitem.hxx>
23 :
24 : #include "X11_selection.hxx"
25 :
26 : #define SETTINGS_CONFIGNODE "VCL/Settings/Transfer"
27 : #define SELECTION_PROPERTY "SelectionTimeout"
28 :
29 : namespace x11
30 : {
31 :
32 : class DtransX11ConfigItem : public ::utl::ConfigItem
33 : {
34 : sal_Int32 m_nSelectionTimeout;
35 :
36 : virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rPropertyNames );
37 : virtual void Commit();
38 : public:
39 : DtransX11ConfigItem();
40 : virtual ~DtransX11ConfigItem();
41 :
42 0 : sal_Int32 getSelectionTimeout() const { return m_nSelectionTimeout; }
43 : };
44 :
45 : }
46 :
47 : using namespace com::sun::star::lang;
48 : using namespace com::sun::star::uno;
49 : using namespace x11;
50 :
51 : using ::rtl::OUString;
52 :
53 0 : sal_Int32 SelectionManager::getSelectionTimeout()
54 : {
55 0 : if( m_nSelectionTimeout < 1 )
56 : {
57 0 : DtransX11ConfigItem aCfg;
58 0 : m_nSelectionTimeout = aCfg.getSelectionTimeout();
59 : #if OSL_DEBUG_LEVEL > 1
60 : fprintf( stderr, "initialized selection timeout to %" SAL_PRIdINT32 " seconds\n", m_nSelectionTimeout );
61 : #endif
62 : }
63 0 : return m_nSelectionTimeout;
64 : }
65 :
66 : /*
67 : * DtransX11ConfigItem constructor
68 : */
69 :
70 0 : DtransX11ConfigItem::DtransX11ConfigItem() :
71 : ConfigItem( OUString( RTL_CONSTASCII_USTRINGPARAM( SETTINGS_CONFIGNODE ) ),
72 : CONFIG_MODE_DELAYED_UPDATE ),
73 0 : m_nSelectionTimeout( 3 )
74 : {
75 0 : if( IsValidConfigMgr() )
76 : {
77 0 : Sequence< OUString > aKeys( 1 );
78 0 : aKeys.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SELECTION_PROPERTY ) );
79 0 : Sequence< Any > aValues = GetProperties( aKeys );
80 : #if OSL_DEBUG_LEVEL > 1
81 : fprintf( stderr, "found %" SAL_PRIdINT32 " properties for %s\n", aValues.getLength(), SELECTION_PROPERTY );
82 : #endif
83 0 : Any* pValue = aValues.getArray();
84 0 : for( int i = 0; i < aValues.getLength(); i++, pValue++ )
85 : {
86 0 : if( pValue->getValueTypeClass() == TypeClass_STRING )
87 : {
88 0 : const OUString* pLine = (const OUString*)pValue->getValue();
89 0 : if( !pLine->isEmpty() )
90 : {
91 0 : m_nSelectionTimeout = pLine->toInt32();
92 0 : if( m_nSelectionTimeout < 1 )
93 0 : m_nSelectionTimeout = 1;
94 : }
95 : #if OSL_DEBUG_LEVEL > 1
96 : fprintf( stderr, "found SelectionTimeout \"%s\"\n",
97 : OUStringToOString( *pLine, osl_getThreadTextEncoding() ).getStr() );
98 : #endif
99 : }
100 : #if OSL_DEBUG_LEVEL > 1
101 : else
102 : fprintf( stderr, "found SelectionTimeout of type \"%s\"\n",
103 : OUStringToOString( pValue->getValueType().getTypeName(), osl_getThreadTextEncoding() ).getStr() );
104 : #endif
105 0 : }
106 : }
107 : #if OSL_DEBUG_LEVEL > 1
108 : else
109 : fprintf( stderr, "no valid configmanager, could not read timeout setting\n" );
110 : #endif
111 0 : }
112 :
113 : /*
114 : * DtransX11ConfigItem destructor
115 : */
116 :
117 0 : DtransX11ConfigItem::~DtransX11ConfigItem()
118 : {
119 0 : }
120 :
121 : /*
122 : * DtransX11ConfigItem::Commit
123 : */
124 :
125 0 : void DtransX11ConfigItem::Commit()
126 : {
127 : // for the clipboard service this is readonly, so
128 : // there is nothing to commit
129 0 : }
130 :
131 : /*
132 : * DtransX11ConfigItem::Notify
133 : */
134 :
135 0 : void DtransX11ConfigItem::Notify( const Sequence< OUString >& /*rPropertyNames*/ )
136 : {
137 0 : }
138 :
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|