1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLChangeElementImportContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLChangeElementImportContext.hxx"
34 #include "XMLChangedRegionImportContext.hxx"
35 #include "XMLChangeInfoContext.hxx"
36 #include <com/sun/star/uno/Reference.h>
37 #include <xmloff/xmlimp.hxx>
38 #include "xmlnmspe.hxx"
39 #include <xmloff/xmltoken.hxx>
43 using ::rtl::OUString
;
44 using ::com::sun::star::uno::Reference
;
45 using ::com::sun::star::xml::sax::XAttributeList
;
46 using ::xmloff::token::IsXMLToken
;
47 using ::xmloff::token::XML_P
;
48 using ::xmloff::token::XML_CHANGE_INFO
;
50 TYPEINIT1( XMLChangeElementImportContext
, SvXMLImportContext
);
52 XMLChangeElementImportContext::XMLChangeElementImportContext(
55 const OUString
& rLocalName
,
57 XMLChangedRegionImportContext
& rParent
) :
58 SvXMLImportContext(rImport
, nPrefix
, rLocalName
),
59 bAcceptContent(bAccContent
),
60 rChangedRegion(rParent
)
64 SvXMLImportContext
* XMLChangeElementImportContext::CreateChildContext(
66 const OUString
& rLocalName
,
67 const Reference
<XAttributeList
> & xAttrList
)
69 SvXMLImportContext
* pContext
= NULL
;
71 if ( (XML_NAMESPACE_OFFICE
== nPrefix
) &&
72 IsXMLToken( rLocalName
, XML_CHANGE_INFO
) )
74 pContext
= new XMLChangeInfoContext(GetImport(), nPrefix
, rLocalName
,
75 rChangedRegion
, GetLocalName());
79 // import into redline -> create XText
80 rChangedRegion
.UseRedlineText();
82 pContext
= GetImport().GetTextImport()->CreateTextChildContext(
83 GetImport(), nPrefix
, rLocalName
, xAttrList
,
84 XML_TEXT_TYPE_CHANGED_REGION
);
88 // no text element -> use default
89 pContext
= SvXMLImportContext::CreateChildContext(
90 nPrefix
, rLocalName
, xAttrList
);
92 // illegal element content! TODO: discard this redline!
101 void XMLChangeElementImportContext::StartElement( const Reference
< XAttributeList
>& )
105 GetImport().GetTextImport()->SetInsideDeleteContext(sal_True
);
110 void XMLChangeElementImportContext::EndElement()
114 GetImport().GetTextImport()->SetInsideDeleteContext(sal_False
);