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

Generated by: LCOV version 1.11