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>
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>
32 
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;
37 
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::text;
40 using namespace ::xmloff::token;
41 
43  SvXMLImport& rImport,
44  sal_uInt16 nPrfx,
45  const OUString& rLocalName,
46  Reference<XPropertySet> & rSectPropSet) :
47  SvXMLImportContext(rImport, nPrfx, rLocalName),
48  rSectionPropertySet(rSectPropSet)
49 {
50 }
51 
53 {
54 }
55 
57  const Reference<XFastAttributeList> & xAttrList)
58 {
59  OUString sApplication;
60  OUString sTopic;
61  OUString sItem;
62  bool bAutomaticUpdate = false;
63 
64  for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
65  {
66  switch (aIter.getToken())
67  {
69  sApplication = aIter.toString();
70  break;
72  sTopic = aIter.toString();
73  break;
75  sItem = aIter.toString();
76  break;
78  {
79  bool bTmp(false);
80  if (::sax::Converter::convertBool(bTmp, aIter.toString()))
81  {
82  bAutomaticUpdate = bTmp;
83  }
84  break;
85  }
86  default:
87  ; // ignore
88  break;
89  }
90  }
91 
92  // DDE not supported on all platforms; query property first
93  if (!rSectionPropertySet->getPropertySetInfo()->
94  hasPropertyByName("DDECommandFile"))
95  return;
96 
97  // use multi property set to force single update of connection #83654#
98  Sequence<OUString> aNames(4);
99  Sequence<Any> aValues(4);
100 
101  aValues[0] <<= sApplication;
102  aNames[0] = "DDECommandFile";
103 
104  aValues[1] <<= sTopic;
105  aNames[1] = "DDECommandType";
106 
107  aValues[2] <<= sItem;
108  aNames[2] = "DDECommandElement";
109 
110  aValues[3] <<= bAutomaticUpdate;
111  aNames[3] = "IsAutomaticUpdate";
112 
113  Reference<XMultiPropertySet> rMultiPropSet(rSectionPropertySet,
114  UNO_QUERY);
115  DBG_ASSERT(rMultiPropSet.is(), "we'd really like a XMultiPropertySet");
116  if (rMultiPropSet.is())
117  rMultiPropSet->setPropertyValues(aNames, aValues);
118  // else: ignore
119 
120 }
121 
123 {
124  // nothing to be done!
125 }
126 
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
static bool convertBool(bool &rBool, const OUString &rString)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
#define DBG_ASSERT(sCon, aError)
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
XMLSectionSourceDDEImportContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLocalName, css::uno::Reference< css::beans::XPropertySet > &rSectPropSet)
css::uno::Reference< css::beans::XPropertySet > & rSectionPropertySet
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:94