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: XMLChangeImportContext.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 "XMLChangeImportContext.hxx"
34 #include <com/sun/star/text/XTextRange.hpp>
35 #include <tools/debug.hxx>
36 #include <xmloff/xmlimp.hxx>
37 #include "xmlnmspe.hxx"
38 #include <xmloff/nmspmap.hxx>
39 #include <xmloff/xmltoken.hxx>
41 using ::rtl::OUString
;
42 using ::com::sun::star::uno::Reference
;
43 using ::com::sun::star::text::XTextRange
;
44 using ::com::sun::star::xml::sax::XAttributeList
;
45 using ::xmloff::token::IsXMLToken
;
46 using ::xmloff::token::XML_CHANGE_ID
;
48 TYPEINIT1( XMLChangeImportContext
, SvXMLImportContext
);
50 XMLChangeImportContext::XMLChangeImportContext(
53 const OUString
& rLocalName
,
56 sal_Bool bOutsideOfParagraph
) :
57 SvXMLImportContext(rImport
, nPrefix
, rLocalName
),
60 bIsOutsideOfParagraph(bOutsideOfParagraph
)
62 DBG_ASSERT(bStart
|| bEnd
, "Must be either start, end, or both!");
65 XMLChangeImportContext::~XMLChangeImportContext()
69 void XMLChangeImportContext::StartElement(
70 const Reference
<XAttributeList
>& xAttrList
)
72 sal_Int16 nLength
= xAttrList
->getLength();
73 for(sal_Int16 nAttr
= 0; nAttr
< nLength
; nAttr
++)
76 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().
77 GetKeyByAttrName( xAttrList
->getNameByIndex(nAttr
),
79 if ( (XML_NAMESPACE_TEXT
== nPrefix
) &&
80 IsXMLToken( sLocalName
, XML_CHANGE_ID
) )
82 // Id found! Now call RedlineImportHelper
85 UniReference
<XMLTextImportHelper
> rHelper
=
86 GetImport().GetTextImport();
87 OUString sID
= xAttrList
->getValueByIndex(nAttr
);
89 // call for bStart and bEnd (may both be true)
91 rHelper
->RedlineSetCursor(sID
,sal_True
,bIsOutsideOfParagraph
);
93 rHelper
->RedlineSetCursor(sID
,sal_False
,bIsOutsideOfParagraph
);
95 // outside of paragraph and still open? set open redline ID
96 if (bIsOutsideOfParagraph
)
98 rHelper
->SetOpenRedlineId(sID
);