Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/forms/layerimport.hxx
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
#pragma once
21
22
#include <sal/config.h>
23
24
#include <map>
25
#include <unordered_map>
26
27
#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
28
#include <com/sun/star/drawing/XDrawPage.hpp>
29
#include <com/sun/star/form/XFormsSupplier2.hpp>
30
#include <rtl/ref.hxx>
31
#include "formattributes.hxx"
32
#include "eventimport.hxx"
33
34
class SvXMLImport;
35
class SvXMLImportContext;
36
class SvXMLStyleContext;
37
class SvXMLStylesContext;
38
39
    // unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
40
    // declaration of the class name, which then would be in the namespace, too
41
42
namespace xmloff
43
{
44
    //= OFormLayerXMLImport_Impl
45
    class OFormLayerXMLImport_Impl
46
                : public ODefaultEventAttacherManager
47
    {
48
        friend class OFormLayerXMLImport;
49
50
        SvXMLImport&                        m_rImporter;
51
        OAttribute2Property                 m_aAttributeMetaData;
52
53
        /// the supplier for the forms of the currently imported page
54
        css::uno::Reference< css::form::XFormsSupplier2 >
55
                                            m_xCurrentPageFormsSupp;
56
        rtl::Reference<SvXMLStylesContext>  m_xAutoStyles;
57
58
        typedef std::map< OUString, css::uno::Reference< css::beans::XPropertySet > > MapString2PropertySet;
59
        typedef std::unordered_map<css::uno::Reference<css::drawing::XDrawPage>, MapString2PropertySet> MapDrawPage2Map;
60
61
        MapDrawPage2Map         m_aControlIds;          // ids of the controls on all known page
62
        MapDrawPage2Map::iterator m_aCurrentPageIds;      // ifs of the controls on the current page
63
64
        typedef ::std::pair< css::uno::Reference< css::beans::XPropertySet >, OUString >
65
                                ModelStringPair;
66
        ::std::vector< ModelStringPair >
67
                                m_aControlReferences;   // control reference descriptions for current page
68
        ::std::vector< ModelStringPair >
69
                                m_aCellValueBindings;   // information about controls bound to spreadsheet cells
70
        ::std::vector< ModelStringPair >
71
                                m_aCellRangeListSources;// information about controls bound to spreadsheet cell range list sources
72
73
        ::std::vector< ModelStringPair >
74
                                m_aXFormsValueBindings; // collect xforms:bind attributes to be resolved
75
76
        ::std::vector< ModelStringPair >
77
                                m_aXFormsListBindings; // collect forms:xforms-list-source attributes to be resolved
78
79
        ::std::vector< ModelStringPair >
80
                                m_aXFormsSubmissions;   // collect xforms:submission attributes to be resolved
81
82
    public:
83
        // IControlIdMap
84
        void    registerControlId(
85
            const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
86
            const OUString& _rId);
87
        void    registerControlReferences(
88
            const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
89
            const OUString& _rReferringControls);
90
91
        // OFormLayerXMLImport_Impl
92
0
        OAttribute2Property&         getAttributeMap()   { return m_aAttributeMetaData; }
93
2.96k
        SvXMLImport&                 getGlobalContext()  { return m_rImporter; }
94
        const SvXMLStyleContext*            getStyleElement(const OUString& _rStyleName) const;
95
        void                                enterEventContext();
96
        void                                leaveEventContext();
97
        void                                applyControlNumberStyle(
98
            const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
99
            const OUString& _rControlNumberStyleName
100
        );
101
        void                        registerCellValueBinding(
102
            const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
103
            const OUString& _rCellAddress
104
        );
105
106
        void                        registerCellRangeListSource(
107
            const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
108
            const OUString& _rCellRangeAddress
109
        );
110
111
        void                        registerXFormsValueBinding(
112
            const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
113
            const OUString& _rBindingID
114
        );
115
116
        void                        registerXFormsListBinding(
117
            const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
118
            const OUString& _rBindingID
119
        );
120
121
        void                        registerXFormsSubmission(
122
            const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
123
            const OUString& _rSubmissionID
124
        );
125
126
        ~OFormLayerXMLImport_Impl() override;
127
128
    private:
129
        explicit OFormLayerXMLImport_Impl(SvXMLImport& _rImporter);
130
131
        /** start importing the forms of the given page
132
        */
133
        void startPage(
134
            const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
135
136
        /** end importing the forms of the current page
137
        */
138
        void endPage();
139
140
        /** creates an import context for the office:forms element
141
        */
142
        static SvXMLImportContext* createOfficeFormsContext(
143
            SvXMLImport& _rImport);
144
145
        /** create an <type>SvXMLImportContext</type> instance which is able to import the &lt;form:form&gt;
146
            element.
147
        */
148
        SvXMLImportContext* createContext(
149
            sal_Int32 nElement,
150
            const css::uno::Reference< css::xml::sax::XFastAttributeList >& _rxAttribs);
151
152
        /** get the control with the given id
153
        */
154
        css::uno::Reference< css::beans::XPropertySet >
155
                lookupControlId(const OUString& _rControlId);
156
157
        /** announces the auto-style context to the form importer
158
        */
159
        void setAutoStyleContext(SvXMLStylesContext* _pNewContext);
160
161
        /** to be called when the document has been completely imported
162
163
            <p>For some documents (currently: only some spreadsheet documents) it's necessary
164
            do to a post processing, since not all information from the file can be processed
165
            if the document is not completed, yet.</p>
166
        */
167
        void documentDone( );
168
    };
169
170
}   // namespace xmloff
171
172
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */