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

Generated by: LCOV version 1.10