tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / reportdesign / source / core / api / Tools.cxx
blob8f066a68d6689fde45378d7358b60291f9dff98d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include <Tools.hxx>
20 #include <strings.hrc>
21 #include <core_resource.hxx>
22 #include <comphelper/property.hxx>
25 namespace reportdesign
28 using namespace com::sun::star;
30 uno::Reference< report::XSection> lcl_getSection(const uno::Reference< uno::XInterface>& _xReportComponent)
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() )
36 uno::Reference< uno::XInterface> xTemp = xChild->getParent();
37 xChild.set(xTemp,uno::UNO_QUERY);
38 xRet.set(xTemp,uno::UNO_QUERY);
40 return xRet;
43 void throwIllegallArgumentException( std::u16string_view _sTypeName
44 ,const uno::Reference< uno::XInterface >& ExceptionContext_
45 ,sal_Int16 ArgumentPosition_
48 OUString sErrorMessage(RptResId(RID_STR_ERROR_WRONG_ARGUMENT));
49 sErrorMessage = sErrorMessage.replaceAt(sErrorMessage.indexOf('#'),2,_sTypeName);
50 throw lang::IllegalArgumentException(sErrorMessage,ExceptionContext_,ArgumentPosition_);
53 uno::Reference< util::XCloneable > cloneObject(const uno::Reference< report::XReportComponent>& _xReportComponent
54 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
55 ,const OUString& _sServiceName)
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, xClone);
60 return xClone;
64 } // namespace reportdesign
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */