LibreOffice Module xmloff (master) 1
XMLSectionSourceDDEImportContext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
22#include <xmloff/xmlictxt.hxx>
23#include <xmloff/xmlimp.hxx>
26#include <xmloff/xmltoken.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>
32
33using ::com::sun::star::beans::XPropertySet;
34using ::com::sun::star::beans::XMultiPropertySet;
35using ::com::sun::star::uno::Reference;
36using ::com::sun::star::xml::sax::XFastAttributeList;
37
38using namespace ::com::sun::star::uno;
39using namespace ::com::sun::star::text;
40using namespace ::xmloff::token;
41
43 SvXMLImport& rImport,
44 Reference<XPropertySet> & rSectPropSet) :
45 SvXMLImportContext(rImport),
46 rSectionPropertySet(rSectPropSet)
47{
48}
49
51{
52}
53
55 const Reference<XFastAttributeList> & xAttrList)
56{
57 OUString sApplication;
58 OUString sTopic;
59 OUString sItem;
60 bool bAutomaticUpdate = false;
61
62 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
63 {
64 switch (aIter.getToken())
65 {
67 sApplication = aIter.toString();
68 break;
70 sTopic = aIter.toString();
71 break;
73 sItem = aIter.toString();
74 break;
76 {
77 bool bTmp(false);
78 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
79 {
80 bAutomaticUpdate = bTmp;
81 }
82 break;
83 }
84 default:
85 ; // ignore
86 break;
87 }
88 }
89
90 // DDE not supported on all platforms; query property first
91 if (!rSectionPropertySet->getPropertySetInfo()->
92 hasPropertyByName("DDECommandFile"))
93 return;
94
95 // use multi property set to force single update of connection #83654#
96 Sequence<OUString> aNames { "DDECommandFile", "DDECommandType", "DDECommandElement", "IsAutomaticUpdate" };
97 Sequence<Any> aValues { Any(sApplication), Any(sTopic), Any(sItem), Any(bAutomaticUpdate) };
98
99 Reference<XMultiPropertySet> rMultiPropSet(rSectionPropertySet,
100 UNO_QUERY);
101 DBG_ASSERT(rMultiPropSet.is(), "we'd really like a XMultiPropertySet");
102 if (rMultiPropSet.is())
103 rMultiPropSet->setPropertyValues(aNames, aValues);
104 // else: ignore
105
106}
107
108/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
XMLSectionSourceDDEImportContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rSectPropSet)
css::uno::Reference< css::beans::XPropertySet > & rSectionPropertySet
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
static bool convertBool(bool &rBool, std::u16string_view rString)
#define DBG_ASSERT(sCon, aError)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_AUTOMATIC_UPDATE
Definition: xmltoken.hxx:304
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97