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/container/XIndexContainer.hpp>
16 #include <com/sun/star/drawing/XDrawPages.hpp>
17 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
18 
22 #include <oox/token/namespaces.hxx>
23 
24 using namespace ::com::sun::star;
25 using namespace ::com::sun::star::uno;
26 
27 namespace oox::ppt
28 {
30  const OUString& rFragmentPath)
31  : FragmentHandler2(rFilter, rFragmentPath)
32 {
33 }
34 
36 
38 {
39  css::uno::Reference<css::presentation::XPresentationSupplier> xPresentationSupplier(
40  getFilter().getModel(), css::uno::UNO_QUERY_THROW);
41  css::uno::Reference<css::beans::XPropertySet> xPresentationProps(
42  xPresentationSupplier->getPresentation(), css::uno::UNO_QUERY_THROW);
43  xPresentationProps->setPropertyValue("IsEndless", css::uno::Any(m_bLoop));
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);
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  return this;
77  case PPT_TOKEN(custShow):
78  m_sId = rAttribs.getString(XML_id).get();
79  return this;
80  case PPT_TOKEN(sldRg):
81  m_sSt = rAttribs.getString(XML_st).get();
82  return this;
83  }
84  return this;
85 }
86 } // namespace oox::ppt
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
OptValue< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
virtual core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
const Type & get() const
Definition: helper.hxx:185
virtual ~PresPropsFragmentHandler() override
Provides access to attribute values of an element.
PresPropsFragmentHandler(core::XmlFilterBase &rFilter, const OUString &rFragmentPath)