LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / xmloff / source / text / xmllinebreakcontext.cxx
blob97d8c918b35698f299dab2de7737165f9e4d8b50
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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;
25 namespace
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)
34 , m_rHelper(rHelper)
38 void SvXMLLineBreakContext::startFastElement(
39 sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList)
41 uno::Reference<lang::XMultiServiceFactory> xFactory(GetImport().GetModel(), uno::UNO_QUERY);
42 if (!xFactory.is())
43 return;
45 uno::Reference<text::XTextContent> xLineBreak(
46 xFactory->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY);
48 sal_Int16 eClear = 0;
49 OUString aClear = xAttrList->getValue(XML_ELEMENT(LO_EXT, XML_CLEAR));
50 if (SvXMLUnitConverter::convertEnum(eClear, aClear, pXML_LineBreakClear_Enum))
52 uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY);
53 xLineBreakProps->setPropertyValue("Clear", uno::makeAny(eClear));
56 m_rHelper.InsertTextContent(xLineBreak);
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */