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

Generated by: LCOV version 1.10