bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / uno / unomod.cxx
blob54423f6554224605997e1acae56ff05187927918
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <swtypes.hxx>
21 #include <osl/diagnose.h>
22 #include <unomod.hxx>
23 #include <unomid.h>
24 #include <unoprnms.hxx>
25 #include <unomap.hxx>
26 #include <prtopt.hxx>
27 #include <tools/shl.hxx>
28 #include <swmodule.hxx>
29 #include <view.hxx>
30 #include <docsh.hxx>
31 #include <wrtsh.hxx>
32 #include <viewopt.hxx>
33 #include <osl/mutex.hxx>
34 #include <vcl/svapp.hxx>
35 #include <com/sun/star/text/NotePrintMode.hpp>
36 #include <doc.hxx>
37 #include <comphelper/TypeGeneration.hxx>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/view/DocumentZoomType.hpp>
40 #include <comphelper/ChainablePropertySetInfo.hxx>
41 #include <edtwin.hxx>
42 #include <rtl/ustrbuf.hxx>
43 #include <tools/urlobj.hxx>
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::beans;
47 using namespace ::com::sun::star::lang;
48 using namespace ::comphelper;
50 enum SwViewSettingsPropertyHandles
52 HANDLE_VIEWSET_ANNOTATIONS,
53 HANDLE_VIEWSET_BREAKS,
54 HANDLE_VIEWSET_DRAWINGS,
55 HANDLE_VIEWSET_FIELD_COMMANDS,
56 HANDLE_VIEWSET_FOOTNOTE_BACKGROUND,
57 HANDLE_VIEWSET_GRAPHICS,
58 HANDLE_VIEWSET_HIDDEN_CHARACTERS,
59 HANDLE_VIEWSET_HIDDEN_PARAGRAPHS,
60 HANDLE_VIEWSET_HIDDEN_TEXT,
61 HANDLE_VIEWSET_HRULER,
62 HANDLE_VIEWSET_HSCROLL,
63 HANDLE_VIEWSET_INDEX_MARK_BACKGROUND,
64 HANDLE_VIEWSET_NONPRINTING_CHARACTERS,
65 HANDLE_VIEWSET_ONLINE_LAYOUT,
66 HANDLE_VIEWSET_PARA_BREAKS,
67 HANDLE_VIEWSET_PROTECTED_SPACES,
68 HANDLE_VIEWSET_SOFT_HYPHENS,
69 HANDLE_VIEWSET_SPACES,
70 HANDLE_VIEWSET_TABLE_BOUNDARIES,
71 HANDLE_VIEWSET_TABLES,
72 HANDLE_VIEWSET_TABSTOPS,
73 HANDLE_VIEWSET_TEXT_BOUNDARIES,
74 HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND,
75 HANDLE_VIEWSET_VRULER,
76 HANDLE_VIEWSET_VSCROLL,
77 HANDLE_VIEWSET_SMOOTH_SCROLLING,
78 HANDLE_VIEWSET_ZOOM_TYPE,
79 HANDLE_VIEWSET_ZOOM,
80 HANDLE_VIEWSET_SHOW_CONTENT_TIPS,
81 HANDLE_VIEWSET_HELP_URL,
82 HANDLE_VIEWSET_VRULER_RIGHT,
83 HANDLE_VIEWSET_SHOW_RULER,
84 HANDLE_VIEWSET_IS_RASTER_VISIBLE,
85 HANDLE_VIEWSET_IS_SNAP_TO_RASTER,
86 HANDLE_VIEWSET_RASTER_RESOLUTION_X,
87 HANDLE_VIEWSET_RASTER_RESOLUTION_Y,
88 HANDLE_VIEWSET_RASTER_SUBDIVISION_X,
89 HANDLE_VIEWSET_RASTER_SUBDIVISION_Y,
90 HANDLE_VIEWSET_HORI_RULER_METRIC,
91 HANDLE_VIEWSET_VERT_RULER_METRIC
94 enum SwPrintSettingsPropertyHandles
96 HANDLE_PRINTSET_ANNOTATION_MODE,
97 HANDLE_PRINTSET_BLACK_FONTS,
98 HANDLE_PRINTSET_CONTROLS,
99 HANDLE_PRINTSET_DRAWINGS,
100 HANDLE_PRINTSET_GRAPHICS,
101 HANDLE_PRINTSET_LEFT_PAGES,
102 HANDLE_PRINTSET_PAGE_BACKGROUND,
103 HANDLE_PRINTSET_PROSPECT,
104 HANDLE_PRINTSET_REVERSED,
105 HANDLE_PRINTSET_RIGHT_PAGES,
106 HANDLE_PRINTSET_FAX_NAME,
107 HANDLE_PRINTSET_PAPER_FROM_SETUP,
108 HANDLE_PRINTSET_TABLES,
109 HANDLE_PRINTSET_SINGLE_JOBS,
110 HANDLE_PRINTSET_EMPTY_PAGES,
111 HANDLE_PRINTSET_PROSPECT_RTL,
112 HANDLE_PRINTSET_PLACEHOLDER,
113 HANDLE_PRINTSET_HIDDEN_TEXT
116 static ChainablePropertySetInfo * lcl_createViewSettingsInfo()
118 static PropertyInfo aViewSettingsMap_Impl[] =
120 { RTL_CONSTASCII_STRINGPARAM ( "HelpURL" ), HANDLE_VIEWSET_HELP_URL , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0},
121 { RTL_CONSTASCII_STRINGPARAM ( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC , CPPUTYPE_INT32, PROPERTY_NONE, 0},
122 { RTL_CONSTASCII_STRINGPARAM ( "IsRasterVisible"), HANDLE_VIEWSET_IS_RASTER_VISIBLE, CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
123 { RTL_CONSTASCII_STRINGPARAM ( "IsSnapToRaster"), HANDLE_VIEWSET_IS_SNAP_TO_RASTER, CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
124 { RTL_CONSTASCII_STRINGPARAM ( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
125 { RTL_CONSTASCII_STRINGPARAM ( "ShowContentTips" ), HANDLE_VIEWSET_SHOW_CONTENT_TIPS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
126 { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionX"), HANDLE_VIEWSET_RASTER_RESOLUTION_X, CPPUTYPE_INT32, PROPERTY_NONE, 0},
127 { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionY"), HANDLE_VIEWSET_RASTER_RESOLUTION_Y, CPPUTYPE_INT32, PROPERTY_NONE, 0},
128 { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionX"), HANDLE_VIEWSET_RASTER_SUBDIVISION_X, CPPUTYPE_INT32, PROPERTY_NONE, 0},
129 { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionY"), HANDLE_VIEWSET_RASTER_SUBDIVISION_Y, CPPUTYPE_INT32, PROPERTY_NONE, 0},
130 { RTL_CONSTASCII_STRINGPARAM ( "ShowAnnotations" ), HANDLE_VIEWSET_ANNOTATIONS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
131 { RTL_CONSTASCII_STRINGPARAM ( "ShowBreaks"), HANDLE_VIEWSET_BREAKS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
132 { RTL_CONSTASCII_STRINGPARAM ( "ShowDrawings"), HANDLE_VIEWSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
133 { RTL_CONSTASCII_STRINGPARAM ( "ShowFieldCommands"), HANDLE_VIEWSET_FIELD_COMMANDS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
134 { RTL_CONSTASCII_STRINGPARAM ( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
135 { RTL_CONSTASCII_STRINGPARAM ( "ShowGraphics"), HANDLE_VIEWSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
136 { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
137 { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenParagraphs"), HANDLE_VIEWSET_HIDDEN_PARAGRAPHS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
138 { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenText"), HANDLE_VIEWSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
139 { RTL_CONSTASCII_STRINGPARAM ( "ShowHoriRuler"), HANDLE_VIEWSET_HRULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
140 { RTL_CONSTASCII_STRINGPARAM ( "ShowHoriScrollBar"), HANDLE_VIEWSET_HSCROLL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
141 { RTL_CONSTASCII_STRINGPARAM ( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
142 { RTL_CONSTASCII_STRINGPARAM ( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
143 { RTL_CONSTASCII_STRINGPARAM ( "ShowOnlineLayout"), HANDLE_VIEWSET_ONLINE_LAYOUT , CPPUTYPE_BOOLEAN, PropertyAttribute::MAYBEVOID, 0},
144 { RTL_CONSTASCII_STRINGPARAM ( "ShowParaBreaks"), HANDLE_VIEWSET_PARA_BREAKS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
145 { RTL_CONSTASCII_STRINGPARAM ( "ShowProtectedSpaces"), HANDLE_VIEWSET_PROTECTED_SPACES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
146 { RTL_CONSTASCII_STRINGPARAM ( "ShowRulers"), HANDLE_VIEWSET_SHOW_RULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
147 { RTL_CONSTASCII_STRINGPARAM ( "ShowSoftHyphens"), HANDLE_VIEWSET_SOFT_HYPHENS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
148 { RTL_CONSTASCII_STRINGPARAM ( "ShowSpaces"), HANDLE_VIEWSET_SPACES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
149 { RTL_CONSTASCII_STRINGPARAM ( "ShowTableBoundaries"), HANDLE_VIEWSET_TABLE_BOUNDARIES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
150 { RTL_CONSTASCII_STRINGPARAM ( "ShowTables"), HANDLE_VIEWSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
151 { RTL_CONSTASCII_STRINGPARAM ( "ShowTabstops"), HANDLE_VIEWSET_TABSTOPS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
152 { RTL_CONSTASCII_STRINGPARAM ( "ShowTextBoundaries"), HANDLE_VIEWSET_TEXT_BOUNDARIES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
153 { RTL_CONSTASCII_STRINGPARAM ( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
154 { RTL_CONSTASCII_STRINGPARAM ( "ShowVertRuler"), HANDLE_VIEWSET_VRULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
155 { RTL_CONSTASCII_STRINGPARAM ( "ShowVertScrollBar"), HANDLE_VIEWSET_VSCROLL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
156 { RTL_CONSTASCII_STRINGPARAM ( "SmoothScrolling"), HANDLE_VIEWSET_SMOOTH_SCROLLING , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
157 { RTL_CONSTASCII_STRINGPARAM ( "VerticalRulerMetric"), HANDLE_VIEWSET_VERT_RULER_METRIC , CPPUTYPE_INT32, PROPERTY_NONE, 0},
158 { RTL_CONSTASCII_STRINGPARAM ( "ZoomType"), HANDLE_VIEWSET_ZOOM_TYPE , CPPUTYPE_INT16, PROPERTY_NONE, 0},
159 { RTL_CONSTASCII_STRINGPARAM ( "ZoomValue"), HANDLE_VIEWSET_ZOOM , CPPUTYPE_INT16, PROPERTY_NONE, 0},
160 { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
162 return new ChainablePropertySetInfo ( aViewSettingsMap_Impl );
165 static ChainablePropertySetInfo * lcl_createPrintSettingsInfo()
167 static PropertyInfo aPrintSettingsMap_Impl[] =
169 { RTL_CONSTASCII_STRINGPARAM ( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE , CPPUTYPE_INT16, PROPERTY_NONE, 0},
170 { RTL_CONSTASCII_STRINGPARAM ( "PrintBlackFonts" ), HANDLE_PRINTSET_BLACK_FONTS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
171 { RTL_CONSTASCII_STRINGPARAM ( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
172 { RTL_CONSTASCII_STRINGPARAM ( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
173 { RTL_CONSTASCII_STRINGPARAM ( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
174 { RTL_CONSTASCII_STRINGPARAM ( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
175 { RTL_CONSTASCII_STRINGPARAM ( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
176 { RTL_CONSTASCII_STRINGPARAM ( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
177 { RTL_CONSTASCII_STRINGPARAM ( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
178 { RTL_CONSTASCII_STRINGPARAM ( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
179 { RTL_CONSTASCII_STRINGPARAM ( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
180 { RTL_CONSTASCII_STRINGPARAM ( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
181 { RTL_CONSTASCII_STRINGPARAM ( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0},
182 { RTL_CONSTASCII_STRINGPARAM ( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
183 { RTL_CONSTASCII_STRINGPARAM ( "PrintTables" ), HANDLE_PRINTSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
184 { RTL_CONSTASCII_STRINGPARAM ( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
185 { RTL_CONSTASCII_STRINGPARAM ( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
186 { RTL_CONSTASCII_STRINGPARAM ( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
187 { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
189 return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl );
192 /******************************************************************
193 * SwXModule
194 ******************************************************************/
195 Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(
196 const Reference< XMultiServiceFactory > & /*rSMgr*/) throw( Exception )
198 static Reference< uno::XInterface > xModule = (cppu::OWeakObject*)new SwXModule();
199 return xModule;
202 Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw()
204 OUString sService( "com.sun.star.text.GlobalSettings");
205 const Sequence< OUString > aSeq( &sService, 1 );
206 return aSeq;
209 OUString SAL_CALL SwXModule_getImplementationName() throw()
211 return OUString( "SwXModule" );
214 SwXModule::SwXModule() :
215 pxViewSettings(0),
216 pxPrintSettings(0)
220 SwXModule::~SwXModule()
222 delete pxViewSettings;
223 delete pxPrintSettings;
226 Reference< XPropertySet > SwXModule::getViewSettings(void) throw( uno::RuntimeException )
228 SolarMutexGuard aGuard;
229 if(!pxViewSettings)
231 ((SwXModule*)this)->pxViewSettings = new Reference< XPropertySet > ;
232 OSL_FAIL("Web or Text?");
233 *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, 0 ) );
235 return *pxViewSettings;
238 Reference< XPropertySet > SwXModule::getPrintSettings(void) throw( uno::RuntimeException )
240 SolarMutexGuard aGuard;
241 if(!pxPrintSettings)
243 ((SwXModule*)this)->pxPrintSettings = new Reference< XPropertySet > ;
244 OSL_FAIL("Web or Text?");
245 *pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) );
247 return *pxPrintSettings;
250 OUString SwXModule::getImplementationName(void) throw( RuntimeException )
252 return SwXModule_getImplementationName();
255 sal_Bool SwXModule::supportsService(const OUString& rServiceName) throw( RuntimeException )
257 const Sequence< OUString > aNames = SwXModule_getSupportedServiceNames();
258 for(sal_Int32 nService = 0; nService < aNames.getLength(); nService++)
260 if(aNames.getConstArray()[nService] == rServiceName)
261 return sal_True;
263 return sal_False;
266 Sequence< OUString > SwXModule::getSupportedServiceNames(void) throw( RuntimeException )
268 return SwXModule_getSupportedServiceNames();
271 /******************************************************************
272 * SwXPrintSettings
273 ******************************************************************/
274 SwXPrintSettings::SwXPrintSettings(SwXPrintSettingsType eType, SwDoc* pDoc)
275 : ChainableHelperNoState ( lcl_createPrintSettingsInfo (), &Application::GetSolarMutex() )
276 , meType(eType)
277 , mpPrtOpt ( NULL )
278 , mpDoc ( pDoc )
282 SwXPrintSettings::~SwXPrintSettings()
283 throw()
287 void SwXPrintSettings::_preSetValues ()
288 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
290 switch (meType)
292 case PRINT_SETTINGS_MODULE:
293 mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
294 break;
295 case PRINT_SETTINGS_WEB:
296 mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
297 break;
298 case PRINT_SETTINGS_DOCUMENT:
300 if (!mpDoc)
301 throw IllegalArgumentException ();
302 mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
304 break;
308 void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
309 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
311 sal_Bool bVal;
312 if ( rInfo.mnHandle != HANDLE_PRINTSET_ANNOTATION_MODE &&
313 rInfo.mnHandle != HANDLE_PRINTSET_FAX_NAME )
314 bVal = *(sal_Bool*)rValue.getValue();
316 switch( rInfo.mnHandle )
318 case HANDLE_PRINTSET_LEFT_PAGES:
320 bVal = *(sal_Bool*)rValue.getValue();
321 mpPrtOpt->SetPrintLeftPage(bVal);
323 break;
324 case HANDLE_PRINTSET_RIGHT_PAGES:
326 bVal = *(sal_Bool*)rValue.getValue();
327 mpPrtOpt->SetPrintRightPage(bVal);
329 break;
330 case HANDLE_PRINTSET_REVERSED:
332 bVal = *(sal_Bool*)rValue.getValue();
333 mpPrtOpt->SetPrintReverse(bVal);
335 break;
336 case HANDLE_PRINTSET_PROSPECT:
338 bVal = *(sal_Bool*)rValue.getValue();
339 mpPrtOpt->SetPrintProspect(bVal);
341 break;
342 case HANDLE_PRINTSET_GRAPHICS:
344 bVal = *(sal_Bool*)rValue.getValue();
345 mpPrtOpt->SetPrintGraphic(bVal);
347 break;
348 case HANDLE_PRINTSET_TABLES:
350 bVal = *(sal_Bool*)rValue.getValue();
351 mpPrtOpt->SetPrintTable(bVal);
353 break;
354 case HANDLE_PRINTSET_DRAWINGS:
356 bVal = *(sal_Bool*)rValue.getValue();
357 mpPrtOpt->SetPrintDraw(bVal);
359 break;
360 case HANDLE_PRINTSET_CONTROLS:
362 bVal = *(sal_Bool*)rValue.getValue();
363 mpPrtOpt->SetPrintControl(bVal);
365 break;
366 case HANDLE_PRINTSET_PAGE_BACKGROUND:
368 bVal = *(sal_Bool*)rValue.getValue();
369 mpPrtOpt->SetPrintPageBackground(bVal);
371 break;
372 case HANDLE_PRINTSET_BLACK_FONTS:
374 bVal = *(sal_Bool*)rValue.getValue();
375 mpPrtOpt->SetPrintBlackFont(bVal);
377 break;
378 case HANDLE_PRINTSET_SINGLE_JOBS:
380 bVal = *(sal_Bool*)rValue.getValue();
381 mpPrtOpt->SetPrintSingleJobs(bVal);
383 break;
384 case HANDLE_PRINTSET_PAPER_FROM_SETUP:
386 bVal = *(sal_Bool*)rValue.getValue();
387 mpPrtOpt->SetPaperFromSetup(bVal);
389 break;
390 case HANDLE_PRINTSET_ANNOTATION_MODE:
392 sal_Int16 nVal = 0;
393 rValue >>= nVal;
394 if(nVal <= text::NotePrintMode_PAGE_END)
395 mpPrtOpt->SetPrintPostIts(nVal);
396 else
397 throw lang::IllegalArgumentException();
399 break;
400 case HANDLE_PRINTSET_EMPTY_PAGES:
402 bVal = *(sal_Bool*)rValue.getValue();
403 mpPrtOpt->SetPrintEmptyPages(bVal);
405 break;
406 case HANDLE_PRINTSET_FAX_NAME:
408 OUString sString;
409 if ( rValue >>= sString)
410 mpPrtOpt->SetFaxName(sString);
411 else
412 throw lang::IllegalArgumentException();
414 break;
415 case HANDLE_PRINTSET_PROSPECT_RTL:
417 bVal = *(sal_Bool*)rValue.getValue();
418 mpPrtOpt->SetPrintProspect_RTL(bVal);
420 break;
421 case HANDLE_PRINTSET_PLACEHOLDER:
423 bVal = *(sal_Bool*)rValue.getValue();
424 mpPrtOpt->SetPrintTextPlaceholder(bVal);
426 break;
427 case HANDLE_PRINTSET_HIDDEN_TEXT:
429 bVal = *(sal_Bool*)rValue.getValue();
430 mpPrtOpt->SetPrintHiddenText(bVal);
432 break;
433 default:
434 throw UnknownPropertyException();
438 void SwXPrintSettings::_postSetValues ()
439 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
441 mpPrtOpt = NULL;
444 void SwXPrintSettings::_preGetValues ()
445 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
447 switch (meType)
449 case PRINT_SETTINGS_MODULE:
450 mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
451 break;
452 case PRINT_SETTINGS_WEB:
453 mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
454 break;
455 case PRINT_SETTINGS_DOCUMENT:
457 if (!mpDoc)
458 throw IllegalArgumentException ();
459 mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
461 break;
465 void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
466 throw(UnknownPropertyException, WrappedTargetException )
468 switch( rInfo.mnHandle )
470 case HANDLE_PRINTSET_LEFT_PAGES:
471 rValue <<= mpPrtOpt->IsPrintLeftPage();
472 break;
473 case HANDLE_PRINTSET_RIGHT_PAGES:
474 rValue <<= mpPrtOpt->IsPrintRightPage();
475 break;
476 case HANDLE_PRINTSET_REVERSED:
477 rValue <<= mpPrtOpt->IsPrintReverse();
478 break;
479 case HANDLE_PRINTSET_PROSPECT:
480 rValue <<= mpPrtOpt->IsPrintProspect();
481 break;
482 case HANDLE_PRINTSET_GRAPHICS:
483 rValue <<= mpPrtOpt->IsPrintGraphic();
484 break;
485 case HANDLE_PRINTSET_TABLES:
486 rValue <<= mpPrtOpt->IsPrintTable();
487 break;
488 case HANDLE_PRINTSET_DRAWINGS:
489 rValue <<= mpPrtOpt->IsPrintDraw();
490 break;
491 case HANDLE_PRINTSET_CONTROLS:
492 rValue <<= mpPrtOpt->IsPrintControl();
493 break;
494 case HANDLE_PRINTSET_PAGE_BACKGROUND:
495 rValue <<= mpPrtOpt->IsPrintPageBackground();
496 break;
497 case HANDLE_PRINTSET_BLACK_FONTS:
498 rValue <<= mpPrtOpt->IsPrintBlackFont();
499 break;
500 case HANDLE_PRINTSET_SINGLE_JOBS:
501 rValue <<= mpPrtOpt->IsPrintSingleJobs();
502 break;
503 case HANDLE_PRINTSET_EMPTY_PAGES:
504 rValue <<= mpPrtOpt->IsPrintEmptyPages();
505 break;
506 case HANDLE_PRINTSET_PAPER_FROM_SETUP:
507 rValue <<= mpPrtOpt->IsPaperFromSetup();
508 break;
509 case HANDLE_PRINTSET_ANNOTATION_MODE:
511 rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() );
513 break;
514 case HANDLE_PRINTSET_FAX_NAME :
516 rValue <<= mpPrtOpt->GetFaxName();
518 break;
519 case HANDLE_PRINTSET_PROSPECT_RTL:
521 rValue <<= mpPrtOpt->IsPrintProspectRTL();
523 break;
524 case HANDLE_PRINTSET_PLACEHOLDER:
526 rValue <<= mpPrtOpt->IsPrintTextPlaceholder();
528 break;
529 case HANDLE_PRINTSET_HIDDEN_TEXT:
531 rValue <<= mpPrtOpt->IsPrintHiddenText();
533 break;
534 default:
535 throw UnknownPropertyException();
539 void SwXPrintSettings::_postGetValues ()
540 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
542 mpPrtOpt = NULL;
545 OUString SwXPrintSettings::getImplementationName(void) throw( RuntimeException )
547 return OUString("SwXPrintSettings");
550 sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
552 return rServiceName == "com.sun.star.text.PrintSettings";
555 Sequence< OUString > SwXPrintSettings::getSupportedServiceNames(void) throw( RuntimeException )
557 Sequence< OUString > aRet(1);
558 OUString* pArray = aRet.getArray();
559 pArray[0] = "com.sun.star.text.PrintSettings";
560 return aRet;
563 SwXViewSettings::SwXViewSettings(sal_Bool bWebView, SwView* pVw)
564 : ChainableHelperNoState( lcl_createViewSettingsInfo (), &Application::GetSolarMutex() )
565 , pView(pVw)
566 , mpViewOption ( NULL )
567 , mpConstViewOption ( NULL )
568 , bObjectValid(sal_True)
569 , bWeb(bWebView)
570 , eHRulerUnit( FUNIT_CM )
571 , mbApplyHRulerMetric( sal_False )
572 , eVRulerUnit( FUNIT_CM )
573 , mbApplyVRulerMetric( sal_False )
575 // This property only exists if we have a view (ie, not at the module )
576 if ( !pView )
577 mpInfo->remove ( OUString ( "HelpURL" ) );
581 SwXViewSettings::~SwXViewSettings()
582 throw()
587 void SwXViewSettings::_preSetValues ()
588 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
590 const SwViewOption* pVOpt = 0;
591 if(pView)
593 if(!IsValid())
594 return;
595 pVOpt = pView->GetWrtShell().GetViewOptions();
597 else
598 pVOpt = SW_MOD()->GetViewOption(bWeb);
600 mpViewOption = new SwViewOption (*pVOpt);
601 mbApplyZoom = sal_False;
602 if(pView)
603 mpViewOption->SetStarOneSetting(sal_True);
606 void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
607 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
609 sal_Bool bVal = HANDLE_VIEWSET_ZOOM != rInfo.mnHandle ?
610 *(sal_Bool*)rValue.getValue() : sal_False;
611 // the API flag should not be set to the application's view settings
612 switch( rInfo.mnHandle )
614 case HANDLE_VIEWSET_SHOW_RULER : mpViewOption->SetViewAnyRuler(bVal); break;
615 case HANDLE_VIEWSET_HRULER : mpViewOption->SetViewHRuler(bVal); break;
616 case HANDLE_VIEWSET_VRULER : mpViewOption->SetViewVRuler(bVal);break;
617 case HANDLE_VIEWSET_VRULER_RIGHT : mpViewOption->SetVRulerRight(bVal);break;
618 case HANDLE_VIEWSET_HSCROLL : mpViewOption->SetViewHScrollBar(bVal);break;
619 case HANDLE_VIEWSET_VSCROLL : mpViewOption->SetViewVScrollBar(bVal);break;
620 case HANDLE_VIEWSET_GRAPHICS : mpViewOption->SetGraphic(bVal);break;
621 case HANDLE_VIEWSET_TABLES : mpViewOption->SetTable(bVal); break;
622 case HANDLE_VIEWSET_DRAWINGS : mpViewOption->SetDraw(bVal); break;
623 case HANDLE_VIEWSET_FIELD_COMMANDS : mpViewOption->SetFldName(bVal); break;
624 case HANDLE_VIEWSET_ANNOTATIONS : mpViewOption->SetPostIts(bVal); break;
625 case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
626 case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( bVal ); break;
627 case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
628 case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
629 case HANDLE_VIEWSET_PARA_BREAKS : mpViewOption->SetParagraph(bVal); break;
630 case HANDLE_VIEWSET_SOFT_HYPHENS : mpViewOption->SetSoftHyph(bVal); break;
631 case HANDLE_VIEWSET_SPACES : mpViewOption->SetBlank(bVal); break;
632 case HANDLE_VIEWSET_PROTECTED_SPACES : mpViewOption->SetHardBlank(bVal); break;
633 case HANDLE_VIEWSET_TABSTOPS : mpViewOption->SetTab(bVal); break;
634 case HANDLE_VIEWSET_BREAKS : mpViewOption->SetLineBreak(bVal); break;
635 case HANDLE_VIEWSET_HIDDEN_TEXT : mpViewOption->SetShowHiddenField(bVal); break;
636 case HANDLE_VIEWSET_HIDDEN_CHARACTERS : mpViewOption->SetShowHiddenChar(bVal); break;
637 case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : mpViewOption->SetShowHiddenPara(bVal); break;
638 case HANDLE_VIEWSET_TABLE_BOUNDARIES : mpViewOption->SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bVal, sal_True); break;
639 case HANDLE_VIEWSET_TEXT_BOUNDARIES : mpViewOption->SetDocBoundaries(bVal); break;
640 case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(bVal); break;
641 case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : mpViewOption->SetShowContentTips(bVal); break;
642 case HANDLE_VIEWSET_IS_RASTER_VISIBLE : mpViewOption->SetGridVisible(bVal); break;
643 case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : mpViewOption->SetSnap(bVal); break;
644 case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
646 sal_Int32 nTmp = 0;
647 if(!(rValue >>= nTmp) || nTmp < 10)
648 throw IllegalArgumentException();
649 Size aSize( mpViewOption->GetSnapSize() );
650 aSize.Width() = MM100_TO_TWIP( nTmp );
651 mpViewOption->SetSnapSize( aSize );
653 break;
654 case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
656 sal_Int32 nTmp = 0;
657 if(!(rValue >>= nTmp) || nTmp < 10)
658 throw IllegalArgumentException();
659 Size aSize( mpViewOption->GetSnapSize() );
660 aSize.Height() = MM100_TO_TWIP( nTmp );
661 mpViewOption->SetSnapSize( aSize );
663 break;
664 case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
666 sal_Int32 nTmp = 0;
667 if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
668 throw IllegalArgumentException();
669 mpViewOption->SetDivisionX( (short) nTmp );
671 break;
672 case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
674 sal_Int32 nTmp = 0;
675 if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
676 throw IllegalArgumentException();
677 mpViewOption->SetDivisionY( (short) nTmp );
679 break;
680 case HANDLE_VIEWSET_ZOOM :
682 sal_Int16 nZoom = 0;
683 if(!(rValue >>= nZoom) || nZoom > 1000 || nZoom < 5)
684 throw lang::IllegalArgumentException();
685 mpViewOption->SetZoom((sal_uInt16)nZoom);
686 mbApplyZoom = sal_True;
688 break;
689 case HANDLE_VIEWSET_ZOOM_TYPE:
691 sal_Int16 nZoom = 0;
692 if(!(rValue >>= nZoom))
693 throw IllegalArgumentException();
694 SvxZoomType eZoom;
695 switch (nZoom)
697 case view::DocumentZoomType::OPTIMAL:
698 eZoom = SVX_ZOOM_OPTIMAL;
699 break;
700 case view::DocumentZoomType::PAGE_WIDTH:
701 eZoom = SVX_ZOOM_PAGEWIDTH;
702 break;
703 case view::DocumentZoomType::ENTIRE_PAGE:
704 eZoom = SVX_ZOOM_WHOLEPAGE;
705 break;
706 case view::DocumentZoomType::BY_VALUE:
707 eZoom = SVX_ZOOM_PERCENT;
708 break;
709 case view::DocumentZoomType::PAGE_WIDTH_EXACT:
710 eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER;
711 break;
712 default:
713 throw IllegalArgumentException(
714 OUString( "SwXViewSettings: invalid zoom type"), 0, 0);
716 mpViewOption->SetZoomType( eZoom );
717 mbApplyZoom = sal_True;
719 break;
720 case HANDLE_VIEWSET_ONLINE_LAYOUT :
722 if( pView && !bVal != !pView->GetWrtShell().GetViewOptions()->getBrowseMode() )
724 SwViewOption aOpt( *pView->GetWrtShell().GetViewOptions() );
725 aOpt.setBrowseMode( bVal );
726 pView->GetWrtShell().ApplyViewOptions( aOpt );
727 pView->RecheckBrowseMode();
729 // must be set in mpViewOption as this will overwrite settings in _post!
730 if(mpViewOption)
731 mpViewOption->setBrowseMode(bVal);
733 // disable multiple layout
734 pView->GetDocShell()->ToggleBrowserMode(bVal, pView );
737 break;
738 case HANDLE_VIEWSET_HELP_URL :
740 if ( pView )
742 OUString sHelpURL;
743 if ( ! ( rValue >>= sHelpURL ) )
744 throw IllegalArgumentException();
746 INetURLObject aHID( sHelpURL );
747 if ( aHID.GetProtocol() == INET_PROT_HID )
748 pView->GetEditWin().SetHelpId( OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) );
749 else
750 throw IllegalArgumentException ();
752 else
753 throw UnknownPropertyException();
755 break;
756 case HANDLE_VIEWSET_HORI_RULER_METRIC:
757 case HANDLE_VIEWSET_VERT_RULER_METRIC:
759 sal_Int32 nUnit = -1;
760 if( rValue >>= nUnit )
761 switch( nUnit )
763 case FUNIT_MM:
764 case FUNIT_CM:
765 case FUNIT_POINT:
766 case FUNIT_PICA:
767 case FUNIT_INCH:
768 if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
770 eHRulerUnit = nUnit;
771 mbApplyHRulerMetric = sal_True;
773 else
775 eVRulerUnit = nUnit;
776 mbApplyVRulerMetric = sal_True;
778 break;
779 default:
780 throw IllegalArgumentException();
783 break;
784 default:
785 throw UnknownPropertyException();
789 void SwXViewSettings::_postSetValues ()
790 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
792 if( pView )
794 if(mbApplyZoom )
795 pView->SetZoom( (SvxZoomType)mpViewOption->GetZoomType(),
796 mpViewOption->GetZoom(), sal_True );
797 if(mbApplyHRulerMetric)
798 pView->ChangeTabMetric((FieldUnit)eHRulerUnit);
799 if(mbApplyVRulerMetric)
800 pView->ChangeVRulerMetric((FieldUnit)eVRulerUnit);
803 else
805 if(mbApplyHRulerMetric)
806 SW_MOD()->ApplyRulerMetric( (FieldUnit)eHRulerUnit, sal_True, bWeb );
807 if(mbApplyVRulerMetric)
808 SW_MOD()->ApplyRulerMetric( (FieldUnit)eVRulerUnit, sal_False, bWeb );
812 SW_MOD()->ApplyUsrPref( *mpViewOption, pView, pView ? VIEWOPT_DEST_VIEW_ONLY
813 : bWeb ? VIEWOPT_DEST_WEB
814 : VIEWOPT_DEST_TEXT );
817 delete mpViewOption;
818 mpViewOption = NULL;
821 void SwXViewSettings::_preGetValues ()
822 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
824 if(pView)
826 if(!IsValid())
827 return;
828 mpConstViewOption = pView->GetWrtShell().GetViewOptions();
830 else
831 mpConstViewOption = SW_MOD()->GetViewOption(bWeb);
834 void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
835 throw(UnknownPropertyException, WrappedTargetException )
837 bool bBool = true;
838 sal_Bool bBoolVal;
839 switch( rInfo.mnHandle )
841 case HANDLE_VIEWSET_SHOW_RULER: bBoolVal = mpConstViewOption->IsViewAnyRuler(); break;
842 case HANDLE_VIEWSET_HRULER : bBoolVal = mpConstViewOption->IsViewHRuler(sal_True); break;
843 case HANDLE_VIEWSET_VRULER : bBoolVal = mpConstViewOption->IsViewVRuler(sal_True);break;
844 case HANDLE_VIEWSET_VRULER_RIGHT : bBoolVal = mpConstViewOption->IsVRulerRight();break;
845 case HANDLE_VIEWSET_HSCROLL: bBoolVal = mpConstViewOption->IsViewHScrollBar();break;
846 case HANDLE_VIEWSET_VSCROLL: bBoolVal = mpConstViewOption->IsViewVScrollBar();break;
847 case HANDLE_VIEWSET_GRAPHICS : bBoolVal = mpConstViewOption->IsGraphic();break;
848 case HANDLE_VIEWSET_TABLES : bBoolVal = mpConstViewOption->IsTable(); break;
849 case HANDLE_VIEWSET_DRAWINGS : bBoolVal = mpConstViewOption->IsDraw(); break;
850 case HANDLE_VIEWSET_FIELD_COMMANDS : bBoolVal = mpConstViewOption->IsFldName(); break;
851 case HANDLE_VIEWSET_ANNOTATIONS : bBoolVal = mpConstViewOption->IsPostIts(); break;
852 case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
853 case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: bBoolVal = mpConstViewOption->IsViewMetaChars(); break;
854 case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
855 case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
856 case HANDLE_VIEWSET_PARA_BREAKS : bBoolVal = mpConstViewOption->IsParagraph(sal_True); break;
857 case HANDLE_VIEWSET_SOFT_HYPHENS : bBoolVal = mpConstViewOption->IsSoftHyph(); break;
858 case HANDLE_VIEWSET_SPACES : bBoolVal = mpConstViewOption->IsBlank(sal_True); break;
859 case HANDLE_VIEWSET_PROTECTED_SPACES : bBoolVal = mpConstViewOption->IsHardBlank(); break;
860 case HANDLE_VIEWSET_TABSTOPS : bBoolVal = mpConstViewOption->IsTab(sal_True); break;
861 case HANDLE_VIEWSET_BREAKS : bBoolVal = mpConstViewOption->IsLineBreak(sal_True); break;
862 case HANDLE_VIEWSET_HIDDEN_TEXT : bBoolVal = mpConstViewOption->IsShowHiddenField(); break;
863 case HANDLE_VIEWSET_HIDDEN_CHARACTERS : bBoolVal = mpConstViewOption->IsShowHiddenChar(sal_True); break;
864 case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : bBoolVal = mpConstViewOption->IsShowHiddenPara(); break;
865 case HANDLE_VIEWSET_TABLE_BOUNDARIES : bBoolVal = SwViewOption::IsTableBoundaries(); break;
866 case HANDLE_VIEWSET_TEXT_BOUNDARIES : bBoolVal = SwViewOption::IsDocBoundaries(); break;
867 case HANDLE_VIEWSET_SMOOTH_SCROLLING : bBoolVal = mpConstViewOption->IsSmoothScroll(); break;
868 case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : bBoolVal = mpConstViewOption->IsShowContentTips(); break;
869 case HANDLE_VIEWSET_IS_RASTER_VISIBLE : bBoolVal = mpConstViewOption->IsGridVisible(); break;
870 case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : bBoolVal = mpConstViewOption->IsSnap(); break;
871 case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
872 bBool = false;
873 rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Width());
874 break;
875 case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
876 bBool = false;
877 rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Height());
878 break;
879 case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
880 bBool = false;
881 rValue <<= (sal_Int32) mpConstViewOption->GetDivisionX();
882 break;
883 case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
884 bBool = false;
885 rValue <<= (sal_Int32) mpConstViewOption->GetDivisionY();
886 break;
887 case HANDLE_VIEWSET_ZOOM :
888 bBool = false;
889 rValue <<= (sal_Int16)mpConstViewOption->GetZoom();
890 break;
891 case HANDLE_VIEWSET_ZOOM_TYPE:
893 bBool = false;
894 sal_Int16 nRet(0);
895 switch (mpConstViewOption->GetZoomType())
897 case SVX_ZOOM_OPTIMAL:
898 nRet = view::DocumentZoomType::OPTIMAL;
899 break;
900 case SVX_ZOOM_PAGEWIDTH:
901 nRet = view::DocumentZoomType::PAGE_WIDTH;
902 break;
903 case SVX_ZOOM_WHOLEPAGE:
904 nRet = view::DocumentZoomType::ENTIRE_PAGE;
905 break;
906 case SVX_ZOOM_PERCENT:
907 nRet = view::DocumentZoomType::BY_VALUE;
908 break;
909 case SVX_ZOOM_PAGEWIDTH_NOBORDER:
910 nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT;
911 break;
912 default:
913 OSL_FAIL("SwXViewSettings: invalid zoom type");
914 break;
916 rValue <<= nRet;
918 break;
919 case HANDLE_VIEWSET_ONLINE_LAYOUT:
920 if(pView)
921 bBoolVal = pView->GetWrtShell().GetViewOptions()->getBrowseMode();
922 break;
923 case HANDLE_VIEWSET_HELP_URL :
925 if ( pView )
927 bBool = false;
928 OUStringBuffer sHelpURL;
929 sHelpURL.appendAscii ( INET_HID_SCHEME );
930 SwEditWin &rEditWin = pView->GetEditWin();
931 sHelpURL.append( OStringToOUString( rEditWin.GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
932 rValue <<= sHelpURL.makeStringAndClear();
934 else
935 throw UnknownPropertyException();
937 break;
938 case HANDLE_VIEWSET_HORI_RULER_METRIC:
940 if ( pView )
942 FieldUnit eUnit;
943 pView->GetHRulerMetric( eUnit );
944 rValue <<= (sal_Int32)eUnit;
946 else
948 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
949 rValue <<= (sal_Int32)pUsrPref->GetHScrollMetric();
951 bBool = false;
953 break;
954 case HANDLE_VIEWSET_VERT_RULER_METRIC:
956 if ( pView )
958 FieldUnit eUnit;
959 pView->GetVRulerMetric( eUnit );
960 rValue <<= (sal_Int32)eUnit;
962 else
964 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
965 rValue <<= (sal_Int32)pUsrPref->GetVScrollMetric();
967 bBool = false;
969 break;
970 default: OSL_FAIL("there is no such ID!");
972 if( bBool )
973 rValue.setValue(&bBoolVal, ::getBooleanCppuType());
976 void SwXViewSettings::_postGetValues ()
977 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
979 mpConstViewOption = NULL;
982 OUString SwXViewSettings::getImplementationName(void) throw( RuntimeException )
984 return OUString("SwXViewSettings");
987 sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
989 return rServiceName == "com.sun.star.text.ViewSettings";
992 Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( RuntimeException )
994 Sequence< OUString > aRet(1);
995 OUString* pArray = aRet.getArray();
996 pArray[0] = "com.sun.star.text.ViewSettings";
997 return aRet;
1000 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */