Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/txtdropi.cxx
Line
Count
Source
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>
26
#include <sax/tools/converter.hxx>
27
28
#include <xmloff/xmluconv.hxx>
29
#include <xmloff/xmlnamespace.hxx>
30
#include <xmloff/xmlimp.hxx>
31
#include <xmloff/xmltoken.hxx>
32
33
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;
38
39
void XMLTextDropCapImportContext::ProcessAttrs(
40
        const Reference< xml::sax::XFastAttributeList >& xAttrList )
41
0
{
42
0
    DropCapFormat aFormat;
43
0
    bool bWholeWord = false;
44
45
0
    sal_Int32 nTmp;
46
0
    for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList))
47
0
    {
48
0
        switch( aIter.getToken() )
49
0
        {
50
0
        case XML_ELEMENT(STYLE, XML_LINES):
51
0
            if (::sax::Converter::convertNumber( nTmp, aIter.toView(), 0, 255 ))
52
0
            {
53
0
                aFormat.Lines = nTmp < 2 ? 0 : static_cast<sal_Int8>(nTmp);
54
0
            }
55
0
            break;
56
57
0
        case XML_ELEMENT(STYLE, XML_LENGTH):
58
0
            if( IsXMLToken( aIter, XML_WORD ) )
59
0
            {
60
0
                bWholeWord = true;
61
0
            }
62
0
            else if (::sax::Converter::convertNumber( nTmp, aIter.toView(), 1, 255 ))
63
0
            {
64
0
                bWholeWord = false;
65
0
                aFormat.Count = static_cast<sal_Int8>(nTmp);
66
0
            }
67
0
            break;
68
69
0
        case XML_ELEMENT(STYLE, XML_DISTANCE):
70
0
            if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
71
0
                        nTmp, aIter.toView(), 0, SAL_MAX_INT16 ))
72
0
            {
73
0
                aFormat.Distance = static_cast<sal_Int16>(nTmp);
74
0
            }
75
0
            break;
76
77
0
        case XML_ELEMENT(STYLE, XML_STYLE_NAME):
78
0
            sStyleName = aIter.toString();
79
0
            break;
80
81
0
        default:
82
0
            XMLOFF_WARN_UNKNOWN("xmloff", aIter);
83
0
        }
84
0
    }
85
86
0
    if( aFormat.Lines > 1 && aFormat.Count < 1 )
87
0
        aFormat.Count = 1;
88
89
0
    aProp.maValue <<= aFormat;
90
91
0
    aWholeWordProp.maValue <<= bWholeWord;
92
0
}
93
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
0
    XMLElementPropertyContext( rImport, nElement, rProp, rProps ),
101
0
    aWholeWordProp( nWholeWordIdx )
102
0
{
103
0
    ProcessAttrs( xAttrList );
104
0
}
105
106
XMLTextDropCapImportContext::~XMLTextDropCapImportContext()
107
0
{
108
0
}
109
110
void XMLTextDropCapImportContext::endFastElement(sal_Int32 nElement)
111
0
{
112
0
    SetInsert( true );
113
0
    XMLElementPropertyContext::endFastElement(nElement);
114
115
0
    if( -1 != aWholeWordProp.mnIndex )
116
0
        rProperties.push_back( aWholeWordProp );
117
0
}
118
119
120
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */