Avoid potential negative array index access to cached text.
[LibreOffice.git] / extensions / source / propctrlr / MasterDetailLinkDialog.cxx
blob5f38856fc9c4947006c954dff25ec1b0745cd45b
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 .
20 #include <sal/log.hxx>
21 #include <com/sun/star/beans/PropertyValue.hpp>
22 #include <vcl/svapp.hxx>
23 #include "MasterDetailLinkDialog.hxx"
24 #include "formlinkdialog.hxx"
26 namespace pcr
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::lang;
32 using namespace ::com::sun::star::beans;
34 MasterDetailLinkDialog::MasterDetailLinkDialog(const Reference< XComponentContext >& _rxContext )
35 :OGenericUnoDialog( _rxContext )
39 Sequence<sal_Int8> SAL_CALL MasterDetailLinkDialog::getImplementationId( )
41 return css::uno::Sequence<sal_Int8>();
45 OUString SAL_CALL MasterDetailLinkDialog::getImplementationName()
47 return "org.openoffice.comp.form.ui.MasterDetailLinkDialog";
51 css::uno::Sequence<OUString> SAL_CALL MasterDetailLinkDialog::getSupportedServiceNames()
53 return { "com.sun.star.form.MasterDetailLinkDialog" };
57 Reference<XPropertySetInfo> SAL_CALL MasterDetailLinkDialog::getPropertySetInfo()
59 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
60 return xInfo;
64 ::cppu::IPropertyArrayHelper& MasterDetailLinkDialog::getInfoHelper()
66 return *getArrayHelper();
70 ::cppu::IPropertyArrayHelper* MasterDetailLinkDialog::createArrayHelper( ) const
72 Sequence< Property > aProps;
73 describeProperties(aProps);
74 return new ::cppu::OPropertyArrayHelper(aProps);
77 std::unique_ptr<weld::DialogController> MasterDetailLinkDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
79 return std::make_unique<FormLinkDialog>(Application::GetFrameWeld(rParent), m_xDetail,
80 m_xMaster, m_aContext, m_sExplanation,
81 m_sDetailLabel, m_sMasterLabel);
84 void MasterDetailLinkDialog::implInitialize(const Any& _rValue)
86 PropertyValue aProperty;
87 if (_rValue >>= aProperty)
89 if (aProperty.Name == "Detail")
91 if ( ! (aProperty.Value >>= m_xDetail) )
92 SAL_WARN("extensions.propctrlr", "implInitialize: unable to get property Detail");
93 return;
95 else if (aProperty.Name == "Master")
97 if ( ! (aProperty.Value >>= m_xMaster) )
98 SAL_WARN("extensions.propctrlr", "implInitialize: unable to get property Master");
99 return;
101 else if (aProperty.Name == "Explanation")
103 if ( ! (aProperty.Value >>= m_sExplanation) )
104 SAL_WARN("extensions.propctrlr", "implInitialize: unable to get property Explanation");
105 return;
107 else if (aProperty.Name == "DetailLabel")
109 if ( ! (aProperty.Value >>= m_sDetailLabel) )
110 SAL_WARN("extensions.propctrlr", "implInitialize: unable to get property DetailLabel");
111 return;
113 else if (aProperty.Name == "MasterLabel")
115 if ( ! (aProperty.Value >>= m_sMasterLabel) )
116 SAL_WARN("extensions.propctrlr", "implInitialize: unable to get property MasterLabel");
117 return;
120 MasterDetailLinkDialog_DBase::implInitialize(_rValue);
124 } // namespace pcr
126 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
127 extensions_propctrlr_MasterDetailLinkDialog_get_implementation(
128 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
130 return cppu::acquire(new pcr::MasterDetailLinkDialog(context));
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */