/src/libreoffice/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx
Line | Count | Source |
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 | | |
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> |
30 | | |
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; |
35 | | |
36 | | using namespace ::com::sun::star::uno; |
37 | | using namespace ::xmloff::token; |
38 | | |
39 | | XMLSectionSourceDDEImportContext::XMLSectionSourceDDEImportContext( |
40 | | SvXMLImport& rImport, |
41 | | Reference<XPropertySet> & rSectPropSet) : |
42 | 0 | SvXMLImportContext(rImport), |
43 | 0 | rSectionPropertySet(rSectPropSet) |
44 | 0 | { |
45 | 0 | } |
46 | | |
47 | | XMLSectionSourceDDEImportContext::~XMLSectionSourceDDEImportContext() |
48 | 0 | { |
49 | 0 | } |
50 | | |
51 | | void XMLSectionSourceDDEImportContext::startFastElement(sal_Int32 /*nElement*/, |
52 | | const Reference<XFastAttributeList> & xAttrList) |
53 | 0 | { |
54 | 0 | OUString sApplication; |
55 | 0 | OUString sTopic; |
56 | 0 | OUString sItem; |
57 | 0 | bool bAutomaticUpdate = false; |
58 | |
|
59 | 0 | for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) |
60 | 0 | { |
61 | 0 | switch (aIter.getToken()) |
62 | 0 | { |
63 | 0 | case XML_ELEMENT(OFFICE, XML_DDE_APPLICATION): |
64 | 0 | sApplication = aIter.toString(); |
65 | 0 | break; |
66 | 0 | case XML_ELEMENT(OFFICE, XML_DDE_TOPIC): |
67 | 0 | sTopic = aIter.toString(); |
68 | 0 | break; |
69 | 0 | case XML_ELEMENT(OFFICE, XML_DDE_ITEM): |
70 | 0 | sItem = aIter.toString(); |
71 | 0 | break; |
72 | 0 | case XML_ELEMENT(OFFICE, XML_AUTOMATIC_UPDATE): |
73 | 0 | { |
74 | 0 | bool bTmp(false); |
75 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
76 | 0 | { |
77 | 0 | bAutomaticUpdate = bTmp; |
78 | 0 | } |
79 | 0 | break; |
80 | 0 | } |
81 | 0 | default: |
82 | 0 | ; // ignore |
83 | 0 | break; |
84 | 0 | } |
85 | 0 | } |
86 | | |
87 | | // DDE not supported on all platforms; query property first |
88 | 0 | if (!rSectionPropertySet->getPropertySetInfo()-> |
89 | 0 | hasPropertyByName(u"DDECommandFile"_ustr)) |
90 | 0 | return; |
91 | | |
92 | | // use multi property set to force single update of connection #83654# |
93 | 0 | Sequence<OUString> aNames { u"DDECommandFile"_ustr, u"DDECommandType"_ustr, u"DDECommandElement"_ustr, u"IsAutomaticUpdate"_ustr }; |
94 | 0 | Sequence<Any> aValues { Any(sApplication), Any(sTopic), Any(sItem), Any(bAutomaticUpdate) }; |
95 | |
|
96 | 0 | Reference<XMultiPropertySet> rMultiPropSet(rSectionPropertySet, |
97 | 0 | UNO_QUERY); |
98 | 0 | DBG_ASSERT(rMultiPropSet.is(), "we'd really like a XMultiPropertySet"); |
99 | 0 | if (rMultiPropSet.is()) |
100 | 0 | rMultiPropSet->setPropertyValues(aNames, aValues); |
101 | | // else: ignore |
102 | |
|
103 | 0 | } |
104 | | |
105 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |