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

Generated by: LCOV version 1.10