Update ooo320-m1
[ooovba.git] / sc / source / filter / excel / xltracer.cxx
blob3b6f217825b1c30b2eb701fb7dbfeefb7164ad19
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: xltracer.cxx,v $
10 * $Revision: 1.10.32.1 $
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_sc.hxx"
34 // ============================================================================
35 #include "xltracer.hxx"
36 #include <svx/msfiltertracer.hxx>
37 #include "address.hxx"
39 using ::rtl::OUString;
40 using ::com::sun::star::uno::Sequence;
41 using ::com::sun::star::beans::PropertyValue;
43 // ============================================================================
45 // Trace Table details are grouped by functionality using the context entry.
46 // Each separate context starts at the next 1000 interval. New entries should
47 // be added to their appropriate context. New contexts should be added onto
48 // the end. Any gaps in the 1000 sequence or within the 1000 are the result
49 // of trace events no longer present.
50 static const XclTracerDetails pTracerDetails[] =
52 { eUnKnown, 0, "UNKNOWN", "UNKNOWN", "Unknown trace property." },
53 { eRowLimitExceeded, 1000, "Limits", "Sheet", "Row limit exceeded." },
54 { eTabLimitExceeded, 1001, "Limits", "Sheet", "Sheet limit exceeded." },
55 { ePassword, 2000, "Protection", "Password", "Document is password protected." },
56 { ePrintRange, 3000, "Print", "Print Range", "Print Range present." },
57 { eShortDate, 4000, "CellFormatting", "Short Dates", "Possible Date format issue." },
58 { eBorderLineStyle, 4004, "CellFormatting", "Border", "Line style not supported.", },
59 { eFillPattern, 4005, "CellFormatting", "Pattern", "Fill Pattern not supported.", },
60 { eInvisibleGrid, 5000, "Properties", "Grid Invisible", "Grid invisible on first sheet." },
61 { eFormattedNote, 6000, "Notes", "Formatting", "Text may be formatted." },
62 { eFormulaExtName, 7000, "Formula", "External Name", "External names not supported." },
63 { eFormulaMissingArg, 7001, "Formula", "Missing Argument","Parameter missing." },
64 { ePivotDataSource, 8000, "Chart", "Pivot", "External data source not supported."},
65 { ePivotChartExists, 8001, "Chart", "Pivot", "Pivot Chart not supported."},
66 { eChartUnKnownType, 8002, "Chart", "Type", "Chart Type not supported."},
67 { eChartTrendLines, 8003, "Chart", "Type", "Chart trendlines not supported."},
68 { eChartOnlySheet, 8004, "Chart", "Type", "Chart only sheet not supported."},
69 { eChartRange, 8005, "Chart", "Source Data", "Chart source ranges too complex."},
70 { eChartDSName, 8006, "Chart", "Source Data", "Series titles not linked to cells."},
71 { eChartDataTable, 8007, "Chart", "Legend", "Data table not supported."},
72 { eChartLegendPosition, 8008, "Chart", "Legend", "Position not guaranteed."},
73 { eChartTextFormatting, 8009, "Chart", "Formatting", "Text formatting present."},
74 { eChartEmbeddedObj, 8010, "Chart", "Area", "Object inside chart."},
75 { eChartAxisAuto, 8012, "Chart", "Axis", "Axis interval is automatic."},
76 { eChartInvalidXY, 8013, "Chart", "Scatter", "Unsupported or invalid data range for XY chart."},
77 { eChartErrorBars, 8014, "Chart", "Type", "Chart error bars not supported."},
78 { eChartAxisManual, 8015, "Chart", "Axis", "Manual axis crossing point adjusted."},
79 { eUnsupportedObject, 9000, "Object", "Type", "Limited Object support."},
80 { eObjectNotPrintable, 9001, "Object", "Print", "Object not printable."},
81 { eDVType, 10000, "DataValidation", "Type", "Custom type present."}
84 XclTracer::XclTracer( const String& rDocUrl, const OUString& rConfigPath ) :
85 maFirstTimes(eTraceLength,true)
87 Sequence< PropertyValue > aConfigData( 1 );
88 aConfigData[ 0 ].Name = CREATE_OUSTRING( "DocumentURL" );
89 aConfigData[ 0 ].Value <<= OUString( rDocUrl );
90 mpTracer.reset( new MSFilterTracer( rConfigPath, &aConfigData ) );
91 mpTracer->StartTracing();
92 mbEnabled = mpTracer->IsEnabled();
95 XclTracer::~XclTracer()
97 mpTracer->EndTracing();
100 void XclTracer::AddAttribute( const OUString& rName, const OUString& rValue )
102 if( mbEnabled )
103 mpTracer->AddAttribute( rName, rValue );
106 void XclTracer::Trace( const OUString& rElementID, const OUString& rMessage )
108 if( mbEnabled )
110 mpTracer->Trace( rElementID, rMessage );
111 mpTracer->ClearAttributes();
115 void XclTracer::TraceLog( XclTracerId eProblem, sal_Int32 nValue )
117 if( mbEnabled )
119 OUString sID( CREATE_STRING( "SC" ) );
120 sID += OUString::valueOf( static_cast< sal_Int32 >( pTracerDetails[ eProblem ].mnID ) );
121 OUString sProblem = OUString::createFromAscii( pTracerDetails[ eProblem ].mpProblem );
123 switch (eProblem)
125 case eRowLimitExceeded:
126 Context(eProblem,static_cast<SCTAB>(nValue));
127 break;
128 case eTabLimitExceeded:
129 Context(eProblem,static_cast<SCTAB>(nValue));
130 break;
131 default:
132 Context(eProblem);
133 break;
135 Trace(sID, sProblem);
139 void XclTracer::Context( XclTracerId eProblem, SCTAB nTab )
141 OUString sContext = OUString::createFromAscii( pTracerDetails[ eProblem ].mpContext );
142 OUString sDetail = OUString::createFromAscii( pTracerDetails[ eProblem ].mpDetail );
144 switch (eProblem)
146 case eRowLimitExceeded:
147 case eTabLimitExceeded:
148 sDetail += OUString::valueOf( static_cast< sal_Int32 >( nTab + 1 ) );
149 break;
150 default:
151 break;
153 AddAttribute(sContext, sDetail);
156 void XclTracer::ProcessTraceOnce(XclTracerId eProblem, SCTAB nTab)
158 if( mbEnabled && maFirstTimes[eProblem])
160 TraceLog(pTracerDetails[eProblem].meProblemId, nTab);
161 maFirstTimes[eProblem] = false;
165 void XclTracer::TraceInvalidAddress( const ScAddress& rPos, const ScAddress& rMaxPos )
167 TraceInvalidRow(rPos.Tab(), rPos.Row(), rMaxPos.Row());
168 TraceInvalidTab(rPos.Tab(), rMaxPos.Tab());
171 void XclTracer::TraceInvalidRow( SCTAB nTab, sal_uInt32 nRow, sal_uInt32 nMaxRow )
173 if(nRow > nMaxRow)
174 ProcessTraceOnce(eRowLimitExceeded, nTab);
177 void XclTracer::TraceInvalidTab( SCTAB nTab, SCTAB nMaxTab )
179 if(nTab > nMaxTab)
180 ProcessTraceOnce(eTabLimitExceeded, nTab);
183 void XclTracer::TracePrintRange()
185 ProcessTraceOnce( ePrintRange);
188 void XclTracer::TraceDates( sal_uInt16 nNumFmt)
190 // Short Date = 14 and Short Date+Time = 22
191 if(nNumFmt == 14 || nNumFmt == 22)
192 ProcessTraceOnce(eShortDate);
195 void XclTracer::TraceBorderLineStyle( bool bBorderLineStyle)
197 if(bBorderLineStyle)
198 ProcessTraceOnce(eBorderLineStyle);
201 void XclTracer::TraceFillPattern( bool bFillPattern)
203 if(bFillPattern)
204 ProcessTraceOnce(eFillPattern);
207 void XclTracer::TraceFormulaMissingArg()
209 // missing parameter in Formula record
210 ProcessTraceOnce(eFormulaMissingArg);
213 void XclTracer::TracePivotDataSource( bool bExternal)
215 if(bExternal)
216 ProcessTraceOnce(ePivotDataSource);
219 void XclTracer::TracePivotChartExists()
221 // Pivot Charts not currently displayed.
222 ProcessTraceOnce(ePivotChartExists);
225 void XclTracer::TraceChartUnKnownType()
227 ProcessTraceOnce(eChartUnKnownType);
230 void XclTracer::TraceChartOnlySheet()
232 ProcessTraceOnce(eChartOnlySheet);
235 void XclTracer::TraceChartDataTable()
237 // Data table is not supported.
238 ProcessTraceOnce(eChartDataTable);
241 void XclTracer::TraceChartLegendPosition()
243 // If position is set to "not docked or inside the plot area" then
244 // we cannot guarantee the legend position.
245 ProcessTraceOnce(eChartLegendPosition);
248 void XclTracer::TraceChartEmbeddedObj()
250 // drawing objects e.g. text boxes etc not supported inside charts
251 ProcessTraceOnce(eChartEmbeddedObj);
254 void XclTracer::TraceUnsupportedObjects()
256 // Called from Excel 5.0 - limited Graphical object support.
257 ProcessTraceOnce(eUnsupportedObject);
260 void XclTracer::TraceObjectNotPrintable()
262 ProcessTraceOnce(eObjectNotPrintable);
265 void XclTracer::TraceDVType( bool bType)
267 // Custom types work if 'Data->validity dialog' is not OKed.
268 if(bType)
269 ProcessTraceOnce(eDVType);
272 // ============================================================================