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