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 .
21 #include <unotools/configitem.hxx>
23 #include "X11_selection.hxx"
25 #define SETTINGS_CONFIGNODE "VCL/Settings/Transfer"
26 #define SELECTION_PROPERTY "SelectionTimeout"
31 class DtransX11ConfigItem
: public ::utl::ConfigItem
33 sal_Int32 m_nSelectionTimeout
;
35 virtual void Notify( const ::com::sun::star::uno::Sequence
< OUString
>& rPropertyNames
) SAL_OVERRIDE
;
36 virtual void Commit() SAL_OVERRIDE
;
38 DtransX11ConfigItem();
39 virtual ~DtransX11ConfigItem();
41 sal_Int32
getSelectionTimeout() const { return m_nSelectionTimeout
; }
46 using namespace com::sun::star::lang
;
47 using namespace com::sun::star::uno
;
50 sal_Int32
SelectionManager::getSelectionTimeout()
52 if( m_nSelectionTimeout
< 1 )
54 DtransX11ConfigItem aCfg
;
55 m_nSelectionTimeout
= aCfg
.getSelectionTimeout();
56 #if OSL_DEBUG_LEVEL > 1
57 fprintf( stderr
, "initialized selection timeout to %" SAL_PRIdINT32
" seconds\n", m_nSelectionTimeout
);
60 return m_nSelectionTimeout
;
64 * DtransX11ConfigItem constructor
67 DtransX11ConfigItem::DtransX11ConfigItem() :
68 ConfigItem( OUString( SETTINGS_CONFIGNODE
),
69 CONFIG_MODE_DELAYED_UPDATE
),
70 m_nSelectionTimeout( 3 )
72 Sequence
< OUString
> aKeys( 1 );
73 aKeys
.getArray()[0] = OUString( SELECTION_PROPERTY
);
74 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
);
78 Any
* pValue
= aValues
.getArray();
79 for( int i
= 0; i
< aValues
.getLength(); i
++, pValue
++ )
81 if( pValue
->getValueTypeClass() == TypeClass_STRING
)
83 const OUString
* pLine
= (const OUString
*)pValue
->getValue();
84 if( !pLine
->isEmpty() )
86 m_nSelectionTimeout
= pLine
->toInt32();
87 if( m_nSelectionTimeout
< 1 )
88 m_nSelectionTimeout
= 1;
90 #if OSL_DEBUG_LEVEL > 1
91 fprintf( stderr
, "found SelectionTimeout \"%s\"\n",
92 OUStringToOString( *pLine
, osl_getThreadTextEncoding() ).getStr() );
95 #if OSL_DEBUG_LEVEL > 1
97 fprintf( stderr
, "found SelectionTimeout of type \"%s\"\n",
98 OUStringToOString( pValue
->getValueType().getTypeName(), osl_getThreadTextEncoding() ).getStr() );
104 * DtransX11ConfigItem destructor
107 DtransX11ConfigItem::~DtransX11ConfigItem()
112 * DtransX11ConfigItem::Commit
115 void DtransX11ConfigItem::Commit()
117 // for the clipboard service this is readonly, so
118 // there is nothing to commit
122 * DtransX11ConfigItem::Notify
125 void DtransX11ConfigItem::Notify( const Sequence
< OUString
>& /*rPropertyNames*/ )
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */