LibreOffice Module reportdesign (master)  1
Tools.cxx
Go to the documentation of this file.
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 #include <Tools.hxx>
20 #include <strings.hrc>
21 #include <core_resource.hxx>
22 #include <comphelper/property.hxx>
23 
24 
25 namespace reportdesign
26 {
27 
28 using namespace com::sun::star;
29 
30 uno::Reference< report::XSection> lcl_getSection(const uno::Reference< uno::XInterface>& _xReportComponent)
31 {
32  uno::Reference< container::XChild> xChild(_xReportComponent,uno::UNO_QUERY);
33  uno::Reference< report::XSection> xRet(_xReportComponent,uno::UNO_QUERY);
34  while( !xRet.is() && xChild.is() )
35  {
36  uno::Reference< uno::XInterface> xTemp = xChild->getParent();
37  xChild.set(xTemp,uno::UNO_QUERY);
38  xRet.set(xTemp,uno::UNO_QUERY);
39  }
40  return xRet;
41 }
42 
43 void throwIllegallArgumentException( const OUString& _sTypeName
44  ,const uno::Reference< uno::XInterface >& ExceptionContext_
45  ,sal_Int16 ArgumentPosition_
46  )
47 {
48  OUString sErrorMessage(RptResId(RID_STR_ERROR_WRONG_ARGUMENT));
49  sErrorMessage = sErrorMessage.replaceAt(sErrorMessage.indexOf('#'),2,_sTypeName);
50  throw lang::IllegalArgumentException(sErrorMessage,ExceptionContext_,ArgumentPosition_);
51 }
52 
53 uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent>& _xReportComponent
54  ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
55  ,const OUString& _sServiceName)
56 {
57  OSL_ENSURE(_xReportComponent.is() && _xFactory.is() ,"reportcomponent is null -> GPF");
58  uno::Reference< report::XReportComponent> xClone(_xFactory->createInstance(_sServiceName),uno::UNO_QUERY_THROW);
59  ::comphelper::copyProperties(_xReportComponent.get(),xClone.get());
60  return xClone.get();
61 }
62 
63 
64 } // namespace reportdesign
65 
66 
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno::Reference< report::XSection > lcl_getSection(const uno::Reference< uno::XInterface > &_xReportComponent)
Definition: Tools.cxx:30
void throwIllegallArgumentException(const OUString &_sTypeName, const uno::Reference< uno::XInterface > &ExceptionContext_, sal_Int16 ArgumentPosition_)
Definition: Tools.cxx:43
OUString RptResId(const char *pId)
uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent > &_xReportComponent, const uno::Reference< lang::XMultiServiceFactory > &_xFactory, const OUString &_sServiceName)
Definition: Tools.cxx:53