LibreOffice Module sw (master)  1
vbaoptions.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
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>
27 #include <basic/sberrors.hxx>
28 #include <osl/file.hxx>
29 
30 using namespace ::ooo::vba;
31 using namespace ::com::sun::star;
32 
33 SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext > const & xContext ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext )
34 {
35 }
36 
38 {
39 }
40 
41 uno::Any SAL_CALL
43 {
44  switch( _path )
45  {
46  case word::WdDefaultFilePath::wdDocumentsPath:
47  {
48  msDefaultFilePath = "Work";
49  break;
50  }
51  case word::WdDefaultFilePath::wdPicturesPath:
52  {
53  msDefaultFilePath = "Gallery";
54  break;
55  }
56  case word::WdDefaultFilePath::wdUserTemplatesPath:
57  case word::WdDefaultFilePath::wdWorkgroupTemplatesPath:
58  {
59  msDefaultFilePath = "Template";
60  break;
61  }
62  case word::WdDefaultFilePath::wdStartupPath:
63  {
64  msDefaultFilePath = "Addin";
65  break;
66  }
67  case word::WdDefaultFilePath::wdUserOptionsPath:
68  {
69  msDefaultFilePath = "UserConfig";
70  break;
71  }
72  case word::WdDefaultFilePath::wdToolsPath:
73  case word::WdDefaultFilePath::wdProgramPath:
74  {
75  msDefaultFilePath = "Module";
76  break;
77  }
78  case word::WdDefaultFilePath::wdTempFilePath:
79  {
80  msDefaultFilePath = "Temp";
81  break;
82  }
83  default:
84  {
85  DebugHelper::basicexception( ERRCODE_BASIC_NOT_IMPLEMENTED, {} );
86  break;
87  }
88  }
89  return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
90 }
91 
93 {
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 )
105  {
106  sNewPathUrl = sOldPathUrl.subView( 0, nIndex + 1 ) + sNewPathUrl;
107  }
108  xPathSettings->setPropertyValue( msDefaultFilePath, uno::makeAny( sNewPathUrl ) );
109 }
110 
112 {
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 )
120  {
121  sPathUrl = sPathUrl.copy( nIndex + 1 );
122  }
123  OUString sPath;
124  ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath );
125  return uno::makeAny( sPath );
126 }
127 
129 {
130  return word::WdLineStyle::wdLineStyleSingle;
131 }
132 
133 void SAL_CALL SwVbaOptions::setDefaultBorderLineStyle( ::sal_Int32 /*_defaultborderlinestyle*/ )
134 {
135  // not support in Writer
136 }
137 
139 {
140  return word::WdLineWidth::wdLineWidth050pt;
141 }
142 
143 void SAL_CALL SwVbaOptions::setDefaultBorderLineWidth( ::sal_Int32 /*_defaultborderlinewidth*/ )
144 {
145  // not support in Writer
146 }
147 
149 {
150  return word::WdColorIndex::wdAuto;
151 }
152 
153 void SAL_CALL SwVbaOptions::setDefaultBorderColorIndex( ::sal_Int32 /*_defaultbordercolorindex*/ )
154 {
155  // not support in Writer
156 }
157 
159 {
160  return true;
161 }
162 
163 void SAL_CALL SwVbaOptions::setReplaceSelection( sal_Bool /*_replaceselection*/ )
164 {
165  // not support in Writer
166 }
167 
169 {
170  return false;
171 }
172 
173 void SAL_CALL SwVbaOptions::setMapPaperSize( sal_Bool /*_mappapersize*/ )
174 {
175  // not support in Writer
176 }
177 
179 {
180  return false;
181 }
182 
183 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( sal_Bool /*_autoformatasyoutypeapplyheadings*/ )
184 {
185  // not support in Writer
186 }
187 
189 {
190  return false;
191 }
192 
193 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( sal_Bool /*_autoformatasyoutypeapplybulletedlists*/ )
194 {
195  // not support in Writer
196 }
197 
199 {
200  return false;
201 }
202 
203 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( sal_Bool /*_autoformatasyoutypeapplynumberedlists*/ )
204 {
205  // not support in Writer
206 }
207 
209 {
210  return false;
211 }
212 
213 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( sal_Bool /*_autoformatasyoutypeformatlistitembeginning*/ )
214 {
215  // not support in Writer
216 }
217 
219 {
220  return false;
221 }
222 
223 void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( sal_Bool /*_autoformatasyoutypedefinestyles*/ )
224 {
225  // not support in Writer
226 }
227 
229 {
230  return false;
231 }
232 
233 void SAL_CALL SwVbaOptions::setAutoFormatApplyHeadings( sal_Bool /*_autoformatapplyheadings*/ )
234 {
235  // not support in Writer
236 }
237 
239 {
240  return false;
241 }
242 
243 void SAL_CALL SwVbaOptions::setAutoFormatApplyLists( sal_Bool /*_autoformatapplylists*/ )
244 {
245  // not support in Writer
246 }
247 
249 {
250  return false;
251 }
252 
253 void SAL_CALL SwVbaOptions::setAutoFormatApplyBulletedLists( sal_Bool /*_autoformatapplybulletedlists*/ )
254 {
255  // not support in Writer
256 }
257 
258 OUString
260 {
261  return "SwVbaOptions";
262 }
263 
264 uno::Sequence< OUString >
266 {
267  static uno::Sequence< OUString > const aServiceNames
268  {
269  "ooo.vba.word.Options"
270  };
271  return aServiceNames;
272 }
273 
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual sal_Bool SAL_CALL getAutoFormatAsYouTypeFormatListItemBeginning() override
Definition: vbaoptions.cxx:208
virtual void setValueEvent(const css::uno::Any &value) override
Definition: vbaoptions.cxx:92
sal_Int32 nIndex
virtual OUString getServiceImplName() override
Definition: vbaoptions.cxx:259
virtual void SAL_CALL setAutoFormatAsYouTypeApplyNumberedLists(sal_Bool _autoformatasyoutypeapplynumberedlists) override
Definition: vbaoptions.cxx:203
virtual void SAL_CALL setReplaceSelection(sal_Bool _replaceselection) override
Definition: vbaoptions.cxx:163
virtual ::sal_Int32 SAL_CALL getDefaultBorderColorIndex() override
Definition: vbaoptions.cxx:148
Reference
Sequence< OUString > aServiceNames
virtual sal_Bool SAL_CALL getAutoFormatAsYouTypeDefineStyles() override
Definition: vbaoptions.cxx:218
virtual void SAL_CALL setAutoFormatApplyHeadings(sal_Bool _autoformatapplyheadings) override
Definition: vbaoptions.cxx:233
#define ERRCODE_BASIC_NOT_IMPLEMENTED
virtual void SAL_CALL setAutoFormatApplyBulletedLists(sal_Bool _autoformatapplybulletedlists) override
Definition: vbaoptions.cxx:253
SwVbaOptions(css::uno::Reference< css::uno::XComponentContext > const &m_xContext)
Definition: vbaoptions.cxx:33
virtual sal_Bool SAL_CALL getAutoFormatAsYouTypeApplyNumberedLists() override
Definition: vbaoptions.cxx:198
virtual void SAL_CALL setAutoFormatApplyLists(sal_Bool _autoformatapplylists) override
Definition: vbaoptions.cxx:243
virtual void SAL_CALL setMapPaperSize(sal_Bool _mappapersize) override
Definition: vbaoptions.cxx:173
OUString msDefaultFilePath
Definition: vbaoptions.hxx:32
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaoptions.cxx:265
virtual sal_Bool SAL_CALL getMapPaperSize() override
Definition: vbaoptions.cxx:168
virtual void SAL_CALL setDefaultBorderLineWidth(::sal_Int32 _defaultborderlinewidth) override
Definition: vbaoptions.cxx:143
virtual sal_Bool SAL_CALL getAutoFormatApplyHeadings() override
Definition: vbaoptions.cxx:228
virtual sal_Bool SAL_CALL getAutoFormatApplyBulletedLists() override
Definition: vbaoptions.cxx:248
virtual ::sal_Int32 SAL_CALL getDefaultBorderLineStyle() override
Definition: vbaoptions.cxx:128
virtual void SAL_CALL setAutoFormatAsYouTypeDefineStyles(sal_Bool _autoformatasyoutypedefinestyles) override
Definition: vbaoptions.cxx:223
virtual sal_Bool SAL_CALL getAutoFormatAsYouTypeApplyHeadings() override
Definition: vbaoptions.cxx:178
virtual css::uno::Any getValueEvent() override
Definition: vbaoptions.cxx:111
unsigned char sal_Bool
virtual void SAL_CALL setDefaultBorderColorIndex(::sal_Int32 _defaultbordercolorindex) override
Definition: vbaoptions.cxx:153
virtual void SAL_CALL setAutoFormatAsYouTypeApplyHeadings(sal_Bool _autoformatasyoutypeapplyheadings) override
Definition: vbaoptions.cxx:183
virtual sal_Bool SAL_CALL getReplaceSelection() override
Definition: vbaoptions.cxx:158
virtual void SAL_CALL setAutoFormatAsYouTypeApplyBulletedLists(sal_Bool _autoformatasyoutypeapplybulletedlists) override
Definition: vbaoptions.cxx:193
virtual void SAL_CALL setDefaultBorderLineStyle(::sal_Int32 _defaultborderlinestyle) override
Definition: vbaoptions.cxx:133
Reference< XComponentContext > getProcessComponentContext()
virtual void SAL_CALL setAutoFormatAsYouTypeFormatListItemBeginning(sal_Bool _autoformatasyoutypeformatlistitembeginning) override
Definition: vbaoptions.cxx:213
virtual sal_Bool SAL_CALL getAutoFormatApplyLists() override
Definition: vbaoptions.cxx:238
virtual ~SwVbaOptions() override
Definition: vbaoptions.cxx:37
virtual sal_Bool SAL_CALL getAutoFormatAsYouTypeApplyBulletedLists() override
Definition: vbaoptions.cxx:188
virtual css::uno::Any SAL_CALL DefaultFilePath(sal_Int32 _path) override
Definition: vbaoptions.cxx:42
virtual ::sal_Int32 SAL_CALL getDefaultBorderLineWidth() override
Definition: vbaoptions.cxx:138