LibreOffice Module xmloff (master) 1
txtdropi.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
21#include "txtdropi.hxx"
22
23#include <com/sun/star/style/DropCapFormat.hpp>
24
25#include <sal/log.hxx>
27
28#include <xmloff/xmltkmap.hxx>
29#include <xmloff/xmluconv.hxx>
32#include <xmloff/xmlimp.hxx>
33#include <xmloff/xmltoken.hxx>
34
35
36using namespace ::com::sun::star;
37using namespace ::com::sun::star::uno;
38using namespace ::com::sun::star::style;
39using namespace ::xmloff::token;
40
42 const Reference< xml::sax::XFastAttributeList >& xAttrList )
43{
44 DropCapFormat aFormat;
45 bool bWholeWord = false;
46
47 sal_Int32 nTmp;
48 for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList))
49 {
50 switch( aIter.getToken() )
51 {
53 if (::sax::Converter::convertNumber( nTmp, aIter.toView(), 0, 255 ))
54 {
55 aFormat.Lines = nTmp < 2 ? 0 : static_cast<sal_Int8>(nTmp);
56 }
57 break;
58
60 if( IsXMLToken( aIter, XML_WORD ) )
61 {
62 bWholeWord = true;
63 }
64 else if (::sax::Converter::convertNumber( nTmp, aIter.toView(), 1, 255 ))
65 {
66 bWholeWord = false;
67 aFormat.Count = static_cast<sal_Int8>(nTmp);
68 }
69 break;
70
72 if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
73 nTmp, aIter.toView(), 0 ))
74 {
75 aFormat.Distance = static_cast<sal_uInt16>(nTmp);
76 }
77 break;
78
80 sStyleName = aIter.toString();
81 break;
82
83 default:
84 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
85 }
86 }
87
88 if( aFormat.Lines > 1 && aFormat.Count < 1 )
89 aFormat.Count = 1;
90
91 aProp.maValue <<= aFormat;
92
93 aWholeWordProp.maValue <<= bWholeWord;
94}
95
97 SvXMLImport& rImport, sal_Int32 nElement,
98 const Reference< xml::sax::XFastAttributeList > & xAttrList,
99 const XMLPropertyState& rProp,
100 sal_Int32 nWholeWordIdx,
101 ::std::vector< XMLPropertyState > &rProps ) :
102 XMLElementPropertyContext( rImport, nElement, rProp, rProps ),
103 aWholeWordProp( nWholeWordIdx )
104{
105 ProcessAttrs( xAttrList );
106}
107
109{
110}
111
113{
114 SetInsert( true );
116
117 if( -1 != aWholeWordProp.mnIndex )
118 rProperties.push_back( aWholeWordProp );
119}
120
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
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 ...
::std::vector< XMLPropertyState > & rProperties
void ProcessAttrs(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: txtdropi.cxx:41
XMLTextDropCapImportContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const XMLPropertyState &rProp, sal_Int32 nWholeWOrdIdx, ::std::vector< XMLPropertyState > &rProps)
Definition: txtdropi.cxx:96
virtual ~XMLTextDropCapImportContext() override
Definition: txtdropi.cxx:108
XMLPropertyState aWholeWordProp
Definition: txtdropi.hxx:26
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 ...
Definition: txtdropi.cxx:112
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3597
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:140
css::uno::Any maValue
Definition: maptype.hxx:142
sal_Int32 mnIndex
Definition: maptype.hxx:141
signed char sal_Int8
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97