update dev300-m58
[ooovba.git] / dtrans / source / X11 / config.cxx
blobf5293fd508e42116ba1a0f0db28630cfb9695af8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: config.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dtrans.hxx"
34 #include <cstdio>
35 #include <unotools/configitem.hxx>
37 #include "X11_selection.hxx"
39 #define SETTINGS_CONFIGNODE "VCL/Settings/Transfer"
40 #define SELECTION_PROPERTY "SelectionTimeout"
42 namespace x11
45 class DtransX11ConfigItem : public ::utl::ConfigItem
47 sal_Int32 m_nSelectionTimeout;
49 virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rPropertyNames );
50 virtual void Commit();
51 public:
52 DtransX11ConfigItem();
53 virtual ~DtransX11ConfigItem();
55 sal_Int32 getSelectionTimeout() const { return m_nSelectionTimeout; }
60 using namespace com::sun::star::lang;
61 using namespace com::sun::star::uno;
62 using namespace rtl;
63 using namespace x11;
65 sal_Int32 SelectionManager::getSelectionTimeout()
67 if( m_nSelectionTimeout < 1 )
69 DtransX11ConfigItem aCfg;
70 m_nSelectionTimeout = aCfg.getSelectionTimeout();
71 #if OSL_DEBUG_LEVEL > 1
72 fprintf( stderr, "initialized selection timeout to %ld seconds\n", m_nSelectionTimeout );
73 #endif
75 return m_nSelectionTimeout;
79 * DtransX11ConfigItem constructor
82 DtransX11ConfigItem::DtransX11ConfigItem() :
83 ConfigItem( OUString( RTL_CONSTASCII_USTRINGPARAM( SETTINGS_CONFIGNODE ) ),
84 CONFIG_MODE_DELAYED_UPDATE ),
85 m_nSelectionTimeout( 3 )
87 if( IsValidConfigMgr() )
89 Sequence< OUString > aKeys( 1 );
90 aKeys.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SELECTION_PROPERTY ) );
91 Sequence< Any > aValues = GetProperties( aKeys );
92 #if OSL_DEBUG_LEVEL > 1
93 fprintf( stderr, "found %ld properties for %s\n", aValues.getLength(), SELECTION_PROPERTY );
94 #endif
95 Any* pValue = aValues.getArray();
96 for( int i = 0; i < aValues.getLength(); i++, pValue++ )
98 if( pValue->getValueTypeClass() == TypeClass_STRING )
100 const OUString* pLine = (const OUString*)pValue->getValue();
101 if( pLine->getLength() )
103 m_nSelectionTimeout = pLine->toInt32();
104 if( m_nSelectionTimeout < 1 )
105 m_nSelectionTimeout = 1;
107 #if OSL_DEBUG_LEVEL > 1
108 fprintf( stderr, "found SelectionTimeout \"%s\"\n",
109 OUStringToOString( *pLine, osl_getThreadTextEncoding() ).getStr() );
110 #endif
112 #if OSL_DEBUG_LEVEL > 1
113 else
114 fprintf( stderr, "found SelectionTimeout of type \"%s\"\n",
115 OUStringToOString( pValue->getValueType().getTypeName(), osl_getThreadTextEncoding() ).getStr() );
116 #endif
119 #if OSL_DEBUG_LEVEL > 1
120 else
121 fprintf( stderr, "no valid configmanager, could not read timeout setting\n" );
122 #endif
126 * DtransX11ConfigItem destructor
129 DtransX11ConfigItem::~DtransX11ConfigItem()
134 * DtransX11ConfigItem::Commit
137 void DtransX11ConfigItem::Commit()
139 // for the clipboard service this is readonly, so
140 // there is nothing to commit
144 * DtransX11ConfigItem::Notify
147 void DtransX11ConfigItem::Notify( const Sequence< OUString >& /*rPropertyNames*/ )