Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/ppt/presPropsfragmenthandler.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10
#include <com/sun/star/beans/XPropertySet.hpp>
11
#include <com/sun/star/frame/XModel.hpp>
12
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
13
#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
14
#include <com/sun/star/container/XNamed.hpp>
15
#include <com/sun/star/drawing/XDrawPages.hpp>
16
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
17
18
#include <oox/core/xmlfilterbase.hxx>
19
#include <oox/helper/attributelist.hxx>
20
#include <oox/ppt/presPropsfragmenthandler.hxx>
21
#include <oox/token/namespaces.hxx>
22
23
using namespace ::com::sun::star;
24
using namespace ::com::sun::star::uno;
25
26
namespace oox::ppt
27
{
28
PresPropsFragmentHandler::PresPropsFragmentHandler(core::XmlFilterBase& rFilter,
29
                                                   const OUString& rFragmentPath)
30
824
    : FragmentHandler2(rFilter, rFragmentPath)
31
824
{
32
824
}
33
34
824
PresPropsFragmentHandler::~PresPropsFragmentHandler() = default;
35
36
void PresPropsFragmentHandler::finalizeImport()
37
716
{
38
716
    css::uno::Reference<css::presentation::XPresentationSupplier> xPresentationSupplier(
39
716
        getFilter().getModel(), css::uno::UNO_QUERY_THROW);
40
716
    css::uno::Reference<css::beans::XPropertySet> xPresentationProps(
41
716
        xPresentationSupplier->getPresentation(), css::uno::UNO_QUERY_THROW);
42
716
    xPresentationProps->setPropertyValue(u"IsEndless"_ustr, css::uno::Any(m_bLoop));
43
716
    xPresentationProps->setPropertyValue(u"IsAutomatic"_ustr, css::uno::Any(!m_bTiming));
44
45
716
    if (!m_sId.isEmpty())
46
0
    {
47
0
        css::uno::Reference<css::presentation::XCustomPresentationSupplier>
48
0
            XCustPresentationSupplier(getFilter().getModel(), css::uno::UNO_QUERY_THROW);
49
0
        css::uno::Reference<css::container::XNameContainer> mxCustShows;
50
0
        mxCustShows = XCustPresentationSupplier->getCustomPresentations();
51
0
        const css::uno::Sequence<OUString> aNameSeq(mxCustShows->getElementNames());
52
0
        xPresentationProps->setPropertyValue(u"CustomShow"_ustr,
53
0
                                             css::uno::Any(aNameSeq[m_sId.toInt32()]));
54
0
    }
55
56
716
    if (!m_sSt.isEmpty())
57
0
    {
58
0
        Reference<drawing::XDrawPagesSupplier> xDPS(getFilter().getModel(), uno::UNO_QUERY_THROW);
59
0
        Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
60
0
        Reference<drawing::XDrawPage> xDrawPage;
61
0
        xDrawPages->getByIndex(m_sSt.toInt32() - 1) >>= xDrawPage;
62
0
        Reference<container::XNamed> xNamed(xDrawPage, uno::UNO_QUERY_THROW);
63
0
        xPresentationProps->setPropertyValue(u"FirstPage"_ustr, uno::Any(xNamed->getName()));
64
0
    }
65
716
}
66
67
core::ContextHandlerRef PresPropsFragmentHandler::onCreateContext(sal_Int32 aElementToken,
68
                                                                  const AttributeList& rAttribs)
69
4.03k
{
70
4.03k
    switch (aElementToken)
71
4.03k
    {
72
716
        case PPT_TOKEN(presentationPr):
73
716
            return this;
74
82
        case PPT_TOKEN(showPr):
75
82
            m_bLoop = rAttribs.getBool(XML_loop, false);
76
82
            m_bTiming = rAttribs.getBool(XML_useTimings, true);
77
82
            return this;
78
0
        case PPT_TOKEN(custShow):
79
0
            m_sId = rAttribs.getStringDefaulted(XML_id);
80
0
            return this;
81
0
        case PPT_TOKEN(sldRg):
82
0
            m_sSt = rAttribs.getStringDefaulted(XML_st);
83
0
            return this;
84
4.03k
    }
85
3.23k
    return this;
86
4.03k
}
87
} // namespace oox::ppt
88
89
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */