LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - textattr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 325 0.3 %
Date: 2012-12-27 Functions: 2 17 11.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/app.hxx>
      21             : #include <sfx2/module.hxx>
      22             : #include <tools/shl.hxx>
      23             : #include <cuires.hrc>
      24             : #include <svx/svddef.hxx>
      25             : #include <svx/sdtditm.hxx>
      26             : #include <svx/sdtagitm.hxx>
      27             : #include <svx/sdtaitm.hxx>
      28             : #include <svx/sdtfsitm.hxx>
      29             : #include <svx/sdtcfitm.hxx>
      30             : #include <svx/svdobj.hxx>
      31             : #include <svx/svdmark.hxx>
      32             : #include <svx/svdview.hxx>
      33             : #include <svx/svdotext.hxx>
      34             : #include <svx/dialogs.hrc>
      35             : 
      36             : #ifndef _SVX_TEXTATTR_CXX
      37             : #define _SVX_TEXTATTR_CXX
      38             : #endif
      39             : #include "textattr.hxx"
      40             : #include "textattr.hrc"
      41             : #include <dialmgr.hxx>
      42             : #include "svx/dlgutil.hxx"
      43             : #include <sfx2/request.hxx>
      44             : #include <svx/ofaitem.hxx>
      45             : #include <editeng/writingmodeitem.hxx>
      46             : 
      47             : static sal_uInt16 pRanges[] =
      48             : {
      49             :     SDRATTR_MISC_FIRST, SDRATTR_TEXT_HORZADJUST,
      50             :     SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
      51             :     0
      52             : };
      53             : 
      54             : /*************************************************************************
      55             : |*
      56             : |* dialog (page) for copying objects
      57             : |*
      58             : \************************************************************************/
      59             : 
      60           0 : SvxTextAttrPage::SvxTextAttrPage( Window* pWindow, const SfxItemSet& rInAttrs ) :
      61           0 :                 SvxTabPage      ( pWindow, CUI_RES( RID_SVXPAGE_TEXTATTR ),
      62             :                                   rInAttrs ),
      63             : 
      64           0 :                 aFlText         ( this, CUI_RES( FL_TEXT ) ),
      65           0 :                 aTsbAutoGrowWidth  ( this, CUI_RES( TSB_AUTOGROW_WIDTH ) ),
      66           0 :                 aTsbAutoGrowHeight ( this, CUI_RES( TSB_AUTOGROW_HEIGHT ) ),
      67           0 :                 aTsbFitToSize   ( this, CUI_RES( TSB_FIT_TO_SIZE ) ),
      68           0 :                 aTsbContour     ( this, CUI_RES( TSB_CONTOUR ) ),
      69           0 :                 aTsbWordWrapText( this, CUI_RES( TSB_WORDWRAP_TEXT ) ),
      70           0 :                 aTsbAutoGrowSize( this, CUI_RES( TSB_AUTOGROW_SIZE ) ),
      71           0 :                 aFlDistance     ( this, CUI_RES( FL_DISTANCE ) ),
      72           0 :                 aFtLeft         ( this, CUI_RES( FT_LEFT ) ),
      73           0 :                 aMtrFldLeft     ( this, CUI_RES( MTR_FLD_LEFT ) ),
      74           0 :                 aFtRight        ( this, CUI_RES( FT_RIGHT ) ),
      75           0 :                 aMtrFldRight    ( this, CUI_RES( MTR_FLD_RIGHT ) ),
      76           0 :                 aFtTop          ( this, CUI_RES( FT_TOP ) ),
      77           0 :                 aMtrFldTop      ( this, CUI_RES( MTR_FLD_TOP ) ),
      78           0 :                 aFtBottom       ( this, CUI_RES( FT_BOTTOM ) ),
      79           0 :                 aMtrFldBottom   ( this, CUI_RES( MTR_FLD_BOTTOM ) ),
      80             : 
      81           0 :                 aFlSeparator    ( this, CUI_RES( FL_SEPARATOR ) ),
      82             : 
      83           0 :                 aFlPosition     ( this, CUI_RES( FL_POSITION ) ),
      84           0 :                 aCtlPosition    ( this, CUI_RES( CTL_POSITION ),
      85             :                                             RP_MM, 240, 100 ),
      86           0 :                 aTsbFullWidth   ( this, CUI_RES( TSB_FULL_WIDTH ) ),
      87             : 
      88           0 :                 rOutAttrs       ( rInAttrs )
      89             : {
      90           0 :     FreeResource();
      91             : 
      92           0 :     FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
      93           0 :     SetFieldUnit( aMtrFldLeft, eFUnit );
      94           0 :     SetFieldUnit( aMtrFldRight, eFUnit );
      95           0 :     SetFieldUnit( aMtrFldTop, eFUnit );
      96           0 :     SetFieldUnit( aMtrFldBottom, eFUnit );
      97             : 
      98           0 :     Link aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
      99           0 :     aTsbAutoGrowWidth.SetClickHdl( aLink );
     100           0 :     aTsbAutoGrowHeight.SetClickHdl( aLink );
     101           0 :     aTsbFitToSize.SetClickHdl( aLink );
     102           0 :     aTsbContour.SetClickHdl( aLink );
     103             : 
     104             :     aTsbFullWidth.SetClickHdl(
     105           0 :         LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
     106             : 
     107           0 :     aCtlPosition.SetAccessibleRelationMemberOf( &aFlPosition );
     108           0 : }
     109             : 
     110             : /*************************************************************************
     111             : |*
     112             : |* Dtor
     113             : |*
     114             : \************************************************************************/
     115             : 
     116           0 : SvxTextAttrPage::~SvxTextAttrPage()
     117             : {
     118           0 : }
     119             : 
     120             : /*************************************************************************
     121             : |*
     122             : |* reads the passed item set
     123             : |*
     124             : \************************************************************************/
     125             : 
     126           0 : void SvxTextAttrPage::Reset( const SfxItemSet& rAttrs )
     127             : {
     128           0 :     SfxItemPool* pPool = rAttrs.GetPool();
     129             :     DBG_ASSERT( pPool, "Wo ist der Pool" );
     130           0 :     SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
     131             : 
     132           0 :     const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_TEXT_LEFTDIST );
     133             : 
     134           0 :     if( !pItem )
     135           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
     136           0 :     if( pItem )
     137             :     {
     138           0 :         long nValue = ( ( const SdrTextLeftDistItem* )pItem )->GetValue();
     139           0 :         SetMetricValue( aMtrFldLeft, nValue, eUnit );
     140             :     }
     141             :     else
     142           0 :         aMtrFldLeft.SetText( String() );
     143           0 :     aMtrFldLeft.SaveValue();
     144             : 
     145           0 :     pItem = GetItem( rAttrs, SDRATTR_TEXT_RIGHTDIST );
     146           0 :     if( !pItem )
     147           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
     148           0 :     if( pItem )
     149             :     {
     150           0 :         long nValue = ( ( const SdrTextRightDistItem* )pItem )->GetValue();
     151           0 :         SetMetricValue( aMtrFldRight, nValue, eUnit );
     152             :     }
     153             :     else
     154           0 :         aMtrFldRight.SetText( String() );
     155           0 :     aMtrFldRight.SaveValue();
     156             : 
     157           0 :     pItem = GetItem( rAttrs, SDRATTR_TEXT_UPPERDIST );
     158           0 :     if( !pItem )
     159           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
     160           0 :     if( pItem )
     161             :     {
     162           0 :         long nValue = ( ( const SdrTextUpperDistItem* )pItem )->GetValue();
     163           0 :         SetMetricValue( aMtrFldTop, nValue, eUnit );
     164             :     }
     165             :     else
     166           0 :         aMtrFldTop.SetText( String() );
     167           0 :     aMtrFldTop.SaveValue();
     168             : 
     169           0 :     pItem = GetItem( rAttrs, SDRATTR_TEXT_LOWERDIST );
     170           0 :     if( !pItem )
     171           0 :         pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
     172           0 :     if( pItem )
     173             :     {
     174           0 :         long nValue = ( ( const SdrTextLowerDistItem* )pItem )->GetValue();
     175           0 :         SetMetricValue( aMtrFldBottom, nValue, eUnit );
     176             :     }
     177             :     else
     178           0 :         aMtrFldBottom.SetText( String() );
     179           0 :     aMtrFldBottom.SaveValue();
     180             : 
     181             :     // adjust to height
     182           0 :     if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SFX_ITEM_DONTCARE )
     183             :     {
     184           0 :         aTsbAutoGrowHeight.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
     185           0 :                         GetValue() ? STATE_CHECK : STATE_NOCHECK );
     186           0 :         aTsbAutoGrowHeight.EnableTriState( sal_False );
     187             :     }
     188             :     else
     189           0 :         aTsbAutoGrowHeight.SetState( STATE_DONTKNOW );
     190           0 :     aTsbAutoGrowHeight.SaveValue();
     191             : 
     192             :     // adjust to width
     193           0 :     if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SFX_ITEM_DONTCARE )
     194             :     {
     195           0 :         aTsbAutoGrowWidth.SetState( ( ( const SdrTextAutoGrowWidthItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ).
     196           0 :                         GetValue() ? STATE_CHECK : STATE_NOCHECK );
     197           0 :         aTsbAutoGrowWidth.EnableTriState( sal_False );
     198             :     }
     199             :     else
     200           0 :         aTsbAutoGrowWidth.SetState( STATE_DONTKNOW );
     201           0 :     aTsbAutoGrowWidth.SaveValue();
     202             : 
     203             :     // autogrowsize
     204           0 :     if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SFX_ITEM_DONTCARE )
     205             :     {
     206           0 :         aTsbAutoGrowSize.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
     207           0 :                         GetValue() ? STATE_CHECK : STATE_NOCHECK );
     208           0 :         aTsbAutoGrowSize.EnableTriState( sal_False );
     209             :     }
     210             :     else
     211           0 :         aTsbAutoGrowSize.SetState( STATE_DONTKNOW );
     212           0 :     aTsbAutoGrowSize.SaveValue();
     213             : 
     214             :     // wordwrap text
     215           0 :     if ( rAttrs.GetItemState( SDRATTR_TEXT_WORDWRAP ) != SFX_ITEM_DONTCARE )
     216             :     {
     217           0 :         aTsbWordWrapText.SetState( ( ( const SdrTextWordWrapItem& )rAttrs.Get( SDRATTR_TEXT_WORDWRAP ) ).
     218           0 :                         GetValue() ? STATE_CHECK : STATE_NOCHECK );
     219           0 :         aTsbWordWrapText.EnableTriState( sal_False );
     220             :     }
     221             :     else
     222           0 :         aTsbWordWrapText.SetState( STATE_DONTKNOW );
     223           0 :     aTsbWordWrapText.SaveValue();
     224             : 
     225             : 
     226             :     // #103516# Do the setup based on states of hor/ver adjust
     227             :     // Setup center field and FullWidth
     228           0 :     SfxItemState eVState = rAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
     229           0 :     SfxItemState eHState = rAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
     230             : 
     231           0 :     if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
     232             :     {
     233             :         // VertAdjust and HorAdjust are unequivocal, thus
     234           0 :         SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)rAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
     235           0 :         SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)((const SdrTextHorzAdjustItem&)rAttrs.Get(SDRATTR_TEXT_HORZADJUST)).GetValue();
     236           0 :         RECT_POINT eRP = RP_LB;
     237             : 
     238           0 :         aTsbFullWidth.EnableTriState( sal_False );
     239             : 
     240             :         // Translate item values into local anchor position.
     241           0 :         switch (eTVA)
     242             :         {
     243             :             case SDRTEXTVERTADJUST_TOP:
     244             :             {
     245           0 :                 switch (eTHA)
     246             :                 {
     247           0 :                     case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break;
     248             :                     case SDRTEXTHORZADJUST_BLOCK:
     249           0 :                     case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break;
     250           0 :                     case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break;
     251             :                 }
     252           0 :                 break;
     253             :             }
     254             :             case SDRTEXTVERTADJUST_BLOCK:
     255             :             case SDRTEXTVERTADJUST_CENTER:
     256             :             {
     257           0 :                 switch (eTHA)
     258             :                 {
     259           0 :                     case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break;
     260             :                     case SDRTEXTHORZADJUST_BLOCK:
     261           0 :                     case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break;
     262           0 :                     case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break;
     263             :                 }
     264           0 :                 break;
     265             :             }
     266             :             case SDRTEXTVERTADJUST_BOTTOM:
     267             :             {
     268           0 :                 switch (eTHA)
     269             :                 {
     270           0 :                     case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break;
     271             :                     case SDRTEXTHORZADJUST_BLOCK:
     272           0 :                     case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break;
     273           0 :                     case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break;
     274             :                 }
     275           0 :                 break;
     276             :             }
     277             :             default:
     278           0 :                 break;
     279             :         }
     280             : 
     281             :         // See if we have to check the "full width" check button.
     282           0 :         sal_Bool bLeftToRight(IsTextDirectionLeftToRight());
     283             : 
     284           0 :         if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
     285             :         {
     286             :             // Move anchor to valid position.
     287           0 :             ClickFullWidthHdl_Impl(NULL);
     288           0 :             aTsbFullWidth.SetState(STATE_CHECK);
     289             :         }
     290             : 
     291           0 :         aCtlPosition.SetActualRP( eRP );
     292             :     }
     293             :     else
     294             :     {
     295             :         // VertAdjust or HorAdjust is not unequivocal
     296           0 :         aCtlPosition.Reset();
     297             : 
     298           0 :         aCtlPosition.SetState(STATE_DONTKNOW);
     299           0 :         aCtlPosition.DoCompletelyDisable(sal_True);
     300             : 
     301           0 :         aTsbFullWidth.SetState(STATE_DONTKNOW);
     302           0 :         aTsbFullWidth.Enable( sal_False );
     303           0 :         aFlPosition.Enable( sal_False );
     304             :     }
     305             : 
     306             :     // adjust to border
     307           0 :     if ( rAttrs.GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SFX_ITEM_DONTCARE )
     308             :     {
     309             :         SdrFitToSizeType eFTS = (SdrFitToSizeType)
     310           0 :                     ( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
     311           0 :         aTsbFitToSize.SetState( eFTS == SDRTEXTFIT_NONE ? STATE_NOCHECK : STATE_CHECK );
     312           0 :         aTsbFitToSize.EnableTriState( sal_False );
     313             :     }
     314             :     else
     315           0 :         aTsbFitToSize.SetState( STATE_DONTKNOW );
     316           0 :     aTsbFitToSize.SaveValue();
     317             : 
     318           0 :     if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE )
     319             :     {
     320           0 :         sal_Bool bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
     321           0 :         aTsbContour.SetState( bContour ? STATE_CHECK : STATE_NOCHECK );
     322           0 :         aTsbContour.EnableTriState( sal_False );
     323             :     }
     324             :     else
     325           0 :         aTsbContour.SetState( STATE_DONTKNOW );
     326           0 :     aTsbContour.SaveValue();
     327             : 
     328           0 :     ClickHdl_Impl( NULL );
     329           0 : }
     330             : 
     331             : /*************************************************************************
     332             : |*
     333             : |* fills the passed item set with dialog box attributes
     334             : |*
     335             : \************************************************************************/
     336             : 
     337           0 : sal_Bool SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs)
     338             : {
     339           0 :     SfxItemPool* pPool = rAttrs.GetPool();
     340             :     DBG_ASSERT( pPool, "Wo ist der Pool" );
     341           0 :     SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
     342             : 
     343             :     sal_Int32    nValue;
     344             :     TriState eState;
     345             : 
     346           0 :     if( aMtrFldLeft.GetText() != aMtrFldLeft.GetSavedValue() )
     347             :     {
     348           0 :         nValue = GetCoreValue( aMtrFldLeft, eUnit );
     349           0 :         rAttrs.Put( SdrTextLeftDistItem( nValue ) );
     350             :     }
     351             : 
     352           0 :     if( aMtrFldRight.GetText() != aMtrFldRight.GetSavedValue() )
     353             :     {
     354           0 :         nValue = GetCoreValue( aMtrFldRight, eUnit );
     355           0 :         rAttrs.Put( SdrTextRightDistItem( nValue ) );
     356             :     }
     357             : 
     358           0 :     if( aMtrFldTop.GetText() != aMtrFldTop.GetSavedValue() )
     359             :     {
     360           0 :         nValue = GetCoreValue( aMtrFldTop, eUnit );
     361           0 :         rAttrs.Put( SdrTextUpperDistItem( nValue ) );
     362             :     }
     363             : 
     364           0 :     if( aMtrFldBottom.GetText() != aMtrFldBottom.GetSavedValue() )
     365             :     {
     366           0 :         nValue = GetCoreValue( aMtrFldBottom, eUnit );
     367           0 :         rAttrs.Put( SdrTextLowerDistItem( nValue ) );
     368             :     }
     369             : 
     370           0 :     eState = aTsbAutoGrowHeight.GetState();
     371           0 :     if( eState != aTsbAutoGrowHeight.GetSavedValue() )
     372             :     {
     373           0 :         rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
     374             :     }
     375             : 
     376           0 :     eState = aTsbAutoGrowWidth.GetState();
     377           0 :     if( eState != aTsbAutoGrowWidth.GetSavedValue() )
     378             :     {
     379           0 :         rAttrs.Put( SdrTextAutoGrowWidthItem( (sal_Bool) STATE_CHECK == eState ) );
     380             :     }
     381             : 
     382           0 :     eState = aTsbAutoGrowSize.GetState();
     383           0 :     if( eState != aTsbAutoGrowSize.GetSavedValue() )
     384             :     {
     385           0 :         rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
     386             :     }
     387             : 
     388           0 :     eState = aTsbWordWrapText.GetState();
     389           0 :     if( eState != aTsbWordWrapText.GetSavedValue() )
     390             :     {
     391           0 :         rAttrs.Put( SdrTextWordWrapItem( (sal_Bool) STATE_CHECK == eState ) );
     392             :     }
     393             : 
     394           0 :     eState = aTsbContour.GetState();
     395           0 :     if( eState != aTsbContour.GetSavedValue() )
     396             :     {
     397           0 :         rAttrs.Put( SdrTextContourFrameItem( (sal_Bool) STATE_CHECK == eState ) );
     398             :     }
     399             : 
     400           0 :     eState = aTsbFitToSize.GetState();
     401           0 :     if( eState != aTsbFitToSize.GetSavedValue() )
     402             :     {
     403             :         SdrFitToSizeType eFTS;
     404           0 :         switch( eState )
     405             :         {
     406             :             default: ; //prevent warning
     407             :                 OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
     408           0 :             case STATE_NOCHECK: eFTS = SDRTEXTFIT_NONE; break;
     409           0 :             case STATE_CHECK: eFTS = SDRTEXTFIT_AUTOFIT; break;
     410             :         }
     411           0 :         rAttrs.Put( SdrTextFitToSizeTypeItem( eFTS ) );
     412             :     }
     413             : 
     414             :     // centered
     415           0 :     RECT_POINT eRP = aCtlPosition.GetActualRP();
     416             :     SdrTextVertAdjust eTVA, eOldTVA;
     417             :     SdrTextHorzAdjust eTHA, eOldTHA;
     418             : 
     419           0 :     switch( eRP )
     420             :     {
     421             :         default:
     422           0 :         case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
     423           0 :                     eTHA = SDRTEXTHORZADJUST_LEFT; break;
     424           0 :         case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
     425           0 :                     eTHA = SDRTEXTHORZADJUST_LEFT; break;
     426           0 :         case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
     427           0 :                     eTHA = SDRTEXTHORZADJUST_LEFT; break;
     428           0 :         case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
     429           0 :                     eTHA = SDRTEXTHORZADJUST_CENTER; break;
     430           0 :         case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
     431           0 :                     eTHA = SDRTEXTHORZADJUST_CENTER; break;
     432           0 :         case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
     433           0 :                     eTHA = SDRTEXTHORZADJUST_CENTER; break;
     434           0 :         case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
     435           0 :                     eTHA = SDRTEXTHORZADJUST_RIGHT; break;
     436           0 :         case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
     437           0 :                     eTHA = SDRTEXTHORZADJUST_RIGHT; break;
     438           0 :         case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
     439           0 :                     eTHA = SDRTEXTHORZADJUST_RIGHT; break;
     440             :     }
     441             : 
     442             :     // #103516# Do not change values if adjust controls were disabled.
     443           0 :     sal_Bool bIsDisabled(aCtlPosition.IsCompletelyDisabled());
     444             : 
     445           0 :     if(!bIsDisabled)
     446             :     {
     447           0 :         if( aTsbFullWidth.GetState() == STATE_CHECK )
     448             :         {
     449           0 :             if (IsTextDirectionLeftToRight())
     450           0 :                 eTHA = SDRTEXTHORZADJUST_BLOCK;
     451             :             else
     452           0 :                 eTVA = SDRTEXTVERTADJUST_BLOCK;
     453             :         }
     454             : 
     455           0 :         if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
     456             :         {
     457             :             eOldTVA = (SdrTextVertAdjust)
     458           0 :                         ( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
     459           0 :             if( eOldTVA != eTVA )
     460           0 :                 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
     461             :         }
     462             :         else
     463           0 :             rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
     464             : 
     465           0 :         if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE )
     466             :         {
     467             :             eOldTHA = (SdrTextHorzAdjust)
     468           0 :                         ( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
     469           0 :             if( eOldTHA != eTHA )
     470           0 :                 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
     471             :         }
     472             :         else
     473           0 :             rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
     474             :     }
     475             : 
     476           0 :     return( sal_True );
     477             : }
     478             : 
     479           0 : void SvxTextAttrPage::Construct()
     480             : {
     481             :     DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
     482             : 
     483           0 :     bFitToSizeEnabled = bContourEnabled = sal_True;
     484           0 :     bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_False;
     485             : 
     486           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     487           0 :     if( rMarkList.GetMarkCount() == 1 )
     488             :     {
     489           0 :         const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     490           0 :         SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
     491           0 :         if( pObj->GetObjInventor() == SdrInventor )
     492             :         {
     493           0 :             switch( eKind )
     494             :             {
     495             :                 case OBJ_TEXT :
     496             :                 case OBJ_TITLETEXT :
     497             :                 case OBJ_OUTLINETEXT :
     498             :                 case OBJ_CAPTION :
     499             :                 {
     500           0 :                     if ( ((SdrTextObj*)pObj)->HasText() )
     501             :                     {
     502             :                         // contour NOT possible for pure text objects
     503           0 :                         bContourEnabled = sal_False;
     504             : 
     505             :                         // adjusting width and height is ONLY possible for pure text objects
     506           0 :                         bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_True;
     507             :                     }
     508             :                 }
     509           0 :                 break;
     510             :                 case OBJ_CUSTOMSHAPE :
     511             :                 {
     512           0 :                     bFitToSizeEnabled = bContourEnabled = sal_False;
     513           0 :                     bAutoGrowSizeEnabled = sal_True;
     514           0 :                     bWordWrapTextEnabled = sal_True;
     515             :                 }
     516           0 :                 break;
     517             :                 default: ;//prevent warning
     518             :             }
     519             :         }
     520             :     }
     521           0 :     aTsbAutoGrowHeight.Enable( bAutoGrowHeightEnabled );
     522           0 :     aTsbAutoGrowWidth.Enable( bAutoGrowWidthEnabled );
     523           0 :     aTsbFitToSize.Enable( bFitToSizeEnabled );
     524           0 :     aTsbContour.Enable( bContourEnabled );
     525           0 :     aTsbAutoGrowSize.Enable( bAutoGrowSizeEnabled );
     526           0 :     aTsbWordWrapText.Enable( bWordWrapTextEnabled );
     527           0 : }
     528             : 
     529             : /*************************************************************************
     530             : |*
     531             : |* creates the page
     532             : |*
     533             : \************************************************************************/
     534             : 
     535           0 : SfxTabPage* SvxTextAttrPage::Create( Window* pWindow,
     536             :                 const SfxItemSet& rAttrs )
     537             : {
     538           0 :     return( new SvxTextAttrPage( pWindow, rAttrs ) );
     539             : }
     540             : 
     541           0 : sal_uInt16* SvxTextAttrPage::GetRanges()
     542             : {
     543           0 :     return( pRanges );
     544             : }
     545             : 
     546             : /** Check whether we have to uncheck the "Full width" check box.
     547             : */
     548           0 : void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP )
     549             : {
     550           0 :     if (aTsbFullWidth.GetState() == STATE_CHECK)
     551             :     {
     552             :         // Depending on write direction and currently checked anchor we have
     553             :         // to uncheck the "full width" button.
     554           0 :         if (IsTextDirectionLeftToRight())
     555           0 :             switch( eRP )
     556             :             {
     557             :                 case RP_LT:
     558             :                 case RP_LM:
     559             :                 case RP_LB:
     560             :                 case RP_RT:
     561             :                 case RP_RM:
     562             :                 case RP_RB:
     563           0 :                     aTsbFullWidth.SetState( STATE_NOCHECK );
     564           0 :                 break;
     565             :                 default: ;//prevent warning
     566             :             }
     567             :         else
     568           0 :             switch (eRP)
     569             :             {
     570             :                 case RP_LT:
     571             :                 case RP_MT:
     572             :                 case RP_RT:
     573             :                 case RP_LB:
     574             :                 case RP_MB:
     575             :                 case RP_RB:
     576           0 :                     aTsbFullWidth.SetState( STATE_NOCHECK );
     577           0 :                 break;
     578             :                 default: ;//prevent warning
     579             :             }
     580             :     }
     581           0 : }
     582             : 
     583             : /*************************************************************************
     584             : |*
     585             : |* possibly changes the position of the position-control
     586             : |*
     587             : \************************************************************************/
     588             : 
     589             : /** When switching the "full width" check button on the text anchor may have
     590             :     to be moved to a valid and adjacent position.  This position depends on
     591             :     the current anchor position and the text writing direction.
     592             : */
     593           0 : IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl)
     594             : {
     595           0 :     if( aTsbFullWidth.GetState() == STATE_CHECK )
     596             :     {
     597           0 :         if (IsTextDirectionLeftToRight())
     598             :         {
     599             :             // Move text anchor to horizontal middle axis.
     600           0 :             switch( aCtlPosition.GetActualRP() )
     601             :             {
     602             :                 case RP_LT:
     603             :                 case RP_RT:
     604           0 :                     aCtlPosition.SetActualRP( RP_MT );
     605           0 :                     break;
     606             : 
     607             :                 case RP_LM:
     608             :                 case RP_RM:
     609           0 :                     aCtlPosition.SetActualRP( RP_MM );
     610           0 :                     break;
     611             : 
     612             :                 case RP_LB:
     613             :                 case RP_RB:
     614           0 :                     aCtlPosition.SetActualRP( RP_MB );
     615           0 :                     break;
     616             :                 default: ;//prevent warning
     617             :             }
     618             :         }
     619             :         else
     620             :         {
     621             :             // Move text anchor to vertical middle axis.
     622           0 :             switch( aCtlPosition.GetActualRP() )
     623             :             {
     624             :                 case RP_LT:
     625             :                 case RP_LB:
     626           0 :                     aCtlPosition.SetActualRP( RP_LM );
     627           0 :                     break;
     628             : 
     629             :                 case RP_MT:
     630             :                 case RP_MB:
     631           0 :                     aCtlPosition.SetActualRP( RP_MM );
     632           0 :                     break;
     633             : 
     634             :                 case RP_RT:
     635             :                 case RP_RB:
     636           0 :                     aCtlPosition.SetActualRP( RP_RM );
     637           0 :                 break;
     638             :                 default: ;//prevent warning
     639             :             }
     640             :         }
     641             :     }
     642           0 :     return( 0L );
     643             : }
     644             : 
     645             : /*************************************************************************
     646             : |*
     647             : |* enables/disables "size at text" or "adjust to frame"
     648             : |*
     649             : \************************************************************************/
     650             : 
     651           0 : IMPL_LINK_NOARG(SvxTextAttrPage, ClickHdl_Impl)
     652             : {
     653           0 :     sal_Bool bAutoGrowWidth  = aTsbAutoGrowWidth.GetState() == STATE_CHECK;
     654           0 :     sal_Bool bAutoGrowHeight = aTsbAutoGrowHeight.GetState() == STATE_CHECK;
     655           0 :     sal_Bool bFitToSize      = aTsbFitToSize.GetState() == STATE_CHECK;
     656           0 :     sal_Bool bContour        = aTsbContour.GetState() == STATE_CHECK;
     657             : 
     658             :     aTsbContour.Enable( !bFitToSize &&
     659           0 :                         !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
     660           0 :                         bContourEnabled );
     661             : 
     662             :     aTsbAutoGrowWidth.Enable( !bFitToSize &&
     663           0 :                               !( bContour && bContourEnabled ) &&
     664           0 :                               bAutoGrowWidthEnabled );
     665             : 
     666             :     aTsbAutoGrowHeight.Enable( !bFitToSize &&
     667           0 :                                !( bContour && bContourEnabled ) &&
     668           0 :                                bAutoGrowHeightEnabled );
     669             : 
     670           0 :     aTsbFitToSize.Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
     671           0 :                           !( bContour && bContourEnabled ) &&
     672           0 :                           bFitToSizeEnabled );
     673             : 
     674             :     // #101901# enable/disable metric fields and decorations dependent of contour
     675           0 :     aMtrFldLeft.Enable(!bContour);
     676           0 :     aMtrFldRight.Enable(!bContour);
     677           0 :     aMtrFldTop.Enable(!bContour);
     678           0 :     aMtrFldBottom.Enable(!bContour);
     679           0 :     aFlDistance.Enable(!bContour);
     680           0 :     aFtLeft.Enable(!bContour);
     681           0 :     aFtRight.Enable(!bContour);
     682           0 :     aFtTop.Enable(!bContour);
     683           0 :     aFtBottom.Enable(!bContour);
     684             : 
     685           0 :     if( bContour && bContourEnabled )
     686             :     {
     687           0 :         aMtrFldLeft.SetValue( 0 );
     688           0 :         aMtrFldRight.SetValue( 0 );
     689           0 :         aMtrFldTop.SetValue( 0 );
     690           0 :         aMtrFldBottom.SetValue( 0 );
     691             :     }
     692             : 
     693             :     // #103516# Do the setup based on states of hor/ver adjust
     694           0 :     SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
     695           0 :     SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
     696           0 :     sal_Bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState);
     697             : 
     698             :     // #83698# enable/disable text anchoring dependent of contour
     699           0 :     aCtlPosition.Enable(!bContour && !bHorAndVer);
     700           0 :     aTsbFullWidth.Enable(!bContour && !bHorAndVer);
     701           0 :     aFlPosition.Enable(!bContour && !bHorAndVer);
     702             : 
     703           0 :     return( 0L );
     704             : }
     705             : 
     706             : 
     707           0 : bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const
     708             : {
     709             :     // Determine the text writing direction with left to right as default.
     710           0 :     bool bLeftToRightDirection = true;
     711           0 :     SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
     712             : 
     713           0 :     if(SFX_ITEM_DONTCARE != eState)
     714             :     {
     715             :         const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
     716           0 :             rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
     717           0 :         if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
     718           0 :             bLeftToRightDirection = false;
     719             :     }
     720           0 :     return bLeftToRightDirection;
     721             : }
     722             : 
     723           0 : void SvxTextAttrPage::PageCreated(SfxAllItemSet aSet)
     724             : {
     725           0 :     SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,sal_False);
     726             : 
     727           0 :     if (pViewItem)
     728           0 :         SetView( static_cast<SdrView *>(pViewItem->GetValue()));
     729             : 
     730           0 :     Construct();
     731           3 : }
     732             : 
     733             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10