LCOV - code coverage report
Current view: top level - sw/source/ui/config - optcomp.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 265 0.0 %
Date: 2014-04-11 Functions: 0 22 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 "optcomp.hxx"
      21             : 
      22             : #include "docsh.hxx"
      23             : #include "swmodule.hxx"
      24             : #include "swtypes.hxx"
      25             : #include "uiitems.hxx"
      26             : #include "view.hxx"
      27             : #include "wrtsh.hxx"
      28             : 
      29             : #include "globals.hrc"
      30             : #include <unotools/configmgr.hxx>
      31             : #include <vcl/layout.hxx>
      32             : #include <sfx2/docfile.hxx>
      33             : #include <sfx2/docfilt.hxx>
      34             : #include <sfx2/fcontnr.hxx>
      35             : #include "svtools/treelistentry.hxx"
      36             : #include <IDocumentSettingAccess.hxx>
      37             : 
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::document;
      40             : using namespace ::com::sun::star::uno;
      41             : using namespace ::std;
      42             : 
      43             : #define DEFAULT_ENTRY       COMPATIBILITY_DEFAULT_NAME
      44             : #define USER_ENTRY          "_user"
      45             : 
      46             : // struct CompatibilityItem ----------------------------------------------
      47             : 
      48           0 : struct CompatibilityItem
      49             : {
      50             :     OUString    m_sName;
      51             :     OUString    m_sModule;
      52             :     bool        m_bUsePrtMetrics;
      53             :     bool        m_bAddSpacing;
      54             :     bool        m_bAddSpacingAtPages;
      55             :     bool        m_bUseOurTabStops;
      56             :     bool        m_bNoExtLeading;
      57             :     bool        m_bUseLineSpacing;
      58             :     bool        m_bAddTableSpacing;
      59             :     bool        m_bUseObjPos;
      60             :     bool        m_bUseOurTextWrapping;
      61             :     bool        m_bConsiderWrappingStyle;
      62             :     bool        m_bExpandWordSpace;
      63             :     bool        m_bIsDefault;
      64             :     bool        m_bIsUser;
      65             : 
      66           0 :     CompatibilityItem( const OUString& _rName, const OUString& _rModule,
      67             :                        bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages,
      68             :                        bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing,
      69             :                        bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping,
      70             :                        bool _bConsiderWrappingStyle, bool _bExpandWordSpace,
      71             :                        bool _bIsDefault, bool _bIsUser ) :
      72             : 
      73             :         m_sName                 ( _rName ),
      74             :         m_sModule               ( _rModule ),
      75             :         m_bUsePrtMetrics        ( _bUsePrtMetrics ),
      76             :         m_bAddSpacing           ( _bAddSpacing ),
      77             :         m_bAddSpacingAtPages    ( _bAddSpacingAtPages ),
      78             :         m_bUseOurTabStops       ( _bUseOurTabStops ),
      79             :         m_bNoExtLeading         ( _bNoExtLeading ),
      80             :         m_bUseLineSpacing       ( _bUseLineSpacing ),
      81             :         m_bAddTableSpacing      ( _bAddTableSpacing ),
      82             :         m_bUseObjPos            ( _bUseObjPos ),
      83             :         m_bUseOurTextWrapping   ( _bUseOurTextWrapping ),
      84             :         m_bConsiderWrappingStyle( _bConsiderWrappingStyle ),
      85             :         m_bExpandWordSpace      ( _bExpandWordSpace ),
      86             :         m_bIsDefault            ( _bIsDefault ),
      87           0 :         m_bIsUser               ( _bIsUser ) {}
      88             : };
      89             : 
      90             : #include <vector>
      91             : 
      92           0 : struct SwCompatibilityOptPage_Impl
      93             : {
      94             :     typedef vector< CompatibilityItem > SwCompatibilityItemList;
      95             : 
      96             :     SwCompatibilityItemList     m_aList;
      97             : };
      98             : 
      99             : // class SwCompatibilityOptPage ------------------------------------------
     100             : 
     101           0 : SwCompatibilityOptPage::SwCompatibilityOptPage(Window* pParent, const SfxItemSet& rSet)
     102             :     : SfxTabPage(pParent, "OptCompatPage",
     103             :         "modules/swriter/ui/optcompatpage.ui", rSet)
     104             :     , m_pWrtShell(NULL)
     105           0 :     , m_pImpl(new SwCompatibilityOptPage_Impl)
     106           0 :     , m_nSavedOptions(0)
     107             : {
     108           0 :     get(m_pMain, "compatframe");
     109           0 :     get(m_pFormattingLB, "format");
     110           0 :     get(m_pOptionsLB, "options");
     111           0 :     get(m_pDefaultPB, "default");
     112             : 
     113           0 :     for (sal_uInt16 nId = COPT_USE_PRINTERDEVICE; nId <= COPT_EXPAND_WORDSPACE; ++nId)
     114             :     {
     115           0 :         OUString sEntry = m_pFormattingLB->GetEntry(nId);
     116           0 :         SvTreeListEntry* pEntry = m_pOptionsLB->SvTreeListBox::InsertEntry( sEntry );
     117           0 :         if ( pEntry )
     118             :         {
     119           0 :             m_pOptionsLB->SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
     120             :         }
     121           0 :     }
     122           0 :     m_sUserEntry = m_pFormattingLB->GetEntry(m_pFormattingLB->GetEntryCount()-1);
     123             : 
     124           0 :     m_pFormattingLB->Clear();
     125             : 
     126           0 :     m_pOptionsLB->SetStyle( m_pOptionsLB->GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
     127           0 :     m_pOptionsLB->SetHighlightRange();
     128             : 
     129           0 :     InitControls( rSet );
     130             : 
     131             :     // set handler
     132           0 :     m_pFormattingLB->SetSelectHdl( LINK( this, SwCompatibilityOptPage, SelectHdl ) );
     133           0 :     m_pDefaultPB->SetClickHdl( LINK( this, SwCompatibilityOptPage, UseAsDefaultHdl ) );
     134           0 : }
     135             : 
     136           0 : SwCompatibilityOptPage::~SwCompatibilityOptPage()
     137             : {
     138           0 :     delete m_pImpl;
     139           0 : }
     140             : 
     141           0 : sal_uLong convertBools2Ulong_Impl
     142             : (
     143             :     bool _bUsePrtMetrics,
     144             :     bool _bAddSpacing,
     145             :     bool _bAddSpacingAtPages,
     146             :     bool _bUseOurTabStops,
     147             :     bool _bNoExtLeading,
     148             :     bool _bUseLineSpacing,
     149             :     bool _bAddTableSpacing,
     150             :     bool _bUseObjPos,
     151             :     bool _bUseOurTextWrapping,
     152             :     bool _bConsiderWrappingStyle,
     153             :     bool _bExpandWordSpace
     154             : )
     155             : {
     156           0 :     sal_uLong nRet = 0;
     157           0 :     sal_uLong nSetBit = 1;
     158             : 
     159           0 :     if ( _bUsePrtMetrics )
     160           0 :         nRet |= nSetBit;
     161           0 :     nSetBit = nSetBit << 1;
     162           0 :     if ( _bAddSpacing )
     163           0 :         nRet |= nSetBit;
     164           0 :     nSetBit = nSetBit << 1;
     165           0 :     if ( _bAddSpacingAtPages )
     166           0 :         nRet |= nSetBit;
     167           0 :     nSetBit = nSetBit << 1;
     168           0 :     if ( _bUseOurTabStops )
     169           0 :         nRet |= nSetBit;
     170           0 :     nSetBit = nSetBit << 1;
     171           0 :     if ( _bNoExtLeading )
     172           0 :         nRet |= nSetBit;
     173           0 :     nSetBit = nSetBit << 1;
     174           0 :     if ( _bUseLineSpacing )
     175           0 :         nRet |= nSetBit;
     176           0 :     nSetBit = nSetBit << 1;
     177           0 :     if ( _bAddTableSpacing )
     178           0 :         nRet |= nSetBit;
     179           0 :     nSetBit = nSetBit << 1;
     180           0 :     if ( _bUseObjPos )
     181           0 :         nRet |= nSetBit;
     182           0 :     nSetBit = nSetBit << 1;
     183           0 :     if ( _bUseOurTextWrapping )
     184           0 :         nRet |= nSetBit;
     185           0 :     nSetBit = nSetBit << 1;
     186           0 :     if ( _bConsiderWrappingStyle )
     187           0 :         nRet |= nSetBit;
     188           0 :     nSetBit = nSetBit << 1;
     189           0 :     if ( _bExpandWordSpace )
     190           0 :         nRet |= nSetBit;
     191             : 
     192           0 :     return nRet;
     193             : }
     194             : 
     195           0 : void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
     196             : {
     197             :     // init objectshell and detect document name
     198           0 :     OUString sDocTitle;
     199           0 :     const SfxPoolItem* pItem = NULL;
     200           0 :     SfxObjectShell* pObjShell = NULL;
     201           0 :     if ( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_WRTSHELL, false, &pItem ) )
     202           0 :         m_pWrtShell = (SwWrtShell*)( (const SwPtrItem*)pItem )->GetValue();
     203           0 :     if ( m_pWrtShell )
     204             :     {
     205           0 :         pObjShell = m_pWrtShell->GetView().GetDocShell();
     206           0 :         if ( pObjShell )
     207           0 :             sDocTitle = pObjShell->GetTitle( SFX_TITLE_TITLE );
     208             :     }
     209             :     else
     210             :     {
     211           0 :         m_pMain->Disable();
     212             :     }
     213           0 :     const OUString& rText = m_pMain->get_label();
     214           0 :     m_pMain->set_label(rText.replaceAll("%DOCNAME", sDocTitle));
     215             : 
     216             :     // loading file formats
     217           0 :     Sequence< Sequence< PropertyValue > > aList = m_aConfigItem.GetList();
     218           0 :     OUString sName;
     219           0 :     OUString sModule;
     220           0 :     bool bUsePrtMetrics = false;
     221           0 :     bool bAddSpacing = false;
     222           0 :     bool bAddSpacingAtPages = false;
     223           0 :     bool bUseOurTabStops = false;
     224           0 :     bool bNoExtLeading = false;
     225           0 :     bool bUseLineSpacing = false;
     226           0 :     bool bAddTableSpacing = false;
     227           0 :     bool bUseObjPos = false;
     228           0 :     bool bUseOurTextWrapping = false;
     229           0 :     bool bConsiderWrappingStyle = false;
     230           0 :     bool bExpandWordSpace = false;
     231           0 :     const sal_Int32 nCount = aList.getLength();
     232           0 :     for ( sal_Int32 i = 0; i < nCount; ++i )
     233             :     {
     234           0 :         const Sequence< PropertyValue >& rEntry = aList[i];
     235           0 :         const sal_Int32 nEntries = rEntry.getLength();
     236           0 :         for ( sal_Int32 j = 0; j < nEntries; j++ )
     237             :         {
     238           0 :             PropertyValue aValue = rEntry[j];
     239           0 :             if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NAME )
     240           0 :                 aValue.Value >>= sName;
     241           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_MODULE )
     242           0 :                 aValue.Value >>= sModule;
     243           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS )
     244           0 :                 aValue.Value >>= bUsePrtMetrics;
     245           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACING )
     246           0 :                 aValue.Value >>= bAddSpacing;
     247           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES )
     248           0 :                 aValue.Value >>= bAddSpacingAtPages;
     249           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS )
     250           0 :                 aValue.Value >>= bUseOurTabStops;
     251           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NOEXTLEADING )
     252           0 :                 aValue.Value >>= bNoExtLeading;
     253           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USELINESPACING )
     254           0 :                 aValue.Value >>= bUseLineSpacing;
     255           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING )
     256           0 :                 aValue.Value >>= bAddTableSpacing;
     257           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING )
     258           0 :                 aValue.Value >>= bUseObjPos;
     259           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING )
     260           0 :                 aValue.Value >>= bUseOurTextWrapping;
     261           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE )
     262           0 :                 aValue.Value >>= bConsiderWrappingStyle;
     263           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
     264           0 :                 aValue.Value >>= bExpandWordSpace;
     265           0 :         }
     266             : 
     267             :         CompatibilityItem aItem(
     268             :             sName, sModule, bUsePrtMetrics, bAddSpacing,
     269             :             bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
     270             :             bUseLineSpacing, bAddTableSpacing, bUseObjPos,
     271             :             bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace,
     272           0 :             sName.equals( DEFAULT_ENTRY ),
     273           0 :             sName.equals( USER_ENTRY ) );
     274           0 :         m_pImpl->m_aList.push_back( aItem );
     275             : 
     276           0 :         if ( aItem.m_bIsDefault )
     277           0 :             continue;
     278             : 
     279           0 :         OUString sNewEntry;
     280           0 :         if ( sName.equals( USER_ENTRY ) )
     281           0 :             sNewEntry = m_sUserEntry;
     282           0 :         else if ( pObjShell && !sName.isEmpty() )
     283             :         {
     284           0 :             SfxFilterContainer* pFacCont = pObjShell->GetFactory().GetFilterContainer();
     285           0 :             const SfxFilter* pFilter = pFacCont->GetFilter4FilterName( sName );
     286           0 :             if ( pFilter )
     287           0 :                 sNewEntry = pFilter->GetUIName();
     288             :         }
     289             : 
     290           0 :         if ( sNewEntry.isEmpty() )
     291           0 :             sNewEntry = sName;
     292             : 
     293           0 :         sal_uInt16 nPos = m_pFormattingLB->InsertEntry( sNewEntry );
     294             :         sal_uLong nOptions = convertBools2Ulong_Impl(
     295             :             bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages,
     296             :             bUseOurTabStops, bNoExtLeading, bUseLineSpacing,
     297             :             bAddTableSpacing, bUseObjPos, bUseOurTextWrapping,
     298           0 :             bConsiderWrappingStyle, bExpandWordSpace );
     299           0 :         m_pFormattingLB->SetEntryData( nPos, (void*)(sal_IntPtr)nOptions );
     300           0 :     }
     301             : 
     302           0 :     m_pFormattingLB->SetDropDownLineCount( m_pFormattingLB->GetEntryCount() );
     303           0 : }
     304             : 
     305           0 : IMPL_LINK_NOARG(SwCompatibilityOptPage, SelectHdl)
     306             : {
     307           0 :     sal_uInt16 nPos = m_pFormattingLB->GetSelectEntryPos();
     308           0 :     sal_uLong nOptions = (sal_uLong)(void*)m_pFormattingLB->GetEntryData( nPos );
     309           0 :     SetCurrentOptions( nOptions );
     310             : 
     311           0 :     return 0;
     312             : }
     313             : 
     314           0 : IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl)
     315             : {
     316             :     MessageDialog aQuery(this, "QueryDefaultCompatDialog",
     317           0 :         "modules/swriter/ui/querydefaultcompatdialog.ui");
     318           0 :     if (aQuery.Execute() == RET_YES)
     319             :     {
     320           0 :         for ( vector< CompatibilityItem >::iterator pItem = m_pImpl->m_aList.begin();
     321           0 :               pItem != m_pImpl->m_aList.end(); ++pItem )
     322             :         {
     323           0 :             if ( pItem->m_bIsDefault )
     324             :             {
     325           0 :                 sal_uInt16 nCount = static_cast< sal_uInt16 >( m_pOptionsLB->GetEntryCount() );
     326           0 :                 for ( sal_uInt16 i = 0; i < nCount; ++i )
     327             :                 {
     328           0 :                     bool bChecked = m_pOptionsLB->IsChecked(i);
     329           0 :                     CompatibilityOptions eOption = static_cast< CompatibilityOptions >(i);
     330           0 :                     switch ( eOption )
     331             :                     {
     332           0 :                         case COPT_USE_PRINTERDEVICE : pItem->m_bUsePrtMetrics = bChecked; break;
     333           0 :                         case COPT_ADD_SPACING : pItem->m_bAddSpacing = bChecked; break;
     334           0 :                         case COPT_ADD_SPACING_AT_PAGES : pItem->m_bAddSpacingAtPages = bChecked; break;
     335           0 :                         case COPT_USE_OUR_TABSTOPS : pItem->m_bUseOurTabStops = bChecked; break;
     336           0 :                         case COPT_NO_EXTLEADING : pItem->m_bNoExtLeading = bChecked; break;
     337           0 :                         case COPT_USE_LINESPACING : pItem->m_bUseLineSpacing = bChecked; break;
     338           0 :                         case COPT_ADD_TABLESPACING : pItem->m_bAddTableSpacing = bChecked; break;
     339           0 :                         case COPT_USE_OBJECTPOSITIONING: pItem->m_bUseObjPos = bChecked; break;
     340           0 :                         case COPT_USE_OUR_TEXTWRAPPING: pItem->m_bUseOurTextWrapping = bChecked; break;
     341           0 :                         case COPT_CONSIDER_WRAPPINGSTYLE: pItem->m_bConsiderWrappingStyle = bChecked; break;
     342           0 :                         case COPT_EXPAND_WORDSPACE:  pItem->m_bExpandWordSpace = bChecked; break;
     343             :                         default:
     344             :                         {
     345             :                             OSL_FAIL("SwCompatibilityOptPage::UseAsDefaultHdl(): wrong option" );
     346             :                         }
     347             :                     }
     348             :                 }
     349           0 :                 break;
     350             :             }
     351             :         }
     352             : 
     353           0 :         WriteOptions();
     354             :     }
     355             : 
     356           0 :     return 0;
     357             : }
     358             : 
     359           0 : void SwCompatibilityOptPage::SetCurrentOptions( sal_uLong nOptions )
     360             : {
     361           0 :     sal_uLong nCount = m_pOptionsLB->GetEntryCount();
     362             :     OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
     363           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
     364             :     {
     365           0 :         sal_Bool bChecked = ( ( nOptions & 0x00000001 ) == 0x00000001 );
     366           0 :         m_pOptionsLB->CheckEntryPos( i, bChecked );
     367           0 :         nOptions = nOptions >> 1;
     368             :     }
     369           0 : }
     370             : 
     371           0 : sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
     372             : {
     373           0 :     sal_uLong nRet = 0;
     374           0 :     if ( m_pWrtShell )
     375             :     {
     376           0 :         const IDocumentSettingAccess& rIDocumentSettingAccess = *m_pWrtShell->getIDocumentSettingAccess();
     377             :         nRet = convertBools2Ulong_Impl(
     378           0 :                 !rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE),
     379           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX),
     380           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES),
     381           0 :                 !rIDocumentSettingAccess.get(IDocumentSettingAccess::TAB_COMPAT),
     382           0 :                 !rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_EXT_LEADING),
     383           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::OLD_LINE_SPACING),
     384           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS),
     385           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS),
     386           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING),
     387           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION),
     388           0 :                 !rIDocumentSettingAccess.get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) );
     389             :     }
     390           0 :     return nRet;
     391             : }
     392             : 
     393           0 : void SwCompatibilityOptPage::WriteOptions()
     394             : {
     395           0 :     m_aConfigItem.Clear();
     396           0 :     for ( vector< CompatibilityItem >::const_iterator pItem = m_pImpl->m_aList.begin();
     397           0 :           pItem != m_pImpl->m_aList.end(); ++pItem )
     398             :         m_aConfigItem.AppendItem(
     399           0 :             pItem->m_sName, pItem->m_sModule, pItem->m_bUsePrtMetrics, pItem->m_bAddSpacing,
     400           0 :             pItem->m_bAddSpacingAtPages, pItem->m_bUseOurTabStops,
     401           0 :             pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing,
     402           0 :             pItem->m_bAddTableSpacing, pItem->m_bUseObjPos,
     403           0 :             pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle,
     404           0 :             pItem->m_bExpandWordSpace );
     405           0 : }
     406             : 
     407           0 : SfxTabPage* SwCompatibilityOptPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
     408             : {
     409           0 :     return new SwCompatibilityOptPage( pParent, rAttrSet );
     410             : }
     411             : 
     412           0 : bool SwCompatibilityOptPage::FillItemSet( SfxItemSet&  )
     413             : {
     414           0 :     sal_Bool bModified = sal_False;
     415           0 :     if ( m_pWrtShell )
     416             :     {
     417           0 :         sal_uLong nSavedOptions = m_nSavedOptions;
     418           0 :         sal_uLong nCount = m_pOptionsLB->GetEntryCount();
     419             :         OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
     420             : 
     421           0 :         bool bSetParaSpaceMax = false;
     422             : 
     423           0 :         for ( sal_uInt16 i = 0; i < nCount; ++i )
     424             :         {
     425           0 :             CompatibilityOptions nOption = static_cast< CompatibilityOptions >(i);
     426           0 :             sal_Bool bChecked = m_pOptionsLB->IsChecked(i);
     427           0 :             sal_Bool bSavedChecked = ( ( nSavedOptions & 0x00000001 ) == 0x00000001 );
     428           0 :             if ( bChecked != bSavedChecked )
     429             :             {
     430           0 :                 if ( COPT_USE_PRINTERDEVICE == nOption )
     431             :                 {
     432           0 :                     m_pWrtShell->SetUseVirDev( !bChecked );
     433           0 :                     bModified = sal_True;
     434             :                 }
     435           0 :                 else if ( ( COPT_ADD_SPACING == nOption || COPT_ADD_SPACING_AT_PAGES == nOption ) && !bSetParaSpaceMax )
     436           0 :                     bSetParaSpaceMax = true;
     437           0 :                 else if ( COPT_USE_OUR_TABSTOPS == nOption )
     438             :                 {
     439           0 :                     m_pWrtShell->SetTabCompat( !bChecked );
     440           0 :                     bModified = sal_True;
     441             :                 }
     442           0 :                 else if ( COPT_NO_EXTLEADING == nOption )
     443             :                 {
     444           0 :                     m_pWrtShell->SetAddExtLeading( !bChecked );
     445           0 :                     bModified = sal_True;
     446             :                 }
     447           0 :                 else if ( COPT_USE_LINESPACING == nOption )
     448             :                 {
     449           0 :                        m_pWrtShell->SetUseFormerLineSpacing( bChecked );
     450           0 :                     bModified = sal_True;
     451             :                 }
     452           0 :                 else if ( COPT_ADD_TABLESPACING == nOption )
     453             :                 {
     454           0 :                     m_pWrtShell->SetAddParaSpacingToTableCells( bChecked );
     455           0 :                     bModified = sal_True;
     456             :                 }
     457           0 :                 else if ( COPT_USE_OBJECTPOSITIONING == nOption )
     458             :                 {
     459           0 :                     m_pWrtShell->SetUseFormerObjectPositioning( bChecked );
     460           0 :                     bModified = sal_True;
     461             :                 }
     462           0 :                 else if ( COPT_USE_OUR_TEXTWRAPPING == nOption )
     463             :                 {
     464           0 :                     m_pWrtShell->SetUseFormerTextWrapping( bChecked );
     465           0 :                     bModified = sal_True;
     466             :                 }
     467           0 :                 else if ( COPT_CONSIDER_WRAPPINGSTYLE == nOption )
     468             :                 {
     469           0 :                     m_pWrtShell->SetConsiderWrapOnObjPos( bChecked );
     470           0 :                     bModified = sal_True;
     471             :                 }
     472           0 :                 else if ( COPT_EXPAND_WORDSPACE == nOption )
     473             :                 {
     474           0 :                     m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked );
     475           0 :                     bModified = sal_True;
     476             :                 }
     477             :             }
     478             : 
     479           0 :             nSavedOptions = nSavedOptions >> 1;
     480             :         }
     481             : 
     482           0 :         if ( bSetParaSpaceMax )
     483             :         {
     484           0 :             m_pWrtShell->SetParaSpaceMax( m_pOptionsLB->IsChecked( (sal_uInt16)COPT_ADD_SPACING ) );
     485           0 :             m_pWrtShell->SetParaSpaceMaxAtPages( m_pOptionsLB->IsChecked( (sal_uInt16)COPT_ADD_SPACING_AT_PAGES ) );
     486           0 :             bModified = sal_True;
     487             :         }
     488             :     }
     489             : 
     490           0 :     if ( bModified )
     491           0 :         WriteOptions();
     492             : 
     493           0 :     return bModified;
     494             : }
     495             : 
     496           0 : void SwCompatibilityOptPage::Reset( const SfxItemSet&  )
     497             : {
     498           0 :     m_pOptionsLB->SelectEntryPos( 0 );
     499             : 
     500           0 :     sal_uLong nOptions = GetDocumentOptions();
     501           0 :     SetCurrentOptions( nOptions );
     502           0 :     m_nSavedOptions = nOptions;
     503           0 : }
     504             : 
     505             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10