Line data Source code
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 :
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;
49 : using ::rtl::OUString;
50 : using ::rtl::OUStringBuffer;
51 :
52 : enum SwViewSettingsPropertyHandles
53 : {
54 : HANDLE_VIEWSET_ANNOTATIONS,
55 : HANDLE_VIEWSET_BREAKS,
56 : HANDLE_VIEWSET_DRAWINGS,
57 : HANDLE_VIEWSET_FIELD_COMMANDS,
58 : HANDLE_VIEWSET_FOOTNOTE_BACKGROUND,
59 : HANDLE_VIEWSET_GRAPHICS,
60 : HANDLE_VIEWSET_HIDDEN_CHARACTERS,
61 : HANDLE_VIEWSET_HIDDEN_PARAGRAPHS,
62 : HANDLE_VIEWSET_HIDDEN_TEXT,
63 : HANDLE_VIEWSET_HRULER,
64 : HANDLE_VIEWSET_HSCROLL,
65 : HANDLE_VIEWSET_INDEX_MARK_BACKGROUND,
66 : HANDLE_VIEWSET_NONPRINTING_CHARACTERS,
67 : HANDLE_VIEWSET_ONLINE_LAYOUT,
68 : HANDLE_VIEWSET_PARA_BREAKS,
69 : HANDLE_VIEWSET_PROTECTED_SPACES,
70 : HANDLE_VIEWSET_SOFT_HYPHENS,
71 : HANDLE_VIEWSET_SPACES,
72 : HANDLE_VIEWSET_TABLE_BOUNDARIES,
73 : HANDLE_VIEWSET_TABLES,
74 : HANDLE_VIEWSET_TABSTOPS,
75 : HANDLE_VIEWSET_TEXT_BOUNDARIES,
76 : HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND,
77 : HANDLE_VIEWSET_VRULER,
78 : HANDLE_VIEWSET_VSCROLL,
79 : HANDLE_VIEWSET_SMOOTH_SCROLLING,
80 : HANDLE_VIEWSET_ZOOM_TYPE,
81 : HANDLE_VIEWSET_ZOOM,
82 : HANDLE_VIEWSET_PREVENT_TIPS,
83 : HANDLE_VIEWSET_HELP_URL,
84 : HANDLE_VIEWSET_VRULER_RIGHT,
85 : HANDLE_VIEWSET_SHOW_RULER,
86 : HANDLE_VIEWSET_IS_RASTER_VISIBLE,
87 : HANDLE_VIEWSET_IS_SNAP_TO_RASTER,
88 : HANDLE_VIEWSET_RASTER_RESOLUTION_X,
89 : HANDLE_VIEWSET_RASTER_RESOLUTION_Y,
90 : HANDLE_VIEWSET_RASTER_SUBDIVISION_X,
91 : HANDLE_VIEWSET_RASTER_SUBDIVISION_Y,
92 : HANDLE_VIEWSET_HORI_RULER_METRIC,
93 : HANDLE_VIEWSET_VERT_RULER_METRIC
94 : };
95 :
96 : enum SwPrintSettingsPropertyHandles
97 : {
98 : HANDLE_PRINTSET_ANNOTATION_MODE,
99 : HANDLE_PRINTSET_BLACK_FONTS,
100 : HANDLE_PRINTSET_CONTROLS,
101 : HANDLE_PRINTSET_DRAWINGS,
102 : HANDLE_PRINTSET_GRAPHICS,
103 : HANDLE_PRINTSET_LEFT_PAGES,
104 : HANDLE_PRINTSET_PAGE_BACKGROUND,
105 : HANDLE_PRINTSET_PROSPECT,
106 : HANDLE_PRINTSET_REVERSED,
107 : HANDLE_PRINTSET_RIGHT_PAGES,
108 : HANDLE_PRINTSET_FAX_NAME,
109 : HANDLE_PRINTSET_PAPER_FROM_SETUP,
110 : HANDLE_PRINTSET_TABLES,
111 : HANDLE_PRINTSET_SINGLE_JOBS,
112 : HANDLE_PRINTSET_EMPTY_PAGES,
113 : HANDLE_PRINTSET_PROSPECT_RTL,
114 : HANDLE_PRINTSET_PLACEHOLDER,
115 : HANDLE_PRINTSET_HIDDEN_TEXT
116 : };
117 :
118 4 : static ChainablePropertySetInfo * lcl_createViewSettingsInfo()
119 : {
120 : static PropertyInfo aViewSettingsMap_Impl[] =
121 : {
122 : { RTL_CONSTASCII_STRINGPARAM ( "HelpURL" ), HANDLE_VIEWSET_HELP_URL , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0},
123 : { RTL_CONSTASCII_STRINGPARAM ( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC , CPPUTYPE_INT32, PROPERTY_NONE, 0},
124 : { RTL_CONSTASCII_STRINGPARAM ( "IsRasterVisible"), HANDLE_VIEWSET_IS_RASTER_VISIBLE, CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
125 : { RTL_CONSTASCII_STRINGPARAM ( "IsSnapToRaster"), HANDLE_VIEWSET_IS_SNAP_TO_RASTER, CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
126 : { RTL_CONSTASCII_STRINGPARAM ( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
127 : { RTL_CONSTASCII_STRINGPARAM ( "PreventHelpTips" ), HANDLE_VIEWSET_PREVENT_TIPS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
128 : { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionX"), HANDLE_VIEWSET_RASTER_RESOLUTION_X, CPPUTYPE_INT32, PROPERTY_NONE, 0},
129 : { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionY"), HANDLE_VIEWSET_RASTER_RESOLUTION_Y, CPPUTYPE_INT32, PROPERTY_NONE, 0},
130 : { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionX"), HANDLE_VIEWSET_RASTER_SUBDIVISION_X, CPPUTYPE_INT32, PROPERTY_NONE, 0},
131 : { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionY"), HANDLE_VIEWSET_RASTER_SUBDIVISION_Y, CPPUTYPE_INT32, PROPERTY_NONE, 0},
132 : { RTL_CONSTASCII_STRINGPARAM ( "ShowAnnotations" ), HANDLE_VIEWSET_ANNOTATIONS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
133 : { RTL_CONSTASCII_STRINGPARAM ( "ShowBreaks"), HANDLE_VIEWSET_BREAKS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
134 : { RTL_CONSTASCII_STRINGPARAM ( "ShowDrawings"), HANDLE_VIEWSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
135 : { RTL_CONSTASCII_STRINGPARAM ( "ShowFieldCommands"), HANDLE_VIEWSET_FIELD_COMMANDS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
136 : { RTL_CONSTASCII_STRINGPARAM ( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
137 : { RTL_CONSTASCII_STRINGPARAM ( "ShowGraphics"), HANDLE_VIEWSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
138 : { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
139 : { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenParagraphs"), HANDLE_VIEWSET_HIDDEN_PARAGRAPHS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
140 : { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenText"), HANDLE_VIEWSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
141 : { RTL_CONSTASCII_STRINGPARAM ( "ShowHoriRuler"), HANDLE_VIEWSET_HRULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
142 : { RTL_CONSTASCII_STRINGPARAM ( "ShowHoriScrollBar"), HANDLE_VIEWSET_HSCROLL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
143 : { RTL_CONSTASCII_STRINGPARAM ( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
144 : { RTL_CONSTASCII_STRINGPARAM ( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
145 : { RTL_CONSTASCII_STRINGPARAM ( "ShowOnlineLayout"), HANDLE_VIEWSET_ONLINE_LAYOUT , CPPUTYPE_BOOLEAN, PropertyAttribute::MAYBEVOID, 0},
146 : { RTL_CONSTASCII_STRINGPARAM ( "ShowParaBreaks"), HANDLE_VIEWSET_PARA_BREAKS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
147 : { RTL_CONSTASCII_STRINGPARAM ( "ShowProtectedSpaces"), HANDLE_VIEWSET_PROTECTED_SPACES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
148 : { RTL_CONSTASCII_STRINGPARAM ( "ShowRulers"), HANDLE_VIEWSET_SHOW_RULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
149 : { RTL_CONSTASCII_STRINGPARAM ( "ShowSoftHyphens"), HANDLE_VIEWSET_SOFT_HYPHENS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
150 : { RTL_CONSTASCII_STRINGPARAM ( "ShowSpaces"), HANDLE_VIEWSET_SPACES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
151 : { RTL_CONSTASCII_STRINGPARAM ( "ShowTableBoundaries"), HANDLE_VIEWSET_TABLE_BOUNDARIES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
152 : { RTL_CONSTASCII_STRINGPARAM ( "ShowTables"), HANDLE_VIEWSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
153 : { RTL_CONSTASCII_STRINGPARAM ( "ShowTabstops"), HANDLE_VIEWSET_TABSTOPS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
154 : { RTL_CONSTASCII_STRINGPARAM ( "ShowTextBoundaries"), HANDLE_VIEWSET_TEXT_BOUNDARIES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
155 : { RTL_CONSTASCII_STRINGPARAM ( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
156 : { RTL_CONSTASCII_STRINGPARAM ( "ShowVertRuler"), HANDLE_VIEWSET_VRULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
157 : { RTL_CONSTASCII_STRINGPARAM ( "ShowVertScrollBar"), HANDLE_VIEWSET_VSCROLL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
158 : { RTL_CONSTASCII_STRINGPARAM ( "SmoothScrolling"), HANDLE_VIEWSET_SMOOTH_SCROLLING , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
159 : { RTL_CONSTASCII_STRINGPARAM ( "VerticalRulerMetric"), HANDLE_VIEWSET_VERT_RULER_METRIC , CPPUTYPE_INT32, PROPERTY_NONE, 0},
160 : { RTL_CONSTASCII_STRINGPARAM ( "ZoomType"), HANDLE_VIEWSET_ZOOM_TYPE , CPPUTYPE_INT16, PROPERTY_NONE, 0},
161 : { RTL_CONSTASCII_STRINGPARAM ( "ZoomValue"), HANDLE_VIEWSET_ZOOM , CPPUTYPE_INT16, PROPERTY_NONE, 0},
162 : { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
163 : };
164 4 : return new ChainablePropertySetInfo ( aViewSettingsMap_Impl );
165 : }
166 :
167 532 : static ChainablePropertySetInfo * lcl_createPrintSettingsInfo()
168 : {
169 : static PropertyInfo aPrintSettingsMap_Impl[] =
170 : {
171 : { RTL_CONSTASCII_STRINGPARAM ( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE , CPPUTYPE_INT16, PROPERTY_NONE, 0},
172 : { RTL_CONSTASCII_STRINGPARAM ( "PrintBlackFonts" ), HANDLE_PRINTSET_BLACK_FONTS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
173 : { RTL_CONSTASCII_STRINGPARAM ( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
174 : { RTL_CONSTASCII_STRINGPARAM ( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
175 : { RTL_CONSTASCII_STRINGPARAM ( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
176 : { RTL_CONSTASCII_STRINGPARAM ( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
177 : { RTL_CONSTASCII_STRINGPARAM ( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
178 : { RTL_CONSTASCII_STRINGPARAM ( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
179 : { RTL_CONSTASCII_STRINGPARAM ( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
180 : { RTL_CONSTASCII_STRINGPARAM ( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
181 : { RTL_CONSTASCII_STRINGPARAM ( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
182 : { RTL_CONSTASCII_STRINGPARAM ( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
183 : { RTL_CONSTASCII_STRINGPARAM ( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0},
184 : { RTL_CONSTASCII_STRINGPARAM ( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
185 : { RTL_CONSTASCII_STRINGPARAM ( "PrintTables" ), HANDLE_PRINTSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
186 : { RTL_CONSTASCII_STRINGPARAM ( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
187 : { RTL_CONSTASCII_STRINGPARAM ( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
188 : { RTL_CONSTASCII_STRINGPARAM ( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
189 : { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
190 : };
191 532 : return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl );
192 : }
193 :
194 : /******************************************************************
195 : * SwXModule
196 : ******************************************************************/
197 0 : Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(
198 : const Reference< XMultiServiceFactory > & /*rSMgr*/) throw( Exception )
199 : {
200 0 : static Reference< uno::XInterface > xModule = (cppu::OWeakObject*)new SwXModule();
201 0 : return xModule;
202 : }
203 :
204 0 : Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw()
205 : {
206 0 : OUString sService( "com.sun.star.text.GlobalSettings");
207 0 : const Sequence< OUString > aSeq( &sService, 1 );
208 0 : return aSeq;
209 : }
210 :
211 9 : OUString SAL_CALL SwXModule_getImplementationName() throw()
212 : {
213 9 : return OUString( "SwXModule" );
214 : }
215 :
216 0 : SwXModule::SwXModule() :
217 : pxViewSettings(0),
218 0 : pxPrintSettings(0)
219 : {
220 0 : }
221 :
222 0 : SwXModule::~SwXModule()
223 : {
224 0 : delete pxViewSettings;
225 0 : delete pxPrintSettings;
226 0 : }
227 :
228 0 : Reference< XPropertySet > SwXModule::getViewSettings(void) throw( uno::RuntimeException )
229 : {
230 0 : SolarMutexGuard aGuard;
231 0 : if(!pxViewSettings)
232 : {
233 0 : ((SwXModule*)this)->pxViewSettings = new Reference< XPropertySet > ;
234 : OSL_FAIL("Web or Text?");
235 0 : *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, 0 ) );
236 : }
237 0 : return *pxViewSettings;
238 : }
239 :
240 0 : Reference< XPropertySet > SwXModule::getPrintSettings(void) throw( uno::RuntimeException )
241 : {
242 0 : SolarMutexGuard aGuard;
243 0 : if(!pxPrintSettings)
244 : {
245 0 : ((SwXModule*)this)->pxPrintSettings = new Reference< XPropertySet > ;
246 : OSL_FAIL("Web or Text?");
247 0 : *pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) );
248 : }
249 0 : return *pxPrintSettings;
250 : }
251 :
252 0 : OUString SwXModule::getImplementationName(void) throw( RuntimeException )
253 : {
254 0 : return SwXModule_getImplementationName();
255 : }
256 :
257 0 : sal_Bool SwXModule::supportsService(const OUString& rServiceName) throw( RuntimeException )
258 : {
259 0 : const Sequence< OUString > aNames = SwXModule_getSupportedServiceNames();
260 0 : for(sal_Int32 nService = 0; nService < aNames.getLength(); nService++)
261 : {
262 0 : if(aNames.getConstArray()[nService] == rServiceName)
263 0 : return sal_True;
264 : }
265 0 : return sal_False;
266 : }
267 :
268 0 : Sequence< OUString > SwXModule::getSupportedServiceNames(void) throw( RuntimeException )
269 : {
270 0 : return SwXModule_getSupportedServiceNames();
271 : }
272 :
273 : /******************************************************************
274 : * SwXPrintSettings
275 : ******************************************************************/
276 532 : SwXPrintSettings::SwXPrintSettings(SwXPrintSettingsType eType, SwDoc* pDoc)
277 532 : : ChainableHelperNoState ( lcl_createPrintSettingsInfo (), &Application::GetSolarMutex() )
278 : , meType(eType)
279 : , mpPrtOpt ( NULL )
280 532 : , mpDoc ( pDoc )
281 : {
282 532 : }
283 :
284 1064 : SwXPrintSettings::~SwXPrintSettings()
285 532 : throw()
286 : {
287 1064 : }
288 :
289 320 : void SwXPrintSettings::_preSetValues ()
290 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
291 : {
292 320 : switch (meType)
293 : {
294 : case PRINT_SETTINGS_MODULE:
295 0 : mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
296 0 : break;
297 : case PRINT_SETTINGS_WEB:
298 0 : mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
299 0 : break;
300 : case PRINT_SETTINGS_DOCUMENT:
301 : {
302 320 : if (!mpDoc)
303 0 : throw IllegalArgumentException ();
304 320 : mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
305 : }
306 320 : break;
307 : }
308 320 : }
309 :
310 320 : void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
311 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
312 : {
313 : sal_Bool bVal;
314 320 : if ( rInfo.mnHandle != HANDLE_PRINTSET_ANNOTATION_MODE &&
315 : rInfo.mnHandle != HANDLE_PRINTSET_FAX_NAME )
316 284 : bVal = *(sal_Bool*)rValue.getValue();
317 :
318 320 : switch( rInfo.mnHandle )
319 : {
320 : case HANDLE_PRINTSET_LEFT_PAGES:
321 : {
322 18 : bVal = *(sal_Bool*)rValue.getValue();
323 18 : mpPrtOpt->SetPrintLeftPage(bVal);
324 : }
325 18 : break;
326 : case HANDLE_PRINTSET_RIGHT_PAGES:
327 : {
328 18 : bVal = *(sal_Bool*)rValue.getValue();
329 18 : mpPrtOpt->SetPrintRightPage(bVal);
330 : }
331 18 : break;
332 : case HANDLE_PRINTSET_REVERSED:
333 : {
334 18 : bVal = *(sal_Bool*)rValue.getValue();
335 18 : mpPrtOpt->SetPrintReverse(bVal);
336 : }
337 18 : break;
338 : case HANDLE_PRINTSET_PROSPECT:
339 : {
340 18 : bVal = *(sal_Bool*)rValue.getValue();
341 18 : mpPrtOpt->SetPrintProspect(bVal);
342 : }
343 18 : break;
344 : case HANDLE_PRINTSET_GRAPHICS:
345 : {
346 18 : bVal = *(sal_Bool*)rValue.getValue();
347 18 : mpPrtOpt->SetPrintGraphic(bVal);
348 : }
349 18 : break;
350 : case HANDLE_PRINTSET_TABLES:
351 : {
352 18 : bVal = *(sal_Bool*)rValue.getValue();
353 18 : mpPrtOpt->SetPrintTable(bVal);
354 : }
355 18 : break;
356 : case HANDLE_PRINTSET_DRAWINGS:
357 : {
358 18 : bVal = *(sal_Bool*)rValue.getValue();
359 18 : mpPrtOpt->SetPrintDraw(bVal);
360 : }
361 18 : break;
362 : case HANDLE_PRINTSET_CONTROLS:
363 : {
364 18 : bVal = *(sal_Bool*)rValue.getValue();
365 18 : mpPrtOpt->SetPrintControl(bVal);
366 : }
367 18 : break;
368 : case HANDLE_PRINTSET_PAGE_BACKGROUND:
369 : {
370 18 : bVal = *(sal_Bool*)rValue.getValue();
371 18 : mpPrtOpt->SetPrintPageBackground(bVal);
372 : }
373 18 : break;
374 : case HANDLE_PRINTSET_BLACK_FONTS:
375 : {
376 18 : bVal = *(sal_Bool*)rValue.getValue();
377 18 : mpPrtOpt->SetPrintBlackFont(bVal);
378 : }
379 18 : break;
380 : case HANDLE_PRINTSET_SINGLE_JOBS:
381 : {
382 18 : bVal = *(sal_Bool*)rValue.getValue();
383 18 : mpPrtOpt->SetPrintSingleJobs(bVal);
384 : }
385 18 : break;
386 : case HANDLE_PRINTSET_PAPER_FROM_SETUP:
387 : {
388 18 : bVal = *(sal_Bool*)rValue.getValue();
389 18 : mpPrtOpt->SetPaperFromSetup(bVal);
390 : }
391 18 : break;
392 : case HANDLE_PRINTSET_ANNOTATION_MODE:
393 : {
394 18 : sal_Int16 nVal = 0;
395 18 : rValue >>= nVal;
396 18 : if(nVal <= text::NotePrintMode_PAGE_END)
397 18 : mpPrtOpt->SetPrintPostIts(nVal);
398 : else
399 0 : throw lang::IllegalArgumentException();
400 : }
401 18 : break;
402 : case HANDLE_PRINTSET_EMPTY_PAGES:
403 : {
404 17 : bVal = *(sal_Bool*)rValue.getValue();
405 17 : mpPrtOpt->SetPrintEmptyPages(bVal);
406 : }
407 17 : break;
408 : case HANDLE_PRINTSET_FAX_NAME:
409 : {
410 18 : OUString sString;
411 18 : if ( rValue >>= sString)
412 18 : mpPrtOpt->SetFaxName(sString);
413 : else
414 18 : throw lang::IllegalArgumentException();
415 : }
416 18 : break;
417 : case HANDLE_PRINTSET_PROSPECT_RTL:
418 : {
419 17 : bVal = *(sal_Bool*)rValue.getValue();
420 17 : mpPrtOpt->SetPrintProspect_RTL(bVal);
421 : }
422 17 : break;
423 : case HANDLE_PRINTSET_PLACEHOLDER:
424 : {
425 17 : bVal = *(sal_Bool*)rValue.getValue();
426 17 : mpPrtOpt->SetPrintTextPlaceholder(bVal);
427 : }
428 17 : break;
429 : case HANDLE_PRINTSET_HIDDEN_TEXT:
430 : {
431 17 : bVal = *(sal_Bool*)rValue.getValue();
432 17 : mpPrtOpt->SetPrintHiddenText(bVal);
433 : }
434 17 : break;
435 : default:
436 0 : throw UnknownPropertyException();
437 : }
438 320 : }
439 :
440 320 : void SwXPrintSettings::_postSetValues ()
441 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
442 : {
443 320 : mpPrtOpt = NULL;
444 320 : }
445 :
446 36 : void SwXPrintSettings::_preGetValues ()
447 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
448 : {
449 36 : switch (meType)
450 : {
451 : case PRINT_SETTINGS_MODULE:
452 0 : mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
453 0 : break;
454 : case PRINT_SETTINGS_WEB:
455 0 : mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
456 0 : break;
457 : case PRINT_SETTINGS_DOCUMENT:
458 : {
459 36 : if (!mpDoc)
460 0 : throw IllegalArgumentException ();
461 36 : mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
462 : }
463 36 : break;
464 : }
465 36 : }
466 :
467 36 : void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
468 : throw(UnknownPropertyException, WrappedTargetException )
469 : {
470 36 : switch( rInfo.mnHandle )
471 : {
472 : case HANDLE_PRINTSET_LEFT_PAGES:
473 2 : rValue <<= mpPrtOpt->IsPrintLeftPage();
474 2 : break;
475 : case HANDLE_PRINTSET_RIGHT_PAGES:
476 2 : rValue <<= mpPrtOpt->IsPrintRightPage();
477 2 : break;
478 : case HANDLE_PRINTSET_REVERSED:
479 2 : rValue <<= mpPrtOpt->IsPrintReverse();
480 2 : break;
481 : case HANDLE_PRINTSET_PROSPECT:
482 2 : rValue <<= mpPrtOpt->IsPrintProspect();
483 2 : break;
484 : case HANDLE_PRINTSET_GRAPHICS:
485 2 : rValue <<= mpPrtOpt->IsPrintGraphic();
486 2 : break;
487 : case HANDLE_PRINTSET_TABLES:
488 2 : rValue <<= mpPrtOpt->IsPrintTable();
489 2 : break;
490 : case HANDLE_PRINTSET_DRAWINGS:
491 2 : rValue <<= mpPrtOpt->IsPrintDraw();
492 2 : break;
493 : case HANDLE_PRINTSET_CONTROLS:
494 2 : rValue <<= mpPrtOpt->IsPrintControl();
495 2 : break;
496 : case HANDLE_PRINTSET_PAGE_BACKGROUND:
497 2 : rValue <<= mpPrtOpt->IsPrintPageBackground();
498 2 : break;
499 : case HANDLE_PRINTSET_BLACK_FONTS:
500 2 : rValue <<= mpPrtOpt->IsPrintBlackFont();
501 2 : break;
502 : case HANDLE_PRINTSET_SINGLE_JOBS:
503 2 : rValue <<= mpPrtOpt->IsPrintSingleJobs();
504 2 : break;
505 : case HANDLE_PRINTSET_EMPTY_PAGES:
506 2 : rValue <<= mpPrtOpt->IsPrintEmptyPages();
507 2 : break;
508 : case HANDLE_PRINTSET_PAPER_FROM_SETUP:
509 2 : rValue <<= mpPrtOpt->IsPaperFromSetup();
510 2 : break;
511 : case HANDLE_PRINTSET_ANNOTATION_MODE:
512 : {
513 2 : rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() );
514 : }
515 2 : break;
516 : case HANDLE_PRINTSET_FAX_NAME :
517 : {
518 2 : rValue <<= mpPrtOpt->GetFaxName();
519 : }
520 2 : break;
521 : case HANDLE_PRINTSET_PROSPECT_RTL:
522 : {
523 2 : rValue <<= mpPrtOpt->IsPrintProspectRTL();
524 : }
525 2 : break;
526 : case HANDLE_PRINTSET_PLACEHOLDER:
527 : {
528 2 : rValue <<= mpPrtOpt->IsPrintTextPlaceholder();
529 : }
530 2 : break;
531 : case HANDLE_PRINTSET_HIDDEN_TEXT:
532 : {
533 2 : rValue <<= mpPrtOpt->IsPrintHiddenText();
534 : }
535 2 : break;
536 : default:
537 0 : throw UnknownPropertyException();
538 : }
539 36 : }
540 :
541 36 : void SwXPrintSettings::_postGetValues ()
542 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
543 : {
544 36 : mpPrtOpt = NULL;
545 36 : }
546 :
547 0 : OUString SwXPrintSettings::getImplementationName(void) throw( RuntimeException )
548 : {
549 0 : return OUString("SwXPrintSettings");
550 : }
551 :
552 0 : sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
553 : {
554 0 : return rServiceName == "com.sun.star.text.PrintSettings";
555 : }
556 :
557 0 : Sequence< OUString > SwXPrintSettings::getSupportedServiceNames(void) throw( RuntimeException )
558 : {
559 0 : Sequence< OUString > aRet(1);
560 0 : OUString* pArray = aRet.getArray();
561 0 : pArray[0] = "com.sun.star.text.PrintSettings";
562 0 : return aRet;
563 : }
564 :
565 4 : SwXViewSettings::SwXViewSettings(sal_Bool bWebView, SwView* pVw)
566 4 : : ChainableHelperNoState( lcl_createViewSettingsInfo (), &Application::GetSolarMutex() )
567 : , pView(pVw)
568 : , mpViewOption ( NULL )
569 : , mpConstViewOption ( NULL )
570 : , bObjectValid(sal_True)
571 : , bWeb(bWebView)
572 : , eHRulerUnit( FUNIT_CM )
573 : , mbApplyHRulerMetric( sal_False )
574 : , eVRulerUnit( FUNIT_CM )
575 4 : , mbApplyVRulerMetric( sal_False )
576 : {
577 : // This property only exists if we have a view (ie, not at the module )
578 4 : if ( !pView )
579 0 : mpInfo->remove ( OUString ( "HelpURL" ) );
580 :
581 4 : }
582 :
583 4 : SwXViewSettings::~SwXViewSettings()
584 2 : throw()
585 : {
586 :
587 4 : }
588 :
589 0 : void SwXViewSettings::_preSetValues ()
590 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
591 : {
592 0 : const SwViewOption* pVOpt = 0;
593 0 : if(pView)
594 : {
595 0 : if(!IsValid())
596 0 : return;
597 0 : pVOpt = pView->GetWrtShell().GetViewOptions();
598 : }
599 : else
600 0 : pVOpt = SW_MOD()->GetViewOption(bWeb);
601 :
602 0 : mpViewOption = new SwViewOption (*pVOpt);
603 0 : mbApplyZoom = sal_False;
604 0 : if(pView)
605 0 : mpViewOption->SetStarOneSetting(sal_True);
606 : }
607 :
608 0 : void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
609 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
610 : {
611 : sal_Bool bVal = HANDLE_VIEWSET_ZOOM != rInfo.mnHandle ?
612 0 : *(sal_Bool*)rValue.getValue() : sal_False;
613 : // the API flag should not be set to the application's view settings
614 0 : switch( rInfo.mnHandle )
615 : {
616 0 : case HANDLE_VIEWSET_SHOW_RULER : mpViewOption->SetViewAnyRuler(bVal); break;
617 0 : case HANDLE_VIEWSET_HRULER : mpViewOption->SetViewHRuler(bVal); break;
618 0 : case HANDLE_VIEWSET_VRULER : mpViewOption->SetViewVRuler(bVal);break;
619 0 : case HANDLE_VIEWSET_VRULER_RIGHT : mpViewOption->SetVRulerRight(bVal);break;
620 0 : case HANDLE_VIEWSET_HSCROLL : mpViewOption->SetViewHScrollBar(bVal);break;
621 0 : case HANDLE_VIEWSET_VSCROLL : mpViewOption->SetViewVScrollBar(bVal);break;
622 0 : case HANDLE_VIEWSET_GRAPHICS : mpViewOption->SetGraphic(bVal);break;
623 0 : case HANDLE_VIEWSET_TABLES : mpViewOption->SetTable(bVal); break;
624 0 : case HANDLE_VIEWSET_DRAWINGS : mpViewOption->SetDraw(bVal); break;
625 0 : case HANDLE_VIEWSET_FIELD_COMMANDS : mpViewOption->SetFldName(bVal); break;
626 0 : case HANDLE_VIEWSET_ANNOTATIONS : mpViewOption->SetPostIts(bVal); break;
627 0 : case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
628 0 : case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( bVal ); break;
629 0 : case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
630 0 : case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
631 0 : case HANDLE_VIEWSET_PARA_BREAKS : mpViewOption->SetParagraph(bVal); break;
632 0 : case HANDLE_VIEWSET_SOFT_HYPHENS : mpViewOption->SetSoftHyph(bVal); break;
633 0 : case HANDLE_VIEWSET_SPACES : mpViewOption->SetBlank(bVal); break;
634 0 : case HANDLE_VIEWSET_PROTECTED_SPACES : mpViewOption->SetHardBlank(bVal); break;
635 0 : case HANDLE_VIEWSET_TABSTOPS : mpViewOption->SetTab(bVal); break;
636 0 : case HANDLE_VIEWSET_BREAKS : mpViewOption->SetLineBreak(bVal); break;
637 0 : case HANDLE_VIEWSET_HIDDEN_TEXT : mpViewOption->SetShowHiddenField(bVal); break;
638 0 : case HANDLE_VIEWSET_HIDDEN_CHARACTERS : mpViewOption->SetShowHiddenChar(bVal); break;
639 0 : case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : mpViewOption->SetShowHiddenPara(bVal); break;
640 0 : case HANDLE_VIEWSET_TABLE_BOUNDARIES : mpViewOption->SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bVal, sal_True); break;
641 0 : case HANDLE_VIEWSET_TEXT_BOUNDARIES : mpViewOption->SetDocBoundaries(bVal); break;
642 0 : case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(bVal); break;
643 0 : case HANDLE_VIEWSET_PREVENT_TIPS : mpViewOption->SetPreventTips(bVal); break;
644 0 : case HANDLE_VIEWSET_IS_RASTER_VISIBLE : mpViewOption->SetGridVisible(bVal); break;
645 0 : case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : mpViewOption->SetSnap(bVal); break;
646 : case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
647 : {
648 0 : sal_Int32 nTmp = 0;
649 0 : if(!(rValue >>= nTmp) || nTmp < 10)
650 0 : throw IllegalArgumentException();
651 0 : Size aSize( mpViewOption->GetSnapSize() );
652 0 : aSize.Width() = MM100_TO_TWIP( nTmp );
653 0 : mpViewOption->SetSnapSize( aSize );
654 : }
655 0 : break;
656 : case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
657 : {
658 0 : sal_Int32 nTmp = 0;
659 0 : if(!(rValue >>= nTmp) || nTmp < 10)
660 0 : throw IllegalArgumentException();
661 0 : Size aSize( mpViewOption->GetSnapSize() );
662 0 : aSize.Height() = MM100_TO_TWIP( nTmp );
663 0 : mpViewOption->SetSnapSize( aSize );
664 : }
665 0 : break;
666 : case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
667 : {
668 0 : sal_Int32 nTmp = 0;
669 0 : if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
670 0 : throw IllegalArgumentException();
671 0 : mpViewOption->SetDivisionX( (short) nTmp );
672 : }
673 0 : break;
674 : case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
675 : {
676 0 : sal_Int32 nTmp = 0;
677 0 : if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
678 0 : throw IllegalArgumentException();
679 0 : mpViewOption->SetDivisionY( (short) nTmp );
680 : }
681 0 : break;
682 : case HANDLE_VIEWSET_ZOOM :
683 : {
684 0 : sal_Int16 nZoom = 0;
685 0 : if(!(rValue >>= nZoom) || nZoom > 1000 || nZoom < 5)
686 0 : throw lang::IllegalArgumentException();
687 0 : mpViewOption->SetZoom((sal_uInt16)nZoom);
688 0 : mbApplyZoom = sal_True;
689 : }
690 0 : break;
691 : case HANDLE_VIEWSET_ZOOM_TYPE:
692 : {
693 0 : sal_Int16 nZoom = 0;
694 0 : if(!(rValue >>= nZoom))
695 0 : throw IllegalArgumentException();
696 : SvxZoomType eZoom;
697 0 : switch (nZoom)
698 : {
699 : case view::DocumentZoomType::OPTIMAL:
700 0 : eZoom = SVX_ZOOM_OPTIMAL;
701 0 : break;
702 : case view::DocumentZoomType::PAGE_WIDTH:
703 0 : eZoom = SVX_ZOOM_PAGEWIDTH;
704 0 : break;
705 : case view::DocumentZoomType::ENTIRE_PAGE:
706 0 : eZoom = SVX_ZOOM_WHOLEPAGE;
707 0 : break;
708 : case view::DocumentZoomType::BY_VALUE:
709 0 : eZoom = SVX_ZOOM_PERCENT;
710 0 : break;
711 : case view::DocumentZoomType::PAGE_WIDTH_EXACT:
712 0 : eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER;
713 0 : break;
714 : default:
715 : throw IllegalArgumentException(
716 0 : ::rtl::OUString( "SwXViewSettings: invalid zoom type"), 0, 0);
717 : }
718 0 : mpViewOption->SetZoomType( eZoom );
719 0 : mbApplyZoom = sal_True;
720 : }
721 0 : break;
722 : case HANDLE_VIEWSET_ONLINE_LAYOUT :
723 : {
724 0 : if( pView && !bVal != !pView->GetWrtShell().GetViewOptions()->getBrowseMode() )
725 : {
726 0 : SwViewOption aOpt( *pView->GetWrtShell().GetViewOptions() );
727 0 : aOpt.setBrowseMode( bVal );
728 0 : pView->GetWrtShell().ApplyViewOptions( aOpt );
729 0 : pView->RecheckBrowseMode();
730 :
731 : // must be set in mpViewOption as this will overwrite settings in _post!
732 0 : if(mpViewOption)
733 0 : mpViewOption->setBrowseMode(bVal);
734 :
735 : // disable multiple layout
736 0 : pView->GetDocShell()->ToggleBrowserMode(bVal, pView );
737 : }
738 : }
739 0 : break;
740 : case HANDLE_VIEWSET_HELP_URL :
741 : {
742 0 : if ( pView )
743 : {
744 0 : OUString sHelpURL;
745 0 : if ( ! ( rValue >>= sHelpURL ) )
746 0 : throw IllegalArgumentException();
747 :
748 0 : INetURLObject aHID( sHelpURL );
749 0 : if ( aHID.GetProtocol() == INET_PROT_HID )
750 0 : pView->GetEditWin().SetHelpId( rtl::OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) );
751 : else
752 0 : throw IllegalArgumentException ();
753 : }
754 : else
755 0 : throw UnknownPropertyException();
756 : }
757 0 : break;
758 : case HANDLE_VIEWSET_HORI_RULER_METRIC:
759 : case HANDLE_VIEWSET_VERT_RULER_METRIC:
760 : {
761 0 : sal_Int32 nUnit = -1;
762 0 : if( rValue >>= nUnit )
763 0 : switch( nUnit )
764 : {
765 : case FUNIT_MM:
766 : case FUNIT_CM:
767 : case FUNIT_POINT:
768 : case FUNIT_PICA:
769 : case FUNIT_INCH:
770 0 : if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
771 : {
772 0 : eHRulerUnit = nUnit;
773 0 : mbApplyHRulerMetric = sal_True;
774 : }
775 : else
776 : {
777 0 : eVRulerUnit = nUnit;
778 0 : mbApplyVRulerMetric = sal_True;
779 : }
780 0 : break;
781 : default:
782 0 : throw IllegalArgumentException();
783 : }
784 : }
785 0 : break;
786 : default:
787 0 : throw UnknownPropertyException();
788 : }
789 0 : }
790 :
791 0 : void SwXViewSettings::_postSetValues ()
792 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
793 : {
794 0 : if( pView )
795 : {
796 0 : if(mbApplyZoom )
797 : pView->SetZoom( (SvxZoomType)mpViewOption->GetZoomType(),
798 0 : mpViewOption->GetZoom(), sal_True );
799 0 : if(mbApplyHRulerMetric)
800 0 : pView->ChangeTabMetric((FieldUnit)eHRulerUnit);
801 0 : if(mbApplyVRulerMetric)
802 0 : pView->ChangeVLinealMetric((FieldUnit)eVRulerUnit);
803 :
804 : }
805 : else
806 : {
807 0 : if(mbApplyHRulerMetric)
808 0 : SW_MOD()->ApplyRulerMetric( (FieldUnit)eHRulerUnit, sal_True, bWeb );
809 0 : if(mbApplyVRulerMetric)
810 0 : SW_MOD()->ApplyRulerMetric( (FieldUnit)eVRulerUnit, sal_False, bWeb );
811 : }
812 :
813 :
814 0 : SW_MOD()->ApplyUsrPref( *mpViewOption, pView, pView ? VIEWOPT_DEST_VIEW_ONLY
815 : : bWeb ? VIEWOPT_DEST_WEB
816 0 : : VIEWOPT_DEST_TEXT );
817 :
818 :
819 0 : delete mpViewOption;
820 0 : mpViewOption = NULL;
821 0 : }
822 :
823 4 : void SwXViewSettings::_preGetValues ()
824 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
825 : {
826 4 : if(pView)
827 : {
828 4 : if(!IsValid())
829 4 : return;
830 4 : mpConstViewOption = pView->GetWrtShell().GetViewOptions();
831 : }
832 : else
833 0 : mpConstViewOption = SW_MOD()->GetViewOption(bWeb);
834 : }
835 :
836 4 : void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
837 : throw(UnknownPropertyException, WrappedTargetException )
838 : {
839 4 : sal_Bool bBool = sal_True;
840 : sal_Bool bBoolVal;
841 4 : switch( rInfo.mnHandle )
842 : {
843 0 : case HANDLE_VIEWSET_SHOW_RULER: bBoolVal = mpConstViewOption->IsViewAnyRuler(); break;
844 0 : case HANDLE_VIEWSET_HRULER : bBoolVal = mpConstViewOption->IsViewHRuler(sal_True); break;
845 0 : case HANDLE_VIEWSET_VRULER : bBoolVal = mpConstViewOption->IsViewVRuler(sal_True);break;
846 0 : case HANDLE_VIEWSET_VRULER_RIGHT : bBoolVal = mpConstViewOption->IsVRulerRight();break;
847 0 : case HANDLE_VIEWSET_HSCROLL: bBoolVal = mpConstViewOption->IsViewHScrollBar();break;
848 0 : case HANDLE_VIEWSET_VSCROLL: bBoolVal = mpConstViewOption->IsViewVScrollBar();break;
849 0 : case HANDLE_VIEWSET_GRAPHICS : bBoolVal = mpConstViewOption->IsGraphic();break;
850 0 : case HANDLE_VIEWSET_TABLES : bBoolVal = mpConstViewOption->IsTable(); break;
851 0 : case HANDLE_VIEWSET_DRAWINGS : bBoolVal = mpConstViewOption->IsDraw(); break;
852 0 : case HANDLE_VIEWSET_FIELD_COMMANDS : bBoolVal = mpConstViewOption->IsFldName(); break;
853 0 : case HANDLE_VIEWSET_ANNOTATIONS : bBoolVal = mpConstViewOption->IsPostIts(); break;
854 0 : case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
855 0 : case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: bBoolVal = mpConstViewOption->IsViewMetaChars(); break;
856 0 : case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
857 0 : case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
858 0 : case HANDLE_VIEWSET_PARA_BREAKS : bBoolVal = mpConstViewOption->IsParagraph(sal_True); break;
859 0 : case HANDLE_VIEWSET_SOFT_HYPHENS : bBoolVal = mpConstViewOption->IsSoftHyph(); break;
860 0 : case HANDLE_VIEWSET_SPACES : bBoolVal = mpConstViewOption->IsBlank(sal_True); break;
861 0 : case HANDLE_VIEWSET_PROTECTED_SPACES : bBoolVal = mpConstViewOption->IsHardBlank(); break;
862 0 : case HANDLE_VIEWSET_TABSTOPS : bBoolVal = mpConstViewOption->IsTab(sal_True); break;
863 0 : case HANDLE_VIEWSET_BREAKS : bBoolVal = mpConstViewOption->IsLineBreak(sal_True); break;
864 0 : case HANDLE_VIEWSET_HIDDEN_TEXT : bBoolVal = mpConstViewOption->IsShowHiddenField(); break;
865 0 : case HANDLE_VIEWSET_HIDDEN_CHARACTERS : bBoolVal = mpConstViewOption->IsShowHiddenChar(sal_True); break;
866 0 : case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : bBoolVal = mpConstViewOption->IsShowHiddenPara(); break;
867 0 : case HANDLE_VIEWSET_TABLE_BOUNDARIES : bBoolVal = SwViewOption::IsTableBoundaries(); break;
868 0 : case HANDLE_VIEWSET_TEXT_BOUNDARIES : bBoolVal = SwViewOption::IsDocBoundaries(); break;
869 0 : case HANDLE_VIEWSET_SMOOTH_SCROLLING : bBoolVal = mpConstViewOption->IsSmoothScroll(); break;
870 0 : case HANDLE_VIEWSET_PREVENT_TIPS : bBoolVal = mpConstViewOption->IsPreventTips(); break;
871 0 : case HANDLE_VIEWSET_IS_RASTER_VISIBLE : bBoolVal = mpConstViewOption->IsGridVisible(); break;
872 0 : case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : bBoolVal = mpConstViewOption->IsSnap(); break;
873 : case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
874 0 : bBool = sal_False;
875 0 : rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Width());
876 0 : break;
877 : case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
878 0 : bBool = sal_False;
879 0 : rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Height());
880 0 : break;
881 : case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
882 0 : bBool = sal_False;
883 0 : rValue <<= (sal_Int32) mpConstViewOption->GetDivisionX();
884 0 : break;
885 : case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
886 0 : bBool = sal_False;
887 0 : rValue <<= (sal_Int32) mpConstViewOption->GetDivisionY();
888 0 : break;
889 : case HANDLE_VIEWSET_ZOOM :
890 4 : bBool = sal_False;
891 4 : rValue <<= (sal_Int16)mpConstViewOption->GetZoom();
892 4 : break;
893 : case HANDLE_VIEWSET_ZOOM_TYPE:
894 : {
895 0 : bBool = sal_False;
896 0 : sal_Int16 nRet(0);
897 0 : switch (mpConstViewOption->GetZoomType())
898 : {
899 : case SVX_ZOOM_OPTIMAL:
900 0 : nRet = view::DocumentZoomType::OPTIMAL;
901 0 : break;
902 : case SVX_ZOOM_PAGEWIDTH:
903 0 : nRet = view::DocumentZoomType::PAGE_WIDTH;
904 0 : break;
905 : case SVX_ZOOM_WHOLEPAGE:
906 0 : nRet = view::DocumentZoomType::ENTIRE_PAGE;
907 0 : break;
908 : case SVX_ZOOM_PERCENT:
909 0 : nRet = view::DocumentZoomType::BY_VALUE;
910 0 : break;
911 : case SVX_ZOOM_PAGEWIDTH_NOBORDER:
912 0 : nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT;
913 0 : break;
914 : default:
915 : OSL_FAIL("SwXViewSettings: invalid zoom type");
916 0 : break;
917 : }
918 0 : rValue <<= nRet;
919 : }
920 0 : break;
921 : case HANDLE_VIEWSET_ONLINE_LAYOUT:
922 0 : if(pView)
923 0 : bBoolVal = pView->GetWrtShell().GetViewOptions()->getBrowseMode();
924 0 : break;
925 : case HANDLE_VIEWSET_HELP_URL :
926 : {
927 0 : if ( pView )
928 : {
929 0 : bBool = sal_False;
930 0 : OUStringBuffer sHelpURL;
931 0 : sHelpURL.appendAscii ( INET_HID_SCHEME );
932 0 : SwEditWin &rEditWin = pView->GetEditWin();
933 0 : sHelpURL.append( rtl::OStringToOUString( rEditWin.GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
934 0 : rValue <<= sHelpURL.makeStringAndClear();
935 : }
936 : else
937 0 : throw UnknownPropertyException();
938 : }
939 0 : break;
940 : case HANDLE_VIEWSET_HORI_RULER_METRIC:
941 : {
942 0 : if ( pView )
943 : {
944 : FieldUnit eUnit;
945 0 : pView->GetHLinealMetric( eUnit );
946 0 : rValue <<= (sal_Int32)eUnit;
947 : }
948 : else
949 : {
950 0 : const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
951 0 : rValue <<= (sal_Int32)pUsrPref->GetHScrollMetric();
952 : }
953 0 : bBool = sal_False;
954 : }
955 0 : break;
956 : case HANDLE_VIEWSET_VERT_RULER_METRIC:
957 : {
958 0 : if ( pView )
959 : {
960 : FieldUnit eUnit;
961 0 : pView->GetVLinealMetric( eUnit );
962 0 : rValue <<= (sal_Int32)eUnit;
963 : }
964 : else
965 : {
966 0 : const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
967 0 : rValue <<= (sal_Int32)pUsrPref->GetVScrollMetric();
968 : }
969 0 : bBool = sal_False;
970 : }
971 0 : break;
972 : default: OSL_FAIL("there is no such ID!");
973 : }
974 4 : if( bBool )
975 0 : rValue.setValue(&bBoolVal, ::getBooleanCppuType());
976 4 : }
977 :
978 4 : void SwXViewSettings::_postGetValues ()
979 : throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
980 : {
981 4 : mpConstViewOption = NULL;
982 4 : }
983 :
984 0 : OUString SwXViewSettings::getImplementationName(void) throw( RuntimeException )
985 : {
986 0 : return OUString("SwXViewSettings");
987 : }
988 :
989 0 : sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
990 : {
991 0 : return rServiceName == "com.sun.star.text.ViewSettings";
992 : }
993 :
994 0 : Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( RuntimeException )
995 : {
996 0 : Sequence< OUString > aRet(1);
997 0 : OUString* pArray = aRet.getArray();
998 0 : pArray[0] = "com.sun.star.text.ViewSettings";
999 0 : return aRet;
1000 : }
1001 :
1002 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|