LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbalistformat.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 46 0.0 %
Date: 2015-06-13 12:38:46 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 :     bool bContinuePreviousList = 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 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( mxTextRange, uno::UNO_QUERY_THROW );
      61           0 :     uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
      62           0 :     if (!xEnum->hasMoreElements())
      63           0 :         return;
      64             : 
      65           0 :     SwVbaListTemplate& rListTemplate = dynamic_cast<SwVbaListTemplate&>(*ListTemplate.get());
      66             : 
      67           0 :     bool isFirstElement = true;
      68           0 :     do
      69             :     {
      70           0 :         uno::Reference< beans::XPropertySet > xProps( xEnum->nextElement(), uno::UNO_QUERY_THROW );
      71           0 :         if( isFirstElement )
      72             :         {
      73           0 :             bool isNumberingRestart = !bContinuePreviousList;
      74           0 :             xProps->setPropertyValue("ParaIsNumberingRestart", uno::makeAny( isNumberingRestart ) );
      75           0 :             if( isNumberingRestart )
      76             :             {
      77           0 :                 sal_Int16 nStartValue = 1;
      78           0 :                 xProps->setPropertyValue("NumberingStartValue", uno::makeAny( nStartValue ) );
      79             :             }
      80           0 :             isFirstElement = false;
      81             :         }
      82             :         else
      83             :         {
      84           0 :             xProps->setPropertyValue("ParaIsNumberingRestart", uno::makeAny( false ) );
      85             :         }
      86           0 :         rListTemplate.applyListTemplate( xProps );
      87             :     }
      88           0 :     while( xEnum->hasMoreElements() );
      89             : }
      90             : 
      91           0 : void SAL_CALL SwVbaListFormat::ConvertNumbersToText(  ) throw (css::uno::RuntimeException, std::exception)
      92             : {
      93           0 :     throw uno::RuntimeException("Not implemented" );
      94             : }
      95             : 
      96             : OUString
      97           0 : SwVbaListFormat::getServiceImplName()
      98             : {
      99           0 :     return OUString("SwVbaListFormat");
     100             : }
     101             : 
     102             : uno::Sequence< OUString >
     103           0 : SwVbaListFormat::getServiceNames()
     104             : {
     105           0 :     static uno::Sequence< OUString > aServiceNames;
     106           0 :     if ( aServiceNames.getLength() == 0 )
     107             :     {
     108           0 :         aServiceNames.realloc( 1 );
     109           0 :         aServiceNames[ 0 ] = "ooo.vba.word.ListFormat";
     110             :     }
     111           0 :     return aServiceNames;
     112             : }
     113             : 
     114             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11