1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include "ConfigurationTracer.hxx"
21 
22 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
23 #include <sal/log.hxx>
24 
25 using namespace ::com::sun::star::uno;
26 using namespace ::com::sun::star::drawing::framework;
27 
28 namespace sd::framework {
29 
TraceConfiguration(const Reference<XConfiguration> & rxConfiguration,const char * pMessage)30 void ConfigurationTracer::TraceConfiguration (
31     const Reference<XConfiguration>& rxConfiguration,
32     const char* pMessage)
33 {
34 #if OSL_DEBUG_LEVEL >=1
35     SAL_INFO("sd.ui","" << pMessage << " at " << rxConfiguration.get() << " {");
36     if (rxConfiguration.is())
37     {
38         TraceBoundResources(rxConfiguration, nullptr, 0);
39     }
40     else
41     {
42         SAL_INFO("sd.ui","    empty");
43     }
44     SAL_INFO("sd.ui","}");
45 #else
46     (void)rxConfiguration;
47     (void)pMessage;
48 #endif
49 }
50 
51 #if OSL_DEBUG_LEVEL >=1
TraceBoundResources(const Reference<XConfiguration> & rxConfiguration,const Reference<XResourceId> & rxResourceId,const int nIndentation)52 void ConfigurationTracer::TraceBoundResources (
53     const Reference<XConfiguration>& rxConfiguration,
54     const Reference<XResourceId>& rxResourceId,
55     const int nIndentation)
56 {
57     const Sequence<Reference<XResourceId> > aResourceList (
58         rxConfiguration->getResources(rxResourceId, OUString(), AnchorBindingMode_DIRECT));
59     static const OUStringLiteral sIndentation (u"    ");
60     for (Reference<XResourceId> const & resourceId : aResourceList)
61     {
62         OUString sLine (resourceId->getResourceURL());
63         for (int i=0; i<nIndentation; ++i)
64             sLine = sIndentation + sLine;
65         SAL_INFO("sd.ui", "" << sLine);
66         TraceBoundResources(rxConfiguration, resourceId, nIndentation+1);
67     }
68 }
69 #endif
70 
71 } // end of namespace sd::framework
72 
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
74