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  xPresentationProps->setPropertyValue("IsAutomatic", css::uno::Any(!m_bTiming));
45 
46  if (!m_sId.isEmpty())
47  {
48  css::uno::Reference<css::presentation::XCustomPresentationSupplier>
49  XCustPresentationSupplier(getFilter().getModel(), css::uno::UNO_QUERY_THROW);
50  css::uno::Reference<css::container::XNameContainer> mxCustShows;
51  mxCustShows = XCustPresentationSupplier->getCustomPresentations();
52  const css::uno::Sequence<OUString> aNameSeq(mxCustShows->getElementNames());
53  xPresentationProps->setPropertyValue("CustomShow",
54  css::uno::Any(aNameSeq[m_sId.toInt32()]));
55  }
56 
57  if (!m_sSt.isEmpty())
58  {
59  Reference<drawing::XDrawPagesSupplier> xDPS(getFilter().getModel(), uno::UNO_QUERY_THROW);
60  Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
62  xDrawPages->getByIndex(m_sSt.toInt32() - 1) >>= xDrawPage;
63  Reference<container::XNamed> xNamed(xDrawPage, uno::UNO_QUERY_THROW);
64  xPresentationProps->setPropertyValue("FirstPage", uno::Any(xNamed->getName()));
65  }
66 }
67 
69  const AttributeList& rAttribs)
70 {
71  switch (aElementToken)
72  {
73  case PPT_TOKEN(presentationPr):
74  return this;
75  case PPT_TOKEN(showPr):
76  m_bLoop = rAttribs.getBool(XML_loop, false);
77  m_bTiming = rAttribs.getBool(XML_useTimings, true);
78  return this;
79  case PPT_TOKEN(custShow):
80  m_sId = rAttribs.getString(XML_id).get();
81  return this;
82  case PPT_TOKEN(sldRg):
83  m_sSt = rAttribs.getString(XML_st).get();
84  return this;
85  }
86  return this;
87 }
88 } // namespace oox::ppt
89 
90 /* 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)