LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbalistformat.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 45 0.0 %
Date: 2014-04-14 Functions: 0 7 0.0 %
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             : #include "vbalistformat.hxx"
      20             : #include <vbahelper/vbahelper.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : #include <ooo/vba/word/WdListApplyTo.hpp>
      23             : #include <ooo/vba/word/WdDefaultListBehavior.hpp>
      24             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      25             : #include <com/sun/star/container/XEnumeration.hpp>
      26             : #include <com/sun/star/beans/XPropertySet.hpp>
      27             : #include "vbalisttemplate.hxx"
      28             : 
      29             : using namespace ::ooo::vba;
      30             : using namespace ::com::sun::star;
      31             : 
      32           0 : SwVbaListFormat::SwVbaListFormat( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) : SwVbaListFormat_BASE( rParent, rContext ), mxTextRange( xTextRange )
      33             : {
      34           0 : }
      35             : 
      36           0 : SwVbaListFormat::~SwVbaListFormat()
      37             : {
      38           0 : }
      39             : 
      40           0 : void SAL_CALL SwVbaListFormat::ApplyListTemplate( const css::uno::Reference< word::XListTemplate >& ListTemplate, const css::uno::Any& ContinuePreviousList, const css::uno::Any& ApplyTo, const css::uno::Any& DefaultListBehavior ) throw (css::uno::RuntimeException, std::exception)
      41             : {
      42           0 :     sal_Bool bContinuePreviousList = sal_True;
      43           0 :     if( ContinuePreviousList.hasValue() )
      44           0 :         ContinuePreviousList >>= bContinuePreviousList;
      45             : 
      46             :     // "applyto" must be current selection
      47           0 :     sal_Int32 bApplyTo = word::WdListApplyTo::wdListApplyToSelection;
      48           0 :     if( ApplyTo.hasValue() )
      49           0 :         ApplyTo >>= bApplyTo;
      50           0 :     if( bApplyTo != word::WdListApplyTo::wdListApplyToSelection )
      51           0 :         throw uno::RuntimeException();
      52             : 
      53             :     // default behaviour must be wdWord8ListBehavior
      54           0 :     sal_Int32 nDefaultListBehavior = word::WdDefaultListBehavior::wdWord8ListBehavior;
      55           0 :     if( DefaultListBehavior.hasValue() )
      56           0 :         DefaultListBehavior >>= nDefaultListBehavior;
      57           0 :     if( nDefaultListBehavior != word::WdDefaultListBehavior::wdWord8ListBehavior )
      58           0 :         throw uno::RuntimeException();
      59             : 
      60           0 :     SwVbaListTemplate* pListTemplate = dynamic_cast< SwVbaListTemplate* >( ListTemplate.get() );
      61             : 
      62           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( mxTextRange, uno::UNO_QUERY_THROW );
      63           0 :     uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
      64           0 :     sal_Bool isFirstElement = sal_True;
      65           0 :     while( xEnum->hasMoreElements() )
      66             :     {
      67           0 :         uno::Reference< beans::XPropertySet > xProps( xEnum->nextElement(), uno::UNO_QUERY_THROW );
      68           0 :         if( isFirstElement )
      69             :         {
      70           0 :             sal_Bool isNumberingRestart = !bContinuePreviousList;
      71           0 :             xProps->setPropertyValue("ParaIsNumberingRestart", uno::makeAny( isNumberingRestart ) );
      72           0 :             if( isNumberingRestart )
      73             :             {
      74           0 :                 sal_Int16 nStartValue = 1;
      75           0 :                 xProps->setPropertyValue("NumberingStartValue", uno::makeAny( nStartValue ) );
      76             :             }
      77           0 :             isFirstElement = sal_False;
      78             :         }
      79             :         else
      80             :         {
      81           0 :             xProps->setPropertyValue("ParaIsNumberingRestart", uno::makeAny( sal_False ) );
      82             :         }
      83           0 :         pListTemplate->applyListTemplate( xProps );
      84           0 :     }
      85           0 : }
      86             : 
      87           0 : void SAL_CALL SwVbaListFormat::ConvertNumbersToText(  ) throw (css::uno::RuntimeException, std::exception)
      88             : {
      89           0 :     throw uno::RuntimeException("Not implemented", uno::Reference< uno::XInterface >() );
      90             : }
      91             : 
      92             : OUString
      93           0 : SwVbaListFormat::getServiceImplName()
      94             : {
      95           0 :     return OUString("SwVbaListFormat");
      96             : }
      97             : 
      98             : uno::Sequence< OUString >
      99           0 : SwVbaListFormat::getServiceNames()
     100             : {
     101           0 :     static uno::Sequence< OUString > aServiceNames;
     102           0 :     if ( aServiceNames.getLength() == 0 )
     103             :     {
     104           0 :         aServiceNames.realloc( 1 );
     105           0 :         aServiceNames[ 0 ] = "ooo.vba.word.ListFormat";
     106             :     }
     107           0 :     return aServiceNames;
     108             : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10