LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/config - optcomp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 310 0.0 %
Date: 2013-07-09 Functions: 0 23 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 "optcomp.hrc"
      30             : #include "globals.hrc"
      31             : #include <unotools/configmgr.hxx>
      32             : #include <vcl/msgbox.hxx>
      33             : #include <sfx2/docfile.hxx>
      34             : #include <sfx2/docfilt.hxx>
      35             : #include <sfx2/fcontnr.hxx>
      36             : #include "svtools/treelistentry.hxx"
      37             : #include <IDocumentSettingAccess.hxx>
      38             : 
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::com::sun::star::document;
      41             : using namespace ::com::sun::star::uno;
      42             : using namespace ::std;
      43             : 
      44             : #define DEFAULT_ENTRY       COMPATIBILITY_DEFAULT_NAME
      45             : #define USER_ENTRY          "_user"
      46             : #define BUTTON_BORDER       2
      47             : 
      48             : // struct CompatibilityItem ----------------------------------------------
      49             : 
      50           0 : struct CompatibilityItem
      51             : {
      52             :     String      m_sName;
      53             :     String      m_sModule;
      54             :     bool        m_bUsePrtMetrics;
      55             :     bool        m_bAddSpacing;
      56             :     bool        m_bAddSpacingAtPages;
      57             :     bool        m_bUseOurTabStops;
      58             :     bool        m_bNoExtLeading;
      59             :     bool        m_bUseLineSpacing;
      60             :     bool        m_bAddTableSpacing;
      61             :     bool        m_bUseObjPos;
      62             :     bool        m_bUseOurTextWrapping;
      63             :     bool        m_bConsiderWrappingStyle;
      64             :     bool        m_bExpandWordSpace;
      65             :     bool        m_bIsDefault;
      66             :     bool        m_bIsUser;
      67             : 
      68           0 :     CompatibilityItem( const String& _rName, const String& _rModule,
      69             :                        bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages,
      70             :                        bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing,
      71             :                        bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping,
      72             :                        bool _bConsiderWrappingStyle, bool _bExpandWordSpace,
      73             :                        bool _bIsDefault, bool _bIsUser ) :
      74             : 
      75             :         m_sName                 ( _rName ),
      76             :         m_sModule               ( _rModule ),
      77             :         m_bUsePrtMetrics        ( _bUsePrtMetrics ),
      78             :         m_bAddSpacing           ( _bAddSpacing ),
      79             :         m_bAddSpacingAtPages    ( _bAddSpacingAtPages ),
      80             :         m_bUseOurTabStops       ( _bUseOurTabStops ),
      81             :         m_bNoExtLeading         ( _bNoExtLeading ),
      82             :         m_bUseLineSpacing       ( _bUseLineSpacing ),
      83             :         m_bAddTableSpacing      ( _bAddTableSpacing ),
      84             :         m_bUseObjPos            ( _bUseObjPos ),
      85             :         m_bUseOurTextWrapping   ( _bUseOurTextWrapping ),
      86             :         m_bConsiderWrappingStyle( _bConsiderWrappingStyle ),
      87             :         m_bExpandWordSpace      ( _bExpandWordSpace ),
      88             :         m_bIsDefault            ( _bIsDefault ),
      89           0 :         m_bIsUser               ( _bIsUser ) {}
      90             : };
      91             : 
      92             : #include <vector>
      93             : 
      94           0 : struct SwCompatibilityOptPage_Impl
      95             : {
      96             :     typedef vector< CompatibilityItem > SwCompatibilityItemList;
      97             : 
      98             :     SwCompatibilityItemList     m_aList;
      99             : };
     100             : 
     101             : // class SwCompatibilityOptPage ------------------------------------------
     102             : 
     103           0 : SwCompatibilityOptPage::SwCompatibilityOptPage( Window* pParent, const SfxItemSet& rSet ) :
     104             : 
     105             :     SfxTabPage( pParent, SW_RES( TP_OPTCOMPATIBILITY_PAGE ), rSet ),
     106             : 
     107             :     m_aMainFL           ( this, SW_RES( FL_MAIN ) ),
     108             :     m_aFormattingFT     ( this, SW_RES( FT_FORMATTING ) ),
     109             :     m_aFormattingLB     ( this, SW_RES( LB_FORMATTING ) ),
     110             :     m_aOptionsFT        ( this, SW_RES( FT_OPTIONS ) ),
     111             :     m_aOptionsLB        ( this, SW_RES( LB_OPTIONS ) ),
     112             :     m_aResetPB          ( this, SW_RES( PB_RESET ) ),
     113             :     m_aDefaultPB        ( this, SW_RES( PB_DEFAULT ) ),
     114             :     m_sUserEntry        (       SW_RES( STR_USERENTRY ) ),
     115             :     m_sUseAsDefaultQuery(       SW_RES( STR_QRYBOX_USEASDEFAULT ) ),
     116             :     m_pWrtShell         ( NULL ),
     117           0 :     m_pImpl             ( new SwCompatibilityOptPage_Impl ),
     118           0 :     m_nSavedOptions     ( 0 )
     119             : 
     120             : {
     121             :     // init options strings with local resource ids -> so do it before FreeResource()
     122           0 :     for ( sal_uInt16 nResId = STR_COMP_OPTIONS_START; nResId < STR_COMP_OPTIONS_END; ++nResId )
     123             :     {
     124           0 :         String sEntry = String( SW_RES( nResId ) );
     125           0 :         if ( STR_TAB_ALIGNMENT == nResId ||
     126           0 :              STR_LINE_SPACING == nResId ||
     127           0 :              STR_USE_OBJPOSITIONING == nResId ||
     128             :              STR_USE_OURTEXTWRAPPING == nResId )
     129           0 :             ReplaceFormatName( sEntry );
     130           0 :         SvTreeListEntry* pEntry = m_aOptionsLB.SvTreeListBox::InsertEntry( sEntry );
     131           0 :         if ( pEntry )
     132             :         {
     133           0 :             m_aOptionsLB.SetCheckButtonState( pEntry, SV_BUTTON_UNCHECKED );
     134           0 :             pEntry->SetUserData( (void*)(sal_uLong)nResId );
     135             :         }
     136           0 :     }
     137           0 :     m_aOptionsLB.SetStyle( m_aOptionsLB.GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
     138           0 :     m_aOptionsLB.SetHighlightRange();
     139             : 
     140           0 :     FreeResource();
     141             : 
     142           0 :     InitControls( rSet );
     143             : 
     144             :     // set handler
     145           0 :     m_aFormattingLB.SetSelectHdl( LINK( this, SwCompatibilityOptPage, SelectHdl ) );
     146           0 :     m_aDefaultPB.SetClickHdl( LINK( this, SwCompatibilityOptPage, UseAsDefaultHdl ) );
     147             : 
     148             :     // hide some controls, will be implemented later!!!
     149           0 :     m_aFormattingFT.Hide();
     150           0 :     m_aFormattingLB.Hide();
     151           0 :     m_aResetPB.Hide();
     152             :     // so move and resize the other controls
     153           0 :     Point aMovePnt = m_aFormattingFT.GetPosPixel();
     154           0 :     Point aNewPnt = m_aOptionsFT.GetPosPixel();
     155           0 :     aNewPnt.Y() = aMovePnt.Y();
     156           0 :     m_aOptionsFT.SetPosPixel( aNewPnt );
     157           0 :     aMovePnt = m_aFormattingLB.GetPosPixel();
     158           0 :     aNewPnt = m_aOptionsLB.GetPosPixel();
     159           0 :     long nDelta = aNewPnt.Y() - aMovePnt.Y();
     160           0 :     aNewPnt.Y() = aMovePnt.Y();
     161           0 :     m_aOptionsLB.SetPosPixel( aNewPnt );
     162           0 :     Size aNewSz = m_aOptionsLB.GetSizePixel();
     163           0 :     aNewSz.Height() += nDelta;
     164           0 :     m_aOptionsLB.SetSizePixel( aNewSz );
     165           0 : }
     166             : 
     167           0 : SwCompatibilityOptPage::~SwCompatibilityOptPage()
     168             : {
     169           0 :     delete m_pImpl;
     170           0 : }
     171             : 
     172           0 : void SwCompatibilityOptPage::ReplaceFormatName( String& rEntry )
     173             : {
     174           0 :     OUString sFormatName(utl::ConfigManager::getProductName());
     175           0 :     OUString sFormatVersion;
     176           0 :     bool bOpenOffice = ( sFormatName == "OpenOffice.org" );
     177           0 :     if ( bOpenOffice )
     178           0 :         sFormatVersion = OUString("1.1");
     179             :     else
     180           0 :         sFormatVersion = OUString("6.0/7");
     181           0 :     if ( !bOpenOffice && ( sFormatName != "StarSuite" ) )
     182           0 :         sFormatName = OUString("StarOffice");
     183             : 
     184           0 :     rEntry.SearchAndReplace( OUString("%FORMATNAME"), sFormatName );
     185           0 :     rEntry.SearchAndReplace( OUString("%FORMATVERSION"), sFormatVersion );
     186           0 : }
     187             : 
     188           0 : sal_uLong convertBools2Ulong_Impl
     189             : (
     190             :     bool _bUsePrtMetrics,
     191             :     bool _bAddSpacing,
     192             :     bool _bAddSpacingAtPages,
     193             :     bool _bUseOurTabStops,
     194             :     bool _bNoExtLeading,
     195             :     bool _bUseLineSpacing,
     196             :     bool _bAddTableSpacing,
     197             :     bool _bUseObjPos,
     198             :     bool _bUseOurTextWrapping,
     199             :     bool _bConsiderWrappingStyle,
     200             :     bool _bExpandWordSpace
     201             : )
     202             : {
     203           0 :     sal_uLong nRet = 0;
     204           0 :     sal_uLong nSetBit = 1;
     205             : 
     206           0 :     if ( _bUsePrtMetrics )
     207           0 :         nRet |= nSetBit;
     208           0 :     nSetBit = nSetBit << 1;
     209           0 :     if ( _bAddSpacing )
     210           0 :         nRet |= nSetBit;
     211           0 :     nSetBit = nSetBit << 1;
     212           0 :     if ( _bAddSpacingAtPages )
     213           0 :         nRet |= nSetBit;
     214           0 :     nSetBit = nSetBit << 1;
     215           0 :     if ( _bUseOurTabStops )
     216           0 :         nRet |= nSetBit;
     217           0 :     nSetBit = nSetBit << 1;
     218           0 :     if ( _bNoExtLeading )
     219           0 :         nRet |= nSetBit;
     220           0 :     nSetBit = nSetBit << 1;
     221           0 :     if ( _bUseLineSpacing )
     222           0 :         nRet |= nSetBit;
     223           0 :     nSetBit = nSetBit << 1;
     224           0 :     if ( _bAddTableSpacing )
     225           0 :         nRet |= nSetBit;
     226           0 :     nSetBit = nSetBit << 1;
     227           0 :     if ( _bUseObjPos )
     228           0 :         nRet |= nSetBit;
     229           0 :     nSetBit = nSetBit << 1;
     230           0 :     if ( _bUseOurTextWrapping )
     231           0 :         nRet |= nSetBit;
     232           0 :     nSetBit = nSetBit << 1;
     233           0 :     if ( _bConsiderWrappingStyle )
     234           0 :         nRet |= nSetBit;
     235           0 :     nSetBit = nSetBit << 1;
     236           0 :     if ( _bExpandWordSpace )
     237           0 :         nRet |= nSetBit;
     238             : 
     239           0 :     return nRet;
     240             : }
     241             : 
     242           0 : void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
     243             : {
     244             :     // init objectshell and detect document name
     245           0 :     String sDocTitle;
     246           0 :     const SfxPoolItem* pItem = NULL;
     247           0 :     SfxObjectShell* pObjShell = NULL;
     248           0 :     if ( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_WRTSHELL, sal_False, &pItem ) )
     249           0 :         m_pWrtShell = (SwWrtShell*)( (const SwPtrItem*)pItem )->GetValue();
     250           0 :     if ( m_pWrtShell )
     251             :     {
     252           0 :         pObjShell = m_pWrtShell->GetView().GetDocShell();
     253           0 :         if ( pObjShell )
     254           0 :             sDocTitle = pObjShell->GetTitle( SFX_TITLE_TITLE );
     255             :     }
     256             :     else
     257             :     {
     258           0 :         m_aMainFL.Disable();
     259           0 :         m_aFormattingFT.Disable();
     260           0 :         m_aFormattingLB.Disable();
     261           0 :         m_aOptionsFT.Disable();
     262           0 :         m_aOptionsLB.Disable();
     263           0 :         m_aResetPB.Disable();
     264           0 :         m_aDefaultPB.Disable();
     265             :     }
     266           0 :     String sText = m_aMainFL.GetText();
     267           0 :     sText.SearchAndReplace( OUString("%DOCNAME"), sDocTitle );
     268           0 :     m_aMainFL.SetText( sText );
     269             : 
     270             :     // loading file formats
     271           0 :     Sequence< Sequence< PropertyValue > > aList = m_aConfigItem.GetList();
     272           0 :     OUString sName;
     273           0 :     OUString sModule;
     274           0 :     bool bUsePrtMetrics = false;
     275           0 :     bool bAddSpacing = false;
     276           0 :     bool bAddSpacingAtPages = false;
     277           0 :     bool bUseOurTabStops = false;
     278           0 :     bool bNoExtLeading = false;
     279           0 :     bool bUseLineSpacing = false;
     280           0 :     bool bAddTableSpacing = false;
     281           0 :     bool bUseObjPos = false;
     282           0 :     bool bUseOurTextWrapping = false;
     283           0 :     bool bConsiderWrappingStyle = false;
     284           0 :     bool bExpandWordSpace = false;
     285           0 :     int i, j, nCount = aList.getLength();
     286           0 :     for ( i = 0; i < nCount; ++i )
     287             :     {
     288           0 :         String sNewEntry;
     289           0 :         const Sequence< PropertyValue >& rEntry = aList[i];
     290           0 :         for ( j = 0; j < rEntry.getLength(); j++ )
     291             :         {
     292           0 :             PropertyValue aValue = rEntry[j];
     293           0 :             if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NAME )
     294           0 :                 aValue.Value >>= sName;
     295           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_MODULE )
     296           0 :                 aValue.Value >>= sModule;
     297           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS )
     298           0 :                 aValue.Value >>= bUsePrtMetrics;
     299           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACING )
     300           0 :                 aValue.Value >>= bAddSpacing;
     301           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES )
     302           0 :                 aValue.Value >>= bAddSpacingAtPages;
     303           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS )
     304           0 :                 aValue.Value >>= bUseOurTabStops;
     305           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NOEXTLEADING )
     306           0 :                 aValue.Value >>= bNoExtLeading;
     307           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USELINESPACING )
     308           0 :                 aValue.Value >>= bUseLineSpacing;
     309           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING )
     310           0 :                 aValue.Value >>= bAddTableSpacing;
     311           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING )
     312           0 :                 aValue.Value >>= bUseObjPos;
     313           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING )
     314           0 :                 aValue.Value >>= bUseOurTextWrapping;
     315           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE )
     316           0 :                 aValue.Value >>= bConsiderWrappingStyle;
     317           0 :             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
     318           0 :                 aValue.Value >>= bExpandWordSpace;
     319           0 :         }
     320             : 
     321             :         CompatibilityItem aItem(
     322             :             sName, sModule, bUsePrtMetrics, bAddSpacing,
     323             :             bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
     324             :             bUseLineSpacing, bAddTableSpacing, bUseObjPos,
     325             :             bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace,
     326           0 :             ( sName.equals( DEFAULT_ENTRY ) != sal_False ),
     327           0 :             ( sName.equals( USER_ENTRY ) != sal_False ) );
     328           0 :         m_pImpl->m_aList.push_back( aItem );
     329             : 
     330           0 :         if ( aItem.m_bIsDefault )
     331           0 :             continue;
     332             : 
     333           0 :         if ( sName.equals( USER_ENTRY ) )
     334           0 :             sNewEntry = m_sUserEntry;
     335           0 :         else if ( pObjShell && !sName.isEmpty() )
     336             :         {
     337           0 :             SfxFilterContainer* pFacCont = pObjShell->GetFactory().GetFilterContainer();
     338           0 :             const SfxFilter* pFilter = pFacCont->GetFilter4FilterName( sName );
     339           0 :             if ( pFilter )
     340           0 :                 sNewEntry = pFilter->GetUIName();
     341             :         }
     342             : 
     343           0 :         if ( sNewEntry.Len() == 0 )
     344           0 :             sNewEntry = sName;
     345             : 
     346           0 :         sal_uInt16 nPos = m_aFormattingLB.InsertEntry( sNewEntry );
     347             :         sal_uLong nOptions = convertBools2Ulong_Impl(
     348             :             bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages,
     349             :             bUseOurTabStops, bNoExtLeading, bUseLineSpacing,
     350             :             bAddTableSpacing, bUseObjPos, bUseOurTextWrapping,
     351           0 :             bConsiderWrappingStyle, bExpandWordSpace );
     352           0 :         m_aFormattingLB.SetEntryData( nPos, (void*)(sal_IntPtr)nOptions );
     353           0 :     }
     354             : 
     355           0 :     m_aFormattingLB.SetDropDownLineCount( m_aFormattingLB.GetEntryCount() );
     356             : 
     357             :     // check if the default button text is not too wide otherwise we have to stretch the button
     358             :     // and move its position and the position of the reset button
     359           0 :     long nTxtWidth = m_aDefaultPB.GetTextWidth( m_aDefaultPB.GetText() );
     360           0 :     Size aBtnSz = m_aDefaultPB.GetSizePixel();
     361           0 :     if ( nTxtWidth > aBtnSz.Width() )
     362             :     {
     363           0 :         long nDelta = nTxtWidth - aBtnSz.Width() + 2 * BUTTON_BORDER;
     364           0 :         aBtnSz.Width() += nDelta;
     365           0 :         Point aBtnPnt = m_aDefaultPB.GetPosPixel();
     366           0 :         aBtnPnt.X() -= nDelta;
     367           0 :         m_aDefaultPB.SetPosSizePixel( aBtnPnt, aBtnSz );
     368           0 :         aBtnPnt = m_aResetPB.GetPosPixel();
     369           0 :         aBtnPnt.X() -= 2 * nDelta;
     370           0 :         m_aResetPB.SetPosSizePixel( aBtnPnt, aBtnSz );
     371           0 :     }
     372           0 : }
     373             : 
     374           0 : IMPL_LINK_NOARG(SwCompatibilityOptPage, SelectHdl)
     375             : {
     376           0 :     sal_uInt16 nPos = m_aFormattingLB.GetSelectEntryPos();
     377           0 :     sal_uLong nOptions = (sal_uLong)(void*)m_aFormattingLB.GetEntryData( nPos );
     378           0 :     SetCurrentOptions( nOptions );
     379             : 
     380           0 :     return 0;
     381             : }
     382             : 
     383           0 : IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl)
     384             : {
     385           0 :     QueryBox aBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), m_sUseAsDefaultQuery );
     386           0 :     if ( aBox.Execute() == RET_YES )
     387             :     {
     388           0 :         for ( vector< CompatibilityItem >::iterator pItem = m_pImpl->m_aList.begin();
     389           0 :               pItem != m_pImpl->m_aList.end(); ++pItem )
     390             :         {
     391           0 :             if ( pItem->m_bIsDefault )
     392             :             {
     393           0 :                 sal_uInt16 nCount = static_cast< sal_uInt16 >( m_aOptionsLB.GetEntryCount() );
     394           0 :                 for ( sal_uInt16 i = 0; i < nCount; ++i )
     395             :                 {
     396           0 :                     bool bChecked = ( m_aOptionsLB.IsChecked(i) != sal_False );
     397           0 :                     CompatibilityOptions eOption = static_cast< CompatibilityOptions >(i);
     398           0 :                     switch ( eOption )
     399             :                     {
     400           0 :                         case COPT_USE_PRINTERDEVICE : pItem->m_bUsePrtMetrics = bChecked; break;
     401           0 :                         case COPT_ADD_SPACING : pItem->m_bAddSpacing = bChecked; break;
     402           0 :                         case COPT_ADD_SPACING_AT_PAGES : pItem->m_bAddSpacingAtPages = bChecked; break;
     403           0 :                         case COPT_USE_OUR_TABSTOPS : pItem->m_bUseOurTabStops = bChecked; break;
     404           0 :                         case COPT_NO_EXTLEADING : pItem->m_bNoExtLeading = bChecked; break;
     405           0 :                         case COPT_USE_LINESPACING : pItem->m_bUseLineSpacing = bChecked; break;
     406           0 :                         case COPT_ADD_TABLESPACING : pItem->m_bAddTableSpacing = bChecked; break;
     407           0 :                         case COPT_USE_OBJECTPOSITIONING: pItem->m_bUseObjPos = bChecked; break;
     408           0 :                         case COPT_USE_OUR_TEXTWRAPPING: pItem->m_bUseOurTextWrapping = bChecked; break;
     409           0 :                         case COPT_CONSIDER_WRAPPINGSTYLE: pItem->m_bConsiderWrappingStyle = bChecked; break;
     410           0 :                         case COPT_EXPAND_WORDSPACE:  pItem->m_bExpandWordSpace = bChecked; break;
     411             :                         default:
     412             :                         {
     413             :                             OSL_FAIL("SwCompatibilityOptPage::UseAsDefaultHdl(): wrong option" );
     414             :                         }
     415             :                     }
     416             :                 }
     417           0 :                 break;
     418             :             }
     419             :         }
     420             : 
     421           0 :         WriteOptions();
     422             :     }
     423             : 
     424           0 :     return 0;
     425             : }
     426             : 
     427           0 : void SwCompatibilityOptPage::SetCurrentOptions( sal_uLong nOptions )
     428             : {
     429           0 :     sal_uLong nCount = m_aOptionsLB.GetEntryCount();
     430             :     OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
     431           0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
     432             :     {
     433           0 :         sal_Bool bChecked = ( ( nOptions & 0x00000001 ) == 0x00000001 );
     434           0 :         m_aOptionsLB.CheckEntryPos( i, bChecked );
     435           0 :         nOptions = nOptions >> 1;
     436             :     }
     437           0 : }
     438             : 
     439           0 : sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
     440             : {
     441           0 :     sal_uLong nRet = 0;
     442           0 :     if ( m_pWrtShell )
     443             :     {
     444           0 :         const IDocumentSettingAccess& rIDocumentSettingAccess = *m_pWrtShell->getIDocumentSettingAccess();
     445             :         nRet = convertBools2Ulong_Impl(
     446           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) == sal_False,
     447           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX) != sal_False,
     448           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) != sal_False,
     449           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::TAB_COMPAT) == sal_False,
     450           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_EXT_LEADING) == sal_False,
     451           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::OLD_LINE_SPACING) != sal_False,
     452           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) != sal_False,
     453           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) != sal_False,
     454           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) != sal_False,
     455           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) != sal_False,
     456           0 :                 rIDocumentSettingAccess.get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) != sal_True );
     457             :     }
     458           0 :     return nRet;
     459             : }
     460             : 
     461           0 : void SwCompatibilityOptPage::WriteOptions()
     462             : {
     463           0 :     m_aConfigItem.Clear();
     464           0 :     for ( vector< CompatibilityItem >::const_iterator pItem = m_pImpl->m_aList.begin();
     465           0 :           pItem != m_pImpl->m_aList.end(); ++pItem )
     466             :         m_aConfigItem.AppendItem(
     467           0 :             pItem->m_sName, pItem->m_sModule, pItem->m_bUsePrtMetrics, pItem->m_bAddSpacing,
     468           0 :             pItem->m_bAddSpacingAtPages, pItem->m_bUseOurTabStops,
     469           0 :             pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing,
     470           0 :             pItem->m_bAddTableSpacing, pItem->m_bUseObjPos,
     471           0 :             pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle,
     472           0 :             pItem->m_bExpandWordSpace );
     473           0 : }
     474             : 
     475           0 : SfxTabPage* SwCompatibilityOptPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
     476             : {
     477           0 :     return new SwCompatibilityOptPage( pParent, rAttrSet );
     478             : }
     479             : 
     480           0 : sal_Bool SwCompatibilityOptPage::FillItemSet( SfxItemSet&  )
     481             : {
     482           0 :     sal_Bool bModified = sal_False;
     483           0 :     if ( m_pWrtShell )
     484             :     {
     485           0 :         sal_uLong nSavedOptions = m_nSavedOptions;
     486           0 :         sal_uLong nCount = m_aOptionsLB.GetEntryCount();
     487             :         OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
     488             : 
     489           0 :         bool bSetParaSpaceMax = false;
     490             : 
     491           0 :         for ( sal_uInt16 i = 0; i < nCount; ++i )
     492             :         {
     493           0 :             CompatibilityOptions nOption = static_cast< CompatibilityOptions >(i);
     494           0 :             sal_Bool bChecked = m_aOptionsLB.IsChecked(i);
     495           0 :             sal_Bool bSavedChecked = ( ( nSavedOptions & 0x00000001 ) == 0x00000001 );
     496           0 :             if ( bChecked != bSavedChecked )
     497             :             {
     498           0 :                 if ( COPT_USE_PRINTERDEVICE == nOption )
     499             :                 {
     500           0 :                     m_pWrtShell->SetUseVirDev( !bChecked );
     501           0 :                     bModified = sal_True;
     502             :                 }
     503           0 :                 else if ( ( COPT_ADD_SPACING == nOption || COPT_ADD_SPACING_AT_PAGES == nOption ) && !bSetParaSpaceMax )
     504           0 :                     bSetParaSpaceMax = true;
     505           0 :                 else if ( COPT_USE_OUR_TABSTOPS == nOption )
     506             :                 {
     507           0 :                     m_pWrtShell->SetTabCompat( !bChecked );
     508           0 :                     bModified = sal_True;
     509             :                 }
     510           0 :                 else if ( COPT_NO_EXTLEADING == nOption )
     511             :                 {
     512           0 :                     m_pWrtShell->SetAddExtLeading( !bChecked );
     513           0 :                     bModified = sal_True;
     514             :                 }
     515           0 :                 else if ( COPT_USE_LINESPACING == nOption )
     516             :                 {
     517           0 :                        m_pWrtShell->SetUseFormerLineSpacing( bChecked );
     518           0 :                     bModified = sal_True;
     519             :                 }
     520           0 :                 else if ( COPT_ADD_TABLESPACING == nOption )
     521             :                 {
     522           0 :                     m_pWrtShell->SetAddParaSpacingToTableCells( bChecked );
     523           0 :                     bModified = sal_True;
     524             :                 }
     525           0 :                 else if ( COPT_USE_OBJECTPOSITIONING == nOption )
     526             :                 {
     527           0 :                     m_pWrtShell->SetUseFormerObjectPositioning( bChecked );
     528           0 :                     bModified = sal_True;
     529             :                 }
     530           0 :                 else if ( COPT_USE_OUR_TEXTWRAPPING == nOption )
     531             :                 {
     532           0 :                     m_pWrtShell->SetUseFormerTextWrapping( bChecked );
     533           0 :                     bModified = sal_True;
     534             :                 }
     535           0 :                 else if ( COPT_CONSIDER_WRAPPINGSTYLE == nOption )
     536             :                 {
     537           0 :                     m_pWrtShell->SetConsiderWrapOnObjPos( bChecked );
     538           0 :                     bModified = sal_True;
     539             :                 }
     540           0 :                 else if ( COPT_EXPAND_WORDSPACE == nOption )
     541             :                 {
     542           0 :                     m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked );
     543           0 :                     bModified = sal_True;
     544             :                 }
     545             :             }
     546             : 
     547           0 :             nSavedOptions = nSavedOptions >> 1;
     548             :         }
     549             : 
     550           0 :         if ( bSetParaSpaceMax )
     551             :         {
     552           0 :             m_pWrtShell->SetParaSpaceMax( m_aOptionsLB.IsChecked( (sal_uInt16)COPT_ADD_SPACING ) );
     553           0 :             m_pWrtShell->SetParaSpaceMaxAtPages( m_aOptionsLB.IsChecked( (sal_uInt16)COPT_ADD_SPACING_AT_PAGES ) );
     554           0 :             bModified = sal_True;
     555             :         }
     556             :     }
     557             : 
     558           0 :     if ( bModified )
     559           0 :         WriteOptions();
     560             : 
     561           0 :     return bModified;
     562             : }
     563             : 
     564           0 : void SwCompatibilityOptPage::Reset( const SfxItemSet&  )
     565             : {
     566           0 :     m_aOptionsLB.SelectEntryPos( 0 );
     567             : 
     568           0 :     sal_uLong nOptions = GetDocumentOptions();
     569           0 :     SetCurrentOptions( nOptions );
     570           0 :     m_nSavedOptions = nOptions;
     571           0 : }
     572             : 
     573             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10