1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #include "vbaoptions.hxx" 28*cdf0e10cSrcweir #include <vbahelper/vbahelper.hxx> 29*cdf0e10cSrcweir #include <ooo/vba/word/WdDefaultFilePath.hpp> 30*cdf0e10cSrcweir #include <ooo/vba/word/WdLineStyle.hpp> 31*cdf0e10cSrcweir #include <ooo/vba/word/WdLineWidth.hpp> 32*cdf0e10cSrcweir #include <ooo/vba/word/WdColorIndex.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/util/XStringSubstitution.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 35*cdf0e10cSrcweir #include <osl/file.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using namespace ::ooo::vba; 38*cdf0e10cSrcweir using namespace ::com::sun::star; 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext ) 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir mxFactory.set( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 43*cdf0e10cSrcweir } 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir SwVbaOptions::~SwVbaOptions() 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir } 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir uno::Any SAL_CALL 50*cdf0e10cSrcweir SwVbaOptions::DefaultFilePath( sal_Int32 _path ) throw ( uno::RuntimeException ) 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir switch( _path ) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir case word::WdDefaultFilePath::wdDocumentsPath: 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work") ); 57*cdf0e10cSrcweir break; 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir case word::WdDefaultFilePath::wdPicturesPath: 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Gallery") ); 62*cdf0e10cSrcweir break; 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir case word::WdDefaultFilePath::wdUserTemplatesPath: 65*cdf0e10cSrcweir case word::WdDefaultFilePath::wdWorkgroupTemplatesPath: 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template") ); 68*cdf0e10cSrcweir break; 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir case word::WdDefaultFilePath::wdStartupPath: 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Addin") ); 73*cdf0e10cSrcweir break; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir case word::WdDefaultFilePath::wdUserOptionsPath: 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserConfig") ); 78*cdf0e10cSrcweir break; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir case word::WdDefaultFilePath::wdToolsPath: 81*cdf0e10cSrcweir case word::WdDefaultFilePath::wdProgramPath: 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Module") ); 84*cdf0e10cSrcweir break; 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir case word::WdDefaultFilePath::wdTempFilePath: 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Temp") ); 89*cdf0e10cSrcweir break; 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir default: 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); 94*cdf0e10cSrcweir break; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) ); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir void SwVbaOptions::setValueEvent( const uno::Any& value ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir rtl::OUString sNewPath; 103*cdf0e10cSrcweir value >>= sNewPath; 104*cdf0e10cSrcweir rtl::OUString sNewPathUrl; 105*cdf0e10cSrcweir ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl ); 106*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.PathSettings") ), uno::UNO_QUERY_THROW ); 107*cdf0e10cSrcweir rtl::OUString sOldPathUrl; 108*cdf0e10cSrcweir xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sOldPathUrl; 109*cdf0e10cSrcweir // path could be a multipath, Microsoft doesn't support this feature in Word currently 110*cdf0e10cSrcweir // only the last path is from interest. 111*cdf0e10cSrcweir sal_Int32 nIndex = sOldPathUrl.lastIndexOf( sal_Unicode(';') ); 112*cdf0e10cSrcweir if( nIndex != -1 ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir sNewPathUrl = sOldPathUrl.copy( 0, nIndex + 1 ).concat( sNewPathUrl ); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir xPathSettings->setPropertyValue( msDefaultFilePath, uno::makeAny( sNewPathUrl ) ); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir uno::Any SwVbaOptions::getValueEvent() 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.PathSettings") ), uno::UNO_QUERY_THROW ); 122*cdf0e10cSrcweir rtl::OUString sPathUrl; 123*cdf0e10cSrcweir xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sPathUrl; 124*cdf0e10cSrcweir // path could be a multipath, Microsoft doesn't support this feature in Word currently 125*cdf0e10cSrcweir // only the last path is from interest. 126*cdf0e10cSrcweir sal_Int32 nIndex = sPathUrl.lastIndexOf( sal_Unicode(';') ); 127*cdf0e10cSrcweir if( nIndex != -1 ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir sPathUrl = sPathUrl.copy( nIndex + 1 ); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir rtl::OUString sPath; 132*cdf0e10cSrcweir ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath ); 133*cdf0e10cSrcweir return uno::makeAny( sPath ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineStyle() throw (uno::RuntimeException) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir return word::WdLineStyle::wdLineStyleSingle; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setDefaultBorderLineStyle( ::sal_Int32 /*_defaultborderlinestyle*/ ) throw (uno::RuntimeException) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir // not support in Writer 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineWidth() throw (uno::RuntimeException) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir return word::WdLineWidth::wdLineWidth050pt; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setDefaultBorderLineWidth( ::sal_Int32 /*_defaultborderlinewidth*/ ) throw (uno::RuntimeException) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir // not support in Writer 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderColorIndex() throw (uno::RuntimeException) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir return word::WdColorIndex::wdAuto; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setDefaultBorderColorIndex( ::sal_Int32 /*_defaultbordercolorindex*/ ) throw (uno::RuntimeException) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir // not support in Writer 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getReplaceSelection() throw (uno::RuntimeException) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir return sal_True; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setReplaceSelection( ::sal_Bool /*_replaceselection*/ ) throw (uno::RuntimeException) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir // not support in Writer 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getMapPaperSize() throw (uno::RuntimeException) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir return sal_False; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setMapPaperSize( ::sal_Bool /*_mappapersize*/ ) throw (uno::RuntimeException) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir // not support in Writer 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyHeadings() throw (uno::RuntimeException) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir return sal_False; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( ::sal_Bool /*_autoformatasyoutypeapplyheadings*/ ) throw (uno::RuntimeException) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir // not support in Writer 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyBulletedLists() throw (uno::RuntimeException) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir return sal_False; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( ::sal_Bool /*_autoformatasyoutypeapplybulletedlists*/ ) throw (uno::RuntimeException) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir // not support in Writer 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyNumberedLists() throw (uno::RuntimeException) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir return sal_False; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( ::sal_Bool /*_autoformatasyoutypeapplynumberedlists*/ ) throw (uno::RuntimeException) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir // not support in Writer 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeFormatListItemBeginning() throw (uno::RuntimeException) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir return sal_False; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( ::sal_Bool /*_autoformatasyoutypeformatlistitembeginning*/ ) throw (uno::RuntimeException) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir // not support in Writer 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeDefineStyles() throw (uno::RuntimeException) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir return sal_False; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( ::sal_Bool /*_autoformatasyoutypedefinestyles*/ ) throw (uno::RuntimeException) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir // not support in Writer 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyHeadings() throw (uno::RuntimeException) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir return sal_False; 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatApplyHeadings( ::sal_Bool /*_autoformatapplyheadings*/ ) throw (uno::RuntimeException) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir // not support in Writer 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyLists() throw (uno::RuntimeException) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir return sal_False; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatApplyLists( ::sal_Bool /*_autoformatapplylists*/ ) throw (uno::RuntimeException) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir // not support in Writer 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyBulletedLists() throw (uno::RuntimeException) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir return sal_False; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatApplyBulletedLists( ::sal_Bool /*_autoformatapplybulletedlists*/ ) throw (uno::RuntimeException) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir // not support in Writer 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir rtl::OUString& 268*cdf0e10cSrcweir SwVbaOptions::getServiceImplName() 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaOptions") ); 271*cdf0e10cSrcweir return sImplName; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir uno::Sequence< rtl::OUString > 275*cdf0e10cSrcweir SwVbaOptions::getServiceNames() 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir static uno::Sequence< rtl::OUString > aServiceNames; 278*cdf0e10cSrcweir if ( aServiceNames.getLength() == 0 ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir aServiceNames.realloc( 1 ); 281*cdf0e10cSrcweir aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Options" ) ); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir return aServiceNames; 284*cdf0e10cSrcweir } 285