Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/xforms/XFormsModelContext.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 "XFormsModelContext.hxx"
22
23
#include "XFormsBindContext.hxx"
24
#include "XFormsSubmissionContext.hxx"
25
#include "XFormsInstanceContext.hxx"
26
#include "SchemaContext.hxx"
27
#include "xformsapi.hxx"
28
29
#include <xmloff/xmlimp.hxx>
30
#include <xmloff/xmlnamespace.hxx>
31
#include <xmloff/xmltoken.hxx>
32
#include <xmloff/xmlerror.hxx>
33
34
#include <sal/log.hxx>
35
36
#include <com/sun/star/util/XUpdatable.hpp>
37
38
39
using com::sun::star::util::XUpdatable;
40
using namespace com::sun::star::uno;
41
using namespace xmloff::token;
42
43
44
XFormsModelContext::XFormsModelContext( SvXMLImport& rImport ) :
45
0
    TokenContext( rImport ),
46
0
    mxModel( xforms_createXFormsModel() )
47
0
{
48
0
}
49
50
void XFormsModelContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
51
0
{
52
0
    switch( aIter.getToken() & TOKEN_MASK)
53
0
    {
54
0
    case XML_ID:
55
0
        mxModel->setPropertyValue( u"ID"_ustr, Any( aIter.toString() ) );
56
0
        break;
57
0
    case XML_SCHEMA:
58
0
        GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT );
59
0
        break;
60
0
    default:
61
0
        XMLOFF_WARN_UNKNOWN("xmloff", aIter);
62
0
        assert( false && "this should not happen" );
63
0
        break;
64
0
    }
65
0
}
66
67
SvXMLImportContext* XFormsModelContext::HandleChild(
68
    sal_Int32 nElementToken,
69
    const Reference<css::xml::sax::XFastAttributeList>& )
70
0
{
71
0
    SvXMLImportContext* pContext = nullptr;
72
73
0
    switch( nElementToken )
74
0
    {
75
0
    case XML_ELEMENT(XFORMS, XML_INSTANCE):
76
0
        pContext = new XFormsInstanceContext( GetImport(), mxModel );
77
0
        break;
78
0
    case XML_ELEMENT(XFORMS, XML_BIND):
79
0
        pContext = new XFormsBindContext( GetImport(), mxModel );
80
0
        break;
81
0
    case XML_ELEMENT(XFORMS, XML_SUBMISSION):
82
0
        pContext = new XFormsSubmissionContext( GetImport(), mxModel );
83
0
        break;
84
0
    case XML_ELEMENT(XSD, XML_SCHEMA):
85
0
        pContext = new SchemaContext( GetImport(), mxModel->getDataTypeRepository() );
86
0
        break;
87
0
    default:
88
0
        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken);
89
0
        assert( false && "Boooo!" );
90
0
        break;
91
0
    }
92
93
0
    return pContext;
94
0
}
95
96
void XFormsModelContext::endFastElement(sal_Int32 )
97
0
{
98
    // update before putting model into document
99
0
    Reference<XUpdatable> xUpdate( mxModel, UNO_QUERY );
100
0
    if( xUpdate.is() )
101
0
        xUpdate->update();
102
103
0
    GetImport().initXForms();
104
0
    xforms_addXFormsModel( GetImport().GetModel(), mxModel );
105
0
}
106
107
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */