Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/appl/appbas.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
#include <config_features.h>
21
22
#include <sal/config.h>
23
24
#include <cassert>
25
26
#include <com/sun/star/beans/PropertyValue.hpp>
27
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
28
#include <officecfg/Office/Common.hxx>
29
#include <svl/intitem.hxx>
30
#include <svl/eitem.hxx>
31
#include <svl/whiter.hxx>
32
#include <svl/voiditem.hxx>
33
#include <basic/sbstar.hxx>
34
35
#include <sfx2/frame.hxx>
36
#include <sfx2/dinfdlg.hxx>
37
#include <sfx2/app.hxx>
38
#include <sfx2/msg.hxx>
39
#include <sfx2/request.hxx>
40
#include <sfx2/sfxsids.hrc>
41
#include <appdata.hxx>
42
#include <basic/basmgr.hxx>
43
#include <unotools/configmgr.hxx>
44
#include <sorgitm.hxx>
45
#include <appbaslib.hxx>
46
#include <basic/basicmanagerrepository.hxx>
47
48
#define SFX_TYPEMAP
49
#include <sfxslots.hxx>
50
51
using namespace ::com::sun::star;
52
using namespace ::com::sun::star::script;
53
54
using ::basic::BasicManagerRepository;
55
56
57
void SfxApplication::SaveBasicAndDialogContainer() const
58
0
{
59
0
    if ( pImpl->pBasicManager->isValid() )
60
0
        pImpl->pBasicManager->storeAllLibraries();
61
0
}
62
63
BasicManager* SfxApplication::GetBasicManager()
64
0
{
65
0
#if !HAVE_FEATURE_SCRIPTING
66
0
    return nullptr;
67
#else
68
    if (comphelper::IsFuzzing())
69
        return nullptr;
70
    return BasicManagerRepository::getApplicationBasicManager();
71
#endif
72
0
}
73
74
XStorageBasedLibraryContainer* SfxApplication::GetDialogContainer()
75
0
{
76
0
#if !HAVE_FEATURE_SCRIPTING
77
0
    return nullptr;
78
#else
79
    if (comphelper::IsFuzzing())
80
        return nullptr;
81
    if ( !pImpl->pBasicManager->isValid() )
82
        GetBasicManager();
83
    return pImpl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS );
84
#endif
85
0
}
86
87
88
XStorageBasedLibraryContainer* SfxApplication::GetBasicContainer()
89
22.9k
{
90
22.9k
#if !HAVE_FEATURE_SCRIPTING
91
22.9k
    return nullptr;
92
#else
93
    if (comphelper::IsFuzzing())
94
        return nullptr;
95
    if ( !pImpl->pBasicManager->isValid() )
96
        GetBasicManager();
97
    return pImpl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS );
98
#endif
99
22.9k
}
100
101
StarBASIC* SfxApplication::GetBasic()
102
0
{
103
0
#if !HAVE_FEATURE_SCRIPTING
104
0
    return nullptr;
105
#else
106
    if (comphelper::IsFuzzing())
107
        return nullptr;
108
    return GetBasicManager()->GetLib(0);
109
#endif
110
0
}
111
112
void SfxApplication::PropExec_Impl( SfxRequest const &rReq )
113
0
{
114
0
    sal_uInt16 nSID = rReq.GetSlot();
115
0
    switch ( nSID )
116
0
    {
117
0
        case SID_ATTR_UNDO_COUNT:
118
0
        {
119
0
            if (const SfxUInt16Item* pCountItem = rReq.GetArg<SfxUInt16Item>(nSID))
120
0
            {
121
0
                std::shared_ptr< comphelper::ConfigurationChanges > batch(
122
0
                    comphelper::ConfigurationChanges::create());
123
0
                officecfg::Office::Common::Undo::Steps::set(
124
0
                    pCountItem->GetValue(), batch);
125
0
                batch->commit();
126
0
            }
127
0
            break;
128
0
        }
129
130
0
        default:
131
0
            assert(false);
132
0
    }
133
0
}
134
135
void SfxApplication::PropState_Impl( SfxItemSet &rSet )
136
0
{
137
0
    SfxWhichIter aIter(rSet);
138
0
    for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
139
0
    {
140
0
        switch ( nSID )
141
0
        {
142
0
            case SID_ATTR_UNDO_COUNT:
143
0
                rSet.Put(
144
0
                    SfxUInt16Item(
145
0
                        SID_ATTR_UNDO_COUNT,
146
0
                        officecfg::Office::Common::Undo::Steps::get()));
147
0
                break;
148
149
0
            default:
150
                assert(false);
151
0
        }
152
0
    }
153
0
}
154
155
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */