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 "XMLSectionImportContext.hxx"
22 #include <xmloff/xmlictxt.hxx>
23 #include <xmloff/xmlimp.hxx>
24 #include <xmloff/namespacemap.hxx>
25 #include <xmloff/xmlnamespace.hxx>
26 #include <xmloff/xmltoken.hxx>
27 #include <sax/tools/converter.hxx>
28 #include <com/sun/star/uno/Reference.h>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XMultiPropertySet.hpp>
31 #include <tools/debug.hxx>
33 using ::com::sun::star::beans::XPropertySet
;
34 using ::com::sun::star::beans::XMultiPropertySet
;
35 using ::com::sun::star::uno::Reference
;
36 using ::com::sun::star::xml::sax::XFastAttributeList
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::text
;
40 using namespace ::xmloff::token
;
42 XMLSectionSourceDDEImportContext::XMLSectionSourceDDEImportContext(
45 const OUString
& rLocalName
,
46 Reference
<XPropertySet
> & rSectPropSet
) :
47 SvXMLImportContext(rImport
, nPrfx
, rLocalName
),
48 rSectionPropertySet(rSectPropSet
)
52 XMLSectionSourceDDEImportContext::~XMLSectionSourceDDEImportContext()
56 void XMLSectionSourceDDEImportContext::startFastElement(sal_Int32
/*nElement*/,
57 const Reference
<XFastAttributeList
> & xAttrList
)
59 OUString sApplication
;
62 bool bAutomaticUpdate
= false;
64 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
66 switch (aIter
.getToken())
68 case XML_ELEMENT(OFFICE
, XML_DDE_APPLICATION
):
69 sApplication
= aIter
.toString();
71 case XML_ELEMENT(OFFICE
, XML_DDE_TOPIC
):
72 sTopic
= aIter
.toString();
74 case XML_ELEMENT(OFFICE
, XML_DDE_ITEM
):
75 sItem
= aIter
.toString();
77 case XML_ELEMENT(OFFICE
, XML_AUTOMATIC_UPDATE
):
80 if (::sax::Converter::convertBool(bTmp
, aIter
.toString()))
82 bAutomaticUpdate
= bTmp
;
92 // DDE not supported on all platforms; query property first
93 if (!rSectionPropertySet
->getPropertySetInfo()->
94 hasPropertyByName("DDECommandFile"))
97 // use multi property set to force single update of connection #83654#
98 Sequence
<OUString
> aNames(4);
99 Sequence
<Any
> aValues(4);
101 aValues
[0] <<= sApplication
;
102 aNames
[0] = "DDECommandFile";
104 aValues
[1] <<= sTopic
;
105 aNames
[1] = "DDECommandType";
107 aValues
[2] <<= sItem
;
108 aNames
[2] = "DDECommandElement";
110 aValues
[3] <<= bAutomaticUpdate
;
111 aNames
[3] = "IsAutomaticUpdate";
113 Reference
<XMultiPropertySet
> rMultiPropSet(rSectionPropertySet
,
115 DBG_ASSERT(rMultiPropSet
.is(), "we'd really like a XMultiPropertySet");
116 if (rMultiPropSet
.is())
117 rMultiPropSet
->setPropertyValues(aNames
, aValues
);
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */