LibreOffice Module xmloff (master) 1
XMLTextListItemContext.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <xmloff/xmlimp.hxx>
23#include <xmloff/xmltoken.hxx>
24#include "txtparai.hxx"
25#include <txtlists.hxx>
27#include <xmloff/txtimp.hxx>
28#include <com/sun/star/container/XNameContainer.hpp>
29#include <com/sun/star/beans/XPropertySet.hpp>
30#include <com/sun/star/style/XStyle.hpp>
31#include <xmloff/xmlnumi.hxx>
34#include <sal/log.hxx>
35
36
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::uno;
39using namespace ::xmloff::token;
40
41
43 SvXMLImport& rImport,
44 XMLTextImportHelper& rTxtImp,
45 const Reference< xml::sax::XFastAttributeList > & xAttrList,
46 const bool bIsHeader )
47 : SvXMLImportContext( rImport ),
48 rTxtImport( rTxtImp ),
49 nStartValue( -1 ),
50 mnSubListCount( 0 )
51{
52 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
53 {
54 if( !bIsHeader && aIter.getToken() == XML_ELEMENT(TEXT, XML_START_VALUE) )
55 {
56 sal_Int32 nTmp = aIter.toInt32();
57 if( nTmp >= 0 && nTmp <= SHRT_MAX )
58 nStartValue = static_cast<sal_Int16>(nTmp);
59 }
60 else if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_OVERRIDE) )
61 {
62 OUString sListStyleOverrideName = aIter.toString();
63 if ( !sListStyleOverrideName.isEmpty() )
64 {
65 OUString sDisplayStyleName(
66 GetImport().GetStyleDisplayName( XmlStyleFamily::TEXT_LIST,
67 sListStyleOverrideName ) );
68 const Reference < container::XNameContainer >& rNumStyles =
69 rTxtImp.GetNumberingStyles();
70 if( rNumStyles.is() && rNumStyles->hasByName( sDisplayStyleName ) )
71 {
72 Reference < style::XStyle > xStyle;
73 Any aAny = rNumStyles->getByName( sDisplayStyleName );
74 aAny >>= xStyle;
75
76 uno::Reference< beans::XPropertySet > xPropSet( xStyle, UNO_QUERY );
77 aAny = xPropSet->getPropertyValue("NumberingRules");
78 aAny >>= mxNumRulesOverride;
79 }
80 else
81 {
82 const SvxXMLListStyleContext* pListStyle =
83 rTxtImp.FindAutoListStyle( sListStyleOverrideName );
84 if( pListStyle )
85 {
86 mxNumRulesOverride = pListStyle->GetNumRules();
87 if( !mxNumRulesOverride.is() )
88 {
89 pListStyle->CreateAndInsertAuto();
90 mxNumRulesOverride = pListStyle->GetNumRules();
91 }
92 }
93 }
94 }
95 }
96 else if ( aIter.getToken() == XML_ELEMENT(XML, XML_ID) )
97 {
98//FIXME: there is no UNO API for list items
99 }
100 else
101 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
102 }
103
104 // If this is a <text:list-item> element, then remember it as a sign
105 // that a bullet has to be generated.
106 if( !bIsHeader ) {
107 rTxtImport.GetTextListHelper().SetListItem( this );
108 }
109
110}
111
113{
114}
115
117{
118 // finish current list item
120}
121
122css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextListItemContext::createFastChildContext(
123 sal_Int32 nElement,
124 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
125{
126 SvXMLImportContext *pContext = nullptr;
127
128 switch( nElement )
129 {
130 case XML_ELEMENT(TEXT, XML_H):
131 case XML_ELEMENT(TEXT, XML_P):
132 case XML_ELEMENT(LO_EXT, XML_P):
133 pContext = new XMLParaContext( GetImport(), nElement,
134 xAttrList );
136 GetImport().GetProgressBarHelper()->Increment();
137
138 break;
142 xAttrList,
143 (mnSubListCount > 1) );
144 break;
145 default:
146 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
147 }
148
149 return pContext;
150}
151
152/* 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
const css::uno::Reference< css::container::XIndexReplace > & GetNumRules() const
Definition: xmlnumi.hxx:63
void CreateAndInsertAuto() const
Definition: xmlnumi.cxx:1013
XMLTextListsHelper & GetTextListHelper()
Definition: txtimp.cxx:332
bool IsProgress() const
Definition: txtimp.cxx:246
const SvxXMLListStyleContext * FindAutoListStyle(const OUString &rName) const
Definition: txtimp.cxx:1980
const css::uno::Reference< css::container::XNameContainer > & GetNumberingStyles() const
Definition: txtimp.cxx:264
XMLTextListItemContext(SvXMLImport &rImport, XMLTextImportHelper &rTxtImp, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const bool bIsHeader)
virtual ~XMLTextListItemContext() override
XMLTextImportHelper & rTxtImport
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
void SetListItem(XMLTextListItemContext *pListItem)
set list item on top of the list context stack
Definition: txtlists.cxx:87
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
TEXT
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97