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 #include "precompiled_reportdesign.hxx"
24 #include "Tools.hxx"
25 #include "core_resource.hrc"
26 #include "core_resource.hxx"
27 #include <comphelper/property.hxx>
28 
29 // =============================================================================
30 namespace reportdesign
31 {
32 // =============================================================================
33 using namespace com::sun::star;
34 
lcl_getSection(const uno::Reference<uno::XInterface> & _xReportComponent)35 uno::Reference< report::XSection> lcl_getSection(const uno::Reference< uno::XInterface>& _xReportComponent)
36 {
37     uno::Reference< container::XChild> xChild(_xReportComponent,uno::UNO_QUERY);
38     uno::Reference< report::XSection> xRet(_xReportComponent,uno::UNO_QUERY);
39     while( !xRet.is() && xChild.is() )
40     {
41         uno::Reference< uno::XInterface> xTemp = xChild->getParent();
42         xChild.set(xTemp,uno::UNO_QUERY);
43         xRet.set(xTemp,uno::UNO_QUERY);
44     }
45     return xRet;
46 }
47 // -----------------------------------------------------------------------------
throwIllegallArgumentException(const::rtl::OUString & _sTypeName,const uno::Reference<uno::XInterface> & ExceptionContext_,const::sal_Int16 & ArgumentPosition_,const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & Context_)48 void throwIllegallArgumentException( const ::rtl::OUString& _sTypeName
49                                     ,const uno::Reference< uno::XInterface >& ExceptionContext_
50                                     ,const ::sal_Int16& ArgumentPosition_
51                                     ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context_
52                                     )
53 {
54     ::rtl::OUString sErrorMessage(RPT_RESSTRING(RID_STR_ERROR_WRONG_ARGUMENT,Context_->getServiceManager()));
55     sErrorMessage = sErrorMessage.replaceAt(sErrorMessage.indexOf('#'),2,_sTypeName);
56 	throw lang::IllegalArgumentException(sErrorMessage,ExceptionContext_,ArgumentPosition_);
57 }
58 // -----------------------------------------------------------------------------
cloneObject(const uno::Reference<report::XReportComponent> & _xReportComponent,const uno::Reference<lang::XMultiServiceFactory> & _xFactory,const::rtl::OUString & _sServiceName)59 uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent>& _xReportComponent
60     ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
61     ,const ::rtl::OUString& _sServiceName)
62 {
63     OSL_ENSURE(_xReportComponent.is() && _xFactory.is() ,"reportcomponent is null -> GPF");
64     uno::Reference< report::XReportComponent> xClone(_xFactory->createInstance(_sServiceName),uno::UNO_QUERY_THROW);
65     ::comphelper::copyProperties(_xReportComponent.get(),xClone.get());
66     return xClone.get();
67 }
68 // -----------------------------------------------------------------------------
69 
70 // =============================================================================
71 } // namespace reportdesign
72 // =============================================================================
73