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 #include "precompiled_sd.hxx"
25 
26 #include "ConfigurationTracer.hxx"
27 
28 #include <cstdio>
29 
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::drawing::framework;
32 
33 namespace sd { namespace framework {
34 
TraceConfiguration(const Reference<XConfiguration> & rxConfiguration,const char * pMessage)35 void ConfigurationTracer::TraceConfiguration (
36     const Reference<XConfiguration>& rxConfiguration,
37     const char* pMessage)
38 {
39 #ifdef DEBUG
40     OSL_TRACE("%s at %p {", pMessage, rxConfiguration.get());
41     if (rxConfiguration.is())
42     {
43         TraceBoundResources(rxConfiguration, NULL, 0);
44     }
45     else
46     {
47         OSL_TRACE("    empty");
48     }
49     OSL_TRACE("}");
50 #else
51     (void)rxConfiguration;
52     (void)pMessage;
53 #endif
54 }
55 
56 
57 
58 
59 #ifdef DEBUG
TraceBoundResources(const Reference<XConfiguration> & rxConfiguration,const Reference<XResourceId> & rxResourceId,const int nIndentation)60 void ConfigurationTracer::TraceBoundResources (
61     const Reference<XConfiguration>& rxConfiguration,
62     const Reference<XResourceId>& rxResourceId,
63     const int nIndentation)
64 {
65     Sequence<Reference<XResourceId> > aResourceList (
66         rxConfiguration->getResources(rxResourceId, ::rtl::OUString(), AnchorBindingMode_DIRECT));
67     const ::rtl::OUString sIndentation (::rtl::OUString::createFromAscii("    "));
68     for (sal_Int32 nIndex=0; nIndex<aResourceList.getLength(); ++nIndex)
69     {
70         ::rtl::OUString sLine (aResourceList[nIndex]->getResourceURL());
71         for (int i=0; i<nIndentation; ++i)
72             sLine = sIndentation + sLine;
73         OSL_TRACE("%s", OUStringToOString(sLine, RTL_TEXTENCODING_UTF8).getStr());
74         TraceBoundResources(rxConfiguration, aResourceList[nIndex], nIndentation+1);
75     }
76 }
77 #endif
78 
79 } } // end of namespace sd::framework
80