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