LCOV - code coverage report
Current view: top level - sw/source/ui/config - optcomp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 308 0.0 %
Date: 2012-08-25 Functions: 0 21 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10