LibreOffice Module xmloff (master) 1
xmllinebreakcontext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
11
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>
16
17#include <xmloff/xmlement.hxx>
18#include <xmloff/xmlimp.hxx>
20#include <xmloff/xmluconv.hxx>
21
22using namespace com::sun::star;
23using namespace xmloff::token;
24
25namespace
26{
27const SvXMLEnumMapEntry<sal_Int16> pXML_LineBreakClear_Enum[] = {
28 { XML_NONE, 0 }, { XML_LEFT, 1 }, { XML_RIGHT, 2 }, { XML_ALL, 3 }, { XML_TOKEN_INVALID, 0 }
29};
30}
31
33 : SvXMLImportContext(rImport)
34 , m_rHelper(rHelper)
35{
36}
37
39 sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList)
40{
41 const uno::Reference<frame::XModel>& xModel = GetImport().GetModel();
42 uno::Reference<lang::XMultiServiceFactory> xFactory(xModel, uno::UNO_QUERY);
43 if (!xFactory.is())
44 return;
45
46 uno::Reference<text::XTextContent> xLineBreak(
47 xFactory->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY);
48
49 sal_Int16 eClear = 0;
50 OUString aClear = xAttrList->getValue(XML_ELEMENT(LO_EXT, XML_CLEAR));
51 if (SvXMLUnitConverter::convertEnum(eClear, aClear, pXML_LineBreakClear_Enum))
52 {
53 uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY);
54 xLineBreakProps->setPropertyValue("Clear", uno::Any(eClear));
55 }
56
57 m_rHelper.InsertTextContent(xLineBreak);
58}
59
60/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
SvXMLLineBreakContext(SvXMLImport &rImport, XMLTextImportHelper &rHelper)
XMLTextImportHelper & m_rHelper
void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
void InsertTextContent(css::uno::Reference< css::text::XTextContent > const &xContent)
Definition: txtimp.cxx:757
Reference< XSingleServiceFactory > xFactory
Handling of tokens in XML:
Reference< XModel > xModel
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97