xref: /aoo41x/main/sw/source/ui/vba/vbaoptions.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir #include "vbaoptions.hxx"
24cdf0e10cSrcweir #include <vbahelper/vbahelper.hxx>
25cdf0e10cSrcweir #include <ooo/vba/word/WdDefaultFilePath.hpp>
26cdf0e10cSrcweir #include <ooo/vba/word/WdLineStyle.hpp>
27cdf0e10cSrcweir #include <ooo/vba/word/WdLineWidth.hpp>
28cdf0e10cSrcweir #include <ooo/vba/word/WdColorIndex.hpp>
29cdf0e10cSrcweir #include <com/sun/star/util/XStringSubstitution.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
31cdf0e10cSrcweir #include <osl/file.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::ooo::vba;
34cdf0e10cSrcweir using namespace ::com::sun::star;
35cdf0e10cSrcweir 
SwVbaOptions(uno::Reference<uno::XComponentContext> & xContext)36cdf0e10cSrcweir SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext )
37cdf0e10cSrcweir {
38cdf0e10cSrcweir     mxFactory.set( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
39cdf0e10cSrcweir }
40cdf0e10cSrcweir 
~SwVbaOptions()41cdf0e10cSrcweir SwVbaOptions::~SwVbaOptions()
42cdf0e10cSrcweir {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir 
45cdf0e10cSrcweir uno::Any SAL_CALL
DefaultFilePath(sal_Int32 _path)46cdf0e10cSrcweir SwVbaOptions::DefaultFilePath( sal_Int32 _path ) throw ( uno::RuntimeException )
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     switch( _path )
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         case word::WdDefaultFilePath::wdDocumentsPath:
51cdf0e10cSrcweir         {
52cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work") );
53cdf0e10cSrcweir             break;
54cdf0e10cSrcweir         }
55cdf0e10cSrcweir         case word::WdDefaultFilePath::wdPicturesPath:
56cdf0e10cSrcweir         {
57cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Gallery") );
58cdf0e10cSrcweir             break;
59cdf0e10cSrcweir         }
60cdf0e10cSrcweir         case word::WdDefaultFilePath::wdUserTemplatesPath:
61cdf0e10cSrcweir         case word::WdDefaultFilePath::wdWorkgroupTemplatesPath:
62cdf0e10cSrcweir         {
63cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template") );
64cdf0e10cSrcweir             break;
65cdf0e10cSrcweir         }
66cdf0e10cSrcweir         case word::WdDefaultFilePath::wdStartupPath:
67cdf0e10cSrcweir         {
68cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Addin") );
69cdf0e10cSrcweir             break;
70cdf0e10cSrcweir         }
71cdf0e10cSrcweir         case word::WdDefaultFilePath::wdUserOptionsPath:
72cdf0e10cSrcweir         {
73cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserConfig") );
74cdf0e10cSrcweir             break;
75cdf0e10cSrcweir         }
76cdf0e10cSrcweir         case word::WdDefaultFilePath::wdToolsPath:
77cdf0e10cSrcweir         case word::WdDefaultFilePath::wdProgramPath:
78cdf0e10cSrcweir         {
79cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Module") );
80cdf0e10cSrcweir             break;
81cdf0e10cSrcweir         }
82cdf0e10cSrcweir         case word::WdDefaultFilePath::wdTempFilePath:
83cdf0e10cSrcweir         {
84cdf0e10cSrcweir             msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Temp") );
85cdf0e10cSrcweir             break;
86cdf0e10cSrcweir         }
87cdf0e10cSrcweir         default:
88cdf0e10cSrcweir         {
89cdf0e10cSrcweir             DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() );
90cdf0e10cSrcweir             break;
91cdf0e10cSrcweir         }
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir     return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
setValueEvent(const uno::Any & value)96cdf0e10cSrcweir void SwVbaOptions::setValueEvent( const uno::Any& value )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     rtl::OUString sNewPath;
99cdf0e10cSrcweir     value >>= sNewPath;
100cdf0e10cSrcweir     rtl::OUString sNewPathUrl;
101cdf0e10cSrcweir     ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl );
102cdf0e10cSrcweir     uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.PathSettings") ), uno::UNO_QUERY_THROW );
103cdf0e10cSrcweir     rtl::OUString sOldPathUrl;
104cdf0e10cSrcweir     xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sOldPathUrl;
105cdf0e10cSrcweir     // path could be a multipath, Microsoft doesn't support this feature in Word currently
106cdf0e10cSrcweir     // only the last path is from interest.
107cdf0e10cSrcweir     sal_Int32 nIndex = sOldPathUrl.lastIndexOf( sal_Unicode(';') );
108cdf0e10cSrcweir     if( nIndex != -1 )
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         sNewPathUrl = sOldPathUrl.copy( 0, nIndex + 1 ).concat( sNewPathUrl );
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir     xPathSettings->setPropertyValue( msDefaultFilePath, uno::makeAny( sNewPathUrl ) );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
getValueEvent()115cdf0e10cSrcweir uno::Any SwVbaOptions::getValueEvent()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.PathSettings") ), uno::UNO_QUERY_THROW );
118cdf0e10cSrcweir     rtl::OUString sPathUrl;
119cdf0e10cSrcweir     xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sPathUrl;
120cdf0e10cSrcweir     // path could be a multipath, Microsoft doesn't support this feature in Word currently
121cdf0e10cSrcweir     // only the last path is from interest.
122cdf0e10cSrcweir     sal_Int32 nIndex = sPathUrl.lastIndexOf( sal_Unicode(';') );
123cdf0e10cSrcweir     if( nIndex != -1 )
124cdf0e10cSrcweir     {
125cdf0e10cSrcweir         sPathUrl = sPathUrl.copy( nIndex + 1 );
126cdf0e10cSrcweir     }
127cdf0e10cSrcweir     rtl::OUString sPath;
128cdf0e10cSrcweir     ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath );
129cdf0e10cSrcweir     return uno::makeAny( sPath );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
getDefaultBorderLineStyle()132cdf0e10cSrcweir sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineStyle() throw (uno::RuntimeException)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir     return word::WdLineStyle::wdLineStyleSingle;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
setDefaultBorderLineStyle(::sal_Int32)137cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setDefaultBorderLineStyle( ::sal_Int32 /*_defaultborderlinestyle*/ ) throw (uno::RuntimeException)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     // not support in Writer
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
getDefaultBorderLineWidth()142cdf0e10cSrcweir sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineWidth() throw (uno::RuntimeException)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     return word::WdLineWidth::wdLineWidth050pt;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
setDefaultBorderLineWidth(::sal_Int32)147cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setDefaultBorderLineWidth( ::sal_Int32 /*_defaultborderlinewidth*/ ) throw (uno::RuntimeException)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     // not support in Writer
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
getDefaultBorderColorIndex()152cdf0e10cSrcweir sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderColorIndex() throw (uno::RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     return word::WdColorIndex::wdAuto;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
setDefaultBorderColorIndex(::sal_Int32)157cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setDefaultBorderColorIndex( ::sal_Int32 /*_defaultbordercolorindex*/ ) throw (uno::RuntimeException)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     // not support in Writer
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
getReplaceSelection()162cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getReplaceSelection() throw (uno::RuntimeException)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     return sal_True;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
setReplaceSelection(::sal_Bool)167cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setReplaceSelection( ::sal_Bool /*_replaceselection*/ ) throw (uno::RuntimeException)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     // not support in Writer
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
getMapPaperSize()172cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getMapPaperSize() throw (uno::RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     return sal_False;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
setMapPaperSize(::sal_Bool)177cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setMapPaperSize( ::sal_Bool /*_mappapersize*/ ) throw (uno::RuntimeException)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir     // not support in Writer
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
getAutoFormatAsYouTypeApplyHeadings()182cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyHeadings() throw (uno::RuntimeException)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     return sal_False;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
setAutoFormatAsYouTypeApplyHeadings(::sal_Bool)187cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( ::sal_Bool /*_autoformatasyoutypeapplyheadings*/ ) throw (uno::RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     // not support in Writer
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
getAutoFormatAsYouTypeApplyBulletedLists()192cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyBulletedLists() throw (uno::RuntimeException)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     return sal_False;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
setAutoFormatAsYouTypeApplyBulletedLists(::sal_Bool)197cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( ::sal_Bool /*_autoformatasyoutypeapplybulletedlists*/ ) throw (uno::RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     // not support in Writer
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
getAutoFormatAsYouTypeApplyNumberedLists()202cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyNumberedLists() throw (uno::RuntimeException)
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     return sal_False;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
setAutoFormatAsYouTypeApplyNumberedLists(::sal_Bool)207cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( ::sal_Bool /*_autoformatasyoutypeapplynumberedlists*/ ) throw (uno::RuntimeException)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir     // not support in Writer
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
getAutoFormatAsYouTypeFormatListItemBeginning()212cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeFormatListItemBeginning() throw (uno::RuntimeException)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     return sal_False;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
setAutoFormatAsYouTypeFormatListItemBeginning(::sal_Bool)217cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( ::sal_Bool /*_autoformatasyoutypeformatlistitembeginning*/ ) throw (uno::RuntimeException)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir     // not support in Writer
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
getAutoFormatAsYouTypeDefineStyles()222cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeDefineStyles() throw (uno::RuntimeException)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     return sal_False;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
setAutoFormatAsYouTypeDefineStyles(::sal_Bool)227cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( ::sal_Bool /*_autoformatasyoutypedefinestyles*/ ) throw (uno::RuntimeException)
228cdf0e10cSrcweir {
229cdf0e10cSrcweir     // not support in Writer
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
getAutoFormatApplyHeadings()232cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyHeadings() throw (uno::RuntimeException)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir     return sal_False;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
setAutoFormatApplyHeadings(::sal_Bool)237cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatApplyHeadings( ::sal_Bool /*_autoformatapplyheadings*/ ) throw (uno::RuntimeException)
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     // not support in Writer
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
getAutoFormatApplyLists()242cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyLists() throw (uno::RuntimeException)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     return sal_False;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
setAutoFormatApplyLists(::sal_Bool)247cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatApplyLists( ::sal_Bool /*_autoformatapplylists*/ ) throw (uno::RuntimeException)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     // not support in Writer
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
getAutoFormatApplyBulletedLists()252cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyBulletedLists() throw (uno::RuntimeException)
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     return sal_False;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
setAutoFormatApplyBulletedLists(::sal_Bool)257cdf0e10cSrcweir void SAL_CALL SwVbaOptions::setAutoFormatApplyBulletedLists( ::sal_Bool /*_autoformatapplybulletedlists*/ ) throw (uno::RuntimeException)
258cdf0e10cSrcweir {
259cdf0e10cSrcweir     // not support in Writer
260cdf0e10cSrcweir }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 
263cdf0e10cSrcweir rtl::OUString&
getServiceImplName()264cdf0e10cSrcweir SwVbaOptions::getServiceImplName()
265cdf0e10cSrcweir {
266cdf0e10cSrcweir 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaOptions") );
267cdf0e10cSrcweir 	return sImplName;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir uno::Sequence< rtl::OUString >
getServiceNames()271cdf0e10cSrcweir SwVbaOptions::getServiceNames()
272cdf0e10cSrcweir {
273cdf0e10cSrcweir 	static uno::Sequence< rtl::OUString > aServiceNames;
274cdf0e10cSrcweir 	if ( aServiceNames.getLength() == 0 )
275cdf0e10cSrcweir 	{
276cdf0e10cSrcweir 		aServiceNames.realloc( 1 );
277cdf0e10cSrcweir 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Options" ) );
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir 	return aServiceNames;
280cdf0e10cSrcweir }
281