tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / text / XMLTextListItemContext.cxx
blob886bc43f17f4d3cea35358f2e7648b410bc9b2ea
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <xmloff/xmlimp.hxx>
21 #include <xmloff/xmlnamespace.hxx>
22 #include <xmloff/xmltoken.hxx>
23 #include "txtparai.hxx"
24 #include <txtlists.hxx>
25 #include "XMLTextListBlockContext.hxx"
26 #include <xmloff/txtimp.hxx>
27 #include <com/sun/star/container/XNameContainer.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/style/XStyle.hpp>
30 #include <xmloff/xmlnumi.hxx>
31 #include <xmloff/ProgressBarHelper.hxx>
32 #include "XMLTextListItemContext.hxx"
33 #include <sal/log.hxx>
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using namespace ::xmloff::token;
41 XMLTextListItemContext::XMLTextListItemContext(
42 SvXMLImport& rImport,
43 XMLTextImportHelper& rTxtImp,
44 const Reference< xml::sax::XFastAttributeList > & xAttrList,
45 const bool bIsHeader )
46 : SvXMLImportContext( rImport ),
47 rTxtImport( rTxtImp ),
48 nStartValue( -1 ),
49 mnSubListCount( 0 )
51 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
53 if( !bIsHeader && aIter.getToken() == XML_ELEMENT(TEXT, XML_START_VALUE) )
55 sal_Int32 nTmp = aIter.toInt32();
56 if( nTmp >= 0 && nTmp <= SHRT_MAX )
57 nStartValue = static_cast<sal_Int16>(nTmp);
59 else if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_OVERRIDE) )
61 OUString sListStyleOverrideName = aIter.toString();
62 if ( !sListStyleOverrideName.isEmpty() )
64 OUString sDisplayStyleName(
65 GetImport().GetStyleDisplayName( XmlStyleFamily::TEXT_LIST,
66 sListStyleOverrideName ) );
67 const Reference < container::XNameContainer >& rNumStyles =
68 rTxtImp.GetNumberingStyles();
69 if( rNumStyles.is() && rNumStyles->hasByName( sDisplayStyleName ) )
71 Reference < style::XStyle > xStyle;
72 Any aAny = rNumStyles->getByName( sDisplayStyleName );
73 aAny >>= xStyle;
75 uno::Reference< beans::XPropertySet > xPropSet( xStyle, UNO_QUERY );
76 aAny = xPropSet->getPropertyValue(u"NumberingRules"_ustr);
77 aAny >>= mxNumRulesOverride;
79 else
81 const SvxXMLListStyleContext* pListStyle =
82 rTxtImp.FindAutoListStyle( sListStyleOverrideName );
83 if( pListStyle )
85 mxNumRulesOverride = pListStyle->GetNumRules();
86 if( !mxNumRulesOverride.is() )
88 pListStyle->CreateAndInsertAuto();
89 mxNumRulesOverride = pListStyle->GetNumRules();
95 else if ( aIter.getToken() == XML_ELEMENT(XML, XML_ID) )
97 //FIXME: there is no UNO API for list items
99 else
100 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
103 // If this is a <text:list-item> element, then remember it as a sign
104 // that a bullet has to be generated.
105 if( !bIsHeader ) {
106 rTxtImport.GetTextListHelper().SetListItem( this );
111 XMLTextListItemContext::~XMLTextListItemContext()
115 void XMLTextListItemContext::endFastElement(sal_Int32 )
117 // finish current list item
118 rTxtImport.GetTextListHelper().SetListItem( nullptr );
121 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextListItemContext::createFastChildContext(
122 sal_Int32 nElement,
123 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
125 SvXMLImportContext *pContext = nullptr;
127 switch( nElement )
129 case XML_ELEMENT(TEXT, XML_H):
130 case XML_ELEMENT(TEXT, XML_P):
131 case XML_ELEMENT(LO_EXT, XML_P):
132 pContext = new XMLParaContext( GetImport(), nElement,
133 xAttrList );
134 if (rTxtImport.IsProgress())
135 GetImport().GetProgressBarHelper()->Increment();
137 break;
138 case XML_ELEMENT(TEXT, XML_LIST):
139 ++mnSubListCount;
140 pContext = new XMLTextListBlockContext( GetImport(), rTxtImport,
141 xAttrList,
142 (mnSubListCount > 1) );
143 break;
144 default:
145 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
148 return pContext;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */