1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "Tools.hxx"
28 #ifndef REPORTDESIGN_CORE_RESOURCE_HRC_
29 #include "core_resource.hrc"
30 #endif
31 #include "core_resource.hxx"
32 #include <comphelper/property.hxx>
33 
34 // =============================================================================
35 namespace reportdesign
36 {
37 // =============================================================================
38 using namespace com::sun::star;
39 
40 uno::Reference< report::XSection> lcl_getSection(const uno::Reference< uno::XInterface>& _xReportComponent)
41 {
42     uno::Reference< container::XChild> xChild(_xReportComponent,uno::UNO_QUERY);
43     uno::Reference< report::XSection> xRet(_xReportComponent,uno::UNO_QUERY);
44     while( !xRet.is() && xChild.is() )
45     {
46         uno::Reference< uno::XInterface> xTemp = xChild->getParent();
47         xChild.set(xTemp,uno::UNO_QUERY);
48         xRet.set(xTemp,uno::UNO_QUERY);
49     }
50     return xRet;
51 }
52 // -----------------------------------------------------------------------------
53 void throwIllegallArgumentException( const ::rtl::OUString& _sTypeName
54                                     ,const uno::Reference< uno::XInterface >& ExceptionContext_
55                                     ,const ::sal_Int16& ArgumentPosition_
56                                     ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context_
57                                     )
58 {
59     ::rtl::OUString sErrorMessage(RPT_RESSTRING(RID_STR_ERROR_WRONG_ARGUMENT,Context_->getServiceManager()));
60     sErrorMessage = sErrorMessage.replaceAt(sErrorMessage.indexOf('#'),2,_sTypeName);
61 	throw lang::IllegalArgumentException(sErrorMessage,ExceptionContext_,ArgumentPosition_);
62 }
63 // -----------------------------------------------------------------------------
64 uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent>& _xReportComponent
65     ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
66     ,const ::rtl::OUString& _sServiceName)
67 {
68     OSL_ENSURE(_xReportComponent.is() && _xFactory.is() ,"reportcomponent is null -> GPF");
69     uno::Reference< report::XReportComponent> xClone(_xFactory->createInstance(_sServiceName),uno::UNO_QUERY_THROW);
70     ::comphelper::copyProperties(_xReportComponent.get(),xClone.get());
71     return xClone.get();
72 }
73 // -----------------------------------------------------------------------------
74 
75 // =============================================================================
76 } // namespace reportdesign
77 // =============================================================================
78