nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / script / XMLStarBasicContextFactory.cxx
bloba0c9d7b0c1938c38f485b9cc38e0505d8135ba21
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <XMLStarBasicContextFactory.hxx>
21 #include <xmloff/XMLEventsImportContext.hxx>
22 #include <xmloff/xmlimp.hxx>
23 #include <xmloff/namespacemap.hxx>
24 #include <xmloff/xmlnamespace.hxx>
25 #include <xmloff/xmltoken.hxx>
28 using namespace ::xmloff::token;
30 using ::com::sun::star::xml::sax::XFastAttributeList;
31 using ::com::sun::star::beans::PropertyValue;
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::Sequence;
36 constexpr OUStringLiteral gsEventType(u"EventType");
37 constexpr OUStringLiteral gsLibrary(u"Library");
38 constexpr OUStringLiteral gsMacroName(u"MacroName");
39 constexpr OUStringLiteral gsStarBasic(u"StarBasic");
41 XMLStarBasicContextFactory::XMLStarBasicContextFactory()
45 XMLStarBasicContextFactory::~XMLStarBasicContextFactory()
49 SvXMLImportContext* XMLStarBasicContextFactory::CreateContext(
50 SvXMLImport& rImport,
51 const Reference<XFastAttributeList> & xAttrList,
52 XMLEventsImportContext* rEvents,
53 const OUString& rApiEventName)
55 OUString sLibraryVal;
56 OUString sMacroNameVal;
58 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
60 if (aIter.getToken() == XML_ELEMENT(SCRIPT, XML_MACRO_NAME))
61 sMacroNameVal = aIter.toString();
62 // else: ignore
65 const OUString& rApp = GetXMLToken( XML_APPLICATION );
66 const OUString& rDoc = GetXMLToken( XML_DOCUMENT );
67 if( sMacroNameVal.getLength() > rApp.getLength()+1 &&
68 sMacroNameVal.copy(0,rApp.getLength()).equalsIgnoreAsciiCase( rApp ) &&
69 ':' == sMacroNameVal[rApp.getLength()] )
71 sLibraryVal = "StarOffice";
72 sMacroNameVal = sMacroNameVal.copy( rApp.getLength()+1 );
74 else if( sMacroNameVal.getLength() > rDoc.getLength()+1 &&
75 sMacroNameVal.copy(0,rDoc.getLength()).equalsIgnoreAsciiCase( rDoc ) &&
76 ':' == sMacroNameVal[rDoc.getLength()] )
78 sLibraryVal = rDoc;
79 sMacroNameVal = sMacroNameVal.copy( rDoc.getLength()+1 );
82 Sequence<PropertyValue> aValues(3);
84 // EventType
85 aValues[0].Name = gsEventType;
86 aValues[0].Value <<= OUString(gsStarBasic);
88 // library name
89 aValues[1].Name = gsLibrary;
90 aValues[1].Value <<= sLibraryVal;
92 // macro name
93 aValues[2].Name = gsMacroName;
94 aValues[2].Value <<= sMacroNameVal;
96 // add values for event now
97 rEvents->AddEventValues(rApiEventName, aValues);
99 // return dummy context
100 return new SvXMLImportContext(rImport);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */