1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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(
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
;
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();
66 case XML_ELEMENT(OFFICE
, XML_DDE_TOPIC
):
67 sTopic
= aIter
.toString();
69 case XML_ELEMENT(OFFICE
, XML_DDE_ITEM
):
70 sItem
= aIter
.toString();
72 case XML_ELEMENT(OFFICE
, XML_AUTOMATIC_UPDATE
):
75 if (::sax::Converter::convertBool(bTmp
, aIter
.toView()))
77 bAutomaticUpdate
= bTmp
;
87 // DDE not supported on all platforms; query property first
88 if (!rSectionPropertySet
->getPropertySetInfo()->
89 hasPropertyByName(u
"DDECommandFile"_ustr
))
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
,
98 DBG_ASSERT(rMultiPropSet
.is(), "we'd really like a XMultiPropertySet");
99 if (rMultiPropSet
.is())
100 rMultiPropSet
->setPropertyValues(aNames
, aValues
);
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */