Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / uno / unomod.cxx
blob4599d8386b93cf7fb4c40bedf6b065c2021238f3
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 <com/sun/star/beans/PropertyAttribute.hpp>
21 #include <com/sun/star/view/DocumentZoomType.hpp>
22 #include <comphelper/ChainablePropertySetInfo.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <o3tl/any.hxx>
25 #include <osl/diagnose.h>
26 #include <svl/itemprop.hxx>
27 #include <tools/urlobj.hxx>
28 #include <tools/UnitConversion.hxx>
29 #include <vcl/svapp.hxx>
31 #include <unomod.hxx>
32 #include <usrpref.hxx>
33 #include <prtopt.hxx>
34 #include <swmodule.hxx>
35 #include <view.hxx>
36 #include <docsh.hxx>
37 #include <wrtsh.hxx>
38 #include <viewopt.hxx>
39 #include <doc.hxx>
40 #include <IDocumentDeviceAccess.hxx>
41 #include <edtwin.hxx>
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::lang;
46 using namespace ::comphelper;
48 namespace {
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,
92 HANDLE_VIEWSET_SCROLLBAR_TIPS,
93 HANDLE_VIEWSET_INLINECHANGES_TIPS,
94 HANDLE_VIEWSET_HIDE_WHITESPACE,
95 HANDLE_VIEWSET_USE_HEADERFOOTERMENU,
96 HANDLE_VIEWSET_BOOKMARKS,
97 HANDLE_VIEWSET_SHOW_OUTLINECONTENTVISIBILITYBUTTON,
98 HANDLE_VIEWSET_TREAT_SUB_OUTLINE_LEVELS_AS_CONTENT,
99 HANDLE_VIEWSET_CHANGES_IN_MARGIN
102 enum SwPrintSettingsPropertyHandles
104 HANDLE_PRINTSET_ANNOTATION_MODE,
105 HANDLE_PRINTSET_BLACK_FONTS,
106 HANDLE_PRINTSET_CONTROLS,
107 HANDLE_PRINTSET_DRAWINGS,
108 HANDLE_PRINTSET_GRAPHICS,
109 HANDLE_PRINTSET_LEFT_PAGES,
110 HANDLE_PRINTSET_PAGE_BACKGROUND,
111 HANDLE_PRINTSET_PROSPECT,
112 HANDLE_PRINTSET_REVERSED,
113 HANDLE_PRINTSET_RIGHT_PAGES,
114 HANDLE_PRINTSET_FAX_NAME,
115 HANDLE_PRINTSET_PAPER_FROM_SETUP,
116 HANDLE_PRINTSET_TABLES,
117 HANDLE_PRINTSET_SINGLE_JOBS,
118 HANDLE_PRINTSET_EMPTY_PAGES,
119 HANDLE_PRINTSET_PROSPECT_RTL,
120 HANDLE_PRINTSET_PLACEHOLDER,
121 HANDLE_PRINTSET_HIDDEN_TEXT
126 static rtl::Reference<ChainablePropertySetInfo> lcl_createViewSettingsInfo()
128 static PropertyInfo const aViewSettingsMap_Impl[] =
130 { OUString( "HelpURL" ), HANDLE_VIEWSET_HELP_URL , cppu::UnoType<OUString>::get(), PROPERTY_NONE},
131 { OUString( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC , cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE},
132 { OUString( "IsRasterVisible"), HANDLE_VIEWSET_IS_RASTER_VISIBLE, cppu::UnoType<bool>::get(), PROPERTY_NONE},
133 { OUString( "IsSnapToRaster"), HANDLE_VIEWSET_IS_SNAP_TO_RASTER, cppu::UnoType<bool>::get(), PROPERTY_NONE},
134 { OUString( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE},
135 { OUString( "ShowContentTips" ), HANDLE_VIEWSET_SHOW_CONTENT_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
136 { OUString( "ShowInlineTooltips" ), HANDLE_VIEWSET_INLINECHANGES_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
137 { OUString( "UseHeaderFooterMenu" ), HANDLE_VIEWSET_USE_HEADERFOOTERMENU , cppu::UnoType<bool>::get(), PROPERTY_NONE},
138 { OUString( "ShowOutlineContentVisibilityButton" ), HANDLE_VIEWSET_SHOW_OUTLINECONTENTVISIBILITYBUTTON , cppu::UnoType<bool>::get(), PROPERTY_NONE},
139 { OUString( "TreatSubOutlineLevelsAsContent" ), HANDLE_VIEWSET_TREAT_SUB_OUTLINE_LEVELS_AS_CONTENT , cppu::UnoType<bool>::get(), PROPERTY_NONE},
140 { OUString( "ShowChangesInMargin" ), HANDLE_VIEWSET_CHANGES_IN_MARGIN, cppu::UnoType<bool>::get(), PROPERTY_NONE},
141 { OUString( "RasterResolutionX"), HANDLE_VIEWSET_RASTER_RESOLUTION_X, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE},
142 { OUString( "RasterResolutionY"), HANDLE_VIEWSET_RASTER_RESOLUTION_Y, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE},
143 { OUString( "RasterSubdivisionX"), HANDLE_VIEWSET_RASTER_SUBDIVISION_X, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE},
144 { OUString( "RasterSubdivisionY"), HANDLE_VIEWSET_RASTER_SUBDIVISION_Y, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE},
145 { OUString( "ShowAnnotations" ), HANDLE_VIEWSET_ANNOTATIONS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
146 { OUString( "ShowBookmarks" ), HANDLE_VIEWSET_BOOKMARKS, cppu::UnoType<bool>::get(), PROPERTY_NONE },
147 { OUString( "ShowBreaks"), HANDLE_VIEWSET_BREAKS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
148 { OUString( "ShowDrawings"), HANDLE_VIEWSET_DRAWINGS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
149 { OUString( "ShowFieldCommands"), HANDLE_VIEWSET_FIELD_COMMANDS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
150 { OUString( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , cppu::UnoType<bool>::get(), PROPERTY_NONE},
151 { OUString( "ShowGraphics"), HANDLE_VIEWSET_GRAPHICS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
152 { OUString( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
153 { OUString( "HideWhitespace"), HANDLE_VIEWSET_HIDE_WHITESPACE , cppu::UnoType<bool>::get(), PROPERTY_NONE},
154 { OUString( "ShowHiddenParagraphs"), HANDLE_VIEWSET_HIDDEN_PARAGRAPHS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
155 { OUString( "ShowHiddenText"), HANDLE_VIEWSET_HIDDEN_TEXT , cppu::UnoType<bool>::get(), PROPERTY_NONE},
156 { OUString( "ShowHoriRuler"), HANDLE_VIEWSET_HRULER , cppu::UnoType<bool>::get(), PROPERTY_NONE},
157 { OUString( "ShowHoriScrollBar"), HANDLE_VIEWSET_HSCROLL , cppu::UnoType<bool>::get(), PROPERTY_NONE},
158 { OUString( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, cppu::UnoType<bool>::get(),PROPERTY_NONE},
159 { OUString( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, cppu::UnoType<bool>::get(),PROPERTY_NONE},
160 { OUString( "ShowOnlineLayout"), HANDLE_VIEWSET_ONLINE_LAYOUT , cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID},
161 { OUString( "ShowParaBreaks"), HANDLE_VIEWSET_PARA_BREAKS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
162 { OUString( "ShowProtectedSpaces"), HANDLE_VIEWSET_PROTECTED_SPACES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
163 { OUString( "ShowRulers"), HANDLE_VIEWSET_SHOW_RULER , cppu::UnoType<bool>::get(), PROPERTY_NONE},
164 { OUString( "ShowScrollBarTips"), HANDLE_VIEWSET_SCROLLBAR_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
165 { OUString( "ShowSoftHyphens"), HANDLE_VIEWSET_SOFT_HYPHENS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
166 { OUString( "ShowSpaces"), HANDLE_VIEWSET_SPACES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
167 { OUString( "ShowTableBoundaries"), HANDLE_VIEWSET_TABLE_BOUNDARIES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
168 { OUString( "ShowTables"), HANDLE_VIEWSET_TABLES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
169 { OUString( "ShowTabstops"), HANDLE_VIEWSET_TABSTOPS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
170 { OUString( "ShowTextBoundaries"), HANDLE_VIEWSET_TEXT_BOUNDARIES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
171 { OUString( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, cppu::UnoType<bool>::get(),PROPERTY_NONE},
172 { OUString( "ShowVertRuler"), HANDLE_VIEWSET_VRULER , cppu::UnoType<bool>::get(), PROPERTY_NONE},
173 { OUString( "ShowVertScrollBar"), HANDLE_VIEWSET_VSCROLL , cppu::UnoType<bool>::get(), PROPERTY_NONE},
174 { OUString( "SmoothScrolling"), HANDLE_VIEWSET_SMOOTH_SCROLLING , cppu::UnoType<bool>::get(), PROPERTY_NONE},
175 { OUString( "VerticalRulerMetric"), HANDLE_VIEWSET_VERT_RULER_METRIC , cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE},
176 { OUString( "ZoomType"), HANDLE_VIEWSET_ZOOM_TYPE , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE},
177 { OUString( "ZoomValue"), HANDLE_VIEWSET_ZOOM , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE},
178 { OUString(), 0, css::uno::Type(), 0 }
180 return new ChainablePropertySetInfo ( aViewSettingsMap_Impl );
183 static rtl::Reference<ChainablePropertySetInfo> lcl_createPrintSettingsInfo()
185 static PropertyInfo const aPrintSettingsMap_Impl[] =
187 { OUString( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE},
188 { OUString( "PrintBlackFonts" ), HANDLE_PRINTSET_BLACK_FONTS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
189 { OUString( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
190 { OUString( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
191 { OUString( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
192 { OUString( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , cppu::UnoType<bool>::get(), PROPERTY_NONE},
193 { OUString( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
194 { OUString( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , cppu::UnoType<bool>::get(), PROPERTY_NONE},
195 { OUString( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , cppu::UnoType<bool>::get(), PROPERTY_NONE},
196 { OUString( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , cppu::UnoType<bool>::get(), PROPERTY_NONE},
197 { OUString( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , cppu::UnoType<bool>::get(), PROPERTY_NONE},
198 { OUString( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
199 { OUString( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , cppu::UnoType<OUString>::get(), PROPERTY_NONE},
200 { OUString( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , cppu::UnoType<bool>::get(), PROPERTY_NONE},
201 { OUString( "PrintTables" ), HANDLE_PRINTSET_TABLES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
202 { OUString( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , cppu::UnoType<bool>::get(), PROPERTY_NONE},
203 { OUString( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , cppu::UnoType<bool>::get(), PROPERTY_NONE},
204 { OUString( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE},
205 { OUString(), 0, css::uno::Type(), 0}
207 return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl );
210 SwXModule::SwXModule()
214 SwXModule::~SwXModule()
218 Reference< XPropertySet > SwXModule::getViewSettings()
220 SolarMutexGuard aGuard;
221 if(!mxViewSettings.is())
223 OSL_FAIL("Web or Text?");
224 mxViewSettings = new SwXViewSettings( nullptr );
226 return mxViewSettings;
229 Reference< XPropertySet > SwXModule::getPrintSettings()
231 SolarMutexGuard aGuard;
232 if(!mxPrintSettings.is())
234 OSL_FAIL("Web or Text?");
235 mxPrintSettings = new SwXPrintSettings( SwXPrintSettingsType::Module );
237 return mxPrintSettings;
240 OUString SwXModule::getImplementationName()
242 return "SwXModule";
245 sal_Bool SwXModule::supportsService(const OUString& rServiceName)
247 return cppu::supportsService(this, rServiceName);
250 Sequence< OUString > SwXModule::getSupportedServiceNames()
252 return { "com.sun.star.text.GlobalSettings" };
255 SwXPrintSettings::SwXPrintSettings(SwXPrintSettingsType eType, SwDoc* pDoc)
256 : ChainablePropertySet ( lcl_createPrintSettingsInfo().get(), &Application::GetSolarMutex() )
257 , meType(eType)
258 , mpPrtOpt ( nullptr )
259 , mpDoc ( pDoc )
263 SwXPrintSettings::~SwXPrintSettings()
264 noexcept
268 void SwXPrintSettings::_preSetValues ()
270 switch (meType)
272 case SwXPrintSettingsType::Module:
273 mpPrtOpt = SW_MOD()->GetPrtOptions( false );
274 break;
275 case SwXPrintSettingsType::Document:
277 if (!mpDoc)
278 throw IllegalArgumentException ();
279 mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getIDocumentDeviceAccess().getPrintData());
281 break;
285 namespace
287 bool tryBoolAccess(const uno::Any &rValue)
289 const auto xPrSet = o3tl::tryAccess<bool>(rValue);
290 if (!xPrSet)
291 throw lang::IllegalArgumentException();
292 return *xPrSet;
296 void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
298 switch( rInfo.mnHandle )
300 case HANDLE_PRINTSET_LEFT_PAGES:
302 mpPrtOpt->SetPrintLeftPage(tryBoolAccess(rValue));
304 break;
305 case HANDLE_PRINTSET_RIGHT_PAGES:
307 mpPrtOpt->SetPrintRightPage(tryBoolAccess(rValue));
309 break;
310 case HANDLE_PRINTSET_REVERSED:
312 mpPrtOpt->SetPrintReverse(tryBoolAccess(rValue));
314 break;
315 case HANDLE_PRINTSET_PROSPECT:
317 mpPrtOpt->SetPrintProspect(tryBoolAccess(rValue));
319 break;
320 case HANDLE_PRINTSET_GRAPHICS:
322 mpPrtOpt->SetPrintGraphic(tryBoolAccess(rValue));
324 break;
325 case HANDLE_PRINTSET_TABLES:
327 mpPrtOpt->SetPrintTable(tryBoolAccess(rValue));
329 break;
330 case HANDLE_PRINTSET_DRAWINGS:
332 mpPrtOpt->SetPrintDraw(tryBoolAccess(rValue));
334 break;
335 case HANDLE_PRINTSET_CONTROLS:
337 mpPrtOpt->SetPrintControl(tryBoolAccess(rValue));
339 break;
340 case HANDLE_PRINTSET_PAGE_BACKGROUND:
342 mpPrtOpt->SetPrintPageBackground(tryBoolAccess(rValue));
344 break;
345 case HANDLE_PRINTSET_BLACK_FONTS:
347 mpPrtOpt->SetPrintBlackFont(tryBoolAccess(rValue));
349 break;
350 case HANDLE_PRINTSET_SINGLE_JOBS:
352 mpPrtOpt->SetPrintSingleJobs(tryBoolAccess(rValue));
354 break;
355 case HANDLE_PRINTSET_PAPER_FROM_SETUP:
357 mpPrtOpt->SetPaperFromSetup(tryBoolAccess(rValue));
359 break;
360 case HANDLE_PRINTSET_ANNOTATION_MODE:
362 sal_Int16 nTmp = 0;
363 rValue >>= nTmp;
364 SwPostItMode nVal = static_cast<SwPostItMode>(nTmp);
365 if(nVal > SwPostItMode::EndPage)
366 throw lang::IllegalArgumentException();
368 mpPrtOpt->SetPrintPostIts(nVal);
370 break;
371 case HANDLE_PRINTSET_EMPTY_PAGES:
373 mpPrtOpt->SetPrintEmptyPages(tryBoolAccess(rValue));
375 break;
376 case HANDLE_PRINTSET_FAX_NAME:
378 OUString sString;
379 if ( !(rValue >>= sString))
380 throw lang::IllegalArgumentException();
382 mpPrtOpt->SetFaxName(sString);
384 break;
385 case HANDLE_PRINTSET_PROSPECT_RTL:
387 mpPrtOpt->SetPrintProspect_RTL(tryBoolAccess(rValue));
389 break;
390 case HANDLE_PRINTSET_PLACEHOLDER:
392 mpPrtOpt->SetPrintTextPlaceholder(tryBoolAccess(rValue));
394 break;
395 case HANDLE_PRINTSET_HIDDEN_TEXT:
397 mpPrtOpt->SetPrintHiddenText(tryBoolAccess(rValue));
399 break;
400 default:
401 throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
405 void SwXPrintSettings::_postSetValues()
407 mpPrtOpt = nullptr;
410 void SwXPrintSettings::_preGetValues()
412 switch (meType)
414 case SwXPrintSettingsType::Module:
415 mpPrtOpt = SW_MOD()->GetPrtOptions( false );
416 break;
417 case SwXPrintSettingsType::Document:
419 if (!mpDoc)
420 throw IllegalArgumentException ();
421 mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getIDocumentDeviceAccess().getPrintData());
423 break;
427 void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
429 switch( rInfo.mnHandle )
431 case HANDLE_PRINTSET_LEFT_PAGES:
432 rValue <<= mpPrtOpt->IsPrintLeftPage();
433 break;
434 case HANDLE_PRINTSET_RIGHT_PAGES:
435 rValue <<= mpPrtOpt->IsPrintRightPage();
436 break;
437 case HANDLE_PRINTSET_REVERSED:
438 rValue <<= mpPrtOpt->IsPrintReverse();
439 break;
440 case HANDLE_PRINTSET_PROSPECT:
441 rValue <<= mpPrtOpt->IsPrintProspect();
442 break;
443 case HANDLE_PRINTSET_GRAPHICS:
444 rValue <<= mpPrtOpt->IsPrintGraphic();
445 break;
446 case HANDLE_PRINTSET_TABLES:
447 rValue <<= mpPrtOpt->IsPrintTable();
448 break;
449 case HANDLE_PRINTSET_DRAWINGS:
450 rValue <<= mpPrtOpt->IsPrintDraw();
451 break;
452 case HANDLE_PRINTSET_CONTROLS:
453 rValue <<= mpPrtOpt->IsPrintControl();
454 break;
455 case HANDLE_PRINTSET_PAGE_BACKGROUND:
456 rValue <<= mpPrtOpt->IsPrintPageBackground();
457 break;
458 case HANDLE_PRINTSET_BLACK_FONTS:
459 rValue <<= mpPrtOpt->IsPrintBlackFont();
460 break;
461 case HANDLE_PRINTSET_SINGLE_JOBS:
462 rValue <<= mpPrtOpt->IsPrintSingleJobs();
463 break;
464 case HANDLE_PRINTSET_EMPTY_PAGES:
465 rValue <<= mpPrtOpt->IsPrintEmptyPages();
466 break;
467 case HANDLE_PRINTSET_PAPER_FROM_SETUP:
468 rValue <<= mpPrtOpt->IsPaperFromSetup();
469 break;
470 case HANDLE_PRINTSET_ANNOTATION_MODE:
472 rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() );
474 break;
475 case HANDLE_PRINTSET_FAX_NAME :
477 rValue <<= mpPrtOpt->GetFaxName();
479 break;
480 case HANDLE_PRINTSET_PROSPECT_RTL:
482 rValue <<= mpPrtOpt->IsPrintProspectRTL();
484 break;
485 case HANDLE_PRINTSET_PLACEHOLDER:
487 rValue <<= mpPrtOpt->IsPrintTextPlaceholder();
489 break;
490 case HANDLE_PRINTSET_HIDDEN_TEXT:
492 rValue <<= mpPrtOpt->IsPrintHiddenText();
494 break;
495 default:
496 throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
500 void SwXPrintSettings::_postGetValues ()
502 mpPrtOpt = nullptr;
505 OUString SwXPrintSettings::getImplementationName()
507 return "SwXPrintSettings";
510 sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName)
512 return cppu::supportsService(this, rServiceName);
515 Sequence< OUString > SwXPrintSettings::getSupportedServiceNames()
517 Sequence<OUString> aRet { "com.sun.star.text.PrintSettings" };
518 return aRet;
521 SwXViewSettings::SwXViewSettings(SwView* pVw)
522 : ChainablePropertySet( lcl_createViewSettingsInfo().get(), &Application::GetSolarMutex() )
523 , m_pView(pVw)
524 , mpConstViewOption(nullptr)
525 , m_bObjectValid(true)
526 , mbApplyZoom(false)
527 , m_eHRulerUnit(FieldUnit::CM)
528 , mbApplyHRulerMetric(false)
529 , m_eVRulerUnit(FieldUnit::CM)
530 , mbApplyVRulerMetric(false)
532 // This property only exists if we have a view (ie, not at the module )
533 if ( !m_pView )
534 mxInfo->remove ( "HelpURL" );
538 SwXViewSettings::~SwXViewSettings()
539 noexcept
544 void SwXViewSettings::_preSetValues ()
546 const SwViewOption* pVOpt = nullptr;
547 if(m_pView)
549 if(!IsValid())
550 return;
551 pVOpt = m_pView->GetWrtShell().GetViewOptions();
553 else
554 pVOpt = SW_MOD()->GetViewOption(false);
556 mpViewOption.reset( new SwViewOption (*pVOpt) );
557 mbApplyZoom = false;
558 if(m_pView)
559 mpViewOption->SetStarOneSetting(true);
562 void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
564 // the API flag should not be set to the application's view settings
565 switch( rInfo.mnHandle )
567 case HANDLE_VIEWSET_SHOW_RULER : mpViewOption->SetViewAnyRuler(*o3tl::doAccess<bool>(rValue)); break;
568 case HANDLE_VIEWSET_HRULER : mpViewOption->SetViewHRuler(*o3tl::doAccess<bool>(rValue)); break;
569 case HANDLE_VIEWSET_VRULER : mpViewOption->SetViewVRuler(*o3tl::doAccess<bool>(rValue));break;
570 case HANDLE_VIEWSET_VRULER_RIGHT : mpViewOption->SetVRulerRight(*o3tl::doAccess<bool>(rValue));break;
571 case HANDLE_VIEWSET_HSCROLL : mpViewOption->SetViewHScrollBar(*o3tl::doAccess<bool>(rValue));break;
572 case HANDLE_VIEWSET_VSCROLL : mpViewOption->SetViewVScrollBar(*o3tl::doAccess<bool>(rValue));break;
573 case HANDLE_VIEWSET_GRAPHICS : mpViewOption->SetGraphic(*o3tl::doAccess<bool>(rValue));break;
574 case HANDLE_VIEWSET_TABLES : mpViewOption->SetTable(*o3tl::doAccess<bool>(rValue)); break;
575 case HANDLE_VIEWSET_DRAWINGS : mpViewOption->SetDraw(*o3tl::doAccess<bool>(rValue)); break;
576 case HANDLE_VIEWSET_FIELD_COMMANDS : mpViewOption->SetFieldName(*o3tl::doAccess<bool>(rValue)); break;
577 case HANDLE_VIEWSET_ANNOTATIONS : mpViewOption->SetPostIts(*o3tl::doAccess<bool>(rValue)); break;
578 case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : mpViewOption->SetAppearanceFlag(ViewOptFlags::FieldShadings, *o3tl::doAccess<bool>(rValue), true); break;
579 case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( *o3tl::doAccess<bool>(rValue) ); break;
580 case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : mpViewOption->SetAppearanceFlag(ViewOptFlags::FieldShadings, *o3tl::doAccess<bool>(rValue), true); break;
581 case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : mpViewOption->SetAppearanceFlag(ViewOptFlags::FieldShadings, *o3tl::doAccess<bool>(rValue), true); break;
582 case HANDLE_VIEWSET_PARA_BREAKS : mpViewOption->SetParagraph(*o3tl::doAccess<bool>(rValue)); break;
583 case HANDLE_VIEWSET_SOFT_HYPHENS : mpViewOption->SetSoftHyph(*o3tl::doAccess<bool>(rValue)); break;
584 case HANDLE_VIEWSET_SPACES : mpViewOption->SetBlank(*o3tl::doAccess<bool>(rValue)); break;
585 case HANDLE_VIEWSET_PROTECTED_SPACES : mpViewOption->SetHardBlank(*o3tl::doAccess<bool>(rValue)); break;
586 case HANDLE_VIEWSET_TABSTOPS : mpViewOption->SetTab(*o3tl::doAccess<bool>(rValue)); break;
587 case HANDLE_VIEWSET_BREAKS : mpViewOption->SetLineBreak(*o3tl::doAccess<bool>(rValue)); break;
588 case HANDLE_VIEWSET_BOOKMARKS : mpViewOption->SetShowBookmarks(*o3tl::doAccess<bool>(rValue)); break;
589 case HANDLE_VIEWSET_HIDDEN_TEXT : mpViewOption->SetShowHiddenField(*o3tl::doAccess<bool>(rValue)); break;
590 case HANDLE_VIEWSET_HIDDEN_CHARACTERS : mpViewOption->SetShowHiddenChar(*o3tl::doAccess<bool>(rValue)); break;
591 case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : mpViewOption->SetShowHiddenPara(*o3tl::doAccess<bool>(rValue)); break;
592 case HANDLE_VIEWSET_TABLE_BOUNDARIES : mpViewOption->SetAppearanceFlag(ViewOptFlags::TableBoundaries, *o3tl::doAccess<bool>(rValue), true); break;
593 case HANDLE_VIEWSET_TEXT_BOUNDARIES : mpViewOption->SetDocBoundaries(*o3tl::doAccess<bool>(rValue)); break;
594 case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(*o3tl::doAccess<bool>(rValue)); break;
595 case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : mpViewOption->SetShowContentTips(*o3tl::doAccess<bool>(rValue)); break;
596 case HANDLE_VIEWSET_IS_RASTER_VISIBLE : mpViewOption->SetGridVisible(*o3tl::doAccess<bool>(rValue)); break;
597 case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : mpViewOption->SetSnap(*o3tl::doAccess<bool>(rValue)); break;
598 case HANDLE_VIEWSET_SCROLLBAR_TIPS : mpViewOption->SetShowScrollBarTips(*o3tl::doAccess<bool>(rValue)); break;
599 case HANDLE_VIEWSET_INLINECHANGES_TIPS : mpViewOption->SetShowInlineTooltips(*o3tl::doAccess<bool>(rValue)); break;
600 case HANDLE_VIEWSET_USE_HEADERFOOTERMENU : mpViewOption->SetUseHeaderFooterMenu(*o3tl::doAccess<bool>(rValue)); break;
601 case HANDLE_VIEWSET_SHOW_OUTLINECONTENTVISIBILITYBUTTON : mpViewOption->SetShowOutlineContentVisibilityButton(*o3tl::doAccess<bool>(rValue)); break;
602 case HANDLE_VIEWSET_TREAT_SUB_OUTLINE_LEVELS_AS_CONTENT : mpViewOption->SetTreatSubOutlineLevelsAsContent(*o3tl::doAccess<bool>(rValue)); break;
603 case HANDLE_VIEWSET_CHANGES_IN_MARGIN : mpViewOption->SetShowChangesInMargin(*o3tl::doAccess<bool>(rValue)); break;
604 case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
606 sal_Int32 nTmp = 0;
607 if(!(rValue >>= nTmp) || nTmp < 10)
608 throw IllegalArgumentException();
609 Size aSize( mpViewOption->GetSnapSize() );
610 aSize.setWidth( o3tl::toTwips(nTmp, o3tl::Length::mm100) );
611 mpViewOption->SetSnapSize( aSize );
613 break;
614 case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
616 sal_Int32 nTmp = 0;
617 if(!(rValue >>= nTmp) || nTmp < 10)
618 throw IllegalArgumentException();
619 Size aSize( mpViewOption->GetSnapSize() );
620 aSize.setHeight( o3tl::toTwips(nTmp, o3tl::Length::mm100) );
621 mpViewOption->SetSnapSize( aSize );
623 break;
624 case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
626 sal_Int32 nTmp = 0;
627 if(!(rValue >>= nTmp) || (0 > nTmp || nTmp >= 100))
628 throw IllegalArgumentException();
629 mpViewOption->SetDivisionX( static_cast<short>(nTmp) );
631 break;
632 case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
634 sal_Int32 nTmp = 0;
635 if(!(rValue >>= nTmp) || (0 > nTmp || nTmp >= 100))
636 throw IllegalArgumentException();
637 mpViewOption->SetDivisionY( static_cast<short>(nTmp) );
639 break;
640 case HANDLE_VIEWSET_ZOOM :
642 sal_Int16 nZoom = 0;
643 if(!(rValue >>= nZoom) || nZoom > MAXZOOM || nZoom < MINZOOM)
644 throw lang::IllegalArgumentException();
645 mpViewOption->SetZoom(o3tl::narrowing<sal_uInt16>(nZoom));
646 mbApplyZoom = true;
648 break;
649 case HANDLE_VIEWSET_ZOOM_TYPE:
651 sal_Int16 nZoom = 0;
652 if(!(rValue >>= nZoom))
653 throw IllegalArgumentException();
654 SvxZoomType eZoom;
655 switch (nZoom)
657 case view::DocumentZoomType::OPTIMAL:
658 eZoom = SvxZoomType::OPTIMAL;
659 break;
660 case view::DocumentZoomType::PAGE_WIDTH:
661 eZoom = SvxZoomType::PAGEWIDTH;
662 break;
663 case view::DocumentZoomType::ENTIRE_PAGE:
664 eZoom = SvxZoomType::WHOLEPAGE;
665 break;
666 case view::DocumentZoomType::BY_VALUE:
667 eZoom = SvxZoomType::PERCENT;
668 break;
669 case view::DocumentZoomType::PAGE_WIDTH_EXACT:
670 eZoom = SvxZoomType::PAGEWIDTH_NOBORDER;
671 break;
672 default:
673 throw IllegalArgumentException(
674 "SwXViewSettings: invalid zoom type", nullptr, 0);
676 mpViewOption->SetZoomType( eZoom );
677 mbApplyZoom = true;
679 break;
680 case HANDLE_VIEWSET_ONLINE_LAYOUT :
682 if ( m_pView )
684 bool bVal = *o3tl::doAccess<bool>(rValue);
685 SwViewOption aOpt(*m_pView->GetWrtShell().GetViewOptions());
686 if (!bVal != !aOpt.getBrowseMode())
688 aOpt.setBrowseMode( bVal );
689 m_pView->GetWrtShell().ApplyViewOptions( aOpt );
691 // must be set in mpViewOption as this will overwrite settings in _post!
692 if(mpViewOption)
693 mpViewOption->setBrowseMode(bVal);
695 m_pView->GetDocShell()->ToggleLayoutMode(m_pView);
699 break;
700 case HANDLE_VIEWSET_HIDE_WHITESPACE:
702 if ( m_pView )
704 bool bVal = *o3tl::doAccess<bool>(rValue);
705 SwViewOption aOpt(*m_pView->GetWrtShell().GetViewOptions());
706 if (!bVal != !aOpt.IsHideWhitespaceMode())
708 aOpt.SetHideWhitespaceMode( bVal );
709 m_pView->GetWrtShell().ApplyViewOptions( aOpt );
711 // must be set in mpViewOption as this will overwrite settings in _post!
712 if(mpViewOption)
713 mpViewOption->SetHideWhitespaceMode(bVal);
717 break;
718 case HANDLE_VIEWSET_HELP_URL:
720 if ( !m_pView )
721 throw UnknownPropertyException();
723 OUString sHelpURL;
724 if ( ! ( rValue >>= sHelpURL ) )
725 throw IllegalArgumentException();
727 INetURLObject aHID( sHelpURL );
728 if ( aHID.GetProtocol() != INetProtocol::Hid )
729 throw IllegalArgumentException ();
731 m_pView->GetEditWin().SetHelpId( aHID.GetURLPath() );
733 break;
734 case HANDLE_VIEWSET_HORI_RULER_METRIC:
735 case HANDLE_VIEWSET_VERT_RULER_METRIC:
737 sal_uInt16 nUnit;
738 if( rValue >>= nUnit )
739 switch (static_cast<FieldUnit>(nUnit))
741 case FieldUnit::MM:
742 case FieldUnit::CM:
743 case FieldUnit::POINT:
744 case FieldUnit::PICA:
745 case FieldUnit::INCH:
746 if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
748 m_eHRulerUnit = static_cast<FieldUnit>(nUnit);
749 mbApplyHRulerMetric = true;
751 else
753 m_eVRulerUnit = static_cast<FieldUnit>(nUnit);
754 mbApplyVRulerMetric = true;
756 break;
757 default:
758 throw IllegalArgumentException();
761 break;
762 default:
763 throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
767 void SwXViewSettings::_postSetValues()
769 if( m_pView )
771 if(mbApplyZoom )
772 m_pView->SetZoom( mpViewOption->GetZoomType(),
773 mpViewOption->GetZoom(), true );
774 if(mbApplyHRulerMetric)
775 m_pView->ChangeTabMetric(m_eHRulerUnit);
776 if(mbApplyVRulerMetric)
777 m_pView->ChangeVRulerMetric(m_eVRulerUnit);
780 else
782 if(mbApplyHRulerMetric)
783 SW_MOD()->ApplyRulerMetric( m_eHRulerUnit, true, false );
784 if(mbApplyVRulerMetric)
785 SW_MOD()->ApplyRulerMetric( m_eVRulerUnit, false, false );
788 SW_MOD()->ApplyUsrPref( *mpViewOption, m_pView, m_pView ? SvViewOpt::DestViewOnly
789 : SvViewOpt::DestText );
791 mpViewOption.reset();
794 void SwXViewSettings::_preGetValues ()
796 if(m_pView)
798 if(!IsValid())
799 return;
800 mpConstViewOption = m_pView->GetWrtShell().GetViewOptions();
802 else
803 mpConstViewOption = SW_MOD()->GetViewOption(false);
806 void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
808 bool bBool = true;
809 bool bBoolVal = false;
810 switch( rInfo.mnHandle )
812 case HANDLE_VIEWSET_SHOW_RULER: bBoolVal = mpConstViewOption->IsViewAnyRuler(); break;
813 case HANDLE_VIEWSET_HRULER : bBoolVal = mpConstViewOption->IsViewHRuler(true); break;
814 case HANDLE_VIEWSET_VRULER : bBoolVal = mpConstViewOption->IsViewVRuler(true);break;
815 case HANDLE_VIEWSET_VRULER_RIGHT : bBoolVal = mpConstViewOption->IsVRulerRight();break;
816 case HANDLE_VIEWSET_HSCROLL: bBoolVal = mpConstViewOption->IsViewHScrollBar();break;
817 case HANDLE_VIEWSET_VSCROLL: bBoolVal = mpConstViewOption->IsViewVScrollBar();break;
818 case HANDLE_VIEWSET_GRAPHICS : bBoolVal = mpConstViewOption->IsGraphic();break;
819 case HANDLE_VIEWSET_TABLES : bBoolVal = mpConstViewOption->IsTable(); break;
820 case HANDLE_VIEWSET_DRAWINGS : bBoolVal = mpConstViewOption->IsDraw(); break;
821 case HANDLE_VIEWSET_FIELD_COMMANDS : bBoolVal = mpConstViewOption->IsFieldName(); break;
822 case HANDLE_VIEWSET_ANNOTATIONS : bBoolVal = mpConstViewOption->IsPostIts(); break;
823 case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : bBoolVal = mpConstViewOption->IsFieldShadings(); break;
824 case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: bBoolVal = mpConstViewOption->IsViewMetaChars(); break;
825 case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : bBoolVal = mpConstViewOption->IsFieldShadings(); break;
826 case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : bBoolVal = mpConstViewOption->IsFieldShadings(); break;
827 case HANDLE_VIEWSET_PARA_BREAKS : bBoolVal = mpConstViewOption->IsParagraph(true); break;
828 case HANDLE_VIEWSET_SOFT_HYPHENS : bBoolVal = mpConstViewOption->IsSoftHyph(); break;
829 case HANDLE_VIEWSET_SPACES : bBoolVal = mpConstViewOption->IsBlank(true); break;
830 case HANDLE_VIEWSET_PROTECTED_SPACES : bBoolVal = mpConstViewOption->IsHardBlank(); break;
831 case HANDLE_VIEWSET_TABSTOPS : bBoolVal = mpConstViewOption->IsTab(true); break;
832 case HANDLE_VIEWSET_BREAKS : bBoolVal = mpConstViewOption->IsLineBreak(true); break;
833 case HANDLE_VIEWSET_BOOKMARKS : bBoolVal = mpConstViewOption->IsShowBookmarks(true); break;
834 case HANDLE_VIEWSET_HIDDEN_TEXT : bBoolVal = mpConstViewOption->IsShowHiddenField(); break;
835 case HANDLE_VIEWSET_HIDDEN_CHARACTERS : bBoolVal = mpConstViewOption->IsShowHiddenChar(true); break;
836 case HANDLE_VIEWSET_HIDE_WHITESPACE : bBoolVal = mpConstViewOption->IsHideWhitespaceMode(); break;
837 case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : bBoolVal = mpConstViewOption->IsShowHiddenPara(); break;
838 case HANDLE_VIEWSET_TABLE_BOUNDARIES : bBoolVal = mpConstViewOption->IsTableBoundaries(); break;
839 case HANDLE_VIEWSET_TEXT_BOUNDARIES : bBoolVal = mpConstViewOption->IsDocBoundaries(); break;
840 case HANDLE_VIEWSET_SMOOTH_SCROLLING : bBoolVal = mpConstViewOption->IsSmoothScroll(); break;
841 case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : bBoolVal = mpConstViewOption->IsShowContentTips(); break;
842 case HANDLE_VIEWSET_INLINECHANGES_TIPS : bBoolVal = mpConstViewOption->IsShowInlineTooltips(); break;
843 case HANDLE_VIEWSET_CHANGES_IN_MARGIN : bBoolVal = mpConstViewOption->IsShowChangesInMargin(); break;
844 case HANDLE_VIEWSET_IS_RASTER_VISIBLE : bBoolVal = mpConstViewOption->IsGridVisible(); break;
845 case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : bBoolVal = mpConstViewOption->IsSnap(); break;
846 case HANDLE_VIEWSET_SCROLLBAR_TIPS : bBoolVal = mpConstViewOption->IsShowScrollBarTips(); break;
847 case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
848 bBool = false;
849 rValue <<= static_cast<sal_Int32>(convertTwipToMm100(mpConstViewOption->GetSnapSize().Width()));
850 break;
851 case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
852 bBool = false;
853 rValue <<= static_cast<sal_Int32>(convertTwipToMm100(mpConstViewOption->GetSnapSize().Height()));
854 break;
855 case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
856 bBool = false;
857 rValue <<= static_cast<sal_Int32>(mpConstViewOption->GetDivisionX());
858 break;
859 case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
860 bBool = false;
861 rValue <<= static_cast<sal_Int32>(mpConstViewOption->GetDivisionY());
862 break;
863 case HANDLE_VIEWSET_ZOOM :
864 bBool = false;
865 rValue <<= static_cast<sal_Int16>(mpConstViewOption->GetZoom());
866 break;
867 case HANDLE_VIEWSET_ZOOM_TYPE:
869 bBool = false;
870 sal_Int16 nRet(0);
871 switch (mpConstViewOption->GetZoomType())
873 case SvxZoomType::OPTIMAL:
874 nRet = view::DocumentZoomType::OPTIMAL;
875 break;
876 case SvxZoomType::PAGEWIDTH:
877 nRet = view::DocumentZoomType::PAGE_WIDTH;
878 break;
879 case SvxZoomType::WHOLEPAGE:
880 nRet = view::DocumentZoomType::ENTIRE_PAGE;
881 break;
882 case SvxZoomType::PERCENT:
883 nRet = view::DocumentZoomType::BY_VALUE;
884 break;
885 case SvxZoomType::PAGEWIDTH_NOBORDER:
886 nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT;
887 break;
888 default:
889 OSL_FAIL("SwXViewSettings: invalid zoom type");
890 break;
892 rValue <<= nRet;
894 break;
895 case HANDLE_VIEWSET_ONLINE_LAYOUT:
896 if(m_pView)
897 bBoolVal = m_pView->GetWrtShell().GetViewOptions()->getBrowseMode();
898 break;
899 case HANDLE_VIEWSET_HELP_URL :
901 if ( !m_pView )
902 throw UnknownPropertyException();
904 bBool = false;
905 SwEditWin &rEditWin = m_pView->GetEditWin();
906 OUString sHelpURL = INET_HID_SCHEME + rEditWin.GetHelpId();
907 rValue <<= sHelpURL;
909 break;
910 case HANDLE_VIEWSET_HORI_RULER_METRIC:
912 if ( m_pView )
914 FieldUnit eUnit;
915 m_pView->GetHRulerMetric( eUnit );
916 rValue <<= static_cast<sal_Int32>(eUnit);
918 else
920 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( false );
921 rValue <<= static_cast<sal_Int32>(pUsrPref->GetHScrollMetric());
923 bBool = false;
925 break;
926 case HANDLE_VIEWSET_VERT_RULER_METRIC:
928 if ( m_pView )
930 FieldUnit eUnit;
931 m_pView->GetVRulerMetric( eUnit );
932 rValue <<= static_cast<sal_Int32>(eUnit);
934 else
936 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( false );
937 rValue <<= static_cast<sal_Int32>(pUsrPref->GetVScrollMetric());
939 bBool = false;
941 break;
942 default: OSL_FAIL("there is no such ID!");
944 if( bBool )
945 rValue <<= bBoolVal;
948 void SwXViewSettings::_postGetValues ()
950 mpConstViewOption = nullptr;
953 OUString SwXViewSettings::getImplementationName()
955 return "SwXViewSettings";
958 sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName)
960 return cppu::supportsService(this, rServiceName);
963 Sequence< OUString > SwXViewSettings::getSupportedServiceNames()
965 Sequence<OUString> aRet { "com.sun.star.text.ViewSettings" };
966 return aRet;
969 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
970 SwXModule_get_implementation(css::uno::XComponentContext*,
971 css::uno::Sequence<css::uno::Any> const &)
973 return cppu::acquire(new SwXModule());
976 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */