1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "xmllinebreakcontext.hxx"
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/frame/XModel.hpp>
14 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
15 #include <com/sun/star/text/XTextContent.hpp>
17 #include <xmloff/xmlement.hxx>
18 #include <xmloff/xmlimp.hxx>
19 #include <xmloff/xmlnamespace.hxx>
20 #include <xmloff/xmluconv.hxx>
22 using namespace com::sun::star
;
23 using namespace xmloff::token
;
27 const SvXMLEnumMapEntry
<sal_Int16
> pXML_LineBreakClear_Enum
[] = {
28 { XML_NONE
, 0 }, { XML_LEFT
, 1 }, { XML_RIGHT
, 2 }, { XML_ALL
, 3 }, { XML_TOKEN_INVALID
, 0 }
32 SvXMLLineBreakContext::SvXMLLineBreakContext(SvXMLImport
& rImport
, XMLTextImportHelper
& rHelper
)
33 : SvXMLImportContext(rImport
)
38 void SvXMLLineBreakContext::startFastElement(
39 sal_Int32
/*nElement*/, const uno::Reference
<xml::sax::XFastAttributeList
>& xAttrList
)
41 const uno::Reference
<frame::XModel
>& xModel
= GetImport().GetModel();
42 uno::Reference
<lang::XMultiServiceFactory
> xFactory(xModel
, uno::UNO_QUERY
);
46 uno::Reference
<text::XTextContent
> xLineBreak(
47 xFactory
->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY
);
50 OUString aClear
= xAttrList
->getValue(XML_ELEMENT(LO_EXT
, XML_CLEAR
));
51 if (SvXMLUnitConverter::convertEnum(eClear
, aClear
, pXML_LineBreakClear_Enum
))
53 uno::Reference
<beans::XPropertySet
> xLineBreakProps(xLineBreak
, uno::UNO_QUERY
);
54 xLineBreakProps
->setPropertyValue("Clear", uno::Any(eClear
));
57 m_rHelper
.InsertTextContent(xLineBreak
);
60 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */