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

Generated by: LCOV version 1.10