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