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_cui.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <tools/shl.hxx> 33 #include <svl/eitem.hxx> 34 #include <svl/intitem.hxx> 35 #define _SVX_OPTSAVE_CXX 36 37 #include "optsave.hrc" 38 #include <cuires.hrc> 39 40 #include "optsave.hxx" 41 #include <dialmgr.hxx> 42 #include <comphelper/processfactory.hxx> 43 #include <comphelper/sequenceasvector.hxx> 44 #include <comphelper/sequenceashashmap.hxx> 45 #include <unotools/moduleoptions.hxx> 46 #include <unotools/saveopt.hxx> 47 #include <comphelper/sequenceasvector.hxx> 48 #include <comphelper/sequenceashashmap.hxx> 49 #include <com/sun/star/container/XContainerQuery.hpp> 50 #include <com/sun/star/container/XEnumeration.hpp> 51 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 52 #include <com/sun/star/container/XNameContainer.hpp> 53 #include <com/sun/star/container/XContainerQuery.hpp> 54 #include <com/sun/star/container/XEnumeration.hpp> 55 #include <com/sun/star/beans/PropertyValue.hpp> 56 #include <com/sun/star/util/XFlushable.hpp> 57 #include <sfx2/docfilt.hxx> 58 #include <svtools/stdctrl.hxx> 59 #include <vcl/fixed.hxx> 60 #include <vcl/msgbox.hxx> 61 #include <unotools/configitem.hxx> 62 #include <unotools/optionsdlg.hxx> 63 64 #include <vcl/msgbox.hxx> 65 66 using namespace com::sun::star::uno; 67 using namespace com::sun::star::util; 68 using namespace com::sun::star::lang; 69 using namespace com::sun::star::beans; 70 using namespace com::sun::star::container; 71 using namespace comphelper; 72 using rtl::OUString; 73 74 #define C2U(cChar) OUString::createFromAscii(cChar) 75 #define C2S(cChar) String( RTL_CONSTASCII_STRINGPARAM(cChar) ) 76 #define CFG_PAGE_AND_GROUP C2S("General"), C2S("LoadSave") 77 // !! you have to update these index, if you changed the list of the child windows !! 78 #define WININDEX_AUTOSAVE ((sal_uInt16)6) 79 #define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)9) 80 81 // ---------------------------------------------------------------------- 82 #ifdef FILTER_WARNING_ENABLED 83 class SvxAlienFilterWarningConfig_Impl : public utl::ConfigItem 84 { 85 sal_Bool bWarning; 86 com::sun::star::uno::Sequence< OUString > aPropNames; 87 88 public: 89 SvxAlienFilterWarningConfig_Impl(); 90 ~SvxAlienFilterWarningConfig_Impl(); 91 92 virtual void Commit(); 93 94 void ResetWarning() 95 { 96 if(bWarning) 97 { 98 bWarning = sal_False; 99 ConfigItem::SetModified(); 100 } 101 102 } 103 sal_Bool IsWarning()const{return bWarning;} 104 }; 105 // ---------------------------------------------------------------------- 106 SvxAlienFilterWarningConfig_Impl::SvxAlienFilterWarningConfig_Impl() : 107 ConfigItem(C2U("TypeDetection.Misc/Defaults"), 108 CONFIG_MODE_IMMEDIATE_UPDATE), 109 aPropNames(1), 110 bWarning(sal_True) 111 { 112 aPropNames.getArray()[0] = C2U("ShowAlienFilterWarning"); 113 Sequence<Any> aValues = GetProperties(aPropNames); 114 const Any* pValues = aValues.getConstArray(); 115 DBG_ASSERT(aValues.getLength() == aPropNames.getLength(), "GetProperties failed"); 116 if(aValues.getLength() == aPropNames.getLength() && 117 pValues[0].hasValue() && 118 pValues[0].getValueType() == ::getBooleanCppuType()) 119 bWarning = *(sal_Bool*)pValues[0].getValue(); 120 } 121 // ---------------------------------------------------------------------- 122 SvxAlienFilterWarningConfig_Impl::~SvxAlienFilterWarningConfig_Impl() 123 { 124 if(IsModified()) 125 Commit(); 126 } 127 // ---------------------------------------------------------------------- 128 void SvxAlienFilterWarningConfig_Impl::Commit() 129 { 130 Sequence<Any> aValues(aPropNames.getLength()); 131 Any* pValues = aValues.getArray(); 132 pValues[0].setValue(&bWarning, ::getBooleanCppuType()); 133 PutProperties(aPropNames, aValues); 134 } 135 #endif // FILTER_WARNING_ENABLED 136 // ---------------------------------------------------------------------- 137 // ---------------------------------------------------------------------- 138 139 struct SvxSaveTabPage_Impl 140 { 141 Reference< XNameContainer > xFact; 142 Sequence< OUString > aFilterArr[APP_COUNT]; 143 Sequence< sal_Bool > aAlienArr[APP_COUNT]; 144 Sequence< sal_Bool > aODFArr[APP_COUNT]; 145 Sequence< OUString > aUIFilterArr[APP_COUNT]; 146 OUString aDefaultArr[APP_COUNT]; 147 sal_Bool aDefaultReadonlyArr[APP_COUNT]; 148 sal_Bool bInitialized; 149 150 SvxSaveTabPage_Impl(); 151 ~SvxSaveTabPage_Impl(); 152 }; 153 154 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False ) 155 { 156 } 157 158 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl() 159 { 160 } 161 162 // class SvxSaveTabPage -------------------------------------------------- 163 164 SfxSaveTabPage::SfxSaveTabPage( Window* pParent, const SfxItemSet& rCoreSet ) : 165 166 SfxTabPage( pParent, CUI_RES( RID_SFXPAGE_SAVE ), rCoreSet ), 167 168 aLoadFL ( this, CUI_RES( LB_LOAD ) ), 169 aLoadUserSettingsCB ( this, CUI_RES( CB_LOAD_SETTINGS ) ), 170 aLoadDocPrinterCB ( this, CUI_RES( CB_LOAD_DOCPRINTER ) ), 171 172 aSaveFL ( this, CUI_RES( GB_SAVE ) ), 173 aDocInfoCB ( this, CUI_RES( BTN_DOCINFO ) ), 174 aBackupFI ( this, CUI_RES( FI_BACKUP ) ), 175 aBackupCB ( this, CUI_RES( BTN_BACKUP ) ), 176 aAutoSaveCB ( this, CUI_RES( BTN_AUTOSAVE ) ), 177 aAutoSaveEdit ( this, CUI_RES( ED_AUTOSAVE ) ), 178 aMinuteFT ( this, CUI_RES( FT_MINUTE ) ), 179 aRelativeFsysCB ( this, CUI_RES( BTN_RELATIVE_FSYS ) ), 180 aRelativeInetCB ( this, CUI_RES( BTN_RELATIVE_INET ) ), 181 182 aDefaultFormatFL ( this, CUI_RES( FL_FILTER ) ), 183 aODFVersionFT ( this, CUI_RES( FT_ODF_VERSION ) ), 184 aODFVersionLB ( this, CUI_RES( LB_ODF_VERSION ) ), 185 aSizeOptimizationCB ( this, CUI_RES( BTN_NOPRETTYPRINTING ) ), 186 aWarnAlienFormatCB ( this, CUI_RES( BTN_WARNALIENFORMAT ) ), 187 aDocTypeFT ( this, CUI_RES( FT_APP ) ), 188 aDocTypeLB ( this, CUI_RES( LB_APP ) ), 189 aSaveAsFT ( this, CUI_RES( FT_FILTER ) ), 190 aSaveAsFI ( this, CUI_RES( FI_FILTER ) ), 191 aSaveAsLB ( this, CUI_RES( LB_FILTER ) ), 192 aODFWarningFI ( this, CUI_RES( FI_ODF_WARNING ) ), 193 aODFWarningFT ( this, CUI_RES( FT_WARN ) ), 194 195 pImpl ( new SvxSaveTabPage_Impl ) 196 197 { 198 sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 199 aODFWarningFI.SetImage( 200 Image( CUI_RES( bHighContrast ? IMG_ODF_WARNING_HC : IMG_ODF_WARNING ) ) ); 201 202 FreeResource(); 203 204 Link aLink = LINK( this, SfxSaveTabPage, AutoClickHdl_Impl ); 205 aAutoSaveCB.SetClickHdl( aLink ); 206 aAutoSaveEdit.SetMaxTextLen( 2 ); 207 208 SvtModuleOptions aModuleOpt; 209 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) ) 210 { 211 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_MATH )); 212 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_MATH )); 213 } 214 else 215 { 216 pImpl->aDefaultArr[APP_MATH] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH); 217 pImpl->aDefaultReadonlyArr[APP_MATH] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH); 218 } 219 220 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) 221 { 222 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_DRAW )); 223 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_DRAW )); 224 } 225 else 226 { 227 pImpl->aDefaultArr[APP_DRAW] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW); 228 pImpl->aDefaultReadonlyArr[APP_DRAW] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW); 229 } 230 231 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) 232 { 233 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_IMPRESS )); 234 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_IMPRESS )); 235 } 236 else 237 { 238 pImpl->aDefaultArr[APP_IMPRESS] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS); 239 pImpl->aDefaultReadonlyArr[APP_IMPRESS] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS); 240 } 241 242 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) 243 { 244 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_CALC )); 245 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_CALC )); 246 } 247 else 248 { 249 pImpl->aDefaultArr[APP_CALC] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC); 250 pImpl->aDefaultReadonlyArr[APP_CALC] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC); 251 } 252 253 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) 254 { 255 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER )); 256 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_WEB )); 257 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_GLOBAL )); 258 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER )); 259 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_WEB )); 260 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_GLOBAL )); 261 } 262 else 263 { 264 pImpl->aDefaultArr[APP_WRITER] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER); 265 pImpl->aDefaultArr[APP_WRITER_WEB] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB); 266 pImpl->aDefaultArr[APP_WRITER_GLOBAL] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL); 267 pImpl->aDefaultReadonlyArr[APP_WRITER] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER); 268 pImpl->aDefaultReadonlyArr[APP_WRITER_WEB] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB); 269 pImpl->aDefaultReadonlyArr[APP_WRITER_GLOBAL] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL); 270 } 271 272 aLink = LINK( this, SfxSaveTabPage, ODFVersionHdl_Impl ); 273 aODFVersionLB.SetSelectHdl( aLink ); 274 aLink = LINK( this, SfxSaveTabPage, FilterHdl_Impl ); 275 aDocTypeLB.SetSelectHdl( aLink ); 276 aSaveAsLB.SetSelectHdl( aLink ); 277 278 DetectHiddenControls(); 279 } 280 281 // ----------------------------------------------------------------------- 282 283 SfxSaveTabPage::~SfxSaveTabPage() 284 { 285 delete pImpl; 286 } 287 288 // ----------------------------------------------------------------------- 289 290 SfxTabPage* SfxSaveTabPage::Create( Window* pParent, 291 const SfxItemSet& rAttrSet ) 292 { 293 return ( new SfxSaveTabPage( pParent, rAttrSet ) ); 294 } 295 296 // ----------------------------------------------------------------------- 297 bool SfxSaveTabPage::AcceptFilter( sal_uInt16 nPos ) 298 { 299 const OUString* pFilters = pImpl->aFilterArr[nPos].getConstArray(); 300 sal_Bool bAlien = sal_False, bODF = sal_False; 301 OUString* pUIFilters = pImpl->aUIFilterArr[nPos].getArray(); 302 OUString sUIName; 303 for(int nFilter = 0; nFilter < pImpl->aFilterArr[nPos].getLength(); nFilter++) 304 { 305 if( pImpl->aDefaultArr[nPos] == pFilters[nFilter] ) 306 { 307 bAlien = pImpl->aAlienArr[nPos][nFilter]; 308 bODF = pImpl->aODFArr[nPos][nFilter]; 309 sUIName = pUIFilters[nFilter];; 310 break; 311 } 312 } 313 bool bSet = true; 314 return bSet; 315 } 316 // ----------------------------------------------------------------------- 317 void SfxSaveTabPage::DetectHiddenControls() 318 { 319 long nDelta = 0; 320 // the index of the first child window which perhaps have to move upwards 321 sal_uInt16 nWinIndex = WININDEX_SAVEURL_RELFSYS; 322 SvtOptionsDialogOptions aOptionsDlgOpt; 323 324 if ( aOptionsDlgOpt.IsOptionHidden( C2S("Backup"), CFG_PAGE_AND_GROUP ) ) 325 { 326 // hide controls of "Backup" 327 aBackupFI.Hide(); 328 aBackupCB.Hide(); 329 // the other controls have to move upwards the height of checkbox + space 330 nDelta = aAutoSaveCB.GetPosPixel().Y() - aBackupCB.GetPosPixel().Y(); 331 } 332 333 if ( aOptionsDlgOpt.IsOptionHidden( C2S("AutoSave"), CFG_PAGE_AND_GROUP ) ) 334 { 335 // hide controls of "AutoSave" 336 aAutoSaveCB.Hide(); 337 aAutoSaveEdit.Hide(); 338 aMinuteFT.Hide(); 339 // the other controls have to move upwards the height of checkbox + space 340 nDelta += aRelativeFsysCB.GetPosPixel().Y() - aAutoSaveCB.GetPosPixel().Y(); 341 } 342 else if ( nDelta > 0 ) 343 // the "AutoSave" controls have to move upwards too 344 nWinIndex = WININDEX_AUTOSAVE; 345 346 if ( nDelta > 0 ) 347 { 348 sal_uInt16 i, nChildCount = GetChildCount(); 349 for ( i = nWinIndex; i < nChildCount; ++i ) 350 { 351 Window* pWin = GetChild(i); 352 Point aPos = pWin->GetPosPixel(); 353 aPos.Y() -= nDelta; 354 pWin->SetPosPixel( aPos ); 355 } 356 } 357 } 358 // ----------------------------------------------------------------------- 359 sal_Bool SfxSaveTabPage::FillItemSet( SfxItemSet& rSet ) 360 { 361 sal_Bool bModified = sal_False; 362 SvtSaveOptions aSaveOpt; 363 if(aLoadUserSettingsCB.IsChecked() != aLoadUserSettingsCB.GetSavedValue()) 364 { 365 aSaveOpt.SetLoadUserSettings(aLoadUserSettingsCB.IsChecked()); 366 } 367 368 if ( aLoadDocPrinterCB.IsChecked() != aLoadDocPrinterCB.GetSavedValue() ) 369 aSaveOpt.SetLoadDocumentPrinter( aLoadDocPrinterCB.IsChecked() ); 370 371 if ( aODFVersionLB.GetSelectEntryPos() != aODFVersionLB.GetSavedValue() ) 372 { 373 long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) ); 374 aSaveOpt.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion ) ); 375 } 376 377 if ( aDocInfoCB.IsChecked() != aDocInfoCB.GetSavedValue() ) 378 { 379 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO ), 380 aDocInfoCB.IsChecked() ) ); 381 bModified |= sal_True; 382 } 383 384 if ( aBackupCB.IsEnabled() && aBackupCB.IsChecked() != aBackupCB.GetSavedValue() ) 385 { 386 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP ), 387 aBackupCB.IsChecked() ) ); 388 bModified |= sal_True; 389 } 390 391 if ( aSizeOptimizationCB.IsChecked() != aSizeOptimizationCB.GetSavedValue() ) 392 { 393 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING ), !aSizeOptimizationCB.IsChecked() ) ); 394 bModified |= sal_True; 395 } 396 397 if ( aAutoSaveCB.IsChecked() != aAutoSaveCB.GetSavedValue() ) 398 { 399 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE ), 400 aAutoSaveCB.IsChecked() ) ); 401 bModified |= sal_True; 402 } 403 if ( aWarnAlienFormatCB.IsChecked() != aWarnAlienFormatCB.GetSavedValue() ) 404 { 405 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT ), 406 aWarnAlienFormatCB.IsChecked() ) ); 407 bModified |= sal_True; 408 } 409 410 if ( aAutoSaveEdit.GetText() != aAutoSaveEdit.GetSavedValue() ) 411 { 412 rSet.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ), 413 (sal_uInt16)aAutoSaveEdit.GetValue() ) ); 414 bModified |= sal_True; 415 } 416 // relativ speichern 417 if ( aRelativeFsysCB.IsChecked() != aRelativeFsysCB.GetSavedValue() ) 418 { 419 rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS ), 420 aRelativeFsysCB.IsChecked() ) ); 421 bModified |= sal_True; 422 } 423 424 if ( aRelativeInetCB.IsChecked() != aRelativeInetCB.GetSavedValue() ) 425 { 426 rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET ), 427 aRelativeInetCB.IsChecked() ) ); 428 bModified |= sal_True; 429 } 430 431 SvtModuleOptions aModuleOpt; 432 if(pImpl->aDefaultArr[APP_MATH].getLength() && 433 pImpl->aDefaultArr[APP_MATH] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH) && 434 AcceptFilter( APP_MATH )) 435 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH, pImpl->aDefaultArr[APP_MATH]); 436 437 if( pImpl->aDefaultArr[APP_DRAW].getLength() && 438 pImpl->aDefaultArr[APP_DRAW] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW) && 439 AcceptFilter( APP_DRAW )) 440 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW, pImpl->aDefaultArr[APP_DRAW]); 441 442 if(pImpl->aDefaultArr[APP_IMPRESS].getLength() && 443 pImpl->aDefaultArr[APP_IMPRESS] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS)&& 444 AcceptFilter( APP_IMPRESS )) 445 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS, pImpl->aDefaultArr[APP_IMPRESS]); 446 447 if(pImpl->aDefaultArr[APP_CALC].getLength() && 448 pImpl->aDefaultArr[APP_CALC] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC)&& 449 AcceptFilter( APP_CALC )) 450 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC, pImpl->aDefaultArr[APP_CALC]); 451 452 if(pImpl->aDefaultArr[APP_WRITER].getLength() && 453 pImpl->aDefaultArr[APP_WRITER] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER)&& 454 AcceptFilter( APP_WRITER)) 455 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER, pImpl->aDefaultArr[APP_WRITER]); 456 457 if(pImpl->aDefaultArr[APP_WRITER_WEB].getLength() && 458 pImpl->aDefaultArr[APP_WRITER_WEB] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB)&& 459 AcceptFilter( APP_WRITER_WEB )) 460 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB, pImpl->aDefaultArr[APP_WRITER_WEB]); 461 462 if(pImpl->aDefaultArr[APP_WRITER_GLOBAL].getLength() && 463 pImpl->aDefaultArr[APP_WRITER_GLOBAL] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL)&& 464 AcceptFilter( APP_WRITER_GLOBAL )) 465 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL, pImpl->aDefaultArr[APP_WRITER_GLOBAL]); 466 467 return bModified; 468 } 469 470 // ----------------------------------------------------------------------- 471 472 sal_Bool isODFFormat( OUString sFilter ) 473 { 474 static const char* aODFFormats[] = 475 { 476 "writer8", 477 "writer8_template", 478 "writerglobal8", 479 "writerglobal8_writer", 480 "calc8", 481 "calc8_template", 482 "draw8", 483 "draw8_template", 484 "impress8", 485 "impress8_template", 486 "impress8_draw", 487 "chart8", 488 "math8", 489 NULL 490 }; 491 492 sal_Bool bRet = sal_False; 493 int i = 0; 494 while ( aODFFormats[i] != NULL ) 495 { 496 if ( sFilter.equalsAscii( aODFFormats[i++] ) ) 497 { 498 bRet = sal_True; 499 break; 500 } 501 } 502 503 return bRet; 504 } 505 506 void SfxSaveTabPage::Reset( const SfxItemSet& ) 507 { 508 SvtSaveOptions aSaveOpt; 509 aLoadUserSettingsCB.Check(aSaveOpt.IsLoadUserSettings()); 510 aLoadUserSettingsCB.SaveValue(); 511 aLoadDocPrinterCB.Check( aSaveOpt.IsLoadDocumentPrinter() ); 512 aLoadDocPrinterCB.SaveValue(); 513 514 if ( !pImpl->bInitialized ) 515 { 516 try 517 { 518 Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory(); 519 pImpl->xFact = Reference<XNameContainer>( 520 xMSF->createInstance(C2U("com.sun.star.document.FilterFactory")), UNO_QUERY); 521 522 DBG_ASSERT(pImpl->xFact.is(), "service com.sun.star.document.FilterFactory unavailable"); 523 Reference< XContainerQuery > xQuery(pImpl->xFact, UNO_QUERY); 524 if(xQuery.is()) 525 { 526 for(sal_uInt16 n = 0; n < aDocTypeLB.GetEntryCount(); n++) 527 { 528 long nData = (long) aDocTypeLB.GetEntryData(n); 529 OUString sCommand; 530 sCommand = C2U("matchByDocumentService=%1:iflags="); 531 sCommand += String::CreateFromInt32(SFX_FILTER_IMPORT|SFX_FILTER_EXPORT); 532 sCommand += C2U(":eflags="); 533 sCommand += String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG); 534 sCommand += C2U(":default_first"); 535 String sReplace; 536 switch(nData) 537 { 538 case APP_WRITER : sReplace = C2U("com.sun.star.text.TextDocument"); break; 539 case APP_WRITER_WEB : sReplace = C2U("com.sun.star.text.WebDocument"); break; 540 case APP_WRITER_GLOBAL : sReplace = C2U("com.sun.star.text.GlobalDocument"); break; 541 case APP_CALC : sReplace = C2U("com.sun.star.sheet.SpreadsheetDocument");break; 542 case APP_IMPRESS : sReplace = C2U("com.sun.star.presentation.PresentationDocument");break; 543 case APP_DRAW : sReplace = C2U("com.sun.star.drawing.DrawingDocument");break; 544 case APP_MATH : sReplace = C2U("com.sun.star.formula.FormulaProperties");break; 545 default: DBG_ERROR("illegal user data"); 546 } 547 String sTmp(sCommand); 548 sTmp.SearchAndReplaceAscii("%1", sReplace); 549 sCommand = sTmp; 550 Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand); 551 SequenceAsVector< OUString > lList; 552 SequenceAsVector< sal_Bool > lAlienList; 553 SequenceAsVector< sal_Bool > lODFList; 554 while(xList->hasMoreElements()) 555 { 556 SequenceAsHashMap aFilter(xList->nextElement()); 557 OUString sFilter = aFilter.getUnpackedValueOrDefault(OUString::createFromAscii("Name"),OUString()); 558 if (sFilter.getLength()) 559 { 560 sal_Int32 nFlags = aFilter.getUnpackedValueOrDefault(OUString::createFromAscii("Flags"),sal_Int32()); 561 lList.push_back(sFilter); 562 lAlienList.push_back(0 != (nFlags & SFX_FILTER_ALIEN)); 563 lODFList.push_back( isODFFormat( sFilter ) ); 564 } 565 } 566 pImpl->aFilterArr[nData] = lList.getAsConstList(); 567 pImpl->aAlienArr[nData] = lAlienList.getAsConstList(); 568 pImpl->aODFArr[nData] = lODFList.getAsConstList(); 569 } 570 } 571 aDocTypeLB.SelectEntryPos(0); 572 FilterHdl_Impl(&aDocTypeLB); 573 } 574 catch(Exception& e) 575 { 576 (void) e; 577 DBG_ERROR( 578 rtl::OUStringToOString( 579 (rtl::OUString( 580 RTL_CONSTASCII_USTRINGPARAM( 581 "exception in FilterFactory access: ")) + 582 e.Message), 583 RTL_TEXTENCODING_UTF8). 584 getStr()); 585 } 586 587 pImpl->bInitialized = sal_True; 588 } 589 590 aDocInfoCB.Check(aSaveOpt.IsDocInfoSave()); 591 // aDocInfoCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE)); 592 593 aBackupCB.Check(aSaveOpt.IsBackup()); 594 sal_Bool bBackupRO = aSaveOpt.IsReadOnly(SvtSaveOptions::E_BACKUP); 595 aBackupCB.Enable(!bBackupRO); 596 aBackupFI.Show(bBackupRO); 597 598 aAutoSaveCB.Check(aSaveOpt.IsAutoSave()); 599 aWarnAlienFormatCB.Check(aSaveOpt.IsWarnAlienFormat()); 600 aWarnAlienFormatCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT)); 601 // aAutoSaveCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVE)); 602 603 // the pretty printing 604 aSizeOptimizationCB.Check( !aSaveOpt.IsPrettyPrinting()); 605 // aSizeOptimizationCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING )); 606 607 608 aAutoSaveEdit.SetValue( aSaveOpt.GetAutoSaveTime() ); 609 // aAutoSaveEdit.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME)); 610 611 // relativ speichern 612 aRelativeFsysCB.Check( aSaveOpt.IsSaveRelFSys() ); 613 // aRelativeFsysCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS)); 614 615 aRelativeInetCB.Check( aSaveOpt.IsSaveRelINet() ); 616 // aRelativeInetCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELINET)); 617 618 void* pDefaultVersion = (void*)long( aSaveOpt.GetODFDefaultVersion() ); 619 aODFVersionLB.SelectEntryPos( aODFVersionLB.GetEntryPos( pDefaultVersion ) ); 620 621 AutoClickHdl_Impl( &aAutoSaveCB ); 622 ODFVersionHdl_Impl( &aODFVersionLB ); 623 624 aDocInfoCB.SaveValue(); 625 aBackupCB.SaveValue(); 626 aWarnAlienFormatCB.SaveValue(); 627 aSizeOptimizationCB.SaveValue(); 628 aAutoSaveCB.SaveValue(); 629 aAutoSaveEdit.SaveValue(); 630 // aAutoSavePromptBtn.SaveValue(); 631 632 aRelativeFsysCB.SaveValue(); 633 aRelativeInetCB.SaveValue(); 634 aODFVersionLB.SaveValue(); 635 } 636 637 // ----------------------------------------------------------------------- 638 639 IMPL_LINK( SfxSaveTabPage, AutoClickHdl_Impl, CheckBox *, pBox ) 640 { 641 if ( pBox == &aAutoSaveCB ) 642 { 643 if ( aAutoSaveCB.IsChecked() ) 644 { 645 aAutoSaveEdit.Enable(); 646 aMinuteFT.Enable(); 647 // aAutoSavePromptBtn.Enable(); 648 aAutoSaveEdit.GrabFocus(); 649 } 650 else 651 { 652 aAutoSaveEdit.Disable(); 653 aMinuteFT.Disable(); 654 // aAutoSavePromptBtn.Disable(); 655 } 656 } 657 return 0; 658 } 659 /* -----------------------------05.04.01 13:10-------------------------------- 660 661 ---------------------------------------------------------------------------*/ 662 OUString lcl_ExtracUIName(const Sequence<PropertyValue> rProperties) 663 { 664 OUString sRet; 665 sal_Int32 nFlags; 666 const PropertyValue* pProperties = rProperties.getConstArray(); 667 for(int nProp = 0; nProp < rProperties.getLength(); nProp++) 668 { 669 if(!pProperties[nProp].Name.compareToAscii("UIName")) 670 { 671 pProperties[nProp].Value >>= sRet; 672 //! break; 673 } 674 else if(!pProperties[nProp].Name.compareToAscii("Flags")) 675 { 676 if ( pProperties[nProp].Value >>= nFlags ) 677 { 678 nFlags &= 0x100; 679 } 680 } 681 else if(!pProperties[nProp].Name.compareToAscii("Name")) 682 { 683 pProperties[nProp].Value >>= sRet; 684 } 685 } 686 return sRet; 687 } 688 /* -----------------------------05.04.01 13:37-------------------------------- 689 690 ---------------------------------------------------------------------------*/ 691 IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox ) 692 { 693 sal_uInt16 nCurPos = aDocTypeLB.GetSelectEntryPos(); 694 695 long nData = -1; 696 if(nCurPos < APP_COUNT) 697 nData = (long) aDocTypeLB.GetEntryData(nCurPos); 698 699 if ( nData >= 0 && nData < APP_COUNT ) 700 { 701 if(&aDocTypeLB == pBox) 702 { 703 aSaveAsLB.Clear(); 704 const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray(); 705 if(!pImpl->aUIFilterArr[nData].getLength()) 706 { 707 pImpl->aUIFilterArr[nData].realloc(pImpl->aFilterArr[nData].getLength()); 708 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray(); 709 for(int nFilter = 0; nFilter < pImpl->aFilterArr[nData].getLength(); nFilter++) 710 { 711 Any aProps = pImpl->xFact->getByName(pFilters[nFilter]); 712 Sequence<PropertyValue> aProperties; 713 aProps >>= aProperties; 714 pUIFilters[nFilter] = lcl_ExtracUIName(aProperties); 715 } 716 } 717 const OUString* pUIFilters = pImpl->aUIFilterArr[nData].getConstArray(); 718 OUString sSelect; 719 for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++) 720 { 721 sal_uInt16 nEntryPos = aSaveAsLB.InsertEntry(pUIFilters[i]); 722 if ( pImpl->aODFArr[nData][i] ) 723 aSaveAsLB.SetEntryData( nEntryPos, (void*)pImpl ); 724 if(pFilters[i] == pImpl->aDefaultArr[nData]) 725 sSelect = pUIFilters[i]; 726 } 727 if(sSelect.getLength()) 728 aSaveAsLB.SelectEntry(sSelect); 729 aSaveAsFI.Show(pImpl->aDefaultReadonlyArr[nData]); 730 aSaveAsFT.Enable(!pImpl->aDefaultReadonlyArr[nData]); 731 aSaveAsLB.Enable(!pImpl->aDefaultReadonlyArr[nData]); 732 } 733 else 734 { 735 OUString sSelect = pBox->GetSelectEntry(); 736 const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray(); 737 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray(); 738 for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++) 739 if(pUIFilters[i] == sSelect) 740 { 741 sSelect = pFilters[i]; 742 break; 743 } 744 745 pImpl->aDefaultArr[nData] = sSelect; 746 } 747 } 748 749 ODFVersionHdl_Impl( &aSaveAsLB ); 750 return 0; 751 }; 752 753 IMPL_LINK( SfxSaveTabPage, ODFVersionHdl_Impl, ListBox *, EMPTYARG ) 754 { 755 long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) ); 756 bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) != SvtSaveOptions::ODFVER_LATEST; 757 if ( bShown ) 758 { 759 bool bHasODFFormat = false; 760 sal_uInt16 i = 0, nCount = aSaveAsLB.GetEntryCount(); 761 for ( ; i < nCount; ++ i ) 762 { 763 if ( aSaveAsLB.GetEntryData(i) != NULL ) 764 { 765 bHasODFFormat = true; 766 break; 767 } 768 } 769 770 bShown = !bHasODFFormat 771 || ( aSaveAsLB.GetEntryData( aSaveAsLB.GetSelectEntryPos() ) != NULL ); 772 } 773 774 aODFWarningFI.Show( bShown ); 775 aODFWarningFT.Show( bShown ); 776 777 return 0; 778 } 779 780