Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "XMLStarBasicExportHandler.hxx"
30 : :
31 : : #include <com/sun/star/beans/PropertyValue.hpp>
32 : : #include <xmloff/xmlexp.hxx>
33 : : #include <xmloff/xmltoken.hxx>
34 : : #include <xmloff/nmspmap.hxx>
35 : : #include "xmloff/xmlnmspe.hxx"
36 : :
37 : :
38 : : using namespace ::com::sun::star::uno;
39 : : using namespace ::xmloff::token;
40 : :
41 : : using ::rtl::OUString;
42 : : using ::rtl::OUStringBuffer;
43 : : using ::com::sun::star::beans::PropertyValue;
44 : :
45 : :
46 : 242 : XMLStarBasicExportHandler::XMLStarBasicExportHandler() :
47 : : sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")),
48 : : sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
49 : : sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
50 : : sStarOffice(RTL_CONSTASCII_USTRINGPARAM("StarOffice")),
51 [ + - ][ + - ]: 242 : sApplication(RTL_CONSTASCII_USTRINGPARAM("application"))
[ + - ][ + - ]
[ + - ]
52 : : {
53 : 242 : }
54 : :
55 : 242 : XMLStarBasicExportHandler::~XMLStarBasicExportHandler()
56 : : {
57 [ - + ]: 484 : }
58 : :
59 : 0 : void XMLStarBasicExportHandler::Export(
60 : : SvXMLExport& rExport,
61 : : const OUString& rEventQName,
62 : : Sequence<PropertyValue> & rValues,
63 : : sal_Bool bUseWhitespace)
64 : : {
65 : : rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_LANGUAGE,
66 : 0 : rExport.GetNamespaceMap().GetQNameByKey(
67 [ # # ][ # # ]: 0 : XML_NAMESPACE_OOO, sStarBasic ) );
68 [ # # ]: 0 : rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, rEventQName);
69 : :
70 : 0 : OUString sLocation, sName;
71 : 0 : sal_Int32 nCount = rValues.getLength();
72 [ # # ]: 0 : for(sal_Int32 i = 0; i < nCount; i++)
73 : : {
74 [ # # ][ # # ]: 0 : if (sLibrary.equals(rValues[i].Name))
75 : : {
76 : 0 : OUString sTmp;
77 [ # # ]: 0 : rValues[i].Value >>= sTmp;
78 : : sLocation = GetXMLToken(
79 : 0 : (sTmp.equalsIgnoreAsciiCase(sApplication) ||
80 : 0 : sTmp.equalsIgnoreAsciiCase(sStarOffice) ) ? XML_APPLICATION
81 [ # # ]: 0 : : XML_DOCUMENT );
[ # # # # ]
82 : : }
83 [ # # ][ # # ]: 0 : else if (sMacroName.equals(rValues[i].Name))
84 : : {
85 [ # # ]: 0 : rValues[i].Value >>= sName;
86 : : }
87 : : // else: disregard
88 : : }
89 : :
90 [ # # ]: 0 : if( !sLocation.isEmpty() )
91 : : {
92 : 0 : OUStringBuffer sTmp( sLocation.getLength() + sName.getLength() + 1 );
93 [ # # ][ # # ]: 0 : sTmp = sLocation;
94 [ # # ]: 0 : sTmp.append( sal_Unicode( ':' ) );
95 [ # # ]: 0 : sTmp.append( sName );
96 : : rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME,
97 [ # # ][ # # ]: 0 : sTmp.makeStringAndClear());
98 : : }
99 : : else
100 : : {
101 [ # # ]: 0 : rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME, sName );
102 : : }
103 : :
104 : : SvXMLElementExport aEventElemt(rExport, XML_NAMESPACE_SCRIPT,
105 : : XML_EVENT_LISTENER,
106 [ # # ][ # # ]: 0 : bUseWhitespace, sal_False);
107 : 0 : }
108 : :
109 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|