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