merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / ww8 / tracer.cxx
blob7e1e48b1f9f17a3abbccd3ded7ec7033ef21193a
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: tracer.cxx,v $
10 * $Revision: 1.11 $
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_sw.hxx"
34 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
35 #include <tools/urlobj.hxx> //INetURLObject
36 #include <sfx2/docfile.hxx> //SfxMedium
37 #include <svx/msfiltertracer.hxx> //MSFilterTracer
38 #include "tracer.hxx" //sw::log::Tracer
40 using rtl::OUString;
41 #define CAU(X) RTL_CONSTASCII_USTRINGPARAM(X)
42 #define C2O(X) OUString(CAU(X))
43 #define COMMENT(X) OUString()
45 namespace sw
47 namespace log
49 Tracer::Tracer(const SfxMedium &rMed)
50 : mpTrace(0)
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::beans;
54 Sequence<PropertyValue> aConfig(1);
55 PropertyValue aPropValue;
56 aPropValue.Value <<=
57 OUString(rMed.GetURLObject().GetMainURL(
58 INetURLObject::NO_DECODE));
59 aPropValue.Name = C2O("DocumentURL");
60 aConfig[0] = aPropValue;
61 OUString aTraceConfigPath(CAU("Office.Tracing/Import/Word"));
62 mpTrace = new MSFilterTracer(aTraceConfigPath, &aConfig);
63 if (mpTrace)
64 mpTrace->StartTracing();
67 Tracer::~Tracer()
69 if (mpTrace)
71 mpTrace->EndTracing();
72 delete mpTrace;
76 void Tracer::Log(Problem eProblem)
78 if (!mpTrace)
79 return;
81 OUString sID(CAU("sw"));
82 sID += rtl::OUString::valueOf(static_cast<sal_Int32>(eProblem));
83 switch (eProblem)
85 case ePrinterMetrics:
86 mpTrace->Trace(sID, COMMENT("PrinterMetrics"));
87 break;
88 case eExtraLeading:
89 mpTrace->Trace(sID, COMMENT("Extra Leading"));
90 break;
91 case eTabStopDistance:
92 mpTrace->Trace(sID, COMMENT("Minimum Tab Distance"));
93 break;
94 case eDontUseHTMLAutoSpacing:
95 mpTrace->Trace(sID, COMMENT("HTML AutoSpacing"));
96 break;
97 case eAutoWidthFrame:
98 mpTrace->Trace(sID, COMMENT("AutoWidth"));
99 break;
100 case eRowCanSplit:
101 mpTrace->Trace(sID, COMMENT("Splitable Row"));
102 break;
103 case eSpacingBetweenCells:
104 mpTrace->Trace(sID, COMMENT("Spacing Between Cells"));
105 break;
106 case eTabInNumbering:
107 mpTrace->Trace(sID, COMMENT("Tab In Numbering"));
108 break;
109 case eNegativeVertPlacement:
110 mpTrace->Trace(sID,
111 COMMENT("Negative Vertical Placement"));
112 break;
113 case eAutoColorBg:
114 mpTrace->Trace(sID,
115 COMMENT("Bad Background for Autocolour"));
116 break;
117 case eTooWideAsChar:
118 mpTrace->Trace(sID,
119 COMMENT("Inline wider than TextArea"));
120 break;
121 case eAnimatedText:
122 mpTrace->Trace(sID,
123 COMMENT("Animated Text"));
124 break;
125 case eDontAddSpaceForEqualStyles:
126 mpTrace->Trace(sID,
127 COMMENT("Don't Add Space between Equal Style"));
128 break;
129 case eBorderDistOutside:
130 mpTrace->Trace(sID,
131 COMMENT("Word draws the border outside"));
132 break;
133 case eContainsVisualBasic:
134 mpTrace->Trace(sID, COMMENT("Contains VBA"));
135 break;
136 case eContainsWordBasic:
137 mpTrace->Trace(sID, COMMENT("Contains Word Basic"));
138 break;
139 default:
140 mpTrace->Trace(sID, COMMENT("UNKNOWN"));
141 break;
145 rtl::OUString Tracer::GetContext(Environment eContext) const
147 rtl::OUString sContext;
148 switch (eContext)
150 case eMacros:
151 case eDocumentProperties:
152 sContext = C2O("Global");
153 break;
154 case eMainText:
155 sContext = C2O("Text");
156 break;
157 case eSubDoc:
158 sContext = C2O("Text");
159 break;
160 case eTable:
161 sContext = C2O("Table");
162 break;
163 default:
164 sContext = C2O("UNKNOWN");
165 break;
167 return sContext;
170 rtl::OUString Tracer::GetDetails(Environment eContext) const
172 rtl::OUString sDetails;
173 switch (eContext)
175 case eDocumentProperties:
176 sDetails = C2O("Document Properties");
177 break;
178 case eMacros:
179 sDetails = C2O("Macros");
180 break;
181 case eMainText:
182 sDetails = C2O("MainDocument");
183 break;
184 case eSubDoc:
185 sDetails = C2O("Unknown Subdocument");
186 break;
187 default:
188 sDetails = C2O("UNKNOWN");
189 break;
191 return sDetails;
194 void Tracer::EnterEnvironment(Environment eContext)
196 mpTrace->AddAttribute(GetContext(eContext), GetDetails(eContext));
199 void Tracer::EnterEnvironment(Environment eContext,
200 const rtl::OUString &rDetails)
202 mpTrace->AddAttribute(GetContext(eContext), rDetails);
205 void Tracer::LeaveEnvironment(Environment eContext)
207 mpTrace->RemoveAttribute(GetContext(eContext));
212 /* vi:set tabstop=4 shiftwidth=4 expandtab: */