LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/dlg - tpoption.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 376 0.0 %
Date: 2013-07-09 Functions: 0 30 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      21             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      22             : #include <com/sun/star/frame/Desktop.hpp>
      23             : #include <com/sun/star/lang/XComponent.hpp>
      24             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <comphelper/string.hxx>
      27             : #include <com/sun/star/uno/Exception.hpp>
      28             : #include <sfx2/module.hxx>
      29             : #include <sfx2/app.hxx>
      30             : #include <svx/svxids.hrc>
      31             : #include <svx/dialogs.hrc>
      32             : #include <svx/strarray.hxx>
      33             : #include <svx/dlgutil.hxx>
      34             : #include <vcl/msgbox.hxx>
      35             : 
      36             : #include "sdattr.hxx"
      37             : #include "sdresid.hxx"
      38             : #include "optsitem.hxx"
      39             : #include "tpoption.hrc"
      40             : #include "tpoption.hxx"
      41             : #include "strings.hrc"
      42             : #include "app.hrc"
      43             : #include <svl/intitem.hxx>
      44             : #include <sfx2/request.hxx>
      45             : 
      46             : using namespace ::com::sun::star;
      47             : using namespace ::com::sun::star::uno;
      48             : 
      49           0 : SdTpOptionsSnap::SdTpOptionsSnap( Window* pParent, const SfxItemSet& rInAttrs  ) :
      50           0 :         SvxGridTabPage(pParent, rInAttrs)
      51             : {
      52           0 :     aGrpSnap.Show();
      53           0 :     aCbxSnapHelplines.Show();
      54           0 :     aCbxSnapBorder.Show();
      55           0 :     aCbxSnapFrame.Show();
      56           0 :     aCbxSnapPoints.Show();
      57           0 :     aFtSnapArea.Show();
      58           0 :     aMtrFldSnapArea.Show();
      59           0 :     aGrpOrtho.Show();
      60           0 :     aCbxOrtho.Show();
      61           0 :     aCbxBigOrtho.Show();
      62           0 :     aCbxRotate.Show();
      63           0 :     aMtrFldAngle.Show();
      64           0 :     aFtBezAngle.Show();
      65           0 :     aMtrFldBezAngle.Show();
      66           0 :     aSeparatorFL.Show();
      67           0 : }
      68             : 
      69             : // -----------------------------------------------------------------------
      70             : 
      71           0 : SdTpOptionsSnap::~SdTpOptionsSnap()
      72             : {
      73           0 : }
      74             : 
      75             : // -----------------------------------------------------------------------
      76             : 
      77           0 : sal_Bool SdTpOptionsSnap::FillItemSet( SfxItemSet& rAttrs )
      78             : {
      79           0 :     SvxGridTabPage::FillItemSet(rAttrs);
      80           0 :     SdOptionsSnapItem aOptsItem( ATTR_OPTIONS_SNAP );
      81             : 
      82           0 :     aOptsItem.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines.IsChecked() );
      83           0 :     aOptsItem.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder.IsChecked() );
      84           0 :     aOptsItem.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame.IsChecked() );
      85           0 :     aOptsItem.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints.IsChecked() );
      86           0 :     aOptsItem.GetOptionsSnap().SetOrtho( aCbxOrtho.IsChecked() );
      87           0 :     aOptsItem.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho.IsChecked() );
      88           0 :     aOptsItem.GetOptionsSnap().SetRotate( aCbxRotate.IsChecked() );
      89           0 :     aOptsItem.GetOptionsSnap().SetSnapArea( (sal_Int16) aMtrFldSnapArea.GetValue() );
      90           0 :     aOptsItem.GetOptionsSnap().SetAngle( (sal_Int16) aMtrFldAngle.GetValue() );
      91           0 :     aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (sal_Int16) aMtrFldBezAngle.GetValue() );
      92             : 
      93           0 :     rAttrs.Put( aOptsItem );
      94             : 
      95             :     // we get a possible existing GridItem, this ensures that we do net set
      96             :     // some default values by accident
      97           0 :     return( sal_True );
      98             : }
      99             : 
     100             : // -----------------------------------------------------------------------
     101             : 
     102           0 : void SdTpOptionsSnap::Reset( const SfxItemSet& rAttrs )
     103             : {
     104           0 :     SvxGridTabPage::Reset(rAttrs);
     105             : 
     106             :     SdOptionsSnapItem aOptsItem( (const SdOptionsSnapItem&) rAttrs.
     107           0 :                         Get( ATTR_OPTIONS_SNAP ) );
     108             : 
     109           0 :     aCbxSnapHelplines.Check( aOptsItem.GetOptionsSnap().IsSnapHelplines() );
     110           0 :     aCbxSnapBorder.Check( aOptsItem.GetOptionsSnap().IsSnapBorder() );
     111           0 :     aCbxSnapFrame.Check( aOptsItem.GetOptionsSnap().IsSnapFrame() );
     112           0 :     aCbxSnapPoints.Check( aOptsItem.GetOptionsSnap().IsSnapPoints() );
     113           0 :     aCbxOrtho.Check( aOptsItem.GetOptionsSnap().IsOrtho() );
     114           0 :     aCbxBigOrtho.Check( aOptsItem.GetOptionsSnap().IsBigOrtho() );
     115           0 :     aCbxRotate.Check( aOptsItem.GetOptionsSnap().IsRotate() );
     116           0 :     aMtrFldSnapArea.SetValue( aOptsItem.GetOptionsSnap().GetSnapArea() );
     117           0 :     aMtrFldAngle.SetValue( aOptsItem.GetOptionsSnap().GetAngle() );
     118           0 :     aMtrFldBezAngle.SetValue( aOptsItem.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
     119             : 
     120           0 :     aCbxRotate.GetClickHdl().Call(0);
     121           0 : }
     122             : 
     123             : // -----------------------------------------------------------------------
     124             : 
     125           0 : SfxTabPage* SdTpOptionsSnap::Create( Window* pWindow,
     126             :                 const SfxItemSet& rAttrs )
     127             : {
     128           0 :     return( new SdTpOptionsSnap( pWindow, rAttrs ) );
     129             : }
     130             : 
     131             : /*************************************************************************
     132             : |*
     133             : |*  TabPage to adjust the content options
     134             : |*
     135             : \************************************************************************/
     136             : 
     137           0 : SdTpOptionsContents::SdTpOptionsContents( Window* pParent, const SfxItemSet& rInAttrs  ) :
     138           0 :     SfxTabPage ( pParent, "SdViewPage", "modules/simpress/ui/sdviewpage.ui", rInAttrs )
     139             : {
     140           0 :     get( m_pCbxRuler, "ruler");
     141           0 :     get( m_pCbxDragStripes, "dragstripes");
     142           0 :     get( m_pCbxHandlesBezier, "handlesbezier");
     143           0 :     get( m_pCbxMoveOutline, "moveoutline");
     144           0 : }
     145             : 
     146             : // -----------------------------------------------------------------------
     147             : 
     148           0 : SdTpOptionsContents::~SdTpOptionsContents()
     149             : {
     150           0 : }
     151             : 
     152             : // -----------------------------------------------------------------------
     153             : 
     154           0 : sal_Bool SdTpOptionsContents::FillItemSet( SfxItemSet& rAttrs )
     155             : {
     156           0 :     sal_Bool bModified = sal_False;
     157             : 
     158           0 :     if( m_pCbxRuler->GetSavedValue()           != m_pCbxRuler->IsChecked() ||
     159           0 :         m_pCbxMoveOutline->GetSavedValue()     != m_pCbxMoveOutline->IsChecked() ||
     160           0 :         m_pCbxDragStripes->GetSavedValue()     != m_pCbxDragStripes->IsChecked() ||
     161           0 :         m_pCbxHandlesBezier->GetSavedValue()   != m_pCbxHandlesBezier->IsChecked() )
     162             :     {
     163           0 :         SdOptionsLayoutItem aOptsItem( ATTR_OPTIONS_LAYOUT );
     164             : 
     165           0 :         aOptsItem.GetOptionsLayout().SetRulerVisible( m_pCbxRuler->IsChecked() );
     166           0 :         aOptsItem.GetOptionsLayout().SetMoveOutline( m_pCbxMoveOutline->IsChecked() );
     167           0 :         aOptsItem.GetOptionsLayout().SetDragStripes( m_pCbxDragStripes->IsChecked() );
     168           0 :         aOptsItem.GetOptionsLayout().SetHandlesBezier( m_pCbxHandlesBezier->IsChecked() );
     169             : 
     170           0 :         rAttrs.Put( aOptsItem );
     171           0 :         bModified = sal_True;
     172             :     }
     173           0 :     return( bModified );
     174             : }
     175             : 
     176             : // -----------------------------------------------------------------------
     177             : 
     178           0 : void SdTpOptionsContents::Reset( const SfxItemSet& rAttrs )
     179             : {
     180             :     SdOptionsContentsItem aOptsItem( (const SdOptionsContentsItem&) rAttrs.
     181           0 :                         Get( ATTR_OPTIONS_CONTENTS ) );
     182             : 
     183             :     SdOptionsLayoutItem aLayoutItem( (const SdOptionsLayoutItem&) rAttrs.
     184           0 :                         Get( ATTR_OPTIONS_LAYOUT ) );
     185             : 
     186           0 :     m_pCbxRuler->Check( aLayoutItem.GetOptionsLayout().IsRulerVisible() );
     187           0 :     m_pCbxMoveOutline->Check( aLayoutItem.GetOptionsLayout().IsMoveOutline() );
     188           0 :     m_pCbxDragStripes->Check( aLayoutItem.GetOptionsLayout().IsDragStripes() );
     189           0 :     m_pCbxHandlesBezier->Check( aLayoutItem.GetOptionsLayout().IsHandlesBezier() );
     190             : 
     191           0 :     m_pCbxRuler->SaveValue();
     192           0 :     m_pCbxMoveOutline->SaveValue();
     193           0 :     m_pCbxDragStripes->SaveValue();
     194           0 :     m_pCbxHandlesBezier->SaveValue();
     195           0 : }
     196             : 
     197             : // -----------------------------------------------------------------------
     198             : 
     199           0 : SfxTabPage* SdTpOptionsContents::Create( Window* pWindow,
     200             :                 const SfxItemSet& rAttrs )
     201             : {
     202           0 :     return( new SdTpOptionsContents( pWindow, rAttrs ) );
     203             : }
     204             : 
     205             : /*************************************************************************
     206             : |*
     207             : |*  TabPage to adjust the misc options
     208             : |*
     209             : \************************************************************************/
     210             : #define TABLE_COUNT 12
     211             : #define TOKEN (sal_Unicode(':'))
     212             : 
     213           0 : SdTpOptionsMisc::SdTpOptionsMisc( Window* pParent, const SfxItemSet& rInAttrs  ) :
     214           0 :   SfxTabPage          ( pParent, "OptSavePage","modules/simpress/ui/optimpressgeneralpage.ui", rInAttrs )
     215             : {
     216           0 :     get(m_pCbxQuickEdit , "qickedit");
     217           0 :     get(m_pCbxPickThrough , "textselected");
     218           0 :     get(m_pNewDocumentFrame, "newdocumentframe");
     219           0 :     get(m_pCbxStartWithTemplate,"startwithwizard");
     220           0 :     get(m_pCbxMasterPageCache , "backgroundback");
     221           0 :     get(m_pCbxCopy , "copywhenmove");
     222           0 :     get(m_pCbxMarkedHitMovesAlways , "objalwymov");
     223           0 :     get(m_pLbMetric , "units");
     224           0 :     get(m_pCbxStartWithActualPage , "strtwithPag");
     225           0 :     get(m_pCbxEnableSdremote , "enremotcont");
     226           0 :     get(m_pCbxEnablePresenterScreen , "enprsntcons");
     227           0 :     get(m_pCbxUsePrinterMetrics , "printermetrics");
     228           0 :     get(m_pPresentationFrame , "presentationframe");
     229           0 :     get(m_pScaleFrame , "scaleframe");
     230           0 :     get(m_pCbScale , "scaleBox");
     231           0 :     get(m_pMtrFldTabstop , "metricFields");
     232           0 :     get(m_pMtrFldOriginalWidth , "metricWidthFields");
     233           0 :     get(m_pMtrFldOriginalHeight , "metricHeightFields");
     234           0 :     get(m_pMtrFldInfo1 , "metricInfo1Fields");
     235           0 :     get(m_pMtrFldInfo2 , "metricInfo2Fields");
     236           0 :     get(m_pCbxCompatibility ,"cbCompatibility" );
     237           0 :     get(m_pFiInfo1 , "info1");
     238           0 :     get(m_pFiInfo2 , "info2");
     239           0 :     get(m_pNewDocLb , "newdoclbl");
     240           0 :     get(m_pWidthLb , "widthlbl");
     241           0 :     get(m_pHeightLb , "heightlbl");
     242           0 :     get(m_pCbxDistrot , "distrotcb");
     243             : 
     244           0 :     SetExchangeSupport();
     245             : 
     246             :     // set metric
     247             :     FieldUnit eFUnit;
     248             : 
     249           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
     250           0 :     if ( rInAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
     251             :     {
     252           0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rInAttrs.Get( nWhich );
     253           0 :         eFUnit = (FieldUnit)rItem.GetValue();
     254             :     }
     255             :     else
     256           0 :         eFUnit = SfxModule::GetCurrentFieldUnit();
     257             : 
     258           0 :     SetFieldUnit( *m_pMtrFldTabstop , eFUnit );
     259             : 
     260             :     // Impress is default mode, let' hide the entire scale frame etc.
     261           0 :     m_pCbxDistrot->Hide();
     262           0 :     m_pScaleFrame->Hide();
     263             : 
     264             :     // fill ListBox with metrics
     265           0 :     SvxStringArray aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE );
     266             :     sal_uInt16 i;
     267             : 
     268           0 :     for ( i = 0; i < aMetricArr.Count(); ++i )
     269             :     {
     270           0 :         String sMetric = aMetricArr.GetStringByPos( i );
     271           0 :         sal_IntPtr nFieldUnit = aMetricArr.GetValue( i );
     272           0 :         sal_uInt16 nPos = m_pLbMetric->InsertEntry( sMetric );
     273           0 :         m_pLbMetric->SetEntryData( nPos, (void*)nFieldUnit );
     274           0 :     }
     275           0 :     m_pLbMetric->SetSelectHdl( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) );
     276             : 
     277           0 :     SetFieldUnit( *m_pMtrFldOriginalWidth, eFUnit );
     278           0 :     SetFieldUnit( *m_pMtrFldOriginalHeight, eFUnit );
     279           0 :     m_pMtrFldOriginalWidth->SetLast( 999999999 );
     280           0 :     m_pMtrFldOriginalWidth->SetMax( 999999999 );
     281           0 :     m_pMtrFldOriginalHeight->SetLast( 999999999 );
     282           0 :     m_pMtrFldOriginalHeight->SetMax( 999999999 );
     283             : 
     284             :     // temporary fields for info texts (for formatting/calculation)
     285           0 :     m_pMtrFldInfo1->SetUnit( eFUnit );
     286           0 :     m_pMtrFldInfo1->SetMax( 999999999 );
     287           0 :     m_pMtrFldInfo1->SetDecimalDigits( 2 );
     288           0 :     m_pMtrFldInfo2->SetUnit( eFUnit );
     289           0 :     m_pMtrFldInfo2->SetMax( 999999999 );
     290           0 :     m_pMtrFldInfo2->SetDecimalDigits( 2 );
     291             : 
     292             :     // determine PoolUnit
     293           0 :     SfxItemPool* pPool = rInAttrs.GetPool();
     294             :     DBG_ASSERT( pPool, "Where is the Pool?" );
     295           0 :     ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
     296             : 
     297             :     // Fuellen der CB
     298             :     sal_uInt16 aTable[ TABLE_COUNT ] =
     299           0 :         { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
     300             : 
     301           0 :     for( i = 0; i < TABLE_COUNT; i++ )
     302           0 :         m_pCbScale->InsertEntry( GetScale( 1, aTable[i] ) );
     303           0 :     for( i = 1; i < TABLE_COUNT; i++ )
     304           0 :         m_pCbScale->InsertEntry( GetScale(  aTable[i], 1 ) );
     305           0 : }
     306             : 
     307             : // -----------------------------------------------------------------------
     308             : 
     309           0 : SdTpOptionsMisc::~SdTpOptionsMisc()
     310             : {
     311           0 : }
     312             : // -----------------------------------------------------------------------
     313           0 : void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet )
     314             : {
     315             :     // We have to call SaveValue again since it can happen that the value
     316             :     // has no effect on other TabPages
     317           0 :     m_pLbMetric->SaveValue();
     318             :     // change metric if necessary (since TabPage is in the Dialog where
     319             :     // the metric is set)
     320           0 :     const SfxPoolItem* pAttr = NULL;
     321           0 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC , sal_False,
     322           0 :                                     (const SfxPoolItem**)&pAttr ))
     323             :     {
     324           0 :         const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr;
     325             : 
     326           0 :         FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue();
     327             : 
     328           0 :         if( eFUnit != m_pMtrFldOriginalWidth->GetUnit() )
     329             :         {
     330             :             // set metrics
     331           0 :             sal_Int64 nVal = m_pMtrFldOriginalWidth->Denormalize( m_pMtrFldOriginalWidth->GetValue( FUNIT_TWIP ) );
     332           0 :             SetFieldUnit( *m_pMtrFldOriginalWidth, eFUnit, sal_True );
     333           0 :             m_pMtrFldOriginalWidth->SetValue( m_pMtrFldOriginalWidth->Normalize( nVal ), FUNIT_TWIP );
     334             : 
     335           0 :             nVal = m_pMtrFldOriginalHeight->Denormalize( m_pMtrFldOriginalHeight->GetValue( FUNIT_TWIP ) );
     336           0 :             SetFieldUnit( *m_pMtrFldOriginalHeight, eFUnit, sal_True );
     337           0 :             m_pMtrFldOriginalHeight->SetValue( m_pMtrFldOriginalHeight->Normalize( nVal ), FUNIT_TWIP );
     338             : 
     339             : 
     340           0 :             if( nWidth != 0 && nHeight != 0 )
     341             :             {
     342           0 :                 m_pMtrFldInfo1->SetUnit( eFUnit );
     343           0 :                 m_pMtrFldInfo2->SetUnit( eFUnit );
     344             : 
     345           0 :                 SetMetricValue( *m_pMtrFldInfo1, nWidth, ePoolUnit );
     346           0 :                 aInfo1 = m_pMtrFldInfo1->GetText();
     347           0 :                 m_pFiInfo1->SetText( aInfo1 );
     348             : 
     349           0 :                 SetMetricValue( *m_pMtrFldInfo2, nHeight, ePoolUnit );
     350           0 :                 aInfo2 = m_pMtrFldInfo2->GetText();
     351           0 :                 m_pFiInfo2->SetText( aInfo2 );
     352             :             }
     353             :         }
     354             :     }
     355           0 : }
     356             : 
     357             : // -----------------------------------------------------------------------
     358             : 
     359           0 : int SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet )
     360             : {
     361             :     // check parser
     362             :     sal_Int32 nX, nY;
     363           0 :     if( SetScale( m_pCbScale->GetText(), nX, nY ) )
     364             :     {
     365           0 :         if( pActiveSet )
     366           0 :             FillItemSet( *pActiveSet );
     367           0 :         return( LEAVE_PAGE );
     368             :     }
     369           0 :     WarningBox aWarnBox( GetParent(), WB_YES_NO, String( SdResId( STR_WARN_SCALE_FAIL ) ) );
     370           0 :     short nReturn = aWarnBox.Execute();
     371             : 
     372           0 :     if( nReturn == RET_YES )
     373           0 :         return( KEEP_PAGE );
     374             : 
     375           0 :     if( pActiveSet )
     376           0 :         FillItemSet( *pActiveSet );
     377             : 
     378           0 :     return( LEAVE_PAGE );
     379             : }
     380             : 
     381             : // -----------------------------------------------------------------------
     382             : 
     383           0 : sal_Bool SdTpOptionsMisc::FillItemSet( SfxItemSet& rAttrs )
     384             : {
     385           0 :     sal_Bool bModified = sal_False;
     386             : 
     387           0 :     if( m_pCbxStartWithTemplate->GetSavedValue()   != m_pCbxStartWithTemplate->IsChecked() ||
     388           0 :         m_pCbxMarkedHitMovesAlways->GetSavedValue()!= m_pCbxMarkedHitMovesAlways->IsChecked() ||
     389           0 :         m_pCbxQuickEdit->GetSavedValue()           != m_pCbxQuickEdit->IsChecked() ||
     390           0 :         m_pCbxPickThrough->GetSavedValue()         != m_pCbxPickThrough->IsChecked() ||
     391           0 :         m_pCbxMasterPageCache->GetSavedValue()     != m_pCbxMasterPageCache->IsChecked() ||
     392           0 :         m_pCbxCopy->GetSavedValue()                != m_pCbxCopy->IsChecked() ||
     393           0 :         m_pCbxStartWithActualPage->GetSavedValue() != m_pCbxStartWithActualPage->IsChecked() ||
     394           0 :         m_pCbxEnableSdremote->GetSavedValue()      != m_pCbxEnableSdremote->IsChecked() ||
     395           0 :         m_pCbxEnablePresenterScreen->GetSavedValue()!= m_pCbxEnablePresenterScreen->IsChecked() ||
     396           0 :         m_pCbxCompatibility->GetSavedValue()       != m_pCbxCompatibility->IsChecked() ||
     397           0 :         m_pCbxUsePrinterMetrics->GetSavedValue()   != m_pCbxUsePrinterMetrics->IsChecked() )
     398             :     {
     399           0 :         SdOptionsMiscItem aOptsItem( ATTR_OPTIONS_MISC );
     400             : 
     401           0 :         aOptsItem.GetOptionsMisc().SetStartWithTemplate( m_pCbxStartWithTemplate->IsChecked() );
     402           0 :         aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( m_pCbxMarkedHitMovesAlways->IsChecked() );
     403           0 :         aOptsItem.GetOptionsMisc().SetQuickEdit( m_pCbxQuickEdit->IsChecked() );
     404           0 :         aOptsItem.GetOptionsMisc().SetPickThrough( m_pCbxPickThrough->IsChecked() );
     405           0 :         aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( m_pCbxMasterPageCache->IsChecked() );
     406           0 :         aOptsItem.GetOptionsMisc().SetDragWithCopy( m_pCbxCopy->IsChecked() );
     407           0 :         aOptsItem.GetOptionsMisc().SetStartWithActualPage( m_pCbxStartWithActualPage->IsChecked() );
     408           0 :         aOptsItem.GetOptionsMisc().SetEnableSdremote( m_pCbxEnableSdremote->IsChecked() );
     409           0 :         aOptsItem.GetOptionsMisc().SetEnablePresenterScreen( m_pCbxEnablePresenterScreen->IsChecked() );
     410           0 :         aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( m_pCbxCompatibility->IsChecked() );
     411           0 :         aOptsItem.GetOptionsMisc().SetPrinterIndependentLayout (
     412           0 :             m_pCbxUsePrinterMetrics->IsChecked()
     413             :             ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
     414           0 :             : ::com::sun::star::document::PrinterIndependentLayout::ENABLED);
     415           0 :         rAttrs.Put( aOptsItem );
     416             : 
     417           0 :         bModified = sal_True;
     418             :     }
     419             : 
     420             :     // metric
     421           0 :     const sal_uInt16 nMPos = m_pLbMetric->GetSelectEntryPos();
     422           0 :     if ( nMPos != m_pLbMetric->GetSavedValue() )
     423             :     {
     424           0 :         sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pLbMetric->GetEntryData( nMPos );
     425           0 :         rAttrs.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ),
     426           0 :                                      (sal_uInt16)nFieldUnit ) );
     427           0 :         bModified |= sal_True;
     428             :     }
     429             : 
     430             :     // tabulator space
     431           0 :     if( m_pMtrFldTabstop->GetText() != m_pMtrFldTabstop->GetSavedValue() )
     432             :     {
     433           0 :         sal_uInt16 nWh = GetWhich( SID_ATTR_DEFTABSTOP );
     434           0 :         SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWh );
     435           0 :         SfxUInt16Item aDef( nWh,(sal_uInt16)GetCoreValue( *m_pMtrFldTabstop, eUnit ) );
     436           0 :         rAttrs.Put( aDef );
     437           0 :         bModified |= sal_True;
     438             :     }
     439             : 
     440             :     sal_Int32 nX, nY;
     441           0 :     if( SetScale( m_pCbScale->GetText(), nX, nY ) )
     442             :     {
     443           0 :         rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
     444           0 :         rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
     445             : 
     446           0 :         bModified = sal_True;
     447             :     }
     448             : 
     449           0 :     return( bModified );
     450             : }
     451             : 
     452             : // -----------------------------------------------------------------------
     453             : 
     454           0 : void SdTpOptionsMisc::Reset( const SfxItemSet& rAttrs )
     455             : {
     456             :     SdOptionsMiscItem aOptsItem( (const SdOptionsMiscItem&) rAttrs.
     457           0 :                         Get( ATTR_OPTIONS_MISC ) );
     458             : 
     459           0 :     m_pCbxStartWithTemplate->Check( aOptsItem.GetOptionsMisc().IsStartWithTemplate() );
     460           0 :     m_pCbxMarkedHitMovesAlways->Check( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() );
     461           0 :     m_pCbxQuickEdit->Check( aOptsItem.GetOptionsMisc().IsQuickEdit() );
     462           0 :     m_pCbxPickThrough->Check( aOptsItem.GetOptionsMisc().IsPickThrough() );
     463           0 :     m_pCbxMasterPageCache->Check( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() );
     464           0 :     m_pCbxCopy->Check( aOptsItem.GetOptionsMisc().IsDragWithCopy() );
     465           0 :     m_pCbxStartWithActualPage->Check( aOptsItem.GetOptionsMisc().IsStartWithActualPage() );
     466           0 :     m_pCbxEnableSdremote->Check( aOptsItem.GetOptionsMisc().IsEnableSdremote() );
     467           0 :     m_pCbxEnablePresenterScreen->Check( aOptsItem.GetOptionsMisc().IsEnablePresenterScreen() );
     468           0 :     m_pCbxCompatibility->Check( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() );
     469           0 :     m_pCbxUsePrinterMetrics->Check( aOptsItem.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
     470           0 :     m_pCbxStartWithTemplate->SaveValue();
     471           0 :     m_pCbxMarkedHitMovesAlways->SaveValue();
     472           0 :     m_pCbxQuickEdit->SaveValue();
     473           0 :     m_pCbxPickThrough->SaveValue();
     474             : 
     475           0 :     m_pCbxMasterPageCache->SaveValue();
     476           0 :     m_pCbxCopy->SaveValue();
     477           0 :     m_pCbxEnableSdremote->SaveValue();
     478           0 :     m_pCbxEnablePresenterScreen->SaveValue();
     479           0 :     m_pCbxCompatibility->SaveValue();
     480           0 :     m_pCbxUsePrinterMetrics->SaveValue();
     481             : 
     482             :     // metric
     483           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
     484           0 :     m_pLbMetric->SetNoSelection();
     485             : 
     486           0 :     if ( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
     487             :     {
     488           0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
     489           0 :         long nFieldUnit = (long)rItem.GetValue();
     490             : 
     491           0 :         for ( sal_uInt16 i = 0; i < m_pLbMetric->GetEntryCount(); ++i )
     492             :         {
     493           0 :             if ( (sal_IntPtr)m_pLbMetric->GetEntryData( i ) == nFieldUnit )
     494             :             {
     495           0 :                 m_pLbMetric->SelectEntryPos( i );
     496           0 :                 break;
     497             :             }
     498             :         }
     499             :     }
     500             : 
     501             :     // tabulator space
     502           0 :     nWhich = GetWhich( SID_ATTR_DEFTABSTOP );
     503           0 :     if( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
     504             :     {
     505           0 :         SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWhich );
     506           0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
     507           0 :         SetMetricValue( *m_pMtrFldTabstop, rItem.GetValue(), eUnit );
     508             :     }
     509           0 :     m_pLbMetric->SaveValue();
     510           0 :     m_pMtrFldTabstop->SaveValue();
     511             :     //Scale
     512             :     sal_Int32 nX = ( (const SfxInt32Item&) rAttrs.
     513           0 :                  Get( ATTR_OPTIONS_SCALE_X ) ).GetValue();
     514             :     sal_Int32 nY = ( (const SfxInt32Item&) rAttrs.
     515           0 :                  Get( ATTR_OPTIONS_SCALE_Y ) ).GetValue();
     516             :     nWidth = ( (const SfxUInt32Item&) rAttrs.
     517           0 :                     Get( ATTR_OPTIONS_SCALE_WIDTH ) ).GetValue();
     518             :     nHeight = ( (const SfxUInt32Item&) rAttrs.
     519           0 :                     Get( ATTR_OPTIONS_SCALE_HEIGHT ) ).GetValue();
     520             : 
     521           0 :     m_pCbScale->SetText( GetScale( nX, nY ) );
     522             : 
     523           0 :     m_pMtrFldOriginalWidth->Hide();
     524           0 :     m_pMtrFldOriginalWidth->SetText( aInfo1 ); // empty
     525           0 :     m_pMtrFldOriginalHeight->Hide();
     526           0 :     m_pMtrFldOriginalHeight->SetText( aInfo2 ); //empty
     527           0 :     m_pFiInfo1->Hide();
     528           0 :     m_pFiInfo2->Hide();
     529             : 
     530           0 :     UpdateCompatibilityControls ();
     531           0 : }
     532             : 
     533             : // -----------------------------------------------------------------------
     534             : 
     535           0 : SfxTabPage* SdTpOptionsMisc::Create( Window* pWindow,
     536             :                 const SfxItemSet& rAttrs )
     537             : {
     538           0 :     return( new SdTpOptionsMisc( pWindow, rAttrs ) );
     539             : }
     540             : //------------------------------------------------------------------------
     541             : 
     542           0 : IMPL_LINK_NOARG(SdTpOptionsMisc, SelectMetricHdl_Impl)
     543             : {
     544           0 :     sal_uInt16 nPos = m_pLbMetric->GetSelectEntryPos();
     545             : 
     546           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     547             :     {
     548           0 :         FieldUnit eUnit = (FieldUnit)(sal_IntPtr)m_pLbMetric->GetEntryData( nPos );
     549             :         sal_Int64 nVal =
     550           0 :             m_pMtrFldTabstop->Denormalize( m_pMtrFldTabstop->GetValue( FUNIT_TWIP ) );
     551           0 :         SetFieldUnit( *m_pMtrFldTabstop, eUnit );
     552           0 :         m_pMtrFldTabstop->SetValue( m_pMtrFldTabstop->Normalize( nVal ), FUNIT_TWIP );
     553             :     }
     554           0 :     return 0;
     555             : }
     556             : 
     557             : 
     558           0 : void SdTpOptionsMisc::SetImpressMode (void)
     559             : {
     560             : #ifndef ENABLE_SDREMOTE_BLUETOOTH
     561             :     m_pCbxEnableSdremote->Hide();
     562             : #endif
     563           0 : }
     564             : 
     565           0 : void    SdTpOptionsMisc::SetDrawMode()
     566             : {
     567           0 :     m_pScaleFrame->Show();
     568           0 :     m_pNewDocumentFrame->Hide();
     569           0 :     m_pCbxStartWithActualPage->Hide();
     570           0 :     m_pCbxEnableSdremote->Hide();
     571           0 :     m_pCbxEnablePresenterScreen->Hide();
     572           0 :     m_pCbxCompatibility->Hide();
     573           0 :     m_pNewDocLb->Hide();
     574           0 :     m_pCbScale->Show();
     575           0 :     m_pPresentationFrame->Hide();
     576           0 :     m_pMtrFldInfo1->Hide();
     577           0 :     m_pMtrFldInfo2->Hide();
     578           0 :     m_pWidthLb->Hide();
     579           0 :     m_pHeightLb->Hide();
     580           0 :     m_pFiInfo1->Show();
     581           0 :     m_pMtrFldOriginalWidth->Show();
     582           0 :     m_pFiInfo2->Show();
     583           0 :     m_pMtrFldOriginalHeight->Show();
     584           0 :     m_pCbxDistrot->Show();
     585           0 :     m_pCbxCompatibility->Hide();
     586             :     // Move the printer-independent-metrics check box in the place that the
     587             :     // spacing-between-paragraphs check box normally is in.
     588           0 :     m_pCbxUsePrinterMetrics->SetPosPixel (m_pCbxCompatibility->GetPosPixel());
     589           0 : }
     590             : 
     591             : // -----------------------------------------------------------------------
     592             : 
     593           0 : String SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY )
     594             : {
     595           0 :     String aScale( OUString::valueOf( nX ) );
     596           0 :     aScale.Append( TOKEN );
     597           0 :     aScale.Append( OUString::valueOf( nY ) );
     598             : 
     599           0 :     return( aScale );
     600             : }
     601             : 
     602             : // -----------------------------------------------------------------------
     603             : 
     604           0 : sal_Bool SdTpOptionsMisc::SetScale( const String& aScale, sal_Int32& rX, sal_Int32& rY )
     605             : {
     606           0 :     if( comphelper::string::getTokenCount(aScale, TOKEN) != 2 )
     607           0 :         return( sal_False );
     608             : 
     609           0 :     OUString aTmp(aScale.GetToken( 0, TOKEN ));
     610           0 :     if (!comphelper::string::isdigitAsciiString(aTmp))
     611           0 :         return sal_False;
     612             : 
     613           0 :     rX = (long) aTmp.toInt32();
     614           0 :     if( rX == 0 )
     615           0 :         return( sal_False );
     616             : 
     617           0 :     aTmp = aScale.GetToken( 1, TOKEN );
     618           0 :     if (!comphelper::string::isdigitAsciiString(aTmp))
     619           0 :         return sal_False;
     620             : 
     621           0 :     rY = (long) aTmp.toInt32();
     622           0 :     if( rY == 0 )
     623           0 :         return sal_False;
     624             : 
     625           0 :     return sal_True;
     626             : }
     627             : 
     628           0 : void SdTpOptionsMisc::UpdateCompatibilityControls (void)
     629             : {
     630             :     // Disable the compatibility controls by default.  Enable them only when
     631             :     // there is at least one open document.
     632           0 :     sal_Bool bIsEnabled = sal_False;
     633             : 
     634             :     try
     635             :     {
     636             :         // Get a component enumeration from the desktop and search it for documents.
     637           0 :         Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext());
     638             :         do
     639             :         {
     640           0 :             Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
     641             : 
     642             :             Reference<container::XEnumerationAccess> xComponents (
     643           0 :                 xDesktop->getComponents(), UNO_QUERY);
     644           0 :             if ( ! xComponents.is())
     645           0 :                 break;
     646             : 
     647             :             Reference<container::XEnumeration> xEnumeration (
     648           0 :                 xComponents->createEnumeration());
     649           0 :             if ( ! xEnumeration.is())
     650           0 :                 break;
     651             : 
     652           0 :             while (xEnumeration->hasMoreElements())
     653             :             {
     654           0 :                 Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY);
     655           0 :                 if (xModel.is())
     656             :                 {
     657             :                     // There is at leas one model/document: Enable the compatibility controls.
     658           0 :                     bIsEnabled = sal_True;
     659           0 :                     break;
     660             :                 }
     661           0 :             }
     662             : 
     663             :         }
     664           0 :         while (false); // One 'loop'.
     665             :     }
     666           0 :     catch (const uno::Exception&)
     667             :     {
     668             :         // When there is an exception then simply use the default value of
     669             :         // bIsEnabled and disable the controls.
     670             :     }
     671             : 
     672           0 :     m_pCbxCompatibility->Enable(bIsEnabled);
     673           0 :     m_pCbxUsePrinterMetrics->Enable (bIsEnabled);
     674           0 : }
     675             : 
     676           0 : void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet)
     677             : {
     678           0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False);
     679           0 :     if (pFlagItem)
     680             :     {
     681           0 :         sal_uInt32 nFlags=pFlagItem->GetValue();
     682           0 :         if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
     683           0 :             SetDrawMode();
     684           0 :         if ( ( nFlags & SD_IMPRESS_MODE ) == SD_IMPRESS_MODE )
     685           0 :             SetImpressMode();
     686             :     }
     687           0 : }
     688             : 
     689             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10