LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - tpoption.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 390 0.0 %
Date: 2012-08-25 Functions: 0 30 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                 :            : 
      30                 :            : #ifdef SD_DLLIMPLEMENTATION
      31                 :            : #undef SD_DLLIMPLEMENTATION
      32                 :            : #endif
      33                 :            : 
      34                 :            : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      35                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      36                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      37                 :            : #include <com/sun/star/lang/XComponent.hpp>
      38                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      39                 :            : #include <comphelper/processfactory.hxx>
      40                 :            : #include <comphelper/string.hxx>
      41                 :            : #include <com/sun/star/uno/Exception.hpp>
      42                 :            : #include <sfx2/module.hxx>
      43                 :            : #include <sfx2/app.hxx>
      44                 :            : #include <svx/svxids.hrc>
      45                 :            : #include <svx/dialogs.hrc>
      46                 :            : #include <svx/strarray.hxx>
      47                 :            : #include <svx/dlgutil.hxx>
      48                 :            : #include <vcl/msgbox.hxx>
      49                 :            : 
      50                 :            : #include "sdattr.hxx"
      51                 :            : #include "sdresid.hxx"
      52                 :            : #include "optsitem.hxx"
      53                 :            : #include "tpoption.hrc"
      54                 :            : #include "tpoption.hxx"
      55                 :            : #include "strings.hrc"
      56                 :            : #include "app.hrc"
      57                 :            : #include <svl/intitem.hxx>
      58                 :            : #include <sfx2/request.hxx>
      59                 :            : 
      60                 :            : using namespace ::com::sun::star;
      61                 :            : using namespace ::com::sun::star::uno;
      62                 :            : 
      63                 :          0 : SdTpOptionsSnap::SdTpOptionsSnap( Window* pParent, const SfxItemSet& rInAttrs  ) :
      64                 :          0 :         SvxGridTabPage(pParent, rInAttrs)
      65                 :            : {
      66                 :          0 :     aGrpSnap.Show();
      67                 :          0 :     aCbxSnapHelplines.Show();
      68                 :          0 :     aCbxSnapBorder.Show();
      69                 :          0 :     aCbxSnapFrame.Show();
      70                 :          0 :     aCbxSnapPoints.Show();
      71                 :          0 :     aFtSnapArea.Show();
      72                 :          0 :     aMtrFldSnapArea.Show();
      73                 :          0 :     aGrpOrtho.Show();
      74                 :          0 :     aCbxOrtho.Show();
      75                 :          0 :     aCbxBigOrtho.Show();
      76                 :          0 :     aCbxRotate.Show();
      77                 :          0 :     aMtrFldAngle.Show();
      78                 :          0 :     aFtBezAngle.Show();
      79                 :          0 :     aMtrFldBezAngle.Show();
      80                 :          0 :     aSeparatorFL.Show();
      81                 :          0 : }
      82                 :            : 
      83                 :            : // -----------------------------------------------------------------------
      84                 :            : 
      85                 :          0 : SdTpOptionsSnap::~SdTpOptionsSnap()
      86                 :            : {
      87                 :          0 : }
      88                 :            : 
      89                 :            : // -----------------------------------------------------------------------
      90                 :            : 
      91                 :          0 : sal_Bool SdTpOptionsSnap::FillItemSet( SfxItemSet& rAttrs )
      92                 :            : {
      93                 :          0 :     SvxGridTabPage::FillItemSet(rAttrs);
      94                 :          0 :     SdOptionsSnapItem* pOptsItem = NULL;
      95                 :          0 :     SdOptionsSnapItem aOptsItem( ATTR_OPTIONS_SNAP );
      96                 :            : 
      97                 :          0 :     aOptsItem.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines.IsChecked() );
      98                 :          0 :     aOptsItem.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder.IsChecked() );
      99                 :          0 :     aOptsItem.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame.IsChecked() );
     100                 :          0 :     aOptsItem.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints.IsChecked() );
     101                 :          0 :     aOptsItem.GetOptionsSnap().SetOrtho( aCbxOrtho.IsChecked() );
     102                 :          0 :     aOptsItem.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho.IsChecked() );
     103                 :          0 :     aOptsItem.GetOptionsSnap().SetRotate( aCbxRotate.IsChecked() );
     104                 :          0 :     aOptsItem.GetOptionsSnap().SetSnapArea( (sal_Int16) aMtrFldSnapArea.GetValue() );
     105                 :          0 :     aOptsItem.GetOptionsSnap().SetAngle( (sal_Int16) aMtrFldAngle.GetValue() );
     106                 :          0 :     aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (sal_Int16) aMtrFldBezAngle.GetValue() );
     107                 :            : 
     108                 :          0 :     if( pOptsItem == NULL || !(aOptsItem == *pOptsItem) )
     109                 :          0 :         rAttrs.Put( aOptsItem );
     110                 :            : 
     111                 :            :     // Evtl. vorhandenes GridItem wird geholt, um nicht versehentlich
     112                 :            :     // irgendwelche Standardwerte einzustellen
     113                 :          0 :     return( sal_True );
     114                 :            : }
     115                 :            : 
     116                 :            : // -----------------------------------------------------------------------
     117                 :            : 
     118                 :          0 : void SdTpOptionsSnap::Reset( const SfxItemSet& rAttrs )
     119                 :            : {
     120                 :          0 :     SvxGridTabPage::Reset(rAttrs);
     121                 :            : 
     122                 :            :     SdOptionsSnapItem aOptsItem( (const SdOptionsSnapItem&) rAttrs.
     123                 :          0 :                         Get( ATTR_OPTIONS_SNAP ) );
     124                 :            : 
     125                 :          0 :     aCbxSnapHelplines.Check( aOptsItem.GetOptionsSnap().IsSnapHelplines() );
     126                 :          0 :     aCbxSnapBorder.Check( aOptsItem.GetOptionsSnap().IsSnapBorder() );
     127                 :          0 :     aCbxSnapFrame.Check( aOptsItem.GetOptionsSnap().IsSnapFrame() );
     128                 :          0 :     aCbxSnapPoints.Check( aOptsItem.GetOptionsSnap().IsSnapPoints() );
     129                 :          0 :     aCbxOrtho.Check( aOptsItem.GetOptionsSnap().IsOrtho() );
     130                 :          0 :     aCbxBigOrtho.Check( aOptsItem.GetOptionsSnap().IsBigOrtho() );
     131                 :          0 :     aCbxRotate.Check( aOptsItem.GetOptionsSnap().IsRotate() );
     132                 :          0 :     aMtrFldSnapArea.SetValue( aOptsItem.GetOptionsSnap().GetSnapArea() );
     133                 :          0 :     aMtrFldAngle.SetValue( aOptsItem.GetOptionsSnap().GetAngle() );
     134                 :          0 :     aMtrFldBezAngle.SetValue( aOptsItem.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
     135                 :            : 
     136                 :          0 :     aCbxRotate.GetClickHdl().Call(0);
     137                 :          0 : }
     138                 :            : 
     139                 :            : // -----------------------------------------------------------------------
     140                 :            : 
     141                 :          0 : SfxTabPage* SdTpOptionsSnap::Create( Window* pWindow,
     142                 :            :                 const SfxItemSet& rAttrs )
     143                 :            : {
     144                 :          0 :     return( new SdTpOptionsSnap( pWindow, rAttrs ) );
     145                 :            : }
     146                 :            : 
     147                 :            : /*************************************************************************
     148                 :            : |*
     149                 :            : |*  TabPage zum Einstellen der Inhalte-Optionen
     150                 :            : |*
     151                 :            : \************************************************************************/
     152                 :            : 
     153                 :          0 : SdTpOptionsContents::SdTpOptionsContents( Window* pParent, const SfxItemSet& rInAttrs  ) :
     154                 :            :         SfxTabPage          ( pParent, SdResId( TP_OPTIONS_CONTENTS ), rInAttrs ),
     155                 :            :         aGrpDisplay         ( this, SdResId( GRP_DISPLAY ) ),
     156                 :            :         aCbxRuler           ( this, SdResId( CBX_RULER ) ),
     157                 :            :         aCbxDragStripes     ( this, SdResId( CBX_HELPLINES ) ),
     158                 :            :         aCbxHandlesBezier   ( this, SdResId( CBX_HANDLES_BEZIER ) ),
     159                 :          0 :         aCbxMoveOutline     ( this, SdResId( CBX_MOVE_OUTLINE ) )
     160                 :            : {
     161                 :          0 :     FreeResource();
     162                 :          0 : }
     163                 :            : 
     164                 :            : // -----------------------------------------------------------------------
     165                 :            : 
     166                 :          0 : SdTpOptionsContents::~SdTpOptionsContents()
     167                 :            : {
     168                 :          0 : }
     169                 :            : 
     170                 :            : // -----------------------------------------------------------------------
     171                 :            : 
     172                 :          0 : sal_Bool SdTpOptionsContents::FillItemSet( SfxItemSet& rAttrs )
     173                 :            : {
     174                 :          0 :     sal_Bool bModified = sal_False;
     175                 :            : 
     176                 :          0 :     if( aCbxRuler.GetSavedValue()           != aCbxRuler.IsChecked() ||
     177                 :          0 :         aCbxMoveOutline.GetSavedValue()     != aCbxMoveOutline.IsChecked() ||
     178                 :          0 :         aCbxDragStripes.GetSavedValue()     != aCbxDragStripes.IsChecked() ||
     179                 :          0 :         aCbxHandlesBezier.GetSavedValue()   != aCbxHandlesBezier.IsChecked() )
     180                 :            :     {
     181                 :          0 :         SdOptionsLayoutItem aOptsItem( ATTR_OPTIONS_LAYOUT );
     182                 :            : 
     183                 :          0 :         aOptsItem.GetOptionsLayout().SetRulerVisible( aCbxRuler.IsChecked() );
     184                 :          0 :         aOptsItem.GetOptionsLayout().SetMoveOutline( aCbxMoveOutline.IsChecked() );
     185                 :          0 :         aOptsItem.GetOptionsLayout().SetDragStripes( aCbxDragStripes.IsChecked() );
     186                 :          0 :         aOptsItem.GetOptionsLayout().SetHandlesBezier( aCbxHandlesBezier.IsChecked() );
     187                 :            : 
     188                 :          0 :         rAttrs.Put( aOptsItem );
     189                 :          0 :         bModified = sal_True;
     190                 :            :     }
     191                 :          0 :     return( bModified );
     192                 :            : }
     193                 :            : 
     194                 :            : // -----------------------------------------------------------------------
     195                 :            : 
     196                 :          0 : void SdTpOptionsContents::Reset( const SfxItemSet& rAttrs )
     197                 :            : {
     198                 :            :     SdOptionsContentsItem aOptsItem( (const SdOptionsContentsItem&) rAttrs.
     199                 :          0 :                         Get( ATTR_OPTIONS_CONTENTS ) );
     200                 :            : 
     201                 :            :     SdOptionsLayoutItem aLayoutItem( (const SdOptionsLayoutItem&) rAttrs.
     202                 :          0 :                         Get( ATTR_OPTIONS_LAYOUT ) );
     203                 :            : 
     204                 :          0 :     aCbxRuler.Check( aLayoutItem.GetOptionsLayout().IsRulerVisible() );
     205                 :          0 :     aCbxMoveOutline.Check( aLayoutItem.GetOptionsLayout().IsMoveOutline() );
     206                 :          0 :     aCbxDragStripes.Check( aLayoutItem.GetOptionsLayout().IsDragStripes() );
     207                 :          0 :     aCbxHandlesBezier.Check( aLayoutItem.GetOptionsLayout().IsHandlesBezier() );
     208                 :            : 
     209                 :          0 :     aCbxRuler.SaveValue();
     210                 :          0 :     aCbxMoveOutline.SaveValue();
     211                 :          0 :     aCbxDragStripes.SaveValue();
     212                 :          0 :     aCbxHandlesBezier.SaveValue();
     213                 :          0 : }
     214                 :            : 
     215                 :            : // -----------------------------------------------------------------------
     216                 :            : 
     217                 :          0 : SfxTabPage* SdTpOptionsContents::Create( Window* pWindow,
     218                 :            :                 const SfxItemSet& rAttrs )
     219                 :            : {
     220                 :          0 :     return( new SdTpOptionsContents( pWindow, rAttrs ) );
     221                 :            : }
     222                 :            : 
     223                 :            : /*************************************************************************
     224                 :            : |*
     225                 :            : |*  TabPage zum Einstellen der Sonstige-Optionen
     226                 :            : |*
     227                 :            : \************************************************************************/
     228                 :            : #define TABLE_COUNT 12
     229                 :            : #define TOKEN (sal_Unicode(':'))
     230                 :            : 
     231                 :          0 : SdTpOptionsMisc::SdTpOptionsMisc( Window* pParent, const SfxItemSet& rInAttrs  ) :
     232                 :            :         SfxTabPage          ( pParent, SdResId( TP_OPTIONS_MISC ), rInAttrs ),
     233                 :            :     aGrpText                    ( this, SdResId( GRP_TEXT ) ),
     234                 :            :     aCbxQuickEdit               ( this, SdResId( CBX_QUICKEDIT ) ),
     235                 :            :     aCbxPickThrough             ( this, SdResId( CBX_PICKTHROUGH ) ),
     236                 :            : 
     237                 :            :     // Template & Layout laufen z.Z. synchron!
     238                 :            :     aGrpProgramStart            ( this, SdResId( GRP_PROGRAMSTART ) ),
     239                 :            :     aCbxStartWithTemplate       ( this, SdResId( CBX_START_WITH_TEMPLATE ) ),
     240                 :            : 
     241                 :            :     aGrpSettings                ( this, SdResId( GRP_SETTINGS ) ),
     242                 :            :     aCbxMasterPageCache         ( this, SdResId( CBX_MASTERPAGE_CACHE ) ),
     243                 :            :     aCbxCopy                    ( this, SdResId( CBX_COPY ) ),
     244                 :            :     aCbxMarkedHitMovesAlways    ( this, SdResId( CBX_MARKED_HIT_MOVES_ALWAYS ) ),
     245                 :            :     aCbxCrookNoContortion       ( this, SdResId( CBX_CROOK_NO_CONTORTION ) ),
     246                 :            : 
     247                 :            :     aTxtMetric                  ( this, SdResId( FT_METRIC ) ),
     248                 :            :     aLbMetric                   ( this, SdResId( LB_METRIC ) ),
     249                 :            :     aTxtTabstop                 ( this, SdResId( FT_TABSTOP ) ),
     250                 :            :     aMtrFldTabstop              ( this, SdResId( MTR_FLD_TABSTOP ) ),
     251                 :            : 
     252                 :            :     aCbxStartWithActualPage     ( this, SdResId( CBX_START_WITH_ACTUAL_PAGE ) ),
     253                 :            :     aGrpStartWithActualPage     ( this, SdResId( GRP_START_WITH_ACTUAL_PAGE ) ),
     254                 :            :     aTxtCompatibility           ( this, SdResId( FT_COMPATIBILITY ) ),
     255                 :            :     aCbxUsePrinterMetrics       ( this, SdResId( CB_USE_PRINTER_METRICS ) ),
     256                 :            :     aCbxCompatibility           ( this, SdResId( CB_MERGE_PARA_DIST ) ),
     257                 :            :     aGrpScale                   ( this, SdResId( GRP_SCALE ) ),
     258                 :            :     aFtScale                    ( this, SdResId( FT_SCALE ) ),
     259                 :            :     aCbScale                    ( this, SdResId( CB_SCALE ) ),
     260                 :            :     aFtOriginal                 ( this, SdResId( FT_ORIGINAL ) ),
     261                 :            :     aFtEquivalent               ( this, SdResId( FT_EQUIVALENT ) ),
     262                 :            :     aFtPageWidth                ( this, SdResId( FT_PAGEWIDTH ) ),
     263                 :            :     aFiInfo1                    ( this, SdResId( FI_INFO_1 ) ),
     264                 :            :     aMtrFldOriginalWidth        ( this, SdResId( MTR_FLD_ORIGINAL_WIDTH ) ),
     265                 :            :     aFtPageHeight               ( this, SdResId( FT_PAGEHEIGHT ) ),
     266                 :            :     aFiInfo2                    ( this, SdResId( FI_INFO_2 ) ),
     267                 :            :     aMtrFldOriginalHeight       ( this, SdResId( MTR_FLD_ORIGINAL_HEIGHT ) ),
     268                 :            :     aMtrFldInfo1                ( this, WinBits( WB_HIDE ) ),
     269                 :          0 :     aMtrFldInfo2                ( this, WinBits( WB_HIDE ) )
     270                 :            : {
     271                 :          0 :     FreeResource();
     272                 :          0 :     SetExchangeSupport();
     273                 :            : 
     274                 :            :     // Metrik einstellen
     275                 :            :     FieldUnit eFUnit;
     276                 :            : 
     277                 :          0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
     278                 :          0 :     if ( rInAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
     279                 :            :     {
     280                 :          0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rInAttrs.Get( nWhich );
     281                 :          0 :         eFUnit = (FieldUnit)rItem.GetValue();
     282                 :            :     }
     283                 :            :     else
     284                 :          0 :         eFUnit = SfxModule::GetCurrentFieldUnit();
     285                 :            : 
     286                 :          0 :     SetFieldUnit( aMtrFldTabstop, eFUnit );
     287                 :            : 
     288                 :            :     // ListBox mit Metriken f"ullen
     289                 :          0 :     SvxStringArray aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE );
     290                 :            :     sal_uInt16 i;
     291                 :            : 
     292                 :          0 :     for ( i = 0; i < aMetricArr.Count(); ++i )
     293                 :            :     {
     294                 :          0 :         String sMetric = aMetricArr.GetStringByPos( i );
     295                 :          0 :         long nFieldUnit = aMetricArr.GetValue( i );
     296                 :          0 :         sal_uInt16 nPos = aLbMetric.InsertEntry( sMetric );
     297                 :          0 :         aLbMetric.SetEntryData( nPos, (void*)nFieldUnit );
     298                 :          0 :     }
     299                 :          0 :     aLbMetric.SetSelectHdl( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) );
     300                 :            : 
     301                 :          0 :     SetFieldUnit( aMtrFldOriginalWidth, eFUnit );
     302                 :          0 :     SetFieldUnit( aMtrFldOriginalHeight, eFUnit );
     303                 :          0 :     aMtrFldOriginalWidth.SetLast( 999999999 );
     304                 :          0 :     aMtrFldOriginalWidth.SetMax( 999999999 );
     305                 :          0 :     aMtrFldOriginalHeight.SetLast( 999999999 );
     306                 :          0 :     aMtrFldOriginalHeight.SetMax( 999999999 );
     307                 :            : 
     308                 :            :     // Temporaere Fields fuer Info-Texte (fuer Formatierung/Berechnung)
     309                 :          0 :     aMtrFldInfo1.SetUnit( eFUnit );
     310                 :          0 :     aMtrFldInfo1.SetMax( 999999999 );
     311                 :          0 :     aMtrFldInfo1.SetDecimalDigits( 2 );
     312                 :          0 :     aMtrFldInfo2.SetUnit( eFUnit );
     313                 :          0 :     aMtrFldInfo2.SetMax( 999999999 );
     314                 :          0 :     aMtrFldInfo2.SetDecimalDigits( 2 );
     315                 :            : 
     316                 :            :     // PoolUnit ermitteln
     317                 :          0 :     SfxItemPool* pPool = rInAttrs.GetPool();
     318                 :            :     DBG_ASSERT( pPool, "Wo ist der Pool?" );
     319                 :          0 :     ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
     320                 :            : 
     321                 :            :     // Fuellen der CB
     322                 :            :     sal_uInt16 aTable[ TABLE_COUNT ] =
     323                 :          0 :         { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
     324                 :            : 
     325                 :          0 :     for( i = 0; i < TABLE_COUNT; i++ )
     326                 :          0 :         aCbScale.InsertEntry( GetScale( 1, aTable[i] ) );
     327                 :          0 :     for( i = 1; i < TABLE_COUNT; i++ )
     328                 :          0 :         aCbScale.InsertEntry( GetScale(  aTable[i], 1 ) );
     329                 :          0 : }
     330                 :            : 
     331                 :            : // -----------------------------------------------------------------------
     332                 :            : 
     333                 :          0 : SdTpOptionsMisc::~SdTpOptionsMisc()
     334                 :            : {
     335                 :          0 : }
     336                 :            : // -----------------------------------------------------------------------
     337                 :          0 : void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet )
     338                 :            : {
     339                 :            :     // Hier muss noch einmal SaveValue gerufen werden, da sonst u.U.
     340                 :            :     // der Wert in anderen TabPages keine Wirkung hat
     341                 :          0 :     aLbMetric.SaveValue();
     342                 :            :     // Metrik ggfs. aendern (da TabPage im Dialog liegt,
     343                 :            :     // wo die Metrik eingestellt werden kann
     344                 :          0 :     const SfxPoolItem* pAttr = NULL;
     345                 :          0 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC , sal_False,
     346                 :          0 :                                     (const SfxPoolItem**)&pAttr ))
     347                 :            :     {
     348                 :          0 :         const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr;
     349                 :            : 
     350                 :          0 :         FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue();
     351                 :            : 
     352                 :          0 :         if( eFUnit != aMtrFldOriginalWidth.GetUnit() )
     353                 :            :         {
     354                 :            :             // Metriken einstellen
     355                 :          0 :             sal_Int64 nVal = aMtrFldOriginalWidth.Denormalize( aMtrFldOriginalWidth.GetValue( FUNIT_TWIP ) );
     356                 :          0 :             SetFieldUnit( aMtrFldOriginalWidth, eFUnit, sal_True );
     357                 :          0 :             aMtrFldOriginalWidth.SetValue( aMtrFldOriginalWidth.Normalize( nVal ), FUNIT_TWIP );
     358                 :            : 
     359                 :          0 :             nVal = aMtrFldOriginalHeight.Denormalize( aMtrFldOriginalHeight.GetValue( FUNIT_TWIP ) );
     360                 :          0 :             SetFieldUnit( aMtrFldOriginalHeight, eFUnit, sal_True );
     361                 :          0 :             aMtrFldOriginalHeight.SetValue( aMtrFldOriginalHeight.Normalize( nVal ), FUNIT_TWIP );
     362                 :            : 
     363                 :            : 
     364                 :          0 :             if( nWidth != 0 && nHeight != 0 )
     365                 :            :             {
     366                 :          0 :                 aMtrFldInfo1.SetUnit( eFUnit );
     367                 :          0 :                 aMtrFldInfo2.SetUnit( eFUnit );
     368                 :            : 
     369                 :          0 :                 SetMetricValue( aMtrFldInfo1, nWidth, ePoolUnit );
     370                 :          0 :                 aInfo1 = aMtrFldInfo1.GetText();
     371                 :          0 :                 aFiInfo1.SetText( aInfo1 );
     372                 :            : 
     373                 :          0 :                 SetMetricValue( aMtrFldInfo2, nHeight, ePoolUnit );
     374                 :          0 :                 aInfo2 = aMtrFldInfo2.GetText();
     375                 :          0 :                 aFiInfo2.SetText( aInfo2 );
     376                 :            :             }
     377                 :            :         }
     378                 :            :     }
     379                 :          0 : }
     380                 :            : 
     381                 :            : // -----------------------------------------------------------------------
     382                 :            : 
     383                 :          0 : int SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet )
     384                 :            : {
     385                 :            :     // Parsercheck
     386                 :            :     sal_Int32 nX, nY;
     387                 :          0 :     if( SetScale( aCbScale.GetText(), nX, nY ) )
     388                 :            :     {
     389                 :          0 :         if( pActiveSet )
     390                 :          0 :             FillItemSet( *pActiveSet );
     391                 :          0 :         return( LEAVE_PAGE );
     392                 :            :     }
     393                 :          0 :     WarningBox aWarnBox( GetParent(), WB_YES_NO, String( SdResId( STR_WARN_SCALE_FAIL ) ) );
     394                 :          0 :     short nReturn = aWarnBox.Execute();
     395                 :            : 
     396                 :          0 :     if( nReturn == RET_YES )
     397                 :          0 :         return( KEEP_PAGE );
     398                 :            : 
     399                 :          0 :     if( pActiveSet )
     400                 :          0 :         FillItemSet( *pActiveSet );
     401                 :            : 
     402                 :          0 :     return( LEAVE_PAGE );
     403                 :            : }
     404                 :            : 
     405                 :            : // -----------------------------------------------------------------------
     406                 :            : 
     407                 :          0 : sal_Bool SdTpOptionsMisc::FillItemSet( SfxItemSet& rAttrs )
     408                 :            : {
     409                 :          0 :     sal_Bool bModified = sal_False;
     410                 :            : 
     411                 :          0 :     if( aCbxStartWithTemplate.GetSavedValue()   != aCbxStartWithTemplate.IsChecked() ||
     412                 :          0 :         aCbxMarkedHitMovesAlways.GetSavedValue()!= aCbxMarkedHitMovesAlways.IsChecked() ||
     413                 :          0 :         aCbxCrookNoContortion.GetSavedValue()   != aCbxCrookNoContortion.IsChecked() ||
     414                 :          0 :         aCbxQuickEdit.GetSavedValue()           != aCbxQuickEdit.IsChecked() ||
     415                 :          0 :         aCbxPickThrough.GetSavedValue()         != aCbxPickThrough.IsChecked() ||
     416                 :          0 :         aCbxMasterPageCache.GetSavedValue()     != aCbxMasterPageCache.IsChecked() ||
     417                 :          0 :         aCbxCopy.GetSavedValue()                != aCbxCopy.IsChecked() ||
     418                 :          0 :         aCbxStartWithActualPage.GetSavedValue() != aCbxStartWithActualPage.IsChecked() ||
     419                 :          0 :         aCbxCompatibility.GetSavedValue()       != aCbxCompatibility.IsChecked() ||
     420                 :          0 :         aCbxUsePrinterMetrics.GetSavedValue()   != aCbxUsePrinterMetrics.IsChecked() )
     421                 :            :     {
     422                 :          0 :         SdOptionsMiscItem aOptsItem( ATTR_OPTIONS_MISC );
     423                 :            : 
     424                 :          0 :         aOptsItem.GetOptionsMisc().SetStartWithTemplate( aCbxStartWithTemplate.IsChecked() );
     425                 :          0 :         aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( aCbxMarkedHitMovesAlways.IsChecked() );
     426                 :          0 :         aOptsItem.GetOptionsMisc().SetCrookNoContortion( aCbxCrookNoContortion.IsChecked() );
     427                 :          0 :         aOptsItem.GetOptionsMisc().SetQuickEdit( aCbxQuickEdit.IsChecked() );
     428                 :          0 :         aOptsItem.GetOptionsMisc().SetPickThrough( aCbxPickThrough.IsChecked() );
     429                 :          0 :         aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( aCbxMasterPageCache.IsChecked() );
     430                 :          0 :         aOptsItem.GetOptionsMisc().SetDragWithCopy( aCbxCopy.IsChecked() );
     431                 :          0 :         aOptsItem.GetOptionsMisc().SetStartWithActualPage( aCbxStartWithActualPage.IsChecked() );
     432                 :          0 :         aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( aCbxCompatibility.IsChecked() );
     433                 :          0 :         aOptsItem.GetOptionsMisc().SetPrinterIndependentLayout (
     434                 :          0 :             aCbxUsePrinterMetrics.IsChecked()
     435                 :            :             ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
     436                 :          0 :             : ::com::sun::star::document::PrinterIndependentLayout::ENABLED);
     437                 :          0 :         rAttrs.Put( aOptsItem );
     438                 :            : 
     439                 :          0 :         bModified = sal_True;
     440                 :            :     }
     441                 :            : 
     442                 :            :     // Metrik
     443                 :          0 :     const sal_uInt16 nMPos = aLbMetric.GetSelectEntryPos();
     444                 :          0 :     if ( nMPos != aLbMetric.GetSavedValue() )
     445                 :            :     {
     446                 :          0 :         sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbMetric.GetEntryData( nMPos );
     447                 :          0 :         rAttrs.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ),
     448                 :          0 :                                      (sal_uInt16)nFieldUnit ) );
     449                 :          0 :         bModified |= sal_True;
     450                 :            :     }
     451                 :            : 
     452                 :            :     // Tabulatorabstand
     453                 :          0 :     if( aMtrFldTabstop.GetText() != aMtrFldTabstop.GetSavedValue() )
     454                 :            :     {
     455                 :          0 :         sal_uInt16 nWh = GetWhich( SID_ATTR_DEFTABSTOP );
     456                 :          0 :         SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWh );
     457                 :          0 :         SfxUInt16Item aDef( nWh,(sal_uInt16)GetCoreValue( aMtrFldTabstop, eUnit ) );
     458                 :          0 :         rAttrs.Put( aDef );
     459                 :          0 :         bModified |= sal_True;
     460                 :            :     }
     461                 :            : 
     462                 :            :     sal_Int32 nX, nY;
     463                 :          0 :     if( SetScale( aCbScale.GetText(), nX, nY ) )
     464                 :            :     {
     465                 :          0 :         rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
     466                 :          0 :         rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
     467                 :            : 
     468                 :          0 :         bModified = sal_True;
     469                 :            :     }
     470                 :            : 
     471                 :          0 :     return( bModified );
     472                 :            : }
     473                 :            : 
     474                 :            : // -----------------------------------------------------------------------
     475                 :            : 
     476                 :          0 : void SdTpOptionsMisc::Reset( const SfxItemSet& rAttrs )
     477                 :            : {
     478                 :            :     SdOptionsMiscItem aOptsItem( (const SdOptionsMiscItem&) rAttrs.
     479                 :          0 :                         Get( ATTR_OPTIONS_MISC ) );
     480                 :            : 
     481                 :          0 :     aCbxStartWithTemplate.Check( aOptsItem.GetOptionsMisc().IsStartWithTemplate() );
     482                 :          0 :     aCbxMarkedHitMovesAlways.Check( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() );
     483                 :          0 :     aCbxCrookNoContortion.Check( aOptsItem.GetOptionsMisc().IsCrookNoContortion() );
     484                 :          0 :     aCbxQuickEdit.Check( aOptsItem.GetOptionsMisc().IsQuickEdit() );
     485                 :          0 :     aCbxPickThrough.Check( aOptsItem.GetOptionsMisc().IsPickThrough() );
     486                 :          0 :     aCbxMasterPageCache.Check( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() );
     487                 :          0 :     aCbxCopy.Check( aOptsItem.GetOptionsMisc().IsDragWithCopy() );
     488                 :          0 :     aCbxStartWithActualPage.Check( aOptsItem.GetOptionsMisc().IsStartWithActualPage() );
     489                 :          0 :     aCbxCompatibility.Check( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() );
     490                 :          0 :     aCbxUsePrinterMetrics.Check( aOptsItem.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
     491                 :          0 :     aCbxStartWithTemplate.SaveValue();
     492                 :          0 :     aCbxMarkedHitMovesAlways.SaveValue();
     493                 :          0 :     aCbxCrookNoContortion.SaveValue();
     494                 :          0 :     aCbxQuickEdit.SaveValue();
     495                 :          0 :     aCbxPickThrough.SaveValue();
     496                 :            : 
     497                 :          0 :     aCbxMasterPageCache.SaveValue();
     498                 :          0 :     aCbxCopy.SaveValue();
     499                 :          0 :     aCbxStartWithActualPage.SaveValue();
     500                 :          0 :     aCbxCompatibility.SaveValue();
     501                 :          0 :     aCbxUsePrinterMetrics.SaveValue();
     502                 :            : 
     503                 :            :     // Metrik
     504                 :          0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
     505                 :          0 :     aLbMetric.SetNoSelection();
     506                 :            : 
     507                 :          0 :     if ( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
     508                 :            :     {
     509                 :          0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
     510                 :          0 :         long nFieldUnit = (long)rItem.GetValue();
     511                 :            : 
     512                 :          0 :         for ( sal_uInt16 i = 0; i < aLbMetric.GetEntryCount(); ++i )
     513                 :            :         {
     514                 :          0 :             if ( (long)aLbMetric.GetEntryData( i ) == nFieldUnit )
     515                 :            :             {
     516                 :          0 :                 aLbMetric.SelectEntryPos( i );
     517                 :          0 :                 break;
     518                 :            :             }
     519                 :            :         }
     520                 :            :     }
     521                 :            : 
     522                 :            :     // Tabulatorabstand
     523                 :          0 :     nWhich = GetWhich( SID_ATTR_DEFTABSTOP );
     524                 :          0 :     if( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
     525                 :            :     {
     526                 :          0 :         SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWhich );
     527                 :          0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
     528                 :          0 :         SetMetricValue( aMtrFldTabstop, rItem.GetValue(), eUnit );
     529                 :            :     }
     530                 :          0 :     aLbMetric.SaveValue();
     531                 :          0 :     aMtrFldTabstop.SaveValue();
     532                 :            :     //Scale
     533                 :            :     sal_Int32 nX = ( (const SfxInt32Item&) rAttrs.
     534                 :          0 :                  Get( ATTR_OPTIONS_SCALE_X ) ).GetValue();
     535                 :            :     sal_Int32 nY = ( (const SfxInt32Item&) rAttrs.
     536                 :          0 :                  Get( ATTR_OPTIONS_SCALE_Y ) ).GetValue();
     537                 :            :     nWidth = ( (const SfxUInt32Item&) rAttrs.
     538                 :          0 :                     Get( ATTR_OPTIONS_SCALE_WIDTH ) ).GetValue();
     539                 :            :     nHeight = ( (const SfxUInt32Item&) rAttrs.
     540                 :          0 :                     Get( ATTR_OPTIONS_SCALE_HEIGHT ) ).GetValue();
     541                 :            : 
     542                 :          0 :     aCbScale.SetText( GetScale( nX, nY ) );
     543                 :            : 
     544                 :          0 :     aFtOriginal.Hide();
     545                 :          0 :     aFtEquivalent.Hide();
     546                 :          0 :     aMtrFldOriginalWidth.Hide();
     547                 :          0 :     aMtrFldOriginalWidth.SetText( aInfo1 ); // leer
     548                 :          0 :     aMtrFldOriginalHeight.Hide();
     549                 :          0 :     aMtrFldOriginalHeight.SetText( aInfo2 ); //leer
     550                 :          0 :     aFtPageWidth.Hide();
     551                 :          0 :     aFtPageHeight.Hide();
     552                 :          0 :     aFiInfo1.Hide();
     553                 :          0 :     aFiInfo2.Hide();
     554                 :            : 
     555                 :          0 :     UpdateCompatibilityControls ();
     556                 :          0 : }
     557                 :            : 
     558                 :            : // -----------------------------------------------------------------------
     559                 :            : 
     560                 :          0 : SfxTabPage* SdTpOptionsMisc::Create( Window* pWindow,
     561                 :            :                 const SfxItemSet& rAttrs )
     562                 :            : {
     563                 :          0 :     return( new SdTpOptionsMisc( pWindow, rAttrs ) );
     564                 :            : }
     565                 :            : //------------------------------------------------------------------------
     566                 :            : 
     567                 :          0 : IMPL_LINK_NOARG(SdTpOptionsMisc, SelectMetricHdl_Impl)
     568                 :            : {
     569                 :          0 :     sal_uInt16 nPos = aLbMetric.GetSelectEntryPos();
     570                 :            : 
     571                 :          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     572                 :            :     {
     573                 :          0 :         FieldUnit eUnit = (FieldUnit)(long)aLbMetric.GetEntryData( nPos );
     574                 :            :         sal_Int64 nVal =
     575                 :          0 :             aMtrFldTabstop.Denormalize( aMtrFldTabstop.GetValue( FUNIT_TWIP ) );
     576                 :          0 :         SetFieldUnit( aMtrFldTabstop, eUnit );
     577                 :          0 :         aMtrFldTabstop.SetValue( aMtrFldTabstop.Normalize( nVal ), FUNIT_TWIP );
     578                 :            :     }
     579                 :          0 :     return 0;
     580                 :            : }
     581                 :            : 
     582                 :            : 
     583                 :            : namespace {
     584                 :          0 : void lcl_MoveWin( Window& rWin, long nYDiff)
     585                 :            : {
     586                 :          0 :     Point aPos(rWin.GetPosPixel());
     587                 :          0 :     aPos.Y() += nYDiff;
     588                 :          0 :     rWin.SetPosPixel (aPos);
     589                 :          0 : }
     590                 :            : 
     591                 :          0 : void lcl_MoveWin( Window& rWin, long nXdiff, long nYdiff)
     592                 :            : {
     593                 :          0 :     Point aPos(rWin.GetPosPixel());
     594                 :          0 :     aPos.X() += nXdiff;
     595                 :          0 :     aPos.Y() += nYdiff;
     596                 :          0 :     rWin.SetPosPixel(aPos);
     597                 :          0 : }
     598                 :            : }
     599                 :            : 
     600                 :          0 : void SdTpOptionsMisc::SetImpressMode (void)
     601                 :            : {
     602                 :          0 :     long nDialogWidth = GetSizePixel().Width();
     603                 :          0 :     long nLineHeight = aCbxPickThrough.GetPosPixel().Y()
     604                 :          0 :         - aCbxQuickEdit.GetPosPixel().Y();
     605                 :            : 
     606                 :            :     // Put both "Text objects" check boxes side by side.
     607                 :            :     lcl_MoveWin (aCbxPickThrough,
     608                 :          0 :         nDialogWidth/2 - aCbxPickThrough.GetPosPixel().X(),
     609                 :          0 :         -nLineHeight);
     610                 :            : 
     611                 :            :     // Move the other controls up one line.
     612                 :          0 :     lcl_MoveWin (aGrpProgramStart, -nLineHeight);
     613                 :          0 :     lcl_MoveWin (aCbxStartWithTemplate, -nLineHeight);
     614                 :          0 :     lcl_MoveWin (aGrpSettings, -nLineHeight);
     615                 :          0 :     lcl_MoveWin (aCbxMasterPageCache, -nLineHeight);
     616                 :          0 :     lcl_MoveWin (aCbxCopy, -nLineHeight);
     617                 :          0 :     lcl_MoveWin (aCbxMarkedHitMovesAlways, -nLineHeight);
     618                 :          0 :     lcl_MoveWin (aCbxCrookNoContortion, -nLineHeight);
     619                 :          0 :     lcl_MoveWin (aTxtMetric, -nLineHeight);
     620                 :          0 :     lcl_MoveWin (aLbMetric, -nLineHeight);
     621                 :          0 :     lcl_MoveWin (aTxtTabstop, -nLineHeight);
     622                 :          0 :     lcl_MoveWin (aMtrFldTabstop, -nLineHeight);
     623                 :          0 :     lcl_MoveWin (aGrpStartWithActualPage, -nLineHeight);
     624                 :          0 :     lcl_MoveWin (aCbxStartWithActualPage, -nLineHeight);
     625                 :          0 :     lcl_MoveWin (aTxtCompatibility, -nLineHeight);
     626                 :            : 
     627                 :            :     // Move the printer-independent-metrics check box up two lines to change
     628                 :            :     // places with spacing-between-paragraphs check box.
     629                 :          0 :     lcl_MoveWin (aCbxUsePrinterMetrics, -2*nLineHeight);
     630                 :          0 : }
     631                 :            : 
     632                 :          0 : void    SdTpOptionsMisc::SetDrawMode()
     633                 :            : {
     634                 :          0 :     aCbxStartWithTemplate.Hide();
     635                 :          0 :     aGrpProgramStart.Hide();
     636                 :          0 :     aCbxStartWithActualPage.Hide();
     637                 :          0 :     aCbxCompatibility.Hide();
     638                 :          0 :     aGrpStartWithActualPage.Hide();
     639                 :          0 :     aCbxCrookNoContortion.Show();
     640                 :            : 
     641                 :          0 :     aGrpScale.Show();
     642                 :          0 :     aFtScale.Show();
     643                 :          0 :     aCbScale.Show();
     644                 :            : 
     645                 :          0 :     aFtOriginal.Show();
     646                 :          0 :     aFtEquivalent.Show();
     647                 :            : 
     648                 :          0 :     aFtPageWidth.Show();
     649                 :          0 :     aFiInfo1.Show();
     650                 :          0 :     aMtrFldOriginalWidth.Show();
     651                 :            : 
     652                 :          0 :     aFtPageHeight.Show();
     653                 :          0 :     aFiInfo2.Show();
     654                 :          0 :     aMtrFldOriginalHeight.Show();
     655                 :            : 
     656                 :          0 :     long nDiff = aGrpSettings.GetPosPixel().Y() - aGrpProgramStart.GetPosPixel().Y();
     657                 :          0 :     lcl_MoveWin( aGrpSettings, -nDiff );
     658                 :          0 :     lcl_MoveWin( aCbxMasterPageCache, -nDiff );
     659                 :          0 :     lcl_MoveWin( aCbxCopy, -nDiff );
     660                 :          0 :     lcl_MoveWin( aCbxMarkedHitMovesAlways, -nDiff );
     661                 :          0 :     lcl_MoveWin( aCbxCrookNoContortion, -nDiff );
     662                 :          0 :     nDiff -= aCbxCrookNoContortion.GetPosPixel().Y() - aCbxMarkedHitMovesAlways.GetPosPixel().Y();
     663                 :          0 :     lcl_MoveWin( aTxtMetric, -nDiff );
     664                 :          0 :     lcl_MoveWin( aLbMetric, -nDiff );
     665                 :          0 :     lcl_MoveWin( aTxtTabstop, -nDiff );
     666                 :          0 :     lcl_MoveWin( aMtrFldTabstop, -nDiff );
     667                 :            : 
     668                 :            :     // Move the scale controls so that they are visually centered betwen the
     669                 :            :     // group controls above and below.
     670                 :          0 :     lcl_MoveWin (aFtScale, -17);
     671                 :          0 :     lcl_MoveWin (aCbScale, -17);
     672                 :            : 
     673                 :            :     // Move the printer-independent-metrics check box in the place that the
     674                 :            :     // spacing-between-paragraphs check box normally is in.
     675                 :          0 :     aCbxUsePrinterMetrics.SetPosPixel (aCbxCompatibility.GetPosPixel());
     676                 :          0 : }
     677                 :            : 
     678                 :            : // -----------------------------------------------------------------------
     679                 :            : 
     680                 :          0 : String SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY )
     681                 :            : {
     682                 :          0 :     String aScale( UniString::CreateFromInt32( nX ) );
     683                 :          0 :     aScale.Append( TOKEN );
     684                 :          0 :     aScale.Append( UniString::CreateFromInt32( nY ) );
     685                 :            : 
     686                 :          0 :     return( aScale );
     687                 :            : }
     688                 :            : 
     689                 :            : // -----------------------------------------------------------------------
     690                 :            : 
     691                 :          0 : sal_Bool SdTpOptionsMisc::SetScale( const String& aScale, sal_Int32& rX, sal_Int32& rY )
     692                 :            : {
     693                 :          0 :     if( comphelper::string::getTokenCount(aScale, TOKEN) != 2 )
     694                 :          0 :         return( sal_False );
     695                 :            : 
     696                 :          0 :     rtl::OUString aTmp(aScale.GetToken( 0, TOKEN ));
     697                 :          0 :     if (!comphelper::string::isdigitAsciiString(aTmp))
     698                 :          0 :         return sal_False;
     699                 :            : 
     700                 :          0 :     rX = (long) aTmp.toInt32();
     701                 :          0 :     if( rX == 0 )
     702                 :          0 :         return( sal_False );
     703                 :            : 
     704                 :          0 :     aTmp = aScale.GetToken( 1, TOKEN );
     705                 :          0 :     if (!comphelper::string::isdigitAsciiString(aTmp))
     706                 :          0 :         return sal_False;
     707                 :            : 
     708                 :          0 :     rY = (long) aTmp.toInt32();
     709                 :          0 :     if( rY == 0 )
     710                 :          0 :         return sal_False;
     711                 :            : 
     712                 :          0 :     return sal_True;
     713                 :            : }
     714                 :            : 
     715                 :          0 : void SdTpOptionsMisc::UpdateCompatibilityControls (void)
     716                 :            : {
     717                 :            :     // Disable the compatibility controls by default.  Enable them only when
     718                 :            :     // there is at least one open document.
     719                 :          0 :     sal_Bool bIsEnabled = sal_False;
     720                 :            : 
     721                 :            :     try
     722                 :            :     {
     723                 :            :         // Get a component enumeration from the desktop and search it for documents.
     724                 :            :         Reference<lang::XMultiServiceFactory> xFactory (
     725                 :          0 :             ::comphelper::getProcessServiceFactory ());
     726                 :            :         do
     727                 :            :         {
     728                 :          0 :             if ( ! xFactory.is())
     729                 :            :                 break;
     730                 :            : 
     731                 :          0 :             Reference<frame::XDesktop> xDesktop (xFactory->createInstance ("com.sun.star.frame.Desktop"), UNO_QUERY);
     732                 :          0 :             if ( ! xDesktop.is())
     733                 :            :                 break;
     734                 :            : 
     735                 :            :             Reference<container::XEnumerationAccess> xComponents (
     736                 :          0 :                 xDesktop->getComponents(), UNO_QUERY);
     737                 :          0 :             if ( ! xComponents.is())
     738                 :            :                 break;
     739                 :            : 
     740                 :            :             Reference<container::XEnumeration> xEnumeration (
     741                 :          0 :                 xComponents->createEnumeration());
     742                 :          0 :             if ( ! xEnumeration.is())
     743                 :            :                 break;
     744                 :            : 
     745                 :          0 :             while (xEnumeration->hasMoreElements())
     746                 :            :             {
     747                 :          0 :                 Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY);
     748                 :          0 :                 if (xModel.is())
     749                 :            :                 {
     750                 :            :                     // There is at leas one model/document: Enable the compatibility controls.
     751                 :          0 :                     bIsEnabled = sal_True;
     752                 :            :                     break;
     753                 :            :                 }
     754                 :          0 :             }
     755                 :            : 
     756                 :            :         }
     757                 :          0 :         while (false); // One 'loop'.
     758                 :            :     }
     759                 :          0 :     catch (const uno::Exception&)
     760                 :            :     {
     761                 :            :         // When there is an exception then simply use the default value of
     762                 :            :         // bIsEnabled and disable the controls.
     763                 :            :     }
     764                 :            : 
     765                 :          0 :     aTxtCompatibility.Enable (bIsEnabled);
     766                 :          0 :     aCbxCompatibility.Enable(bIsEnabled);
     767                 :          0 :     aCbxUsePrinterMetrics.Enable (bIsEnabled);
     768                 :          0 : }
     769                 :            : 
     770                 :          0 : void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet)
     771                 :            : {
     772                 :          0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False);
     773                 :          0 :     if (pFlagItem)
     774                 :            :     {
     775                 :          0 :         sal_uInt32 nFlags=pFlagItem->GetValue();
     776                 :          0 :         if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
     777                 :          0 :             SetDrawMode();
     778                 :          0 :         if ( ( nFlags & SD_IMPRESS_MODE ) == SD_IMPRESS_MODE )
     779                 :          0 :             SetImpressMode();
     780                 :            :     }
     781                 :          0 : }
     782                 :            : 
     783                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10