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