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

Generated by: LCOV version 1.10