android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / vba / vbaoptions.cxx
blobef74dcd8a6f01e23e79f096e84f0deac14f17dd6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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/thePathSettings.hpp>
26 #include <comphelper/processfactory.hxx>
27 #include <basic/sberrors.hxx>
28 #include <osl/file.hxx>
30 using namespace ::ooo::vba;
31 using namespace ::com::sun::star;
33 SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext > const & xContext ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext )
37 SwVbaOptions::~SwVbaOptions()
41 uno::Any SAL_CALL
42 SwVbaOptions::DefaultFilePath( sal_Int32 _path )
44 switch( _path )
46 case word::WdDefaultFilePath::wdDocumentsPath:
48 msDefaultFilePath = "Work";
49 break;
51 case word::WdDefaultFilePath::wdPicturesPath:
53 msDefaultFilePath = "Gallery";
54 break;
56 case word::WdDefaultFilePath::wdUserTemplatesPath:
57 case word::WdDefaultFilePath::wdWorkgroupTemplatesPath:
59 msDefaultFilePath = "Template";
60 break;
62 case word::WdDefaultFilePath::wdStartupPath:
64 msDefaultFilePath = "Addin";
65 break;
67 case word::WdDefaultFilePath::wdUserOptionsPath:
69 msDefaultFilePath = "UserConfig";
70 break;
72 case word::WdDefaultFilePath::wdToolsPath:
73 case word::WdDefaultFilePath::wdProgramPath:
75 msDefaultFilePath = "Module";
76 break;
78 case word::WdDefaultFilePath::wdTempFilePath:
80 msDefaultFilePath = "Temp";
81 break;
83 default:
85 DebugHelper::basicexception( ERRCODE_BASIC_NOT_IMPLEMENTED, {} );
86 break;
89 return uno::Any( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
92 void SwVbaOptions::setValueEvent( const uno::Any& value )
94 OUString sNewPath;
95 value >>= sNewPath;
96 OUString sNewPathUrl;
97 ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl );
98 uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() );
99 OUString sOldPathUrl;
100 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 sal_Int32 nIndex = sOldPathUrl.lastIndexOf( ';' );
104 if( nIndex != -1 )
106 sNewPathUrl = sOldPathUrl.subView( 0, nIndex + 1 ) + sNewPathUrl;
108 xPathSettings->setPropertyValue( msDefaultFilePath, uno::Any( sNewPathUrl ) );
111 uno::Any SwVbaOptions::getValueEvent()
113 uno::Reference< util::XPathSettings > xPathSettings = util::thePathSettings::get( comphelper::getProcessComponentContext() );
114 OUString sPathUrl;
115 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 sal_Int32 nIndex = sPathUrl.lastIndexOf( ';' );
119 if( nIndex != -1 )
121 sPathUrl = sPathUrl.copy( nIndex + 1 );
123 OUString sPath;
124 ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath );
125 return uno::Any( sPath );
128 sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineStyle()
130 return word::WdLineStyle::wdLineStyleSingle;
133 void SAL_CALL SwVbaOptions::setDefaultBorderLineStyle( ::sal_Int32 /*_defaultborderlinestyle*/ )
135 // not support in Writer
138 sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineWidth()
140 return word::WdLineWidth::wdLineWidth050pt;
143 void SAL_CALL SwVbaOptions::setDefaultBorderLineWidth( ::sal_Int32 /*_defaultborderlinewidth*/ )
145 // not support in Writer
148 sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderColorIndex()
150 return word::WdColorIndex::wdAuto;
153 void SAL_CALL SwVbaOptions::setDefaultBorderColorIndex( ::sal_Int32 /*_defaultbordercolorindex*/ )
155 // not support in Writer
158 sal_Bool SAL_CALL SwVbaOptions::getReplaceSelection()
160 return true;
163 void SAL_CALL SwVbaOptions::setReplaceSelection( sal_Bool /*_replaceselection*/ )
165 // not support in Writer
168 sal_Bool SAL_CALL SwVbaOptions::getMapPaperSize()
170 return false;
173 void SAL_CALL SwVbaOptions::setMapPaperSize( sal_Bool /*_mappapersize*/ )
175 // not support in Writer
178 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyHeadings()
180 return false;
183 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( sal_Bool /*_autoformatasyoutypeapplyheadings*/ )
185 // not support in Writer
188 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyBulletedLists()
190 return false;
193 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( sal_Bool /*_autoformatasyoutypeapplybulletedlists*/ )
195 // not support in Writer
198 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyNumberedLists()
200 return false;
203 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( sal_Bool /*_autoformatasyoutypeapplynumberedlists*/ )
205 // not support in Writer
208 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeFormatListItemBeginning()
210 return false;
213 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( sal_Bool /*_autoformatasyoutypeformatlistitembeginning*/ )
215 // not support in Writer
218 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeDefineStyles()
220 return false;
223 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( sal_Bool /*_autoformatasyoutypedefinestyles*/ )
225 // not support in Writer
228 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyHeadings()
230 return false;
233 void SAL_CALL SwVbaOptions::setAutoFormatApplyHeadings( sal_Bool /*_autoformatapplyheadings*/ )
235 // not support in Writer
238 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyLists()
240 return false;
243 void SAL_CALL SwVbaOptions::setAutoFormatApplyLists( sal_Bool /*_autoformatapplylists*/ )
245 // not support in Writer
248 sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyBulletedLists()
250 return false;
253 void SAL_CALL SwVbaOptions::setAutoFormatApplyBulletedLists( sal_Bool /*_autoformatapplybulletedlists*/ )
255 // not support in Writer
258 OUString
259 SwVbaOptions::getServiceImplName()
261 return "SwVbaOptions";
264 uno::Sequence< OUString >
265 SwVbaOptions::getServiceNames()
267 static uno::Sequence< OUString > const aServiceNames
269 "ooo.vba.word.Options"
271 return aServiceNames;
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */