tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / xmloff / source / text / XMLSectionSourceDDEImportContext.cxx
blob49525fd977c0915731520c0564e45fa70113e73d
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 "XMLSectionSourceDDEImportContext.hxx"
21 #include <xmloff/xmlictxt.hxx>
22 #include <xmloff/xmlimp.hxx>
23 #include <xmloff/xmlnamespace.hxx>
24 #include <xmloff/xmltoken.hxx>
25 #include <sax/tools/converter.hxx>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/XMultiPropertySet.hpp>
29 #include <tools/debug.hxx>
31 using ::com::sun::star::beans::XPropertySet;
32 using ::com::sun::star::beans::XMultiPropertySet;
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::xml::sax::XFastAttributeList;
36 using namespace ::com::sun::star::uno;
37 using namespace ::xmloff::token;
39 XMLSectionSourceDDEImportContext::XMLSectionSourceDDEImportContext(
40 SvXMLImport& rImport,
41 Reference<XPropertySet> & rSectPropSet) :
42 SvXMLImportContext(rImport),
43 rSectionPropertySet(rSectPropSet)
47 XMLSectionSourceDDEImportContext::~XMLSectionSourceDDEImportContext()
51 void XMLSectionSourceDDEImportContext::startFastElement(sal_Int32 /*nElement*/,
52 const Reference<XFastAttributeList> & xAttrList)
54 OUString sApplication;
55 OUString sTopic;
56 OUString sItem;
57 bool bAutomaticUpdate = false;
59 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
61 switch (aIter.getToken())
63 case XML_ELEMENT(OFFICE, XML_DDE_APPLICATION):
64 sApplication = aIter.toString();
65 break;
66 case XML_ELEMENT(OFFICE, XML_DDE_TOPIC):
67 sTopic = aIter.toString();
68 break;
69 case XML_ELEMENT(OFFICE, XML_DDE_ITEM):
70 sItem = aIter.toString();
71 break;
72 case XML_ELEMENT(OFFICE, XML_AUTOMATIC_UPDATE):
74 bool bTmp(false);
75 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
77 bAutomaticUpdate = bTmp;
79 break;
81 default:
82 ; // ignore
83 break;
87 // DDE not supported on all platforms; query property first
88 if (!rSectionPropertySet->getPropertySetInfo()->
89 hasPropertyByName(u"DDECommandFile"_ustr))
90 return;
92 // use multi property set to force single update of connection #83654#
93 Sequence<OUString> aNames { u"DDECommandFile"_ustr, u"DDECommandType"_ustr, u"DDECommandElement"_ustr, u"IsAutomaticUpdate"_ustr };
94 Sequence<Any> aValues { Any(sApplication), Any(sTopic), Any(sItem), Any(bAutomaticUpdate) };
96 Reference<XMultiPropertySet> rMultiPropSet(rSectionPropertySet,
97 UNO_QUERY);
98 DBG_ASSERT(rMultiPropSet.is(), "we'd really like a XMultiPropertySet");
99 if (rMultiPropSet.is())
100 rMultiPropSet->setPropertyValues(aNames, aValues);
101 // else: ignore
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */