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 <SwXMLSectionList.hxx>
30 : : #include <xmloff/nmspmap.hxx>
31 : : #include <xmloff/xmlnmspe.hxx>
32 : : #include <tools/string.hxx>
33 : : #include <vector>
34 : :
35 : : using namespace ::com::sun::star;
36 : : using ::rtl::OUString;
37 : : using namespace ::xmloff::token;
38 : :
39 : : sal_Char const sXML_np__office[] = "_ooffice";
40 : : sal_Char const sXML_np__text[] = "_otext";
41 : :
42 : : // #110680#
43 : 0 : SwXMLSectionList::SwXMLSectionList(
44 : : const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
45 : : std::vector<String*> &rNewSectionList)
46 : : : SvXMLImport( xServiceFactory ),
47 : 0 : rSectionList ( rNewSectionList )
48 : : {
49 : 0 : GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
50 [ # # ]: 0 : GetXMLToken(XML_N_OFFICE_OOO),
51 [ # # # # ]: 0 : XML_NAMESPACE_OFFICE );
52 : 0 : GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text ) ),
53 [ # # ]: 0 : GetXMLToken(XML_N_TEXT_OOO),
54 [ # # # # ]: 0 : XML_NAMESPACE_TEXT );
55 : 0 : }
56 : :
57 : 0 : SwXMLSectionList::~SwXMLSectionList ( void )
58 : 0 : throw()
59 : : {
60 [ # # ]: 0 : }
61 : :
62 : 0 : SvXMLImportContext *SwXMLSectionList::CreateContext(
63 : : sal_uInt16 nPrefix,
64 : : const OUString& rLocalName,
65 : : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
66 : : {
67 : 0 : SvXMLImportContext *pContext = 0;
68 : :
69 [ # # ][ # # ]: 0 : if(( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken ( rLocalName, XML_BODY )) ||
[ # # # #
# # # # #
# # # # #
# # # # #
# ][ # # ]
70 : : ( nPrefix == XML_NAMESPACE_TEXT &&
71 : 0 : (IsXMLToken ( rLocalName, XML_P ) ||
72 : 0 : IsXMLToken ( rLocalName, XML_H ) ||
73 : 0 : IsXMLToken ( rLocalName, XML_A ) ||
74 : 0 : IsXMLToken ( rLocalName, XML_SPAN ) ||
75 : 0 : IsXMLToken ( rLocalName, XML_SECTION ) ||
76 : 0 : IsXMLToken ( rLocalName, XML_INDEX_BODY ) ||
77 : 0 : IsXMLToken ( rLocalName, XML_INDEX_TITLE )||
78 : 0 : IsXMLToken ( rLocalName, XML_INSERTION ) ||
79 : 0 : IsXMLToken ( rLocalName, XML_DELETION ) )
80 : : )
81 : : )
82 : : {
83 [ # # ]: 0 : pContext = new SvXMLSectionListContext (*this, nPrefix, rLocalName, xAttrList);
84 : : }
85 : : else
86 : 0 : pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
87 : 0 : return pContext;
88 : : }
89 : :
90 : 0 : SvXMLSectionListContext::SvXMLSectionListContext(
91 : : SwXMLSectionList& rImport,
92 : : sal_uInt16 nPrefix,
93 : : const OUString& rLocalName,
94 : : const uno::Reference< xml::sax::XAttributeList > & ) :
95 : : SvXMLImportContext ( rImport, nPrefix, rLocalName ),
96 : 0 : rLocalRef(rImport)
97 : : {
98 : 0 : }
99 : :
100 : 0 : SvXMLImportContext *SvXMLSectionListContext::CreateChildContext(
101 : : sal_uInt16 nPrefix,
102 : : const OUString& rLocalName,
103 : : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
104 : : {
105 : 0 : SvXMLImportContext *pContext = 0;
106 [ # # ]: 0 : String sName;
107 : :
108 [ # # ][ # # ]: 0 : if (nPrefix == XML_NAMESPACE_TEXT && ( IsXMLToken ( rLocalName, XML_SECTION ) ||
[ # # ][ # # ]
[ # # ]
109 [ # # ]: 0 : IsXMLToken ( rLocalName, XML_BOOKMARK) ) )
110 : : {
111 [ # # ][ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ # # ]
112 : :
113 [ # # ]: 0 : for (sal_Int16 i=0; i < nAttrCount; i++)
114 : : {
115 [ # # ][ # # ]: 0 : const OUString& rAttrName = xAttrList->getNameByIndex( i );
116 : 0 : OUString aLocalName;
117 [ # # ]: 0 : sal_uInt16 nPrefx = rLocalRef.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName);
118 [ # # ][ # # ]: 0 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
119 [ # # ][ # # ]: 0 : if (XML_NAMESPACE_TEXT == nPrefx && IsXMLToken ( aLocalName, XML_NAME ) )
[ # # ][ # # ]
120 [ # # ]: 0 : sName = rAttrValue;
121 : 0 : }
122 [ # # ]: 0 : if ( sName.Len() )
123 [ # # ][ # # ]: 0 : rLocalRef.rSectionList.push_back( new String(sName) );
[ # # ]
124 : : }
125 : :
126 [ # # ][ # # ]: 0 : pContext = new SvXMLSectionListContext (rLocalRef, nPrefix, rLocalName, xAttrList);
127 [ # # ]: 0 : return pContext;
128 : : }
129 : 0 : SvXMLSectionListContext::~SvXMLSectionListContext ( void )
130 : : {
131 [ # # ]: 0 : }
132 : :
133 : 0 : SvXMLIgnoreSectionListContext::SvXMLIgnoreSectionListContext(
134 : : SwXMLSectionList& rImport,
135 : : sal_uInt16 nPrefix,
136 : : const OUString& rLocalName,
137 : : const uno::Reference< xml::sax::XAttributeList > & ) :
138 : : SvXMLImportContext ( rImport, nPrefix, rLocalName ),
139 : 0 : rLocalRef(rImport)
140 : : {
141 : 0 : }
142 : :
143 : 0 : SvXMLIgnoreSectionListContext::~SvXMLIgnoreSectionListContext ( void )
144 : : {
145 [ # # ]: 0 : }
146 : 0 : SvXMLImportContext *SvXMLIgnoreSectionListContext::CreateChildContext(
147 : : sal_uInt16 nPrefix,
148 : : const OUString& rLocalName,
149 : : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
150 : : {
151 [ # # ]: 0 : return new SvXMLIgnoreSectionListContext (rLocalRef, nPrefix, rLocalName, xAttrList);
152 : : }
153 : :
154 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|