1*22e87013SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*22e87013SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*22e87013SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*22e87013SAndrew Rist  * distributed with this work for additional information
6*22e87013SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*22e87013SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*22e87013SAndrew Rist  * "License"); you may not use this file except in compliance
9*22e87013SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*22e87013SAndrew Rist  *
11*22e87013SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*22e87013SAndrew Rist  *
13*22e87013SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*22e87013SAndrew Rist  * software distributed under the License is distributed on an
15*22e87013SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*22e87013SAndrew Rist  * KIND, either express or implied.  See the License for the
17*22e87013SAndrew Rist  * specific language governing permissions and limitations
18*22e87013SAndrew Rist  * under the License.
19*22e87013SAndrew Rist  *
20*22e87013SAndrew Rist  *************************************************************/
21*22e87013SAndrew Rist 
22*22e87013SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _FILTERTRACER_HXX
25cdf0e10cSrcweir #define _FILTERTRACER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <tools/stream.hxx>
30cdf0e10cSrcweir #include <tools/string.hxx>
31cdf0e10cSrcweir #include <tools/urlobj.hxx>
32cdf0e10cSrcweir #include <tools/stack.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
35cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
38cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
40cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
41cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
45cdf0e10cSrcweir #include <com/sun/star/util/logging/XLogger.hpp>
46cdf0e10cSrcweir #include <com/sun/star/util/logging/LogLevel.hpp>
47cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
48cdf0e10cSrcweir #include <com/sun/star/util/XTextSearch.hpp>
49cdf0e10cSrcweir #include <com/sun/star/util/SearchResult.hpp>
50cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // -----------------------------------------------------------------------------
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #define NMSP_IO			com::sun::star::io
55cdf0e10cSrcweir #define NMSP_UNO		com::sun::star::uno
56cdf0e10cSrcweir #define NMSP_BEANS      com::sun::star::beans
57cdf0e10cSrcweir #define NMSP_LANG		com::sun::star::lang
58cdf0e10cSrcweir #define NMSP_UTIL		com::sun::star::util
59cdf0e10cSrcweir #define NMSP_SAX		com::sun::star::xml::sax
60cdf0e10cSrcweir #define NMSP_LOGGING	NMSP_UTIL::logging
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #define REF( _def_Obj )         NMSP_UNO::Reference< _def_Obj >
64cdf0e10cSrcweir #define SEQ( _def_Obj )         NMSP_UNO::Sequence< _def_Obj >
65cdf0e10cSrcweir #define B2UCONST( _def_pChar )  (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar )))
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // ----------------
68cdf0e10cSrcweir // - FILTERTRACER -
69cdf0e10cSrcweir // ----------------
70cdf0e10cSrcweir //
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /** Some options of the FilterTracer can be initialized
73cdf0e10cSrcweir     via XInitialization interface.
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	Therefore the first sequence of	PropertyValues that
76cdf0e10cSrcweir 	is given in the argument list is used.
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	Following Properties are supported:
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	OutputStream	com.sun.star.io.XOutputStream	Defines the output stream. Optional it is possible to provide
81cdf0e10cSrcweir 													the URL property, then the corresponding output stream will
82cdf0e10cSrcweir 													be generated automatically.
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	URL				string							Defines the URL, which is used to create an output stream.
85cdf0e10cSrcweir 													This property is used only, if there is no valid
86cdf0e10cSrcweir 													OutputStream property available.
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	DocumentHandler	com.sun.star.xml.sax.XDocumentHandler	The output can also be written to a DocumentHandler,
89cdf0e10cSrcweir 															then the "characters" method of the handler is used.
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     LogLevel		long							Defines the LogLevel for the FilterTracer.
92cdf0e10cSrcweir 													Using logp with a LogLevel that is higher as the LogLevel
93cdf0e10cSrcweir 													for	the FilterTracer component will generate no output.
94cdf0e10cSrcweir 													LogLevel constants are defined in sun::star::util::logging::LogLevel
95cdf0e10cSrcweir 													The default LogLevel com::sun::star::logging::LogLevel::ALL
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	ClassFilter		string							This property defines a filter for the SourceClass string of logp.
98cdf0e10cSrcweir 													The ClassFilter string can be separated into multiple tokens using
99cdf0e10cSrcweir 													a semicolon. If one of the ClassFilter token is part of the
100cdf0e10cSrcweir 													SourceClass string of the logp method then there will be no output.
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	MethodFilter	string							This property defines a filter for the SourceMethod string of logp.
103cdf0e10cSrcweir 													The MethodFilter string can be separated into multiple tokens using
104cdf0e10cSrcweir 													a semicolon. If one of the MethodFilter token is part of the
105cdf0e10cSrcweir 													SourceMethod string of the logp method then there will be no output.
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	MessageFilter	string							This property defines a filter for the Message string of logp.
108cdf0e10cSrcweir 													The MessageFilter string can be separated into multiple tokens using
109cdf0e10cSrcweir 													a semicolon. If one of the MessageFilter token is part of the
110cdf0e10cSrcweir 													Message string of the logp method then there will be no output.
111cdf0e10cSrcweir 
112cdf0e10cSrcweir */
113cdf0e10cSrcweir 
114cdf0e10cSrcweir class FilterTracer : public cppu::WeakImplHelper4
115cdf0e10cSrcweir <
116cdf0e10cSrcweir 	NMSP_LOGGING::XLogger,
117cdf0e10cSrcweir 	NMSP_LANG::XInitialization,
118cdf0e10cSrcweir 	NMSP_LANG::XServiceInfo,
119cdf0e10cSrcweir 	NMSP_UTIL::XTextSearch
120cdf0e10cSrcweir >
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	REF( NMSP_LANG::XMultiServiceFactory )	xFact;
123cdf0e10cSrcweir 	SvStream*		mpStream;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	sal_Int32		mnLogLevel;
126cdf0e10cSrcweir 	rtl::OUString	msClassFilter;
127cdf0e10cSrcweir 	rtl::OUString	msMethodFilter;
128cdf0e10cSrcweir 	rtl::OUString	msMessageFilter;
129cdf0e10cSrcweir 	rtl::OUString	msURL;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	REF( NMSP_IO::XOutputStream )		mxOutputStream;
132cdf0e10cSrcweir 	REF( NMSP_SAX::XDocumentHandler)	mxDocumentHandler;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	REF( NMSP_UTIL::XTextSearch )		mxTextSearch;
135cdf0e10cSrcweir 	NMSP_UTIL::SearchOptions			maSearchOptions;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	sal_Bool				ImplFilter( const rtl::OUString& rFilter, const rtl::OUString& rString );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir public:
140cdf0e10cSrcweir 							FilterTracer( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr );
141cdf0e10cSrcweir 	virtual 				~FilterTracer();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	// XInterface
144cdf0e10cSrcweir     virtual void SAL_CALL	acquire() throw();
145cdf0e10cSrcweir     virtual void SAL_CALL	release() throw();
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	// XInitialization
148cdf0e10cSrcweir     virtual void SAL_CALL initialize( const SEQ( NMSP_UNO::Any )& aArguments )
149cdf0e10cSrcweir 		throw ( NMSP_UNO::Exception, NMSP_UNO::RuntimeException );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	// XServiceInfo
152cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName()
153cdf0e10cSrcweir 		throw ( NMSP_UNO::RuntimeException );
154cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& rServiceName )
155cdf0e10cSrcweir 		throw ( NMSP_UNO::RuntimeException );
156cdf0e10cSrcweir     virtual SEQ( rtl::OUString ) SAL_CALL getSupportedServiceNames()
157cdf0e10cSrcweir 		throw ( NMSP_UNO::RuntimeException );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	// XLogger
160cdf0e10cSrcweir     virtual REF( NMSP_LOGGING::XLogger ) SAL_CALL getLogger( const rtl::OUString& rName ) throw (::com::sun::star::uno::RuntimeException);
161cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getLevel() throw (::com::sun::star::uno::RuntimeException);
162cdf0e10cSrcweir 	virtual rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException);
163cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isLoggable( sal_Int32 nLevel ) throw (::com::sun::star::uno::RuntimeException);
164cdf0e10cSrcweir 	virtual void SAL_CALL logp( sal_Int32 nLevel, const rtl::OUString& rSourceClass,
165cdf0e10cSrcweir 					const rtl::OUString& rSourceMethod, const rtl::OUString& rMessage ) throw (::com::sun::star::uno::RuntimeException);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	// XTextSearch
168cdf0e10cSrcweir 	virtual void SAL_CALL setOptions( const NMSP_UTIL::SearchOptions& ) throw (::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir 	virtual NMSP_UTIL::SearchResult SAL_CALL searchForward( const rtl::OUString& rSearchStr,
170cdf0e10cSrcweir 		sal_Int32 nStartPos, sal_Int32 nEndPos ) throw (::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir 	virtual NMSP_UTIL::SearchResult SAL_CALL searchBackward( const rtl::OUString& rSearchStr,
172cdf0e10cSrcweir 		sal_Int32 nStartPos, sal_Int32 nEndPos ) throw (::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir };
174cdf0e10cSrcweir 
175cdf0e10cSrcweir rtl::OUString FilterTracer_getImplementationName()
176cdf0e10cSrcweir 	throw ( NMSP_UNO::RuntimeException );
177cdf0e10cSrcweir sal_Bool SAL_CALL FilterTracer_supportsService( const rtl::OUString& rServiceName )
178cdf0e10cSrcweir 	throw( NMSP_UNO::RuntimeException );
179cdf0e10cSrcweir SEQ( rtl::OUString ) SAL_CALL FilterTracer_getSupportedServiceNames()
180cdf0e10cSrcweir 	throw( NMSP_UNO::RuntimeException );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir #endif
183