merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / jdbc / ConnectionLog.cxx
blob531cc308f91e621219704b56d94664cfee023c6d
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: ConnectionLog.cxx,v $
10 * $Revision: 1.3 $
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_connectivity.hxx"
34 #include "java/sql/ConnectionLog.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/util/Date.hpp>
38 #include <com/sun/star/util/Time.hpp>
39 #include <com/sun/star/util/DateTime.hpp>
40 /** === end UNO includes === **/
42 #include <stdio.h>
44 //........................................................................
45 namespace connectivity { namespace java { namespace sql {
46 //........................................................................
48 /** === begin UNO using === **/
49 using ::com::sun::star::uno::Reference;
50 using ::com::sun::star::uno::XComponentContext;
51 /** === end UNO using === **/
53 //--------------------------------------------------------------------
54 namespace
56 sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType )
58 static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 };
59 return osl_incrementInterlockedCount( s_nCounts + _eType );
63 //====================================================================
64 //= ConnectionLog
65 //====================================================================
66 //--------------------------------------------------------------------
67 ConnectionLog::ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog )
68 :ConnectionLog_Base( _rDriverLog )
69 ,m_nObjectID( lcl_getFreeID( CONNECTION ) )
73 //--------------------------------------------------------------------
74 ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog )
75 :ConnectionLog_Base( _rSourceLog )
76 ,m_nObjectID( _rSourceLog.m_nObjectID )
80 //--------------------------------------------------------------------
81 ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType )
82 :ConnectionLog_Base( _rSourceLog )
83 ,m_nObjectID( lcl_getFreeID( _eType ) )
87 //........................................................................
88 } } } // namespace connectivity::java::sql
89 //........................................................................
91 //........................................................................
92 namespace comphelper { namespace log { namespace convert
94 //........................................................................
96 /** === begin UNO using === **/
97 using ::com::sun::star::uno::Reference;
98 using ::com::sun::star::uno::XComponentContext;
99 using ::com::sun::star::util::Date;
100 using ::com::sun::star::util::Time;
101 using ::com::sun::star::util::DateTime;
102 /** === end UNO using === **/
104 //--------------------------------------------------------------------
105 ::rtl::OUString convertLogArgToString( const Date& _rDate )
107 char buffer[ 30 ];
108 const size_t buffer_size = sizeof( buffer );
109 snprintf( buffer, buffer_size, "%04i-%02i-%02i",
110 (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day );
111 return ::rtl::OUString::createFromAscii( buffer );
114 //--------------------------------------------------------------------
115 ::rtl::OUString convertLogArgToString( const Time& _rTime )
117 char buffer[ 30 ];
118 const size_t buffer_size = sizeof( buffer );
119 snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i",
120 (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds );
121 return ::rtl::OUString::createFromAscii( buffer );
124 //--------------------------------------------------------------------
125 ::rtl::OUString convertLogArgToString( const DateTime& _rDateTime )
127 char buffer[ 30 ];
128 const size_t buffer_size = sizeof( buffer );
129 snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i",
130 (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day,
131 (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds );
132 return ::rtl::OUString::createFromAscii( buffer );
135 //........................................................................
136 } } } // comphelper::log::convert
137 //........................................................................