LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/cui/source/options - optsave.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 327 0.0 %
Date: 2013-07-09 Functions: 0 19 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/shl.hxx>
      21             : #include <svl/eitem.hxx>
      22             : #include <svl/intitem.hxx>
      23             : 
      24             : #include "optsave.hrc"
      25             : #include <cuires.hrc>
      26             : 
      27             : #include "optsave.hxx"
      28             : #include <dialmgr.hxx>
      29             : #include <comphelper/processfactory.hxx>
      30             : #include <unotools/moduleoptions.hxx>
      31             : #include <unotools/saveopt.hxx>
      32             : #include <comphelper/sequenceasvector.hxx>
      33             : #include <comphelper/sequenceashashmap.hxx>
      34             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35             : #include <com/sun/star/container/XNameContainer.hpp>
      36             : #include <com/sun/star/container/XContainerQuery.hpp>
      37             : #include <com/sun/star/container/XEnumeration.hpp>
      38             : #include <com/sun/star/beans/PropertyValue.hpp>
      39             : #include <com/sun/star/util/XFlushable.hpp>
      40             : #include <sfx2/docfilt.hxx>
      41             : #include <svtools/stdctrl.hxx>
      42             : #include <vcl/fixed.hxx>
      43             : #include <unotools/configitem.hxx>
      44             : #include <unotools/optionsdlg.hxx>
      45             : 
      46             : #include <vcl/msgbox.hxx>
      47             : 
      48             : using namespace com::sun::star::uno;
      49             : using namespace com::sun::star::util;
      50             : using namespace com::sun::star::lang;
      51             : using namespace com::sun::star::beans;
      52             : using namespace com::sun::star::container;
      53             : using namespace comphelper;
      54             : 
      55             : #define CFG_PAGE_AND_GROUP          OUString("General"), OUString("LoadSave")
      56             : 
      57             : // ----------------------------------------------------------------------
      58             : 
      59             : struct SvxSaveTabPage_Impl
      60             : {
      61             :     Reference< XNameContainer > xFact;
      62             :     Sequence< OUString >        aFilterArr[APP_COUNT];
      63             :     Sequence< sal_Bool >        aAlienArr[APP_COUNT];
      64             :     Sequence< sal_Bool >        aODFArr[APP_COUNT];
      65             :     Sequence< OUString >        aUIFilterArr[APP_COUNT];
      66             :     OUString                    aDefaultArr[APP_COUNT];
      67             :     sal_Bool                    aDefaultReadonlyArr[APP_COUNT];
      68             :     sal_Bool                    bInitialized;
      69             : 
      70             :     SvxSaveTabPage_Impl();
      71             :     ~SvxSaveTabPage_Impl();
      72             : };
      73             : 
      74           0 : SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False )
      75             : {
      76           0 : }
      77             : 
      78           0 : SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
      79             : {
      80           0 : }
      81             : 
      82             : // class SvxSaveTabPage --------------------------------------------------
      83             : 
      84           0 : SfxSaveTabPage::SfxSaveTabPage( Window* pParent, const SfxItemSet& rCoreSet ) :
      85             :     SfxTabPage( pParent, "OptSavePage", "cui/ui/optsavepage.ui", rCoreSet ),
      86           0 :     pImpl               ( new SvxSaveTabPage_Impl )
      87             : {
      88           0 :     get(aLoadUserSettingsCB, "load_settings");
      89           0 :     get(aLoadDocPrinterCB,  "load_docprinter");
      90             : 
      91           0 :     get(aDocInfoCB, "docinfo");
      92           0 :     get(aBackupCB, "backup");
      93           0 :     get(aAutoSaveCB, "autosave");
      94           0 :     get(aAutoSaveEdit, "autosave_spin");
      95           0 :     get(aMinuteFT, "autosave_mins");
      96           0 :     get(aUserAutoSaveCB, "userautosave");
      97           0 :     get(aRelativeFsysCB, "relative_fsys");
      98           0 :     get(aRelativeInetCB, "relative_inet");
      99             : 
     100           0 :     get(aODFVersionLB, "odfversion");
     101           0 :     get(aSizeOptimizationCB, "sizeoptimization");
     102           0 :     get(aWarnAlienFormatCB, "warnalienformat");
     103           0 :     get(aDocTypeLB, "doctype");
     104           0 :     get(aSaveAsFT, "saveas_label");
     105           0 :     get(aSaveAsLB, "saveas");
     106           0 :     get(aODFWarningFI, "odfwarning_image");
     107           0 :     get(aODFWarningFT, "odfwarning_label");
     108             : 
     109             : 
     110           0 :     aODFVersionLB->SetEntryData(0, (void*)2         ); // 1.0/1.1
     111           0 :     aODFVersionLB->SetEntryData(1, (void*)4         ); // 1.2
     112           0 :     aODFVersionLB->SetEntryData(2, (void*)8         ); // 1.2 Extended (compat mode)
     113           0 :     aODFVersionLB->SetEntryData(3, (void*)0x7fffffff); // 1.2 Extended (recommended)
     114             : 
     115           0 :     aDocTypeLB->SetEntryData(0, (void*)APP_WRITER       );
     116           0 :     aDocTypeLB->SetEntryData(1, (void*)APP_WRITER_WEB   );
     117           0 :     aDocTypeLB->SetEntryData(2, (void*)APP_WRITER_GLOBAL);
     118           0 :     aDocTypeLB->SetEntryData(3, (void*)APP_CALC         );
     119           0 :     aDocTypeLB->SetEntryData(4, (void*)APP_IMPRESS      );
     120           0 :     aDocTypeLB->SetEntryData(5, (void*)APP_DRAW         );
     121           0 :     aDocTypeLB->SetEntryData(6, (void*)APP_MATH         );
     122             : 
     123           0 :     Link aLink = LINK( this, SfxSaveTabPage, AutoClickHdl_Impl );
     124           0 :     aAutoSaveCB->SetClickHdl( aLink );
     125           0 :     aAutoSaveEdit->SetMaxTextLen( 2 );
     126             : 
     127           0 :     SvtModuleOptions aModuleOpt;
     128           0 :     if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
     129             :     {
     130           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_MATH ));
     131           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_MATH ));
     132             :     }
     133             :     else
     134             :     {
     135           0 :         pImpl->aDefaultArr[APP_MATH] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH);
     136           0 :         pImpl->aDefaultReadonlyArr[APP_MATH] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH);
     137             :     }
     138             : 
     139           0 :     if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
     140             :     {
     141           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_DRAW ));
     142           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_DRAW ));
     143             :     }
     144             :     else
     145             :     {
     146           0 :         pImpl->aDefaultArr[APP_DRAW] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW);
     147           0 :         pImpl->aDefaultReadonlyArr[APP_DRAW] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW);
     148             :     }
     149             : 
     150           0 :     if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
     151             :     {
     152           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_IMPRESS ));
     153           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_IMPRESS ));
     154             :     }
     155             :     else
     156             :     {
     157           0 :         pImpl->aDefaultArr[APP_IMPRESS] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS);
     158           0 :         pImpl->aDefaultReadonlyArr[APP_IMPRESS] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS);
     159             :     }
     160             : 
     161           0 :     if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
     162             :     {
     163           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_CALC ));
     164           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_CALC ));
     165             :     }
     166             :     else
     167             :     {
     168           0 :         pImpl->aDefaultArr[APP_CALC] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC);
     169           0 :         pImpl->aDefaultReadonlyArr[APP_CALC] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC);
     170             :     }
     171             : 
     172           0 :     if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
     173             :     {
     174           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_WRITER ));
     175           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_WRITER_WEB ));
     176           0 :         aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_WRITER_GLOBAL ));
     177           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_WRITER ));
     178           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_WRITER_WEB ));
     179           0 :         aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_WRITER_GLOBAL ));
     180             :     }
     181             :     else
     182             :     {
     183           0 :         pImpl->aDefaultArr[APP_WRITER] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER);
     184           0 :         pImpl->aDefaultArr[APP_WRITER_WEB] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB);
     185           0 :         pImpl->aDefaultArr[APP_WRITER_GLOBAL] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL);
     186           0 :         pImpl->aDefaultReadonlyArr[APP_WRITER] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER);
     187           0 :         pImpl->aDefaultReadonlyArr[APP_WRITER_WEB] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB);
     188           0 :         pImpl->aDefaultReadonlyArr[APP_WRITER_GLOBAL] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL);
     189             :     }
     190             : 
     191           0 :     aLink = LINK( this, SfxSaveTabPage, ODFVersionHdl_Impl );
     192           0 :     aODFVersionLB->SetSelectHdl( aLink );
     193           0 :     aLink = LINK( this, SfxSaveTabPage, FilterHdl_Impl );
     194           0 :     aDocTypeLB->SetSelectHdl( aLink );
     195           0 :     aSaveAsLB->SetSelectHdl( aLink );
     196             : 
     197           0 :     DetectHiddenControls();
     198           0 : }
     199             : 
     200             : // -----------------------------------------------------------------------
     201             : 
     202           0 : SfxSaveTabPage::~SfxSaveTabPage()
     203             : {
     204           0 :     delete pImpl;
     205           0 : }
     206             : 
     207             : // -----------------------------------------------------------------------
     208             : 
     209           0 : SfxTabPage* SfxSaveTabPage::Create( Window* pParent,
     210             :                                     const SfxItemSet& rAttrSet )
     211             : {
     212           0 :     return ( new SfxSaveTabPage( pParent, rAttrSet ) );
     213             : }
     214             : 
     215             : // -----------------------------------------------------------------------
     216           0 : void SfxSaveTabPage::DetectHiddenControls()
     217             : {
     218           0 :     SvtOptionsDialogOptions aOptionsDlgOpt;
     219             : 
     220           0 :     if ( aOptionsDlgOpt.IsOptionHidden( "Backup", CFG_PAGE_AND_GROUP ) )
     221             :     {
     222             :         // hide controls of "Backup"
     223           0 :         aBackupCB->Hide();
     224             :     }
     225             : 
     226           0 :     if ( aOptionsDlgOpt.IsOptionHidden( "AutoSave", CFG_PAGE_AND_GROUP ) )
     227             :     {
     228             :         // hide controls of "AutoSave"
     229           0 :         aAutoSaveCB->Hide();
     230           0 :         aAutoSaveEdit->Hide();
     231           0 :         aMinuteFT->Hide();
     232             :     }
     233             : 
     234           0 :     if ( aOptionsDlgOpt.IsOptionHidden( "UserAutoSave", CFG_PAGE_AND_GROUP ) )
     235             :     {
     236             :         // hide controls of "UserAutoSave"
     237           0 :         aUserAutoSaveCB->Hide();
     238           0 :     }
     239             : 
     240           0 : }
     241             : // -----------------------------------------------------------------------
     242           0 : sal_Bool SfxSaveTabPage::FillItemSet( SfxItemSet& rSet )
     243             : {
     244           0 :     sal_Bool bModified = sal_False;
     245           0 :     SvtSaveOptions aSaveOpt;
     246           0 :     if(aLoadUserSettingsCB->IsChecked() != aLoadUserSettingsCB->GetSavedValue())
     247             :     {
     248           0 :         aSaveOpt.SetLoadUserSettings(aLoadUserSettingsCB->IsChecked());
     249             :     }
     250             : 
     251           0 :     if ( aLoadDocPrinterCB->IsChecked() != aLoadDocPrinterCB->GetSavedValue() )
     252           0 :         aSaveOpt.SetLoadDocumentPrinter( aLoadDocPrinterCB->IsChecked() );
     253             : 
     254           0 :     if ( aODFVersionLB->GetSelectEntryPos() != aODFVersionLB->GetSavedValue() )
     255             :     {
     256           0 :         sal_IntPtr nVersion = sal_IntPtr( aODFVersionLB->GetEntryData( aODFVersionLB->GetSelectEntryPos() ) );
     257           0 :         aSaveOpt.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion ) );
     258             :     }
     259             : 
     260           0 :     if ( aDocInfoCB->IsChecked() != aDocInfoCB->GetSavedValue() )
     261             :     {
     262           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO ),
     263           0 :                                aDocInfoCB->IsChecked() ) );
     264           0 :         bModified |= sal_True;
     265             :     }
     266             : 
     267           0 :     if ( aBackupCB->IsEnabled() && aBackupCB->IsChecked() != aBackupCB->GetSavedValue() )
     268             :     {
     269           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP ),
     270           0 :                                aBackupCB->IsChecked() ) );
     271           0 :         bModified |= sal_True;
     272             :     }
     273             : 
     274           0 :     if ( aSizeOptimizationCB->IsChecked() != aSizeOptimizationCB->GetSavedValue() )
     275             :     {
     276           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING ), !aSizeOptimizationCB->IsChecked() ) );
     277           0 :         bModified |= sal_True;
     278             :     }
     279             : 
     280           0 :     if ( aAutoSaveCB->IsChecked() != aAutoSaveCB->GetSavedValue() )
     281             :     {
     282           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE ),
     283           0 :                                aAutoSaveCB->IsChecked() ) );
     284           0 :         bModified |= sal_True;
     285             :     }
     286           0 :     if ( aWarnAlienFormatCB->IsChecked() != aWarnAlienFormatCB->GetSavedValue() )
     287             :     {
     288           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT ),
     289           0 :                                aWarnAlienFormatCB->IsChecked() ) );
     290           0 :         bModified |= sal_True;
     291             :     }
     292             : 
     293           0 :     if ( aAutoSaveEdit->GetText() != aAutoSaveEdit->GetSavedValue() )
     294             :     {
     295           0 :         rSet.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ),
     296           0 :                                  (sal_uInt16)aAutoSaveEdit->GetValue() ) );
     297           0 :         bModified |= sal_True;
     298             :     }
     299             : 
     300           0 :     if ( aUserAutoSaveCB->IsChecked() != aUserAutoSaveCB->GetSavedValue() )
     301             :     {
     302           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_USERAUTOSAVE ),
     303           0 :                                aUserAutoSaveCB->IsChecked() ) );
     304           0 :         bModified |= sal_True;
     305             :     }
     306             :     // save relatively
     307           0 :     if ( aRelativeFsysCB->IsChecked() != aRelativeFsysCB->GetSavedValue() )
     308             :     {
     309           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS ),
     310           0 :                                aRelativeFsysCB->IsChecked() ) );
     311           0 :         bModified |= sal_True;
     312             :     }
     313             : 
     314           0 :     if ( aRelativeInetCB->IsChecked() != aRelativeInetCB->GetSavedValue() )
     315             :     {
     316           0 :         rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET ),
     317           0 :                                aRelativeInetCB->IsChecked() ) );
     318           0 :         bModified |= sal_True;
     319             :     }
     320             : 
     321           0 :     SvtModuleOptions aModuleOpt;
     322           0 :     if(!pImpl->aDefaultArr[APP_MATH].isEmpty() &&
     323           0 :             pImpl->aDefaultArr[APP_MATH] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH))
     324           0 :         aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH, pImpl->aDefaultArr[APP_MATH]);
     325             : 
     326           0 :     if( !pImpl->aDefaultArr[APP_DRAW].isEmpty() &&
     327           0 :             pImpl->aDefaultArr[APP_DRAW] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW))
     328           0 :             aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW, pImpl->aDefaultArr[APP_DRAW]);
     329             : 
     330           0 :     if(!pImpl->aDefaultArr[APP_IMPRESS].isEmpty() &&
     331           0 :             pImpl->aDefaultArr[APP_IMPRESS] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS))
     332           0 :         aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS, pImpl->aDefaultArr[APP_IMPRESS]);
     333             : 
     334           0 :     if(!pImpl->aDefaultArr[APP_CALC].isEmpty() &&
     335           0 :             pImpl->aDefaultArr[APP_CALC] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC))
     336           0 :         aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC, pImpl->aDefaultArr[APP_CALC]);
     337             : 
     338           0 :     if(!pImpl->aDefaultArr[APP_WRITER].isEmpty() &&
     339           0 :             pImpl->aDefaultArr[APP_WRITER] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER))
     340           0 :         aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER, pImpl->aDefaultArr[APP_WRITER]);
     341             : 
     342           0 :     if(!pImpl->aDefaultArr[APP_WRITER_WEB].isEmpty() &&
     343           0 :             pImpl->aDefaultArr[APP_WRITER_WEB] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB))
     344           0 :         aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB, pImpl->aDefaultArr[APP_WRITER_WEB]);
     345             : 
     346           0 :     if(!pImpl->aDefaultArr[APP_WRITER_GLOBAL].isEmpty() &&
     347           0 :             pImpl->aDefaultArr[APP_WRITER_GLOBAL] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL))
     348           0 :         aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL, pImpl->aDefaultArr[APP_WRITER_GLOBAL]);
     349             : 
     350           0 :     return bModified;
     351             : }
     352             : 
     353             : // -----------------------------------------------------------------------
     354             : 
     355           0 : sal_Bool isODFFormat( OUString sFilter )
     356             : {
     357             :     static const char* aODFFormats[] =
     358             :     {
     359             :         "writer8",
     360             :         "writer8_template",
     361             :         "writerglobal8",
     362             :         "writerglobal8_writer",
     363             :         "calc8",
     364             :         "calc8_template",
     365             :         "draw8",
     366             :         "draw8_template",
     367             :         "impress8",
     368             :         "impress8_template",
     369             :         "impress8_draw",
     370             :         "chart8",
     371             :         "math8",
     372             :         NULL
     373             :     };
     374             : 
     375           0 :     sal_Bool bRet = sal_False;
     376           0 :     int i = 0;
     377           0 :     while ( aODFFormats[i] != NULL )
     378             :     {
     379           0 :         if ( sFilter.equalsAscii( aODFFormats[i++] ) )
     380             :         {
     381           0 :             bRet = sal_True;
     382           0 :             break;
     383             :         }
     384             :     }
     385             : 
     386           0 :     return bRet;
     387             : }
     388             : 
     389           0 : void SfxSaveTabPage::Reset( const SfxItemSet& )
     390             : {
     391           0 :     SvtSaveOptions aSaveOpt;
     392           0 :     aLoadUserSettingsCB->Check(aSaveOpt.IsLoadUserSettings());
     393           0 :     aLoadUserSettingsCB->SaveValue();
     394           0 :     aLoadDocPrinterCB->Check( aSaveOpt.IsLoadDocumentPrinter() );
     395           0 :     aLoadDocPrinterCB->SaveValue();
     396             : 
     397           0 :     if ( !pImpl->bInitialized )
     398             :     {
     399             :         try
     400             :         {
     401           0 :             Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
     402           0 :             pImpl->xFact = Reference<XNameContainer>(
     403           0 :                     xMSF->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY);
     404             : 
     405             :             DBG_ASSERT(pImpl->xFact.is(), "service com.sun.star.document.FilterFactory unavailable");
     406           0 :             Reference< XContainerQuery > xQuery(pImpl->xFact, UNO_QUERY);
     407           0 :             if(xQuery.is())
     408             :             {
     409           0 :                 for(sal_uInt16 n = 0; n < aDocTypeLB->GetEntryCount(); n++)
     410             :                 {
     411           0 :                     sal_IntPtr nData = (sal_IntPtr) aDocTypeLB->GetEntryData(n);
     412           0 :                     OUString sCommand;
     413           0 :                     sCommand = "matchByDocumentService=%1:iflags=" +
     414           0 :                                OUString::number(SFX_FILTER_IMPORT|SFX_FILTER_EXPORT) +
     415           0 :                                ":eflags=" +
     416           0 :                                OUString::number(SFX_FILTER_NOTINFILEDLG) +
     417           0 :                                ":default_first";
     418           0 :                     OUString sReplace;
     419           0 :                     switch(nData)
     420             :                     {
     421           0 :                         case  APP_WRITER        : sReplace = "com.sun.star.text.TextDocument";  break;
     422           0 :                         case  APP_WRITER_WEB    : sReplace = "com.sun.star.text.WebDocument";   break;
     423           0 :                         case  APP_WRITER_GLOBAL : sReplace = "com.sun.star.text.GlobalDocument";   break;
     424           0 :                         case  APP_CALC          : sReplace = "com.sun.star.sheet.SpreadsheetDocument";break;
     425           0 :                         case  APP_IMPRESS       : sReplace = "com.sun.star.presentation.PresentationDocument";break;
     426           0 :                         case  APP_DRAW          : sReplace = "com.sun.star.drawing.DrawingDocument";break;
     427           0 :                         case  APP_MATH          : sReplace = "com.sun.star.formula.FormulaProperties";break;
     428             :                         default: OSL_FAIL("illegal user data");
     429             :                     }
     430           0 :                     OUString sTmp = sCommand.replaceFirst("%1", sReplace);
     431           0 :                     sCommand = sTmp;
     432           0 :                     Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
     433           0 :                     SequenceAsVector< OUString > lList;
     434           0 :                     SequenceAsVector< sal_Bool > lAlienList;
     435           0 :                     SequenceAsVector< sal_Bool > lODFList;
     436           0 :                     while(xList->hasMoreElements())
     437             :                     {
     438           0 :                         SequenceAsHashMap aFilter(xList->nextElement());
     439           0 :                         OUString sFilter = aFilter.getUnpackedValueOrDefault("Name",OUString());
     440           0 :                         if (!sFilter.isEmpty())
     441             :                         {
     442           0 :                             sal_Int32 nFlags = aFilter.getUnpackedValueOrDefault("Flags",sal_Int32());
     443           0 :                             lList.push_back(sFilter);
     444           0 :                             lAlienList.push_back(0 != (nFlags & SFX_FILTER_ALIEN));
     445           0 :                             lODFList.push_back( isODFFormat( sFilter ) );
     446             :                         }
     447           0 :                     }
     448           0 :                     pImpl->aFilterArr[nData] = lList.getAsConstList();
     449           0 :                     pImpl->aAlienArr[nData] = lAlienList.getAsConstList();
     450           0 :                     pImpl->aODFArr[nData] = lODFList.getAsConstList();
     451           0 :                 }
     452             :             }
     453           0 :             aDocTypeLB->SelectEntryPos(0);
     454           0 :             FilterHdl_Impl(aDocTypeLB);
     455             :         }
     456           0 :         catch(Exception& e)
     457             :         {
     458             :             (void) e;
     459             :             OSL_FAIL(
     460             :                 OUStringToOString(
     461             :                     (OUString(
     462             :                             "exception in FilterFactory access: ") +
     463             :                      e.Message),
     464             :                     RTL_TEXTENCODING_UTF8).
     465             :                 getStr());
     466             :         }
     467             : 
     468           0 :         pImpl->bInitialized = sal_True;
     469             :     }
     470             : 
     471           0 :     aDocInfoCB->Check(aSaveOpt.IsDocInfoSave());
     472             : 
     473           0 :     aBackupCB->Check(aSaveOpt.IsBackup());
     474           0 :     sal_Bool bBackupRO = aSaveOpt.IsReadOnly(SvtSaveOptions::E_BACKUP);
     475           0 :     aBackupCB->Enable(!bBackupRO);
     476             : 
     477           0 :     aAutoSaveCB->Check(aSaveOpt.IsAutoSave());
     478           0 :     aUserAutoSaveCB->Check(aSaveOpt.IsUserAutoSave());
     479           0 :     aWarnAlienFormatCB->Check(aSaveOpt.IsWarnAlienFormat());
     480           0 :     aWarnAlienFormatCB->Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT));
     481             : 
     482             :     // the pretty printing
     483           0 :     aSizeOptimizationCB->Check( !aSaveOpt.IsPrettyPrinting());
     484             : 
     485           0 :     aAutoSaveEdit->SetValue( aSaveOpt.GetAutoSaveTime() );
     486             : 
     487             :     // save relatively
     488           0 :     aRelativeFsysCB->Check( aSaveOpt.IsSaveRelFSys() );
     489             : 
     490           0 :     aRelativeInetCB->Check( aSaveOpt.IsSaveRelINet() );
     491             : 
     492           0 :     void* pDefaultVersion = (void*)sal_IntPtr( aSaveOpt.GetODFDefaultVersion() );
     493           0 :     aODFVersionLB->SelectEntryPos( aODFVersionLB->GetEntryPos( pDefaultVersion ) );
     494             : 
     495           0 :     AutoClickHdl_Impl( aAutoSaveCB );
     496           0 :     ODFVersionHdl_Impl( aODFVersionLB );
     497             : 
     498           0 :     aDocInfoCB->SaveValue();
     499           0 :     aBackupCB->SaveValue();
     500           0 :     aWarnAlienFormatCB->SaveValue();
     501           0 :     aSizeOptimizationCB->SaveValue();
     502           0 :     aAutoSaveCB->SaveValue();
     503           0 :     aAutoSaveEdit->SaveValue();
     504             : 
     505           0 :     aUserAutoSaveCB->SaveValue();
     506             : 
     507           0 :     aRelativeFsysCB->SaveValue();
     508           0 :     aRelativeInetCB->SaveValue();
     509           0 :     aODFVersionLB->SaveValue();
     510           0 : }
     511             : 
     512             : // -----------------------------------------------------------------------
     513             : 
     514           0 : IMPL_LINK( SfxSaveTabPage, AutoClickHdl_Impl, CheckBox *, pBox )
     515             : {
     516           0 :     if ( pBox == aAutoSaveCB )
     517             :     {
     518           0 :         if ( aAutoSaveCB->IsChecked() )
     519             :         {
     520           0 :             aAutoSaveEdit->Enable();
     521           0 :             aMinuteFT->Enable();
     522           0 :             aUserAutoSaveCB->Enable();
     523             :         }
     524             :         else
     525             :         {
     526           0 :             aAutoSaveEdit->Disable();
     527           0 :             aMinuteFT->Disable();
     528           0 :             aUserAutoSaveCB->Disable();
     529             :         }
     530             :     }
     531           0 :     return 0;
     532             : }
     533             : 
     534           0 : static OUString lcl_ExtracUIName(const Sequence<PropertyValue> rProperties)
     535             : {
     536           0 :     OUString sRet;
     537           0 :     const PropertyValue* pProperties = rProperties.getConstArray();
     538           0 :     for(int nProp = 0; nProp < rProperties.getLength(); nProp++)
     539             :     {
     540           0 :         if(!pProperties[nProp].Name.compareToAscii("UIName"))
     541             :         {
     542           0 :             pProperties[nProp].Value >>= sRet;
     543           0 :             break;
     544             :         }
     545           0 :         else if(!pProperties[nProp].Name.compareToAscii("Name"))
     546             :         {
     547           0 :             pProperties[nProp].Value >>= sRet;
     548             :         }
     549             :     }
     550           0 :     return sRet;
     551             : }
     552             : 
     553           0 : IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox )
     554             : {
     555           0 :     sal_uInt16 nCurPos = aDocTypeLB->GetSelectEntryPos();
     556             : 
     557           0 :     sal_IntPtr nData = -1;
     558           0 :     if(nCurPos < APP_COUNT)
     559           0 :         nData = (sal_IntPtr) aDocTypeLB->GetEntryData(nCurPos);
     560             : 
     561           0 :     if ( nData >= 0 && nData < APP_COUNT )
     562             :     {
     563           0 :         if(aDocTypeLB == pBox)
     564             :         {
     565           0 :             aSaveAsLB->Clear();
     566           0 :             const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
     567           0 :             if(!pImpl->aUIFilterArr[nData].getLength())
     568             :             {
     569           0 :                 pImpl->aUIFilterArr[nData].realloc(pImpl->aFilterArr[nData].getLength());
     570           0 :                 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
     571           0 :                 for(int nFilter = 0; nFilter < pImpl->aFilterArr[nData].getLength(); nFilter++)
     572             :                 {
     573           0 :                     Any aProps = pImpl->xFact->getByName(pFilters[nFilter]);
     574           0 :                     Sequence<PropertyValue> aProperties;
     575           0 :                     aProps >>= aProperties;
     576           0 :                     pUIFilters[nFilter] = lcl_ExtracUIName(aProperties);
     577           0 :                 }
     578             :             }
     579           0 :             const OUString* pUIFilters = pImpl->aUIFilterArr[nData].getConstArray();
     580           0 :             OUString sSelect;
     581           0 :             for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
     582             :             {
     583           0 :                 sal_uInt16 nEntryPos = aSaveAsLB->InsertEntry(pUIFilters[i]);
     584           0 :                 if ( pImpl->aODFArr[nData][i] )
     585           0 :                     aSaveAsLB->SetEntryData( nEntryPos, (void*)pImpl );
     586           0 :                 if(pFilters[i] == pImpl->aDefaultArr[nData])
     587           0 :                     sSelect = pUIFilters[i];
     588             :             }
     589           0 :             if(!sSelect.isEmpty())
     590             :             {
     591           0 :                 aSaveAsLB->SelectEntry(sSelect);
     592             :             }
     593             : 
     594           0 :             aSaveAsFT->Enable(!pImpl->aDefaultReadonlyArr[nData]);
     595           0 :             aSaveAsLB->Enable(!pImpl->aDefaultReadonlyArr[nData]);
     596             :         }
     597             :         else
     598             :         {
     599           0 :             OUString sSelect = pBox->GetSelectEntry();
     600           0 :             const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
     601           0 :             OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
     602           0 :             for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
     603           0 :                 if(pUIFilters[i] == sSelect)
     604             :                 {
     605           0 :                     sSelect = pFilters[i];
     606           0 :                     break;
     607             :                 }
     608             : 
     609           0 :             pImpl->aDefaultArr[nData] = sSelect;
     610             :         }
     611             :     }
     612             : 
     613           0 :     ODFVersionHdl_Impl( aSaveAsLB );
     614           0 :     return 0;
     615             : };
     616             : 
     617           0 : IMPL_LINK_NOARG(SfxSaveTabPage, ODFVersionHdl_Impl)
     618             : {
     619           0 :     sal_IntPtr nVersion = sal_IntPtr( aODFVersionLB->GetEntryData( aODFVersionLB->GetSelectEntryPos() ) );
     620           0 :     bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) != SvtSaveOptions::ODFVER_LATEST;
     621           0 :     if ( bShown )
     622             :     {
     623           0 :         bool bHasODFFormat = false;
     624           0 :         sal_uInt16 i = 0, nCount = aSaveAsLB->GetEntryCount();
     625           0 :         for ( ; i < nCount; ++ i )
     626             :         {
     627           0 :             if ( aSaveAsLB->GetEntryData(i) != NULL )
     628             :             {
     629           0 :                 bHasODFFormat = true;
     630           0 :                 break;
     631             :             }
     632             :         }
     633             : 
     634           0 :         bShown = !bHasODFFormat
     635           0 :                 || ( aSaveAsLB->GetEntryData( aSaveAsLB->GetSelectEntryPos() ) != NULL );
     636             :     }
     637             : 
     638           0 :     aODFWarningFI->Show( bShown );
     639           0 :     aODFWarningFT->Show( bShown );
     640             : 
     641           0 :     return 0;
     642           0 : }
     643             : 
     644             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10