LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbaoptions.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 106 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 34 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 "vbaoptions.hxx"
      20             : #include <vbahelper/vbahelper.hxx>
      21             : #include <ooo/vba/word/WdDefaultFilePath.hpp>
      22             : #include <ooo/vba/word/WdLineStyle.hpp>
      23             : #include <ooo/vba/word/WdLineWidth.hpp>
      24             : #include <ooo/vba/word/WdColorIndex.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/util/XStringSubstitution.hpp>
      27             : #include <com/sun/star/util/thePathSettings.hpp>
      28             : #include <osl/file.hxx>
      29             : 
      30             : using namespace ::ooo::vba;
      31             : using namespace ::com::sun::star;
      32             : 
      33           0 : SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext >& xContext ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext )
      34             : {
      35           0 : }
      36             : 
      37           0 : SwVbaOptions::~SwVbaOptions()
      38             : {
      39           0 : }
      40             : 
      41             : uno::Any SAL_CALL
      42           0 : SwVbaOptions::DefaultFilePath( sal_Int32 _path )
      43             :     throw (css::script::BasicErrorException, uno::RuntimeException, std::exception)
      44             : {
      45           0 :     switch( _path )
      46             :     {
      47             :         case word::WdDefaultFilePath::wdDocumentsPath:
      48             :         {
      49           0 :             msDefaultFilePath = "Work";
      50           0 :             break;
      51             :         }
      52             :         case word::WdDefaultFilePath::wdPicturesPath:
      53             :         {
      54           0 :             msDefaultFilePath = "Gallery";
      55           0 :             break;
      56             :         }
      57             :         case word::WdDefaultFilePath::wdUserTemplatesPath:
      58             :         case word::WdDefaultFilePath::wdWorkgroupTemplatesPath:
      59             :         {
      60           0 :             msDefaultFilePath = "Template";
      61           0 :             break;
      62             :         }
      63             :         case word::WdDefaultFilePath::wdStartupPath:
      64             :         {
      65           0 :             msDefaultFilePath = "Addin";
      66           0 :             break;
      67             :         }
      68             :         case word::WdDefaultFilePath::wdUserOptionsPath:
      69             :         {
      70           0 :             msDefaultFilePath = "UserConfig";
      71           0 :             break;
      72             :         }
      73             :         case word::WdDefaultFilePath::wdToolsPath:
      74             :         case word::WdDefaultFilePath::wdProgramPath:
      75             :         {
      76           0 :             msDefaultFilePath = "Module";
      77           0 :             break;
      78             :         }
      79             :         case word::WdDefaultFilePath::wdTempFilePath:
      80             :         {
      81           0 :             msDefaultFilePath = "Temp";
      82           0 :             break;
      83             :         }
      84             :         default:
      85             :         {
      86           0 :             DebugHelper::basicexception( SbERR_NOT_IMPLEMENTED, OUString() );
      87           0 :             break;
      88             :         }
      89             :     }
      90           0 :     return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
      91             : }
      92             : 
      93           0 : void SwVbaOptions::setValueEvent( const uno::Any& value )
      94             : {
      95           0 :     OUString sNewPath;
      96           0 :     value >>= sNewPath;
      97           0 :     OUString sNewPathUrl;
      98           0 :     ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl );
      99           0 :     uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() );
     100           0 :     OUString sOldPathUrl;
     101           0 :     xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sOldPathUrl;
     102             :     // path could be a multipath, Microsoft doesn't support this feature in Word currently
     103             :     // only the last path is from interest.
     104           0 :     sal_Int32 nIndex = sOldPathUrl.lastIndexOf( ';' );
     105           0 :     if( nIndex != -1 )
     106             :     {
     107           0 :         sNewPathUrl = sOldPathUrl.copy( 0, nIndex + 1 ).concat( sNewPathUrl );
     108             :     }
     109           0 :     xPathSettings->setPropertyValue( msDefaultFilePath, uno::makeAny( sNewPathUrl ) );
     110           0 : }
     111             : 
     112           0 : uno::Any SwVbaOptions::getValueEvent()
     113             : {
     114           0 :     uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() );
     115           0 :     OUString sPathUrl;
     116           0 :     xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sPathUrl;
     117             :     // path could be a multipath, Microsoft doesn't support this feature in Word currently
     118             :     // only the last path is from interest.
     119           0 :     sal_Int32 nIndex = sPathUrl.lastIndexOf( ';' );
     120           0 :     if( nIndex != -1 )
     121             :     {
     122           0 :         sPathUrl = sPathUrl.copy( nIndex + 1 );
     123             :     }
     124           0 :     OUString sPath;
     125           0 :     ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath );
     126           0 :     return uno::makeAny( sPath );
     127             : }
     128             : 
     129           0 : sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineStyle() throw (uno::RuntimeException, std::exception)
     130             : {
     131           0 :     return word::WdLineStyle::wdLineStyleSingle;
     132             : }
     133             : 
     134           0 : void SAL_CALL SwVbaOptions::setDefaultBorderLineStyle( ::sal_Int32 /*_defaultborderlinestyle*/ ) throw (uno::RuntimeException, std::exception)
     135             : {
     136             :     // not support in Writer
     137           0 : }
     138             : 
     139           0 : sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineWidth() throw (uno::RuntimeException, std::exception)
     140             : {
     141           0 :     return word::WdLineWidth::wdLineWidth050pt;
     142             : }
     143             : 
     144           0 : void SAL_CALL SwVbaOptions::setDefaultBorderLineWidth( ::sal_Int32 /*_defaultborderlinewidth*/ ) throw (uno::RuntimeException, std::exception)
     145             : {
     146             :     // not support in Writer
     147           0 : }
     148             : 
     149           0 : sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderColorIndex() throw (uno::RuntimeException, std::exception)
     150             : {
     151           0 :     return word::WdColorIndex::wdAuto;
     152             : }
     153             : 
     154           0 : void SAL_CALL SwVbaOptions::setDefaultBorderColorIndex( ::sal_Int32 /*_defaultbordercolorindex*/ ) throw (uno::RuntimeException, std::exception)
     155             : {
     156             :     // not support in Writer
     157           0 : }
     158             : 
     159           0 : sal_Bool SAL_CALL SwVbaOptions::getReplaceSelection() throw (uno::RuntimeException, std::exception)
     160             : {
     161           0 :     return sal_True;
     162             : }
     163             : 
     164           0 : void SAL_CALL SwVbaOptions::setReplaceSelection( sal_Bool /*_replaceselection*/ ) throw (uno::RuntimeException, std::exception)
     165             : {
     166             :     // not support in Writer
     167           0 : }
     168             : 
     169           0 : sal_Bool SAL_CALL SwVbaOptions::getMapPaperSize() throw (uno::RuntimeException, std::exception)
     170             : {
     171           0 :     return sal_False;
     172             : }
     173             : 
     174           0 : void SAL_CALL SwVbaOptions::setMapPaperSize( sal_Bool /*_mappapersize*/ ) throw (uno::RuntimeException, std::exception)
     175             : {
     176             :     // not support in Writer
     177           0 : }
     178             : 
     179           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyHeadings() throw (uno::RuntimeException, std::exception)
     180             : {
     181           0 :     return sal_False;
     182             : }
     183             : 
     184           0 : void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( sal_Bool /*_autoformatasyoutypeapplyheadings*/ ) throw (uno::RuntimeException, std::exception)
     185             : {
     186             :     // not support in Writer
     187           0 : }
     188             : 
     189           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyBulletedLists() throw (uno::RuntimeException, std::exception)
     190             : {
     191           0 :     return sal_False;
     192             : }
     193             : 
     194           0 : void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( sal_Bool /*_autoformatasyoutypeapplybulletedlists*/ ) throw (uno::RuntimeException, std::exception)
     195             : {
     196             :     // not support in Writer
     197           0 : }
     198             : 
     199           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyNumberedLists() throw (uno::RuntimeException, std::exception)
     200             : {
     201           0 :     return sal_False;
     202             : }
     203             : 
     204           0 : void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( sal_Bool /*_autoformatasyoutypeapplynumberedlists*/ ) throw (uno::RuntimeException, std::exception)
     205             : {
     206             :     // not support in Writer
     207           0 : }
     208             : 
     209           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeFormatListItemBeginning() throw (uno::RuntimeException, std::exception)
     210             : {
     211           0 :     return sal_False;
     212             : }
     213             : 
     214           0 : void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( sal_Bool /*_autoformatasyoutypeformatlistitembeginning*/ ) throw (uno::RuntimeException, std::exception)
     215             : {
     216             :     // not support in Writer
     217           0 : }
     218             : 
     219           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeDefineStyles() throw (uno::RuntimeException, std::exception)
     220             : {
     221           0 :     return sal_False;
     222             : }
     223             : 
     224           0 : void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( sal_Bool /*_autoformatasyoutypedefinestyles*/ ) throw (uno::RuntimeException, std::exception)
     225             : {
     226             :     // not support in Writer
     227           0 : }
     228             : 
     229           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyHeadings() throw (uno::RuntimeException, std::exception)
     230             : {
     231           0 :     return sal_False;
     232             : }
     233             : 
     234           0 : void SAL_CALL SwVbaOptions::setAutoFormatApplyHeadings( sal_Bool /*_autoformatapplyheadings*/ ) throw (uno::RuntimeException, std::exception)
     235             : {
     236             :     // not support in Writer
     237           0 : }
     238             : 
     239           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyLists() throw (uno::RuntimeException, std::exception)
     240             : {
     241           0 :     return sal_False;
     242             : }
     243             : 
     244           0 : void SAL_CALL SwVbaOptions::setAutoFormatApplyLists( sal_Bool /*_autoformatapplylists*/ ) throw (uno::RuntimeException, std::exception)
     245             : {
     246             :     // not support in Writer
     247           0 : }
     248             : 
     249           0 : sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyBulletedLists() throw (uno::RuntimeException, std::exception)
     250             : {
     251           0 :     return sal_False;
     252             : }
     253             : 
     254           0 : void SAL_CALL SwVbaOptions::setAutoFormatApplyBulletedLists( sal_Bool /*_autoformatapplybulletedlists*/ ) throw (uno::RuntimeException, std::exception)
     255             : {
     256             :     // not support in Writer
     257           0 : }
     258             : 
     259             : OUString
     260           0 : SwVbaOptions::getServiceImplName()
     261             : {
     262           0 :     return OUString("SwVbaOptions");
     263             : }
     264             : 
     265             : uno::Sequence< OUString >
     266           0 : SwVbaOptions::getServiceNames()
     267             : {
     268           0 :     static uno::Sequence< OUString > aServiceNames;
     269           0 :     if ( aServiceNames.getLength() == 0 )
     270             :     {
     271           0 :         aServiceNames.realloc( 1 );
     272           0 :         aServiceNames[ 0 ] = "ooo.vba.word.Options";
     273             :     }
     274           0 :     return aServiceNames;
     275             : }
     276             : 
     277             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11