Bump version to 24.04.3.4
[LibreOffice.git] / oox / source / ppt / presPropsfragmenthandler.cxx
blob2cd9d82950d02a5321f4a7796e233349d7bd542d
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.
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 */
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>
18 #include <oox/core/xmlfilterbase.hxx>
19 #include <oox/helper/attributelist.hxx>
20 #include <oox/ppt/presPropsfragmenthandler.hxx>
21 #include <oox/token/namespaces.hxx>
23 using namespace ::com::sun::star;
24 using namespace ::com::sun::star::uno;
26 namespace oox::ppt
28 PresPropsFragmentHandler::PresPropsFragmentHandler(core::XmlFilterBase& rFilter,
29 const OUString& rFragmentPath)
30 : FragmentHandler2(rFilter, rFragmentPath)
34 PresPropsFragmentHandler::~PresPropsFragmentHandler() = default;
36 void PresPropsFragmentHandler::finalizeImport()
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));
45 if (!m_sId.isEmpty())
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()]));
56 if (!m_sSt.isEmpty())
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()));
67 core::ContextHandlerRef PresPropsFragmentHandler::onCreateContext(sal_Int32 aElementToken,
68 const AttributeList& rAttribs)
70 switch (aElementToken)
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;
85 return this;
87 } // namespace oox::ppt
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */