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 // ============================================================================ 25 26 #ifndef SC_XLTRACER_HXX 27 #define SC_XLTRACER_HXX 28 29 #include "global.hxx" // ScAddress 30 #include "xltools.hxx" 31 32 // As Trace features become implemented, we can safely delete the enum entry as 33 // we use the member mnID to keep track of the actual trace tag ID value. 34 enum XclTracerId 35 { 36 eUnKnown , /// unused but allows us to set the correct index 37 eRowLimitExceeded , 38 eTabLimitExceeded , 39 ePassword , 40 ePrintRange , 41 eShortDate , 42 eBorderLineStyle , 43 eFillPattern , 44 eInvisibleGrid , 45 eFormattedNote , 46 eFormulaExtName , 47 eFormulaMissingArg , 48 ePivotDataSource , 49 ePivotChartExists , 50 eChartUnKnownType , 51 eChartTrendLines , 52 eChartErrorBars , 53 eChartOnlySheet , 54 eChartRange , 55 eChartDSName, 56 eChartDataTable, 57 eChartLegendPosition, 58 eChartTextFormatting, 59 eChartEmbeddedObj, 60 eChartAxisAuto, 61 eChartAxisManual, 62 eChartInvalidXY, 63 eUnsupportedObject , 64 eObjectNotPrintable , 65 eDVType, 66 eTraceLength /// this *should* always be the final entry 67 }; 68 69 struct XclTracerDetails 70 { 71 XclTracerId meProblemId; /// Excel Import Trace index. 72 sal_uInt32 mnID; /// actual ID Index trace tag Value 73 const sal_Char* mpContext; /// Context for problem e.g. Limits 74 const sal_Char* mpDetail; /// Context Detail e.g. SheetX 75 const sal_Char* mpProblem; /// Description of problem 76 }; 77 78 79 // ============================================================================ 80 81 class MSFilterTracer; 82 83 /** This class wraps an MSFilterTracer to create trace logs for import/export filters. */ 84 class XclTracer 85 { 86 public: 87 explicit XclTracer( const String& rDocUrl, const ::rtl::OUString& rConfigPath ); 88 virtual ~XclTracer(); 89 90 /** Returns true, if tracing is enabled. */ IsEnabled() const91 inline bool IsEnabled() const { return mbEnabled; } 92 93 /** Adds an attribute to be traced with the next Trace() call. */ 94 void AddAttribute( const ::rtl::OUString& rName, const ::rtl::OUString& rValue ); 95 96 /** Creates an element including all attributes set up to this call. 97 @descr Removes all attributes after the element is traced. */ 98 void Trace( const ::rtl::OUString& rElementID, const ::rtl::OUString& rMessage ); 99 100 /** Calls Trace() with a known document properties problem. */ 101 void TraceLog( XclTracerId eProblem, sal_Int32 nValue = 0 ); 102 103 /** Calls AddAttribute() to create the Context & Detail for known problems. */ 104 void Context( XclTracerId eProblem, SCTAB nTab = 0 ); 105 106 /** Ensure that particular traces are logged once per document. */ 107 void ProcessTraceOnce(XclTracerId eProblem, SCTAB nTab = 0); 108 109 void TraceInvalidAddress(const ScAddress& rPos, const ScAddress& rMaxPos); 110 void TraceInvalidRow( SCTAB nTab, sal_uInt32 nRow, sal_uInt32 nMaxrow ); 111 void TraceInvalidTab( SCTAB nTab, SCTAB nMaxTab); 112 void TracePrintRange(); 113 void TraceDates(sal_uInt16 nNumFmt); 114 void TraceBorderLineStyle(bool bBorderLineStyle); 115 void TraceFillPattern(bool bFillPattern); 116 void TraceFormulaMissingArg(); 117 void TracePivotDataSource(bool bExternal); 118 void TracePivotChartExists(); 119 void TraceChartUnKnownType(); 120 void TraceChartOnlySheet(); 121 void TraceChartDataTable(); 122 void TraceChartLegendPosition(); 123 void TraceChartEmbeddedObj(); 124 void TraceUnsupportedObjects(); 125 void TraceObjectNotPrintable(); 126 void TraceDVType(bool bType); 127 128 /** Returns the SVX filter tracer for usage in external code (i.e. Escher). */ GetBaseTracer()129 inline MSFilterTracer& GetBaseTracer() { return *mpTracer; } 130 131 private: 132 typedef ::std::auto_ptr< MSFilterTracer > MSFilterTracerPtr; 133 MSFilterTracerPtr mpTracer; 134 bool mbEnabled; 135 typedef ::std::vector< bool > BoolVec; 136 /** array of flags corresponding to each entry in the XclTracerDetails table. */ 137 BoolVec maFirstTimes; 138 }; 139 140 141 // ============================================================================ 142 143 #endif 144 145