Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/XMLCalculationSettingsContext.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 "XMLCalculationSettingsContext.hxx"
22
23
#include <com/sun/star/beans/XPropertySet.hpp>
24
#include <com/sun/star/text/XTextDocument.hpp>
25
26
#include <sal/log.hxx>
27
28
#include <xmloff/xmlimp.hxx>
29
#include <xmloff/xmlnamespace.hxx>
30
#include <xmloff/xmltoken.hxx>
31
32
33
using namespace ::com::sun::star::uno;
34
using namespace ::com::sun::star::beans;
35
using namespace ::com::sun::star::text;
36
using namespace ::xmloff::token;
37
38
XMLCalculationSettingsContext::XMLCalculationSettingsContext( SvXMLImport& rImport,
39
                                    sal_Int32 /*nElement*/,
40
                                    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
41
5
: SvXMLImportContext ( rImport )
42
5
, nYear( 1930 )
43
5
{
44
5
    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
45
10
    {
46
10
        if (aIter.getToken() == XML_ELEMENT(TABLE, XML_NULL_YEAR) )
47
0
        {
48
0
            nYear = static_cast <sal_Int16> (aIter.toInt32());
49
0
        }
50
10
        else
51
10
            XMLOFF_WARN_UNKNOWN("xmloff", aIter);
52
10
    }
53
5
}
54
55
XMLCalculationSettingsContext::~XMLCalculationSettingsContext()
56
5
{
57
5
}
58
void XMLCalculationSettingsContext::endFastElement(sal_Int32 )
59
5
{
60
5
    if (nYear != 1930 )
61
0
    {
62
0
        Reference < XTextDocument > xTextDoc ( GetImport().GetModel(), UNO_QUERY);
63
0
        if (xTextDoc.is())
64
0
        {
65
0
            Reference < XPropertySet > xPropSet ( xTextDoc, UNO_QUERY );
66
0
            xPropSet->setPropertyValue ( u"TwoDigitYear"_ustr, Any(nYear) );
67
0
        }
68
0
    }
69
5
}
70
71
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */