1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tracer.cxx,v $
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
41 #define CAU(X) RTL_CONSTASCII_USTRINGPARAM(X)
42 #define C2O(X) OUString(CAU(X))
43 #define COMMENT(X) OUString()
49 Tracer::Tracer(const SfxMedium
&rMed
)
52 using namespace ::com::sun::star::uno
;
53 using namespace ::com::sun::star::beans
;
54 Sequence
<PropertyValue
> aConfig(1);
55 PropertyValue aPropValue
;
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
);
64 mpTrace
->StartTracing();
71 mpTrace
->EndTracing();
76 void Tracer::Log(Problem eProblem
)
81 OUString
sID(CAU("sw"));
82 sID
+= rtl::OUString::valueOf(static_cast<sal_Int32
>(eProblem
));
86 mpTrace
->Trace(sID
, COMMENT("PrinterMetrics"));
89 mpTrace
->Trace(sID
, COMMENT("Extra Leading"));
91 case eTabStopDistance
:
92 mpTrace
->Trace(sID
, COMMENT("Minimum Tab Distance"));
94 case eDontUseHTMLAutoSpacing
:
95 mpTrace
->Trace(sID
, COMMENT("HTML AutoSpacing"));
98 mpTrace
->Trace(sID
, COMMENT("AutoWidth"));
101 mpTrace
->Trace(sID
, COMMENT("Splitable Row"));
103 case eSpacingBetweenCells
:
104 mpTrace
->Trace(sID
, COMMENT("Spacing Between Cells"));
106 case eTabInNumbering
:
107 mpTrace
->Trace(sID
, COMMENT("Tab In Numbering"));
109 case eNegativeVertPlacement
:
111 COMMENT("Negative Vertical Placement"));
115 COMMENT("Bad Background for Autocolour"));
119 COMMENT("Inline wider than TextArea"));
123 COMMENT("Animated Text"));
125 case eDontAddSpaceForEqualStyles
:
127 COMMENT("Don't Add Space between Equal Style"));
129 case eBorderDistOutside
:
131 COMMENT("Word draws the border outside"));
133 case eContainsVisualBasic
:
134 mpTrace
->Trace(sID
, COMMENT("Contains VBA"));
136 case eContainsWordBasic
:
137 mpTrace
->Trace(sID
, COMMENT("Contains Word Basic"));
140 mpTrace
->Trace(sID
, COMMENT("UNKNOWN"));
145 rtl::OUString
Tracer::GetContext(Environment eContext
) const
147 rtl::OUString sContext
;
151 case eDocumentProperties
:
152 sContext
= C2O("Global");
155 sContext
= C2O("Text");
158 sContext
= C2O("Text");
161 sContext
= C2O("Table");
164 sContext
= C2O("UNKNOWN");
170 rtl::OUString
Tracer::GetDetails(Environment eContext
) const
172 rtl::OUString sDetails
;
175 case eDocumentProperties
:
176 sDetails
= C2O("Document Properties");
179 sDetails
= C2O("Macros");
182 sDetails
= C2O("MainDocument");
185 sDetails
= C2O("Unknown Subdocument");
188 sDetails
= C2O("UNKNOWN");
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: */