tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / text / txtdropi.cxx
blob896da4eed561b2e2c0d1f9d6753e80088b2c1581
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 .
21 #include "txtdropi.hxx"
23 #include <com/sun/star/style/DropCapFormat.hpp>
25 #include <sal/log.hxx>
26 #include <sax/tools/converter.hxx>
28 #include <xmloff/xmluconv.hxx>
29 #include <xmloff/xmlnamespace.hxx>
30 #include <xmloff/xmlimp.hxx>
31 #include <xmloff/xmltoken.hxx>
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::style;
37 using namespace ::xmloff::token;
39 void XMLTextDropCapImportContext::ProcessAttrs(
40 const Reference< xml::sax::XFastAttributeList >& xAttrList )
42 DropCapFormat aFormat;
43 bool bWholeWord = false;
45 sal_Int32 nTmp;
46 for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList))
48 switch( aIter.getToken() )
50 case XML_ELEMENT(STYLE, XML_LINES):
51 if (::sax::Converter::convertNumber( nTmp, aIter.toView(), 0, 255 ))
53 aFormat.Lines = nTmp < 2 ? 0 : static_cast<sal_Int8>(nTmp);
55 break;
57 case XML_ELEMENT(STYLE, XML_LENGTH):
58 if( IsXMLToken( aIter, XML_WORD ) )
60 bWholeWord = true;
62 else if (::sax::Converter::convertNumber( nTmp, aIter.toView(), 1, 255 ))
64 bWholeWord = false;
65 aFormat.Count = static_cast<sal_Int8>(nTmp);
67 break;
69 case XML_ELEMENT(STYLE, XML_DISTANCE):
70 if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
71 nTmp, aIter.toView(), 0, SAL_MAX_INT16 ))
73 aFormat.Distance = static_cast<sal_Int16>(nTmp);
75 break;
77 case XML_ELEMENT(STYLE, XML_STYLE_NAME):
78 sStyleName = aIter.toString();
79 break;
81 default:
82 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
86 if( aFormat.Lines > 1 && aFormat.Count < 1 )
87 aFormat.Count = 1;
89 aProp.maValue <<= aFormat;
91 aWholeWordProp.maValue <<= bWholeWord;
94 XMLTextDropCapImportContext::XMLTextDropCapImportContext(
95 SvXMLImport& rImport, sal_Int32 nElement,
96 const Reference< xml::sax::XFastAttributeList > & xAttrList,
97 const XMLPropertyState& rProp,
98 sal_Int32 nWholeWordIdx,
99 ::std::vector< XMLPropertyState > &rProps ) :
100 XMLElementPropertyContext( rImport, nElement, rProp, rProps ),
101 aWholeWordProp( nWholeWordIdx )
103 ProcessAttrs( xAttrList );
106 XMLTextDropCapImportContext::~XMLTextDropCapImportContext()
110 void XMLTextDropCapImportContext::endFastElement(sal_Int32 nElement)
112 SetInsert( true );
113 XMLElementPropertyContext::endFastElement(nElement);
115 if( -1 != aWholeWordProp.mnIndex )
116 rProperties.push_back( aWholeWordProp );
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */