LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - measure.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 407 0.2 %
Date: 2012-12-27 Functions: 2 20 10.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 <sfx2/app.hxx>
      21             : #include <sfx2/module.hxx>
      22             : #include <tools/shl.hxx>
      23             : 
      24             : #include <cuires.hrc>
      25             : 
      26             : #define _SVX_MEASURE_CXX
      27             : 
      28             : #include <svx/svdomeas.hxx>
      29             : #include <svx/svdattr.hxx>
      30             : #include <svx/svdattrx.hxx>
      31             : #include <svx/svdview.hxx>
      32             : #include <svx/dialogs.hrc>
      33             : #include <svx/dialmgr.hxx>
      34             : #include "svx/measctrl.hxx"
      35             : #include "measure.hxx"
      36             : #include "measure.hrc"
      37             : #include <dialmgr.hxx>
      38             : #include "svx/dlgutil.hxx"
      39             : #include <svx/strarray.hxx>
      40             : #include <sfx2/request.hxx>
      41             : #include "svx/ofaitem.hxx"
      42             : 
      43             : static sal_uInt16 pRanges[] =
      44             : {
      45             :     SDRATTR_MEASURE_FIRST,
      46             :     SDRATTR_MEASURE_LAST,
      47             :     0
      48             : };
      49             : 
      50             : /*************************************************************************
      51             : |*
      52             : |* Dialog to change measure-attributes
      53             : |*
      54             : \************************************************************************/
      55             : 
      56           0 : SvxMeasureDialog::SvxMeasureDialog( Window* pParent, const SfxItemSet& rInAttrs,
      57             :                                 const SdrView* pSdrView ) :
      58           0 :         SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_MEASURE )
      59             : {
      60           0 :     SvxMeasurePage* _pPage = new SvxMeasurePage( this, rInAttrs );
      61             : 
      62           0 :     _pPage->SetView( pSdrView );
      63           0 :     _pPage->Construct();
      64             : 
      65           0 :     SetTabPage( _pPage );
      66           0 :     SetText( _pPage->GetText() );
      67           0 : }
      68             : 
      69             : /*************************************************************************
      70             : |*
      71             : |* Dtor
      72             : |*
      73             : \************************************************************************/
      74             : 
      75           0 : SvxMeasureDialog::~SvxMeasureDialog()
      76             : {
      77           0 : }
      78             : 
      79             : /*************************************************************************
      80             : |*
      81             : |* Tabpage for changing measure-attributes
      82             : |*
      83             : \************************************************************************/
      84             : 
      85           0 : SvxMeasurePage::SvxMeasurePage( Window* pWindow, const SfxItemSet& rInAttrs ) :
      86           0 :                 SvxTabPage      ( pWindow, CUI_RES( RID_SVXPAGE_MEASURE ),
      87             :                                   rInAttrs ),
      88             : 
      89           0 :         aFlLine                 ( this, CUI_RES( FL_LINE ) ),
      90           0 :         aFtLineDist             ( this, CUI_RES( FT_LINE_DIST ) ),
      91           0 :         aMtrFldLineDist         ( this, CUI_RES( MTR_LINE_DIST ) ),
      92           0 :         aFtHelplineOverhang     ( this, CUI_RES( FT_HELPLINE_OVERHANG ) ),
      93           0 :         aMtrFldHelplineOverhang ( this, CUI_RES( MTR_FLD_HELPLINE_OVERHANG ) ),
      94           0 :         aFtHelplineDist         ( this, CUI_RES( FT_HELPLINE_DIST ) ),
      95           0 :         aMtrFldHelplineDist     ( this, CUI_RES( MTR_FLD_HELPLINE_DIST ) ),
      96           0 :         aFtHelpline1Len         ( this, CUI_RES( FT_HELPLINE1_LEN ) ),
      97           0 :         aMtrFldHelpline1Len     ( this, CUI_RES( MTR_FLD_HELPLINE1_LEN ) ),
      98           0 :         aFtHelpline2Len         ( this, CUI_RES( FT_HELPLINE2_LEN ) ),
      99           0 :         aMtrFldHelpline2Len     ( this, CUI_RES( MTR_FLD_HELPLINE2_LEN ) ),
     100           0 :         aTsbBelowRefEdge        ( this, CUI_RES( TSB_BELOW_REF_EDGE ) ),
     101           0 :         aFtDecimalPlaces        ( this, CUI_RES( FT_DECIMALPLACES ) ),
     102           0 :         aMtrFldDecimalPlaces    ( this, CUI_RES( MTR_FLD_DECIMALPLACES ) ),
     103             : 
     104           0 :         aFlLabel                ( this, CUI_RES( FL_LABEL ) ),
     105           0 :         aFtPosition             ( this, CUI_RES( FT_POSITION ) ),
     106           0 :         aCtlPosition            ( this, CUI_RES( CTL_POSITION ) ),
     107           0 :         aTsbAutoPosV            ( this, CUI_RES( TSB_AUTOPOSV ) ),
     108           0 :         aTsbAutoPosH            ( this, CUI_RES( TSB_AUTOPOSH ) ),
     109           0 :         aTsbShowUnit            ( this, CUI_RES( TSB_SHOW_UNIT ) ),
     110           0 :         aLbUnit                 ( this, CUI_RES( LB_UNIT ) ),
     111           0 :         aTsbParallel            ( this, CUI_RES( TSB_PARALLEL ) ),
     112           0 :         aCtlPreview             ( this, CUI_RES( CTL_PREVIEW ), rInAttrs ),
     113             : 
     114           0 :         aFlVert                 ( this, CUI_RES( FL_VERT ) ),
     115             :         rOutAttrs               ( rInAttrs ),
     116           0 :         aAttrSet                ( *rInAttrs.GetPool() ),
     117             :         pView( 0 ),
     118             : 
     119           0 :         bPositionModified       ( sal_False )
     120             : {
     121           0 :     aCtlPreview.SetAccessibleName(aCtlPreview.GetHelpText());
     122           0 :     FillUnitLB();
     123             : 
     124           0 :     FreeResource();
     125             : 
     126           0 :     const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
     127           0 :     SetFieldUnit( aMtrFldLineDist, eFUnit );
     128           0 :     SetFieldUnit( aMtrFldHelplineOverhang, eFUnit );
     129           0 :     SetFieldUnit( aMtrFldHelplineDist, eFUnit );
     130           0 :     SetFieldUnit( aMtrFldHelpline1Len, eFUnit );
     131           0 :     SetFieldUnit( aMtrFldHelpline2Len, eFUnit );
     132           0 :     if( eFUnit == FUNIT_MM )
     133             :     {
     134           0 :         aMtrFldLineDist.SetSpinSize( 50 );
     135           0 :         aMtrFldHelplineOverhang.SetSpinSize( 50 );
     136           0 :         aMtrFldHelplineDist.SetSpinSize( 50 );
     137           0 :         aMtrFldHelpline1Len.SetSpinSize( 50 );
     138           0 :         aMtrFldHelpline2Len.SetSpinSize( 50 );
     139             :     }
     140             : 
     141           0 :     aTsbAutoPosV.SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
     142           0 :     aTsbAutoPosH.SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
     143             : 
     144             :     // set background and border of iconchoicectrl
     145           0 :     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     146           0 :     aCtlPreview.SetBackground ( rStyles.GetWindowColor() );
     147           0 :     aCtlPreview.SetBorderStyle(WINDOW_BORDER_MONO);
     148             : 
     149           0 :     Link aLink( LINK( this, SvxMeasurePage, ChangeAttrHdl_Impl ) );
     150           0 :     aMtrFldLineDist.SetModifyHdl( aLink );
     151           0 :     aMtrFldHelplineOverhang.SetModifyHdl( aLink );
     152           0 :     aMtrFldHelplineDist.SetModifyHdl( aLink );
     153           0 :     aMtrFldHelpline1Len.SetModifyHdl( aLink );
     154           0 :     aMtrFldHelpline2Len.SetModifyHdl( aLink );
     155           0 :     aMtrFldDecimalPlaces.SetModifyHdl( aLink );
     156           0 :     aTsbBelowRefEdge.SetClickHdl( aLink );
     157           0 :     aTsbParallel.SetClickHdl( aLink );
     158           0 :     aTsbShowUnit.SetClickHdl( aLink );
     159           0 :     aLbUnit.SetSelectHdl( aLink );
     160           0 :     aLbUnit.SetAccessibleName(GetNonMnemonicString(aTsbShowUnit.GetText()));
     161           0 :     aCtlPosition.SetAccessibleRelationMemberOf( &aFlLabel );
     162           0 :     aLbUnit.SetAccessibleRelationLabeledBy( &aTsbShowUnit );
     163           0 : }
     164             : 
     165             : /*************************************************************************
     166             : |*
     167             : |* Dtor
     168             : |*
     169             : \************************************************************************/
     170             : 
     171           0 : SvxMeasurePage::~SvxMeasurePage()
     172             : {
     173           0 : }
     174             : 
     175             : /*************************************************************************
     176             : |*
     177             : |* read the delivered Item-Set
     178             : |*
     179             : \************************************************************************/
     180             : 
     181           0 : void SvxMeasurePage::Reset( const SfxItemSet& rAttrs )
     182             : {
     183           0 :     SfxItemPool* pPool = rAttrs.GetPool();
     184             :     DBG_ASSERT( pPool, "Wo ist der Pool" );
     185           0 :     eUnit = pPool->GetMetric( SDRATTR_MEASURELINEDIST );
     186             : 
     187           0 :     const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_MEASURELINEDIST );
     188             : 
     189             :     // SdrMeasureLineDistItem
     190           0 :     if( pItem == NULL )
     191           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
     192           0 :     if( pItem )
     193             :     {
     194           0 :         long nValue = ( ( const SdrMeasureLineDistItem* )pItem )->GetValue();
     195           0 :         SetMetricValue( aMtrFldLineDist, nValue, eUnit );
     196             :     }
     197             :     else
     198             :     {
     199           0 :         aMtrFldLineDist.SetText( String() );
     200             :     }
     201           0 :     aMtrFldLineDist.SaveValue();
     202             : 
     203             :     // SdrMeasureHelplineOverhangItem
     204           0 :     pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
     205           0 :     if( pItem == NULL )
     206           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG );
     207           0 :     if( pItem )
     208             :     {
     209           0 :         long nValue = ( ( const SdrMeasureHelplineOverhangItem* )pItem )->GetValue();
     210           0 :         SetMetricValue( aMtrFldHelplineOverhang, nValue, eUnit );
     211             :     }
     212             :     else
     213             :     {
     214           0 :         aMtrFldHelplineOverhang.SetText( String() );
     215             :     }
     216           0 :     aMtrFldHelplineOverhang.SaveValue();
     217             : 
     218             :     // SdrMeasureHelplineDistItem
     219           0 :     pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINEDIST );
     220           0 :     if( pItem == NULL )
     221           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
     222           0 :     if( pItem )
     223             :     {
     224           0 :         long nValue = ( ( const SdrMeasureHelplineDistItem* )pItem )->GetValue();
     225           0 :         SetMetricValue( aMtrFldHelplineDist, nValue, eUnit );
     226             :     }
     227             :     else
     228             :     {
     229           0 :         aMtrFldHelplineDist.SetText( String() );
     230             :     }
     231           0 :     aMtrFldHelplineDist.SaveValue();
     232             : 
     233             :     // SdrMeasureHelpline1LenItem
     234           0 :     pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
     235           0 :     if( pItem == NULL )
     236           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
     237           0 :     if( pItem )
     238             :     {
     239           0 :         long nValue = ( ( const SdrMeasureHelpline1LenItem* )pItem )->GetValue();
     240           0 :         SetMetricValue( aMtrFldHelpline1Len, nValue, eUnit );
     241             :     }
     242             :     else
     243             :     {
     244           0 :         aMtrFldHelpline1Len.SetText( String() );
     245             :     }
     246           0 :     aMtrFldHelpline1Len.SaveValue();
     247             : 
     248             :     // SdrMeasureHelpline2LenItem
     249           0 :     pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
     250           0 :     if( pItem == NULL )
     251           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
     252           0 :     if( pItem )
     253             :     {
     254           0 :         long nValue = ( ( const SdrMeasureHelpline2LenItem* )pItem )->GetValue();
     255           0 :         SetMetricValue( aMtrFldHelpline2Len, nValue, eUnit );
     256             :     }
     257             :     else
     258             :     {
     259           0 :         aMtrFldHelpline2Len.SetText( String() );
     260             :     }
     261           0 :     aMtrFldHelpline2Len.SaveValue();
     262             : 
     263             :     // SdrMeasureBelowRefEdgeItem
     264           0 :     if( rAttrs.GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SFX_ITEM_DONTCARE )
     265             :     {
     266           0 :         aTsbBelowRefEdge.SetState( ( ( const SdrMeasureBelowRefEdgeItem& )rAttrs.Get( SDRATTR_MEASUREBELOWREFEDGE ) ).
     267           0 :                         GetValue() ? STATE_CHECK : STATE_NOCHECK );
     268           0 :         aTsbBelowRefEdge.EnableTriState( sal_False );
     269             :     }
     270             :     else
     271             :     {
     272           0 :         aTsbBelowRefEdge.SetState( STATE_DONTKNOW );
     273             :     }
     274           0 :     aTsbBelowRefEdge.SaveValue();
     275             : 
     276             :     // SdrMeasureDecimalPlacesItem
     277           0 :     pItem = GetItem( rAttrs, SDRATTR_MEASUREDECIMALPLACES );
     278           0 :     if( pItem == NULL )
     279           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
     280           0 :     if( pItem )
     281             :     {
     282           0 :         sal_Int16 nValue = ( ( const SdrMeasureDecimalPlacesItem* )pItem )->GetValue();
     283           0 :         aMtrFldDecimalPlaces.SetValue( nValue );
     284             :     }
     285             :     else
     286             :     {
     287           0 :         aMtrFldDecimalPlaces.SetText( String() );
     288             :     }
     289           0 :     aMtrFldDecimalPlaces.SaveValue();
     290             : 
     291             :     // SdrMeasureTextRota90Item
     292             :     // Attention: negate !
     293           0 :     if( rAttrs.GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SFX_ITEM_DONTCARE )
     294             :     {
     295           0 :         aTsbParallel.SetState( ( ( const SdrMeasureTextRota90Item& )rAttrs.Get( SDRATTR_MEASURETEXTROTA90 ) ).
     296           0 :                         GetValue() ? STATE_NOCHECK : STATE_CHECK );
     297           0 :         aTsbParallel.EnableTriState( sal_False );
     298             :     }
     299             :     else
     300             :     {
     301           0 :         aTsbParallel.SetState( STATE_DONTKNOW );
     302             :     }
     303           0 :     aTsbParallel.SaveValue();
     304             : 
     305             :     // SdrMeasureShowUnitItem
     306           0 :     if( rAttrs.GetItemState( SDRATTR_MEASURESHOWUNIT ) != SFX_ITEM_DONTCARE )
     307             :     {
     308           0 :         aTsbShowUnit.SetState( ( ( const SdrMeasureShowUnitItem& )rAttrs.Get( SDRATTR_MEASURESHOWUNIT ) ).
     309           0 :                         GetValue() ? STATE_CHECK : STATE_NOCHECK );
     310           0 :         aTsbShowUnit.EnableTriState( sal_False );
     311             :     }
     312             :     else
     313             :     {
     314           0 :         aTsbShowUnit.SetState( STATE_DONTKNOW );
     315             :     }
     316           0 :     aTsbShowUnit.SaveValue();
     317             : 
     318             :     // SdrMeasureUnitItem
     319           0 :     if( rAttrs.GetItemState( SDRATTR_MEASUREUNIT ) != SFX_ITEM_DONTCARE )
     320             :     {
     321             :         long nFieldUnit = (long) ( ( const SdrMeasureUnitItem& )rAttrs.
     322           0 :                                     Get( SDRATTR_MEASUREUNIT ) ).GetValue();
     323             : 
     324           0 :         for( sal_uInt16 i = 0; i < aLbUnit.GetEntryCount(); ++i )
     325             :         {
     326           0 :             if ( (long)aLbUnit.GetEntryData( i ) == nFieldUnit )
     327             :             {
     328           0 :                 aLbUnit.SelectEntryPos( i );
     329           0 :                 break;
     330             :             }
     331             :         }
     332             :     }
     333             :     else
     334             :     {
     335           0 :         aLbUnit.SetNoSelection();
     336             :     }
     337           0 :     aLbUnit.SaveValue();
     338             : 
     339             :     // Position
     340           0 :     if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTVPOS ) != SFX_ITEM_DONTCARE )
     341             :     {
     342             :         SdrMeasureTextVPos eVPos = (SdrMeasureTextVPos)
     343           0 :                     ( ( const SdrMeasureTextVPosItem& )rAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
     344             :         {
     345           0 :             if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTHPOS ) != SFX_ITEM_DONTCARE )
     346             :             {
     347           0 :                 aTsbAutoPosV.EnableTriState( sal_False );
     348           0 :                 aTsbAutoPosH.EnableTriState( sal_False );
     349             : 
     350             :                 SdrMeasureTextHPos eHPos = (SdrMeasureTextHPos)
     351           0 :                             ( ( const SdrMeasureTextHPosItem& )rAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
     352           0 :                 RECT_POINT eRP = RP_MM;
     353           0 :                 switch( eVPos )
     354             :                 {
     355             :                 case SDRMEASURE_ABOVE:
     356           0 :                     switch( eHPos )
     357             :                     {
     358           0 :                     case SDRMEASURE_TEXTLEFTOUTSIDE:    eRP = RP_LT; break;
     359           0 :                     case SDRMEASURE_TEXTINSIDE:         eRP = RP_MT; break;
     360           0 :                     case SDRMEASURE_TEXTRIGHTOUTSIDE:   eRP = RP_RT; break;
     361           0 :                     case SDRMEASURE_TEXTHAUTO:          eRP = RP_MT; break;
     362             :                     }
     363           0 :                     break;
     364             :                 case SDRMEASURETEXT_VERTICALCENTERED:
     365           0 :                     switch( eHPos )
     366             :                     {
     367           0 :                     case SDRMEASURE_TEXTLEFTOUTSIDE:    eRP = RP_LM; break;
     368           0 :                     case SDRMEASURE_TEXTINSIDE:         eRP = RP_MM; break;
     369           0 :                     case SDRMEASURE_TEXTRIGHTOUTSIDE:   eRP = RP_RM; break;
     370           0 :                     case SDRMEASURE_TEXTHAUTO:          eRP = RP_MM; break;
     371             :                     }
     372           0 :                     break;
     373             :                 case SDRMEASURE_BELOW:
     374           0 :                     switch( eHPos )
     375             :                     {
     376           0 :                     case SDRMEASURE_TEXTLEFTOUTSIDE:    eRP = RP_LB; break;
     377           0 :                     case SDRMEASURE_TEXTINSIDE:         eRP = RP_MB; break;
     378           0 :                     case SDRMEASURE_TEXTRIGHTOUTSIDE:   eRP = RP_RB; break;
     379           0 :                     case SDRMEASURE_TEXTHAUTO:          eRP = RP_MB; break;
     380             :                     }
     381           0 :                     break;
     382             :                 case SDRMEASURE_TEXTVAUTO:
     383           0 :                     switch( eHPos )
     384             :                     {
     385           0 :                     case SDRMEASURE_TEXTLEFTOUTSIDE:    eRP = RP_LM; break;
     386           0 :                     case SDRMEASURE_TEXTINSIDE:         eRP = RP_MM; break;
     387           0 :                     case SDRMEASURE_TEXTRIGHTOUTSIDE:   eRP = RP_RM; break;
     388           0 :                     case SDRMEASURE_TEXTHAUTO:          eRP = RP_MM; break;
     389             :                     }
     390           0 :                     break;
     391             :                  default: ;//prevent warning
     392             :                 }
     393             : 
     394           0 :                 CTL_STATE nState = 0;
     395             : 
     396           0 :                 if( eHPos == SDRMEASURE_TEXTHAUTO )
     397             :                 {
     398           0 :                     aTsbAutoPosH.SetState( STATE_CHECK );
     399           0 :                     nState = CS_NOHORZ;
     400             :                 }
     401             : 
     402           0 :                 if( eVPos == SDRMEASURE_TEXTVAUTO )
     403             :                 {
     404           0 :                     aTsbAutoPosV.SetState( STATE_CHECK );
     405           0 :                     nState |= CS_NOVERT;
     406             :                 }
     407             : 
     408           0 :                 aCtlPosition.SetState( nState );
     409           0 :                 aCtlPosition.SetActualRP( eRP );
     410             :             }
     411             :         }
     412             :     }
     413             :     else
     414             :     {
     415           0 :         aCtlPosition.Reset();
     416           0 :         aTsbAutoPosV.SetState( STATE_DONTKNOW );
     417           0 :         aTsbAutoPosH.SetState( STATE_DONTKNOW );
     418             :     }
     419             : 
     420             :     // put the attributes to the preview-control,
     421             :     // otherwise the control don't know about
     422             :     // the settings of the dialog (#67930)
     423           0 :     ChangeAttrHdl_Impl( &aTsbShowUnit );
     424           0 :     aCtlPreview.SetAttributes( rAttrs );
     425             : 
     426           0 :     bPositionModified = sal_False;
     427           0 : }
     428             : 
     429             : /*************************************************************************
     430             : |*
     431             : |* Fill the delivered Item-Set with dialogbox-attributes
     432             : |*
     433             : \************************************************************************/
     434             : 
     435           0 : sal_Bool SvxMeasurePage::FillItemSet( SfxItemSet& rAttrs)
     436             : {
     437           0 :     sal_Bool     bModified = sal_False;
     438             :     sal_Int32    nValue;
     439             :     TriState eState;
     440             : 
     441           0 :     if( aMtrFldLineDist.GetText() != aMtrFldLineDist.GetSavedValue() )
     442             :     {
     443           0 :         nValue = GetCoreValue( aMtrFldLineDist, eUnit );
     444           0 :         rAttrs.Put( SdrMeasureLineDistItem( nValue ) );
     445           0 :         bModified = sal_True;
     446             :     }
     447             : 
     448           0 :     if( aMtrFldHelplineOverhang.GetText() != aMtrFldHelplineOverhang.GetSavedValue() )
     449             :     {
     450           0 :         nValue = GetCoreValue( aMtrFldHelplineOverhang, eUnit );
     451           0 :         rAttrs.Put( SdrMeasureHelplineOverhangItem( nValue ) );
     452           0 :         bModified = sal_True;
     453             :     }
     454             : 
     455           0 :     if( aMtrFldHelplineDist.GetText() != aMtrFldHelplineDist.GetSavedValue() )
     456             :     {
     457           0 :         nValue = GetCoreValue( aMtrFldHelplineDist, eUnit );
     458           0 :         rAttrs.Put( SdrMeasureHelplineDistItem( nValue ) );
     459           0 :         bModified = sal_True;
     460             :     }
     461             : 
     462           0 :     if( aMtrFldHelpline1Len.GetText() != aMtrFldHelpline1Len.GetSavedValue() )
     463             :     {
     464           0 :         nValue = GetCoreValue( aMtrFldHelpline1Len, eUnit );
     465           0 :         rAttrs.Put( SdrMeasureHelpline1LenItem( nValue ) );
     466           0 :         bModified = sal_True;
     467             :     }
     468             : 
     469           0 :     if( aMtrFldHelpline2Len.GetText() != aMtrFldHelpline2Len.GetSavedValue() )
     470             :     {
     471           0 :         nValue = GetCoreValue( aMtrFldHelpline2Len, eUnit );
     472           0 :         rAttrs.Put( SdrMeasureHelpline2LenItem( nValue ) );
     473           0 :         bModified = sal_True;
     474             :     }
     475             : 
     476           0 :     eState = aTsbBelowRefEdge.GetState();
     477           0 :     if( eState != aTsbBelowRefEdge.GetSavedValue() )
     478             :     {
     479           0 :         rAttrs.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool) STATE_CHECK == eState ) );
     480           0 :         bModified = sal_True;
     481             :     }
     482             : 
     483           0 :     if( aMtrFldDecimalPlaces.GetText() != aMtrFldDecimalPlaces.GetSavedValue() )
     484             :     {
     485           0 :         nValue = static_cast<sal_Int32>(aMtrFldDecimalPlaces.GetValue());
     486             :         rAttrs.Put(
     487             :             SdrMeasureDecimalPlacesItem(
     488           0 :                 sal::static_int_cast< sal_Int16 >( nValue ) ) );
     489           0 :         bModified = sal_True;
     490             :     }
     491             : 
     492           0 :     eState = aTsbParallel.GetState();
     493           0 :     if( eState != aTsbParallel.GetSavedValue() )
     494             :     {
     495           0 :         rAttrs.Put( SdrMeasureTextRota90Item( (sal_Bool) STATE_NOCHECK == eState ) );
     496           0 :         bModified = sal_True;
     497             :     }
     498             : 
     499           0 :     eState = aTsbShowUnit.GetState();
     500           0 :     if( eState != aTsbShowUnit.GetSavedValue() )
     501             :     {
     502           0 :         rAttrs.Put( SdrMeasureShowUnitItem( (sal_Bool) STATE_CHECK == eState ) );
     503           0 :         bModified = sal_True;
     504             :     }
     505             : 
     506           0 :     sal_uInt16 nPos = aLbUnit.GetSelectEntryPos();
     507           0 :     if( nPos != aLbUnit.GetSavedValue() )
     508             :     {
     509           0 :         if( nPos != LISTBOX_ENTRY_NOTFOUND )
     510             :         {
     511           0 :             sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbUnit.GetEntryData( nPos );
     512           0 :             FieldUnit _eUnit = (FieldUnit) nFieldUnit;
     513           0 :             rAttrs.Put( SdrMeasureUnitItem( _eUnit ) );
     514           0 :             bModified = sal_True;
     515             :         }
     516             :     }
     517             : 
     518           0 :     if( bPositionModified )
     519             :     {
     520             :         // Position
     521             :         SdrMeasureTextVPos eVPos, eOldVPos;
     522             :         SdrMeasureTextHPos eHPos, eOldHPos;
     523             : 
     524           0 :         RECT_POINT eRP = aCtlPosition.GetActualRP();
     525           0 :         switch( eRP )
     526             :         {
     527             :             default:
     528           0 :             case RP_LT: eVPos = SDRMEASURE_ABOVE;
     529           0 :                         eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
     530           0 :             case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
     531           0 :                         eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
     532           0 :             case RP_LB: eVPos = SDRMEASURE_BELOW;
     533           0 :                         eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
     534           0 :             case RP_MT: eVPos = SDRMEASURE_ABOVE;
     535           0 :                         eHPos = SDRMEASURE_TEXTINSIDE; break;
     536           0 :             case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
     537           0 :                         eHPos = SDRMEASURE_TEXTINSIDE; break;
     538           0 :             case RP_MB: eVPos = SDRMEASURE_BELOW;
     539           0 :                         eHPos = SDRMEASURE_TEXTINSIDE; break;
     540           0 :             case RP_RT: eVPos = SDRMEASURE_ABOVE;
     541           0 :                         eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
     542           0 :             case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
     543           0 :                         eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
     544           0 :             case RP_RB: eVPos = SDRMEASURE_BELOW;
     545           0 :                         eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
     546             :         }
     547           0 :         if( aTsbAutoPosH.GetState() == STATE_CHECK )
     548           0 :             eHPos = SDRMEASURE_TEXTHAUTO;
     549             : 
     550           0 :         if( aTsbAutoPosV.GetState() == STATE_CHECK )
     551           0 :             eVPos = SDRMEASURE_TEXTVAUTO;
     552             : 
     553           0 :         if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTVPOS ) != SFX_ITEM_DONTCARE )
     554             :         {
     555             :             eOldVPos = (SdrMeasureTextVPos)
     556           0 :                         ( ( const SdrMeasureTextVPosItem& )rOutAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
     557           0 :             if( eOldVPos != eVPos )
     558             :             {
     559           0 :                 rAttrs.Put( SdrMeasureTextVPosItem( eVPos ) );
     560           0 :                 bModified = sal_True;
     561             :             }
     562             :         }
     563             :         else
     564             :         {
     565           0 :             rAttrs.Put( SdrMeasureTextVPosItem( eVPos ) );
     566           0 :             bModified = sal_True;
     567             :         }
     568             : 
     569           0 :         if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTHPOS ) != SFX_ITEM_DONTCARE )
     570             :         {
     571             :             eOldHPos = (SdrMeasureTextHPos)
     572           0 :                         ( ( const SdrMeasureTextHPosItem& )rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
     573           0 :             if( eOldHPos != eHPos )
     574             :             {
     575           0 :                 rAttrs.Put( SdrMeasureTextHPosItem( eHPos ) );
     576           0 :                 bModified = sal_True;
     577             :             }
     578             :         }
     579             :         else
     580             :         {
     581           0 :             rAttrs.Put( SdrMeasureTextHPosItem( eHPos ) );
     582           0 :             bModified = sal_True;
     583             :         }
     584             :     }
     585             : 
     586           0 :     return( bModified );
     587             : }
     588             : 
     589             : /*************************************************************************
     590             : |*
     591             : |* The View have to set at the measure-object to be able to notify
     592             : |* unit and floatingpoint-values
     593             : |*
     594             : \************************************************************************/
     595             : 
     596           0 : void SvxMeasurePage::Construct()
     597             : {
     598             :     DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
     599             : 
     600           0 :     aCtlPreview.pMeasureObj->SetModel( pView->GetModel() );
     601           0 :     aCtlPreview.Invalidate();
     602           0 : }
     603             : 
     604             : /*************************************************************************
     605             : |*
     606             : |* create the tabpage
     607             : |*
     608             : \************************************************************************/
     609             : 
     610           0 : SfxTabPage* SvxMeasurePage::Create( Window* pWindow,
     611             :                 const SfxItemSet& rAttrs )
     612             : {
     613           0 :     return( new SvxMeasurePage( pWindow, rAttrs ) );
     614             : }
     615             : 
     616           0 : sal_uInt16* SvxMeasurePage::GetRanges()
     617             : {
     618           0 :     return( pRanges );
     619             : }
     620             : 
     621           0 : void SvxMeasurePage::PointChanged( Window* pWindow, RECT_POINT /*eRP*/ )
     622             : {
     623           0 :     ChangeAttrHdl_Impl( pWindow );
     624           0 : }
     625             : 
     626           0 : IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, void *, p )
     627             : {
     628           0 :     if( aTsbAutoPosH.GetState() == STATE_CHECK )
     629             :     {
     630           0 :         switch( aCtlPosition.GetActualRP() )
     631             :         {
     632             :             case RP_LT:
     633             :             case RP_RT:
     634           0 :                 aCtlPosition.SetActualRP( RP_MT );
     635           0 :             break;
     636             : 
     637             :             case RP_LM:
     638             :             case RP_RM:
     639           0 :                 aCtlPosition.SetActualRP( RP_MM );
     640           0 :             break;
     641             : 
     642             :             case RP_LB:
     643             :             case RP_RB:
     644           0 :                 aCtlPosition.SetActualRP( RP_MB );
     645           0 :             break;
     646             :             default: ;//prevent warning
     647             :         }
     648             :     }
     649           0 :     if( aTsbAutoPosV.GetState() == STATE_CHECK )
     650             :     {
     651           0 :         switch( aCtlPosition.GetActualRP() )
     652             :         {
     653             :             case RP_LT:
     654             :             case RP_LB:
     655           0 :                 aCtlPosition.SetActualRP( RP_LM );
     656           0 :             break;
     657             : 
     658             :             case RP_MT:
     659             :             case RP_MB:
     660           0 :                 aCtlPosition.SetActualRP( RP_MM );
     661           0 :             break;
     662             : 
     663             :             case RP_RT:
     664             :             case RP_RB:
     665           0 :                 aCtlPosition.SetActualRP( RP_RM );
     666           0 :             break;
     667             :             default: ;//prevent warning
     668             :         }
     669             :     }
     670           0 :     ChangeAttrHdl_Impl( p );
     671             : 
     672           0 :     return( 0L );
     673             : }
     674             : 
     675           0 : IMPL_LINK( SvxMeasurePage, ChangeAttrHdl_Impl, void *, p )
     676             : {
     677             : 
     678           0 :     if( p == &aMtrFldLineDist )
     679             :     {
     680           0 :         sal_Int32 nValue = GetCoreValue( aMtrFldLineDist, eUnit );
     681           0 :         aAttrSet.Put( SdrMeasureLineDistItem( nValue ) );
     682             :     }
     683             : 
     684           0 :     if( p == &aMtrFldHelplineOverhang )
     685             :     {
     686           0 :         sal_Int32 nValue = GetCoreValue( aMtrFldHelplineOverhang, eUnit );
     687           0 :         aAttrSet.Put( SdrMeasureHelplineOverhangItem( nValue) );
     688             :     }
     689             : 
     690           0 :     if( p == &aMtrFldHelplineDist )
     691             :     {
     692           0 :         sal_Int32 nValue = GetCoreValue( aMtrFldHelplineDist, eUnit );
     693           0 :         aAttrSet.Put( SdrMeasureHelplineDistItem( nValue) );
     694             :     }
     695             : 
     696           0 :     if( p == &aMtrFldHelpline1Len )
     697             :     {
     698           0 :         sal_Int32 nValue = GetCoreValue( aMtrFldHelpline1Len, eUnit );
     699           0 :         aAttrSet.Put( SdrMeasureHelpline1LenItem( nValue ) );
     700             :     }
     701             : 
     702           0 :     if( p == &aMtrFldHelpline2Len )
     703             :     {
     704           0 :         sal_Int32 nValue = GetCoreValue( aMtrFldHelpline2Len, eUnit );
     705           0 :         aAttrSet.Put( SdrMeasureHelpline2LenItem( nValue ) );
     706             :     }
     707             : 
     708           0 :     if( p == &aTsbBelowRefEdge )
     709             :     {
     710           0 :         TriState eState = aTsbBelowRefEdge.GetState();
     711           0 :         if( eState != STATE_DONTKNOW )
     712           0 :             aAttrSet.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool) STATE_CHECK == eState ) );
     713             :     }
     714             : 
     715           0 :     if( p == &aMtrFldDecimalPlaces )
     716             :     {
     717             :         sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
     718           0 :             aMtrFldDecimalPlaces.GetValue() );
     719           0 :         aAttrSet.Put( SdrMeasureDecimalPlacesItem( nValue ) );
     720             :     }
     721             : 
     722           0 :     if( p == &aTsbParallel )
     723             :     {
     724           0 :         TriState eState = aTsbParallel.GetState();
     725           0 :         if( eState != STATE_DONTKNOW )
     726           0 :             aAttrSet.Put( SdrMeasureTextRota90Item( (sal_Bool) !STATE_CHECK == eState ) );
     727             :     }
     728             : 
     729           0 :     if( p == &aTsbShowUnit )
     730             :     {
     731           0 :         TriState eState = aTsbShowUnit.GetState();
     732           0 :         if( eState != STATE_DONTKNOW )
     733           0 :             aAttrSet.Put( SdrMeasureShowUnitItem( (sal_Bool) STATE_CHECK == eState ) );
     734             :     }
     735             : 
     736           0 :     if( p == &aLbUnit )
     737             :     {
     738           0 :         sal_uInt16 nPos = aLbUnit.GetSelectEntryPos();
     739           0 :         if( nPos != LISTBOX_ENTRY_NOTFOUND )
     740             :         {
     741           0 :             sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbUnit.GetEntryData( nPos );
     742           0 :             FieldUnit _eUnit = (FieldUnit) nFieldUnit;
     743           0 :             aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
     744             :         }
     745             :     }
     746             : 
     747           0 :     if( p == &aTsbAutoPosV || p == &aTsbAutoPosH || p == &aCtlPosition )
     748             :     {
     749           0 :         bPositionModified = sal_True;
     750             : 
     751             :         // Position
     752           0 :         RECT_POINT eRP = aCtlPosition.GetActualRP();
     753             :         SdrMeasureTextVPos eVPos;
     754             :         SdrMeasureTextHPos eHPos;
     755             : 
     756           0 :         switch( eRP )
     757             :         {
     758             :             default:
     759           0 :             case RP_LT: eVPos = SDRMEASURE_ABOVE;
     760           0 :                         eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
     761           0 :             case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
     762           0 :                         eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
     763           0 :             case RP_LB: eVPos = SDRMEASURE_BELOW;
     764           0 :                         eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
     765           0 :             case RP_MT: eVPos = SDRMEASURE_ABOVE;
     766           0 :                         eHPos = SDRMEASURE_TEXTINSIDE; break;
     767           0 :             case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
     768           0 :                         eHPos = SDRMEASURE_TEXTINSIDE; break;
     769           0 :             case RP_MB: eVPos = SDRMEASURE_BELOW;
     770           0 :                         eHPos = SDRMEASURE_TEXTINSIDE; break;
     771           0 :             case RP_RT: eVPos = SDRMEASURE_ABOVE;
     772           0 :                         eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
     773           0 :             case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
     774           0 :                         eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
     775           0 :             case RP_RB: eVPos = SDRMEASURE_BELOW;
     776           0 :                         eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
     777             :         }
     778             : 
     779           0 :         CTL_STATE nState = 0;
     780             : 
     781           0 :         if( aTsbAutoPosH.GetState() == STATE_CHECK )
     782             :         {
     783           0 :             eHPos = SDRMEASURE_TEXTHAUTO;
     784           0 :             nState = CS_NOHORZ;
     785             :         }
     786             : 
     787           0 :         if( aTsbAutoPosV.GetState() == STATE_CHECK )
     788             :         {
     789           0 :             eVPos = SDRMEASURE_TEXTVAUTO;
     790           0 :             nState |= CS_NOVERT;
     791             :         }
     792             : 
     793           0 :         if( p == &aTsbAutoPosV || p == &aTsbAutoPosH )
     794           0 :             aCtlPosition.SetState( nState );
     795             : 
     796           0 :         aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
     797           0 :         aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
     798             :     }
     799             : 
     800           0 :     aCtlPreview.SetAttributes( aAttrSet );
     801           0 :     aCtlPreview.Invalidate();
     802             : 
     803           0 :     return( 0L );
     804             : }
     805             : 
     806           0 : void SvxMeasurePage::FillUnitLB()
     807             : {
     808             :     // fill ListBox with metrics
     809           0 :     SvxStringArray aMetricArr( SVX_RES( RID_SVXSTR_FIELDUNIT_TABLE ) );
     810             : 
     811           0 :     long nUnit = FUNIT_NONE;
     812           0 :     String aStrMetric( CUI_RES( STR_MEASURE_AUTOMATIC ) );
     813           0 :     sal_uInt16 nPos = aLbUnit.InsertEntry( aStrMetric );
     814           0 :     aLbUnit.SetEntryData( nPos, (void*)nUnit );
     815             : 
     816           0 :     for( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i )
     817             :     {
     818           0 :         aStrMetric = aMetricArr.GetStringByPos( i );
     819           0 :         nUnit = aMetricArr.GetValue( i );
     820           0 :         nPos = aLbUnit.InsertEntry( aStrMetric );
     821           0 :         aLbUnit.SetEntryData( nPos, (void*)nUnit );
     822           0 :     }
     823           0 : }
     824           0 : void SvxMeasurePage::PageCreated (SfxAllItemSet aSet)
     825             : {
     826           0 :     SFX_ITEMSET_ARG (&aSet,pOfaPtrItem,OfaPtrItem,SID_OBJECT_LIST,sal_False);
     827             : 
     828           0 :     if (pOfaPtrItem)
     829           0 :         SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()));
     830             : 
     831           0 :     Construct();
     832           3 : }
     833             : 
     834             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10