LCOV - code coverage report
Current view: top level - cui/source/tabpages - measure.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 391 0.0 %
Date: 2014-11-03 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 <vcl/settings.hxx>
      26             : 
      27             : #include <svx/dialmgr.hxx>
      28             : #include <svx/dialogs.hrc>
      29             : #include <svx/dlgutil.hxx>
      30             : #include <svx/measctrl.hxx>
      31             : #include <svx/ofaitem.hxx>
      32             : #include <svx/strarray.hxx>
      33             : #include <svx/svdattr.hxx>
      34             : #include <svx/svdomeas.hxx>
      35             : #include <svx/svdview.hxx>
      36             : #include <svx/sxekitm.hxx>
      37             : #include <svx/sxelditm.hxx>
      38             : #include <svx/sxenditm.hxx>
      39             : #include <svx/sxmbritm.hxx>
      40             : #include <svx/sxmfsitm.hxx>
      41             : #include <svx/sxmlhitm.hxx>
      42             : #include <svx/sxmsuitm.hxx>
      43             : #include <svx/sxmtfitm.hxx>
      44             : #include <svx/sxmtpitm.hxx>
      45             : #include <svx/sxmtritm.hxx>
      46             : #include <svx/sxmuitm.hxx>
      47             : 
      48             : #include "measure.hxx"
      49             : 
      50             : static const sal_uInt16 pRanges[] =
      51             : {
      52             :     SDRATTR_MEASURE_FIRST,
      53             :     SDRATTR_MEASURE_LAST,
      54             :     0
      55             : };
      56             : 
      57             : /*************************************************************************
      58             : |*
      59             : |* Dialog to change measure-attributes
      60             : |*
      61             : \************************************************************************/
      62             : 
      63           0 : SvxMeasureDialog::SvxMeasureDialog( vcl::Window* pParent, const SfxItemSet& rInAttrs,
      64             :                                 const SdrView* pSdrView )
      65           0 :     : SfxSingleTabDialog(pParent, rInAttrs)
      66             : {
      67           0 :     SvxMeasurePage* _pPage = new SvxMeasurePage( get_content_area(), rInAttrs );
      68             : 
      69           0 :     _pPage->SetView( pSdrView );
      70           0 :     _pPage->Construct();
      71             : 
      72           0 :     SetTabPage(_pPage );
      73           0 :     SetText(CUI_RESSTR(RID_SVXSTR_DIMENSION_LINE));
      74           0 : }
      75             : 
      76             : /*************************************************************************
      77             : |*
      78             : |* Tabpage for changing measure-attributes
      79             : |*
      80             : \************************************************************************/
      81             : 
      82           0 : SvxMeasurePage::SvxMeasurePage( vcl::Window* pWindow, const SfxItemSet& rInAttrs ) :
      83             :                 SvxTabPage      ( pWindow
      84             :                                  ,"DimensionLinesTabPage"
      85             :                                  ,"cui/ui/dimensionlinestabpage.ui"
      86             :                                  ,rInAttrs ),
      87             :         rOutAttrs               ( rInAttrs ),
      88           0 :         aAttrSet                ( *rInAttrs.GetPool() ),
      89             :         pView( 0 ),
      90             :         eUnit( SFX_MAPUNIT_100TH_MM ),
      91           0 :         bPositionModified       ( 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(WindowBorderStyle::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 = static_cast<const SdrMetricItem*>( 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 = static_cast<const SdrMetricItem*>( 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 = static_cast<const SdrMetricItem*>( 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 = static_cast<const SdrMetricItem*>( 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 = static_cast<const SdrMetricItem*>( 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 ) != SfxItemState::DONTCARE )
     251             :     {
     252           0 :         m_pTsbBelowRefEdge->SetState( static_cast<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 = static_cast<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 ) != SfxItemState::DONTCARE )
     280             :     {
     281           0 :         m_pTsbParallel->SetState( static_cast<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 ) != SfxItemState::DONTCARE )
     293             :     {
     294           0 :         m_pTsbShowUnit->SetState( static_cast<const SdrYesNoItem&>( 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 ) != SfxItemState::DONTCARE )
     306             :     {
     307             :         long nFieldUnit = (long) static_cast<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 ( reinterpret_cast<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 ) != SfxItemState::DONTCARE )
     327             :     {
     328             :         SdrMeasureTextVPos eVPos = (SdrMeasureTextVPos)
     329           0 :                     static_cast<const SdrMeasureTextVPosItem&>( rAttrs->Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
     330             :         {
     331           0 :             if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
     332             :             {
     333           0 :                 m_pTsbAutoPosV->EnableTriState( false );
     334           0 :                 m_pTsbAutoPosH->EnableTriState( false );
     335             : 
     336             :                 SdrMeasureTextHPos eHPos = (SdrMeasureTextHPos)
     337           0 :                             static_cast<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 = 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 :     bool     bModified = false;
     424             :     sal_Int32    nValue;
     425             :     TriState eState;
     426             : 
     427           0 :     if( m_pMtrFldLineDist->IsValueChangedFromSaved() )
     428             :     {
     429           0 :         nValue = GetCoreValue( *m_pMtrFldLineDist, eUnit );
     430           0 :         rAttrs->Put( makeSdrMeasureLineDistItem( nValue ) );
     431           0 :         bModified = true;
     432             :     }
     433             : 
     434           0 :     if( m_pMtrFldHelplineOverhang->IsValueChangedFromSaved() )
     435             :     {
     436           0 :         nValue = GetCoreValue( *m_pMtrFldHelplineOverhang, eUnit );
     437           0 :         rAttrs->Put( makeSdrMeasureHelplineOverhangItem( nValue ) );
     438           0 :         bModified = true;
     439             :     }
     440             : 
     441           0 :     if( m_pMtrFldHelplineDist->IsValueChangedFromSaved() )
     442             :     {
     443           0 :         nValue = GetCoreValue( *m_pMtrFldHelplineDist, eUnit );
     444           0 :         rAttrs->Put( makeSdrMeasureHelplineDistItem( nValue ) );
     445           0 :         bModified = true;
     446             :     }
     447             : 
     448           0 :     if( m_pMtrFldHelpline1Len->IsValueChangedFromSaved() )
     449             :     {
     450           0 :         nValue = GetCoreValue( *m_pMtrFldHelpline1Len, eUnit );
     451           0 :         rAttrs->Put( makeSdrMeasureHelpline1LenItem( nValue ) );
     452           0 :         bModified = true;
     453             :     }
     454             : 
     455           0 :     if( m_pMtrFldHelpline2Len->IsValueChangedFromSaved() )
     456             :     {
     457           0 :         nValue = GetCoreValue( *m_pMtrFldHelpline2Len, eUnit );
     458           0 :         rAttrs->Put( makeSdrMeasureHelpline2LenItem( nValue ) );
     459           0 :         bModified = true;
     460             :     }
     461             : 
     462           0 :     eState = m_pTsbBelowRefEdge->GetState();
     463           0 :     if( m_pTsbBelowRefEdge->IsValueChangedFromSaved() )
     464             :     {
     465           0 :         rAttrs->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
     466           0 :         bModified = true;
     467             :     }
     468             : 
     469           0 :     if( m_pMtrFldDecimalPlaces->IsValueChangedFromSaved() )
     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 = true;
     476             :     }
     477             : 
     478           0 :     eState = m_pTsbParallel->GetState();
     479           0 :     if( m_pTsbParallel->IsValueChangedFromSaved() )
     480             :     {
     481           0 :         rAttrs->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
     482           0 :         bModified = true;
     483             :     }
     484             : 
     485           0 :     eState = m_pTsbShowUnit->GetState();
     486           0 :     if( m_pTsbShowUnit->IsValueChangedFromSaved() )
     487             :     {
     488           0 :         rAttrs->Put( makeSdrMeasureShowUnitItem( TRISTATE_TRUE == eState ) );
     489           0 :         bModified = true;
     490             :     }
     491             : 
     492           0 :     sal_Int32 nPos = m_pLbUnit->GetSelectEntryPos();
     493           0 :     if( m_pLbUnit->IsValueChangedFromSaved() )
     494             :     {
     495           0 :         if( nPos != LISTBOX_ENTRY_NOTFOUND )
     496             :         {
     497           0 :             sal_uInt16 nFieldUnit = (sal_uInt16)reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( nPos ));
     498           0 :             FieldUnit _eUnit = (FieldUnit) nFieldUnit;
     499           0 :             rAttrs->Put( SdrMeasureUnitItem( _eUnit ) );
     500           0 :             bModified = 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 ) != SfxItemState::DONTCARE )
     540             :         {
     541             :             eOldVPos = (SdrMeasureTextVPos)
     542           0 :                         static_cast<const SdrMeasureTextVPosItem&>( rOutAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
     543           0 :             if( eOldVPos != eVPos )
     544             :             {
     545           0 :                 rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
     546           0 :                 bModified = true;
     547             :             }
     548             :         }
     549             :         else
     550             :         {
     551           0 :             rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
     552           0 :             bModified = true;
     553             :         }
     554             : 
     555           0 :         if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
     556             :         {
     557             :             eOldHPos = (SdrMeasureTextHPos)
     558           0 :                         static_cast<const SdrMeasureTextHPosItem&>( rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
     559           0 :             if( eOldHPos != eHPos )
     560             :             {
     561           0 :                 rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
     562           0 :                 bModified = true;
     563             :             }
     564             :         }
     565             :         else
     566             :         {
     567           0 :             rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
     568           0 :             bModified = 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( vcl::Window* pWindow,
     597             :                 const SfxItemSet* rAttrs )
     598             : {
     599           0 :     return( new SvxMeasurePage( pWindow, *rAttrs ) );
     600             : }
     601             : 
     602           0 : const sal_uInt16* SvxMeasurePage::GetRanges()
     603             : {
     604           0 :     return( pRanges );
     605             : }
     606             : 
     607           0 : void SvxMeasurePage::PointChanged( vcl::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( makeSdrMeasureLineDistItem( nValue ) );
     668             :     }
     669             : 
     670           0 :     if( p == m_pMtrFldHelplineOverhang )
     671             :     {
     672           0 :         sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelplineOverhang, eUnit );
     673           0 :         aAttrSet.Put( makeSdrMeasureHelplineOverhangItem( nValue) );
     674             :     }
     675             : 
     676           0 :     if( p == m_pMtrFldHelplineDist )
     677             :     {
     678           0 :         sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelplineDist, eUnit );
     679           0 :         aAttrSet.Put( makeSdrMeasureHelplineDistItem( nValue) );
     680             :     }
     681             : 
     682           0 :     if( p == m_pMtrFldHelpline1Len )
     683             :     {
     684           0 :         sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelpline1Len, eUnit );
     685           0 :         aAttrSet.Put( makeSdrMeasureHelpline1LenItem( nValue ) );
     686             :     }
     687             : 
     688           0 :     if( p == m_pMtrFldHelpline2Len )
     689             :     {
     690           0 :         sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelpline2Len, eUnit );
     691           0 :         aAttrSet.Put( makeSdrMeasureHelpline2LenItem( 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( 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( 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( makeSdrMeasureShowUnitItem( 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)reinterpret_cast<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 = 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, reinterpret_cast<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, reinterpret_cast<void*>(nUnit) );
     808           0 :     }
     809           0 : }
     810           0 : void SvxMeasurePage::PageCreated(const 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