1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _MS_FILTERTRACER_HXX 25 #define _MS_FILTERTRACER_HXX 26 27 #include <rtl/ustring.hxx> 28 #include <tools/stream.hxx> 29 #include <xmloff/attrlist.hxx> 30 #include <com/sun/star/uno/Any.h> 31 #include <com/sun/star/uno/Reference.h> 32 #include <com/sun/star/util/XTextSearch.hpp> 33 #include <com/sun/star/util/SearchResult.hpp> 34 #include <com/sun/star/util/logging/XLogger.hpp> 35 #include <com/sun/star/beans/PropertyValue.hpp> 36 #include <com/sun/star/xml/sax/XAttributeList.hpp> 37 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 38 #include "filter/msfilter/msfilterdllapi.h" 39 40 class FilterConfigItem; 41 class MSFILTER_DLLPUBLIC MSFilterTracer 42 { 43 FilterConfigItem* mpCfgItem; 44 SvXMLAttributeList* mpAttributeList; 45 SvStream* mpStream; 46 sal_Bool mbEnabled; 47 48 ::com::sun::star::util::SearchOptions maSearchOptions; 49 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxFilterTracer; 50 ::com::sun::star::uno::Reference< ::com::sun::star::util::XTextSearch > mxTextSearch; 51 52 ::com::sun::star::uno::Reference< ::com::sun::star::util::logging::XLogger > mxLogger; 53 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler; 54 55 public : 56 57 /* The first parameter is expecting the path of the configuration file. 58 The second parameter can be used to override properties of the configuration 59 file. A "DocumentURL" property can be set in the property 60 sequence to provide the current url of the document. 61 If the "Path" property is not set in the configuration file, then the path 62 of the "DocumentURL" property is used instead. If both are not set, the 63 application path is used instead. 64 If the "Name" property is not set in the configuration file, then the name 65 of the "DocumentURL" property is used instead. If both are not set, the 66 name "tracer* is used. 67 The file extension will always be "log" */ 68 69 MSFilterTracer( const ::rtl::OUString& rConfigurationPath, 70 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pConfigData = NULL ); 71 ~MSFilterTracer(); 72 73 void StartTracing(); 74 void EndTracing(); 75 IsEnabled() const76 inline sal_Bool IsEnabled() const { return mbEnabled; } 77 78 void StartElement( const ::rtl::OUString& rName, ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttribs ); 79 void EndElement( const ::rtl::OUString& rName ); 80 81 void Trace( const ::rtl::OUString& rElementID, const ::rtl::OUString& rMessage ); 82 void AddAttribute( const ::rtl::OUString &sName , const ::rtl::OUString &sValue ); 83 void RemoveAttribute( const ::rtl::OUString& sName ); 84 void ClearAttributes(); 85 86 /* initially all properties of the configuration file and the 87 properties which are given to the c'tor can be retrieved */ 88 ::com::sun::star::uno::Any GetProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any* pDefault = NULL ) const; 89 void SetProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rProperty ); 90 }; 91 92 #endif 93