1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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()
42 SwVbaOptions::DefaultFilePath( sal_Int32 _path
)
46 case word::WdDefaultFilePath::wdDocumentsPath
:
48 msDefaultFilePath
= "Work";
51 case word::WdDefaultFilePath::wdPicturesPath
:
53 msDefaultFilePath
= "Gallery";
56 case word::WdDefaultFilePath::wdUserTemplatesPath
:
57 case word::WdDefaultFilePath::wdWorkgroupTemplatesPath
:
59 msDefaultFilePath
= "Template";
62 case word::WdDefaultFilePath::wdStartupPath
:
64 msDefaultFilePath
= "Addin";
67 case word::WdDefaultFilePath::wdUserOptionsPath
:
69 msDefaultFilePath
= "UserConfig";
72 case word::WdDefaultFilePath::wdToolsPath
:
73 case word::WdDefaultFilePath::wdProgramPath
:
75 msDefaultFilePath
= "Module";
78 case word::WdDefaultFilePath::wdTempFilePath
:
80 msDefaultFilePath
= "Temp";
85 DebugHelper::basicexception( ERRCODE_BASIC_NOT_IMPLEMENTED
, {} );
89 return uno::Any( uno::Reference
< XPropValue
> ( new ScVbaPropValue( this ) ) );
92 void SwVbaOptions::setValueEvent( const uno::Any
& value
)
97 ::osl::File::getFileURLFromSystemPath( sNewPath
, sNewPathUrl
);
98 uno::Reference
< util::XPathSettings
> xPathSettings
= util::thePathSettings::get( comphelper::getProcessComponentContext() );
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( ';' );
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() );
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( ';' );
121 sPathUrl
= sPathUrl
.copy( nIndex
+ 1 );
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()
163 void SAL_CALL
SwVbaOptions::setReplaceSelection( sal_Bool
/*_replaceselection*/ )
165 // not support in Writer
168 sal_Bool SAL_CALL
SwVbaOptions::getMapPaperSize()
173 void SAL_CALL
SwVbaOptions::setMapPaperSize( sal_Bool
/*_mappapersize*/ )
175 // not support in Writer
178 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatAsYouTypeApplyHeadings()
183 void SAL_CALL
SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( sal_Bool
/*_autoformatasyoutypeapplyheadings*/ )
185 // not support in Writer
188 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatAsYouTypeApplyBulletedLists()
193 void SAL_CALL
SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( sal_Bool
/*_autoformatasyoutypeapplybulletedlists*/ )
195 // not support in Writer
198 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatAsYouTypeApplyNumberedLists()
203 void SAL_CALL
SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( sal_Bool
/*_autoformatasyoutypeapplynumberedlists*/ )
205 // not support in Writer
208 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatAsYouTypeFormatListItemBeginning()
213 void SAL_CALL
SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( sal_Bool
/*_autoformatasyoutypeformatlistitembeginning*/ )
215 // not support in Writer
218 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatAsYouTypeDefineStyles()
223 void SAL_CALL
SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( sal_Bool
/*_autoformatasyoutypedefinestyles*/ )
225 // not support in Writer
228 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatApplyHeadings()
233 void SAL_CALL
SwVbaOptions::setAutoFormatApplyHeadings( sal_Bool
/*_autoformatapplyheadings*/ )
235 // not support in Writer
238 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatApplyLists()
243 void SAL_CALL
SwVbaOptions::setAutoFormatApplyLists( sal_Bool
/*_autoformatapplylists*/ )
245 // not support in Writer
248 sal_Bool SAL_CALL
SwVbaOptions::getAutoFormatApplyBulletedLists()
253 void SAL_CALL
SwVbaOptions::setAutoFormatApplyBulletedLists( sal_Bool
/*_autoformatapplybulletedlists*/ )
255 // not support in Writer
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: */