LibreOffice Module oox (master) 1
presPropsfragmenthandler.cxx
Go to the documentation of this file.
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
21#include <oox/token/namespaces.hxx>
22
23using namespace ::com::sun::star;
24using namespace ::com::sun::star::uno;
25
26namespace oox::ppt
27{
29 const OUString& rFragmentPath)
30 : FragmentHandler2(rFilter, rFragmentPath)
31{
32}
33
35
37{
38 css::uno::Reference<css::presentation::XPresentationSupplier> xPresentationSupplier(
39 getFilter().getModel(), css::uno::UNO_QUERY_THROW);
40 css::uno::Reference<css::beans::XPropertySet> xPresentationProps(
41 xPresentationSupplier->getPresentation(), css::uno::UNO_QUERY_THROW);
42 xPresentationProps->setPropertyValue("IsEndless", css::uno::Any(m_bLoop));
43 xPresentationProps->setPropertyValue("IsAutomatic", css::uno::Any(!m_bTiming));
44
45 if (!m_sId.isEmpty())
46 {
47 css::uno::Reference<css::presentation::XCustomPresentationSupplier>
48 XCustPresentationSupplier(getFilter().getModel(), css::uno::UNO_QUERY_THROW);
49 css::uno::Reference<css::container::XNameContainer> mxCustShows;
50 mxCustShows = XCustPresentationSupplier->getCustomPresentations();
51 const css::uno::Sequence<OUString> aNameSeq(mxCustShows->getElementNames());
52 xPresentationProps->setPropertyValue("CustomShow",
53 css::uno::Any(aNameSeq[m_sId.toInt32()]));
54 }
55
56 if (!m_sSt.isEmpty())
57 {
58 Reference<drawing::XDrawPagesSupplier> xDPS(getFilter().getModel(), uno::UNO_QUERY_THROW);
59 Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
60 Reference<drawing::XDrawPage> xDrawPage;
61 xDrawPages->getByIndex(m_sSt.toInt32() - 1) >>= xDrawPage;
62 Reference<container::XNamed> xNamed(xDrawPage, uno::UNO_QUERY_THROW);
63 xPresentationProps->setPropertyValue("FirstPage", uno::Any(xNamed->getName()));
64 }
65}
66
68 const AttributeList& rAttribs)
69{
70 switch (aElementToken)
71 {
72 case PPT_TOKEN(presentationPr):
73 return this;
74 case PPT_TOKEN(showPr):
75 m_bLoop = rAttribs.getBool(XML_loop, false);
76 m_bTiming = rAttribs.getBool(XML_useTimings, true);
77 return this;
78 case PPT_TOKEN(custShow):
79 m_sId = rAttribs.getStringDefaulted(XML_id);
80 return this;
81 case PPT_TOKEN(sldRg):
82 m_sSt = rAttribs.getStringDefaulted(XML_st);
83 return this;
84 }
85 return this;
86}
87} // namespace oox::ppt
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
PresPropsFragmentHandler(core::XmlFilterBase &rFilter, const OUString &rFragmentPath)
virtual ~PresPropsFragmentHandler() override
virtual core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, const AttributeList &rAttribs) override