xref: /AOO41X/main/sw/source/filter/xml/xmltext.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <xmloff/xmlnmspe.hxx>
29 #include "xmlimp.hxx"
30 
31 using ::rtl::OUString;
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::text;
35 
36 // ---------------------------------------------------------------------
37 
38 
39 class SwXMLBodyContentContext_Impl : public SvXMLImportContext
40 {
GetSwImport()41     SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
42 
43 public:
44 
45     SwXMLBodyContentContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
46                           const OUString& rLName );
47     virtual ~SwXMLBodyContentContext_Impl();
48 
49     virtual SvXMLImportContext *CreateChildContext(
50             sal_uInt16 nPrefix, const OUString& rLocalName,
51             const Reference< xml::sax::XAttributeList > & xAttrList );
52 
53     // The body element's text:global attribute can be ignored, because
54     // we must have the correct object shell already.
55     virtual void EndElement();
56 };
57 
SwXMLBodyContentContext_Impl(SwXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName)58 SwXMLBodyContentContext_Impl::SwXMLBodyContentContext_Impl( SwXMLImport& rImport,
59                                               sal_uInt16 nPrfx,
60                                               const OUString& rLName ) :
61     SvXMLImportContext( rImport, nPrfx, rLName )
62 {
63 }
64 
~SwXMLBodyContentContext_Impl()65 SwXMLBodyContentContext_Impl::~SwXMLBodyContentContext_Impl()
66 {
67 }
68 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)69 SvXMLImportContext *SwXMLBodyContentContext_Impl::CreateChildContext(
70         sal_uInt16 nPrefix, const OUString& rLocalName,
71         const Reference< xml::sax::XAttributeList > & xAttrList )
72 {
73     SvXMLImportContext *pContext = 0;
74 
75     pContext = GetSwImport().GetTextImport()->CreateTextChildContext(
76             GetImport(), nPrefix, rLocalName, xAttrList,
77             XML_TEXT_TYPE_BODY );
78     if( !pContext )
79         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
80 
81     return pContext;
82 }
83 
EndElement()84 void SwXMLBodyContentContext_Impl::EndElement()
85 {
86     /* #108146# Code moved to SwXMLOmport::endDocument */
87     GetImport().GetTextImport()->SetOutlineStyles( sal_False );
88 }
89 
CreateBodyContentContext(const OUString & rLocalName)90 SvXMLImportContext *SwXMLImport::CreateBodyContentContext(
91                                        const OUString& rLocalName )
92 {
93     SvXMLImportContext *pContext = 0;
94 
95     if( !IsStylesOnlyMode() )
96         pContext = new SwXMLBodyContentContext_Impl( *this, XML_NAMESPACE_OFFICE,
97                                               rLocalName );
98     else
99         pContext = new SvXMLImportContext( *this, XML_NAMESPACE_OFFICE,
100                                            rLocalName );
101 
102     return pContext;
103 }
104