LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/unoidl - SdUnoSlideView.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 67 1.5 %
Date: 2013-07-09 Functions: 2 16 12.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <comphelper/serviceinfohelper.hxx>
      22             : 
      23             : #include "DrawController.hxx"
      24             : #include "SdUnoSlideView.hxx"
      25             : 
      26             : #include "SlideSorter.hxx"
      27             : #include "controller/SlideSorterController.hxx"
      28             : #include "controller/SlsPageSelector.hxx"
      29             : #include "controller/SlsCurrentSlideManager.hxx"
      30             : #include "model/SlsPageEnumerationProvider.hxx"
      31             : #include "model/SlideSorterModel.hxx"
      32             : #include "model/SlsPageDescriptor.hxx"
      33             : #include "sdpage.hxx"
      34             : #include <com/sun/star/beans/XPropertySet.hpp>
      35             : 
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::uno;
      39             : 
      40             : namespace sd {
      41             : 
      42             : 
      43           0 : SdUnoSlideView::SdUnoSlideView (
      44             :     slidesorter::SlideSorter& rSlideSorter) throw()
      45             :     : DrawSubControllerInterfaceBase(m_aMutex),
      46           0 :       mrSlideSorter(rSlideSorter)
      47             : {
      48           0 : }
      49             : 
      50             : 
      51             : 
      52             : 
      53           0 : SdUnoSlideView::~SdUnoSlideView (void) throw()
      54             : {
      55           0 : }
      56             : 
      57             : 
      58             : 
      59             : 
      60             : //----- XSelectionSupplier ----------------------------------------------------
      61             : 
      62           0 : sal_Bool SAL_CALL SdUnoSlideView::select (const Any& aSelection)
      63             :       throw(lang::IllegalArgumentException, RuntimeException)
      64             : {
      65           0 :     bool bOk = true;
      66             : 
      67             :     slidesorter::controller::SlideSorterController& rSlideSorterController
      68           0 :         = mrSlideSorter.GetController();
      69           0 :     slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector());
      70           0 :     rSelector.DeselectAllPages();
      71           0 :     Sequence<Reference<drawing::XDrawPage> > xPages;
      72           0 :     aSelection >>= xPages;
      73           0 :     const sal_uInt32 nCount = xPages.getLength();
      74           0 :     for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
      75             :     {
      76           0 :         Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY);
      77           0 :         if (xSet.is())
      78             :         {
      79             :             try
      80             :             {
      81           0 :                 Any aNumber = xSet->getPropertyValue("Number");
      82           0 :                 sal_Int32 nPageNumber = 0;
      83           0 :                 aNumber >>= nPageNumber;
      84           0 :                 nPageNumber -=1; // Transform 1-based page numbers to 0-based ones.
      85           0 :                 rSelector.SelectPage(nPageNumber);
      86             :             }
      87           0 :             catch (const RuntimeException&)
      88             :             {
      89             :             }
      90             :         }
      91           0 :     }
      92             : 
      93           0 :     return bOk;
      94             : }
      95             : 
      96             : 
      97             : 
      98             : 
      99           0 : Any SAL_CALL SdUnoSlideView::getSelection (void)
     100             :       throw(RuntimeException)
     101             : {
     102           0 :     Any aResult;
     103             : 
     104             :     slidesorter::model::PageEnumeration aSelectedPages (
     105             :         slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
     106           0 :             mrSlideSorter.GetModel()));
     107             :     int nSelectedPageCount (
     108           0 :         mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount());
     109             : 
     110           0 :     Sequence<Reference<XInterface> > aPages(nSelectedPageCount);
     111           0 :     int nIndex = 0;
     112           0 :     while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount)
     113             :     {
     114           0 :         slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
     115           0 :         aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage();
     116           0 :     }
     117           0 :     aResult <<= aPages;
     118             : 
     119           0 :     return aResult;
     120             : }
     121             : 
     122             : 
     123             : 
     124             : 
     125           0 : void SAL_CALL SdUnoSlideView::addSelectionChangeListener (
     126             :     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
     127             :     throw(css::uno::RuntimeException)
     128             : {
     129             :     (void)rxListener;
     130           0 : }
     131             : 
     132             : 
     133             : 
     134             : 
     135           0 : void SAL_CALL SdUnoSlideView::removeSelectionChangeListener (
     136             :     const css::uno::Reference<css::view::XSelectionChangeListener>& rxListener)
     137             :     throw(css::uno::RuntimeException)
     138             : {
     139             :     (void)rxListener;
     140           0 : }
     141             : 
     142             : 
     143             : 
     144             : 
     145             : //----- XDrawView -------------------------------------------------------------
     146             : 
     147           0 : void SAL_CALL SdUnoSlideView::setCurrentPage (
     148             :     const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage)
     149             :     throw(css::uno::RuntimeException)
     150             : {
     151           0 :     Reference<beans::XPropertySet> xProperties (rxDrawPage, UNO_QUERY);
     152           0 :     if (xProperties.is())
     153             :     {
     154           0 :         sal_uInt16 nPageNumber(0);
     155           0 :         if (xProperties->getPropertyValue("Number") >>= nPageNumber)
     156             :         {
     157           0 :             mrSlideSorter.GetController().GetCurrentSlideManager()->SwitchCurrentSlide(
     158           0 :                 nPageNumber-1,
     159           0 :                 true);
     160             :         }
     161           0 :     }
     162           0 : }
     163             : 
     164             : 
     165             : 
     166             : 
     167             : css::uno::Reference<css::drawing::XDrawPage > SAL_CALL
     168           0 :     SdUnoSlideView::getCurrentPage (void)
     169             :     throw(css::uno::RuntimeException)
     170             : {
     171           0 :     return mrSlideSorter.GetController().GetCurrentSlideManager()->GetCurrentSlide()->GetXDrawPage();
     172             : }
     173             : 
     174             : 
     175             : 
     176             : 
     177             : //----- XFastPropertySet ------------------------------------------------------
     178             : 
     179           0 : void SdUnoSlideView::setFastPropertyValue (
     180             :     sal_Int32 nHandle,
     181             :         const Any& rValue)
     182             :     throw(css::beans::UnknownPropertyException,
     183             :         css::beans::PropertyVetoException,
     184             :         css::lang::IllegalArgumentException,
     185             :         css::lang::WrappedTargetException,
     186             :         css::uno::RuntimeException)
     187             : {
     188             :     (void)nHandle;
     189             :     (void)rValue;
     190             : 
     191           0 :     throw beans::UnknownPropertyException();
     192             : }
     193             : 
     194             : 
     195             : 
     196             : 
     197           0 : Any SAL_CALL SdUnoSlideView::getFastPropertyValue (
     198             :     sal_Int32 nHandle)
     199             :     throw(css::beans::UnknownPropertyException,
     200             :         css::lang::WrappedTargetException,
     201             :         css::uno::RuntimeException)
     202             : {
     203             :     (void)nHandle;
     204             : 
     205           0 :     if( nHandle != DrawController::PROPERTY_VIEWOFFSET )
     206           0 :         throw beans::UnknownPropertyException();
     207             : 
     208           0 :     return Any();
     209             : }
     210             : 
     211             : 
     212             : // XServiceInfo
     213           0 : OUString SAL_CALL SdUnoSlideView::getImplementationName(  ) throw (RuntimeException)
     214             : {
     215           0 :     return OUString( "com.sun.star.comp.sd.SdUnoSlideView" );
     216             : }
     217             : 
     218           0 : sal_Bool SAL_CALL SdUnoSlideView::supportsService( const OUString& ServiceName ) throw (RuntimeException)
     219             : {
     220           0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     221             : }
     222             : 
     223           0 : Sequence< OUString > SAL_CALL SdUnoSlideView::getSupportedServiceNames(  ) throw (RuntimeException)
     224             : {
     225           0 :     OUString aSN( "com.sun.star.presentation.SlidesView" );
     226           0 :     uno::Sequence< OUString > aSeq( &aSN, 1 );
     227           0 :     return aSeq;
     228             : }
     229             : 
     230          33 : } // end of namespace sd
     231             : 
     232             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10