LCOV - code coverage report
Current view: top level - svx/source/sidebar/paragraph - ParaLineSpacingControl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 424 0.0 %
Date: 2014-04-11 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : #include "ParaLineSpacingControl.hxx"
      19             : #include "ParaPropertyPanel.hrc"
      20             : #include <sfx2/sidebar/ResourceDefinitions.hrc>
      21             : #include <svx/dialogs.hrc>
      22             : #include <svx/dialmgr.hxx>
      23             : #include <unotools/viewoptions.hxx>
      24             : #include <editeng/kernitem.hxx>
      25             : #include <sfx2/bindings.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <sfx2/sidebar/Theme.hxx>
      28             : #include <svtools/unitconv.hxx>
      29             : #include <vcl/settings.hxx>
      30             : 
      31             : #define _DEFAULT_LINE_SPACING  200
      32             : #define FIX_DIST_DEF           283
      33             : #define LINESPACE_1            100
      34             : #define LINESPACE_15           150
      35             : #define LINESPACE_2            200
      36             : #define LINESPACE_115          115
      37             : 
      38             : #define LLINESPACE_1          0
      39             : #define LLINESPACE_15         1
      40             : #define LLINESPACE_2          2
      41             : #define LLINESPACE_PROP       3
      42             : #define LLINESPACE_MIN        4
      43             : #define LLINESPACE_DURCH      5
      44             : #define LLINESPACE_FIX        6
      45             : 
      46             : #define DO_NOT_CUSTOM          false
      47             : #define USE_CUSTOM             true
      48             : 
      49             : namespace svx { namespace sidebar {
      50             : 
      51             : 
      52           0 : ParaLineSpacingControl::ParaLineSpacingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel)
      53           0 :     : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_LINESPACING))
      54             :     , mbUseLineSPCustom             (false)
      55             :     , mbLineSPDisable               (false)
      56             :     , mrParaPropertyPanel(rPanel)
      57             :     , mpBindings(NULL)
      58             :     , nMinFixDist(BEGIN_VALUE)
      59             :     , pActLineDistFld(&aLineDistAtPercentBox)
      60           0 :     , maLineSpacing(ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) )
      61           0 :     , maCustomFT        ( this, SVX_RES( FT_CUSTOM ) )
      62           0 :     , maLSpacingFT      ( this, SVX_RES( FT_LINE_SPACING ) )
      63           0 :     , aLineDist( this, SVX_RES( LB_LINE_SPACING ))
      64           0 :     , maOfFT            ( this, SVX_RES( FT_OF ) )
      65           0 :     , aLineDistAtPercentBox   ( this, SVX_RES( ED_SBINDE_LINEDISTPERCENT ) )
      66           0 :     , aLineDistAtMetricBox    ( this, SVX_RES( ED_SBINDE_LINEDISTPOINT ) )
      67           0 :     , maSpacing1       (SVX_RES(IMG_SPACING1))
      68           0 :     , maSpacing115     (SVX_RES(IMG_SPACING115))
      69           0 :     , maSpacing15      (SVX_RES(IMG_SPACING15))
      70           0 :     , maSpacing2       (SVX_RES(IMG_SPACING2))
      71           0 :     , maSelSpacing1    (SVX_RES(IMG_SEL_SPACING1))
      72           0 :     , maSelSpacing115  (SVX_RES(IMG_SEL_SPACING115))
      73           0 :     , maSelSpacing15   (SVX_RES(IMG_SEL_SPACING15))
      74           0 :     , maSelSpacing2    (SVX_RES(IMG_SEL_SPACING2))
      75           0 :     , maImgCus         (SVX_RES(IMG_CUSTOM))
      76           0 :     , maImgCusGrey     (SVX_RES(IMG_CUSTOM_GRAY))
      77           0 :     , maStrCus         (SVX_RESSTR(STR_LCVALUE))
      78             :     , mpImg(NULL)
      79             :     , mpImgSel(NULL)
      80             :     , mpStr(NULL)
      81             :     , mpStrTip(NULL)
      82           0 :     , maLine(SVX_RESSTR(STR_LSPACING))
      83           0 :     , maOf(SVX_RESSTR(STR_LS_OF))
      84             :     , maValue( 0 )
      85           0 :     , maPos( 0 )
      86             : {
      87           0 :     initial();
      88           0 :     FreeResource();
      89           0 :     mpBindings = mrParaPropertyPanel.GetBindings();
      90             : //  m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric();
      91           0 :     m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM;
      92           0 : }
      93           0 : ParaLineSpacingControl::~ParaLineSpacingControl()
      94             : {
      95           0 :     delete[] mpImg;
      96           0 :     delete[] mpImgSel;
      97           0 :     delete[] mpStr;
      98           0 :     delete[] mpStrTip;
      99           0 : }
     100             : 
     101           0 : void ParaLineSpacingControl::initial()
     102             : {
     103           0 :     maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK |  WB_NO_DIRECTSELECT  );
     104             : 
     105             :     maLineSpacing.SetControlBackground(
     106           0 :         GetSettings().GetStyleSettings().GetHighContrastMode()
     107           0 :         ? GetSettings().GetStyleSettings().GetMenuColor()
     108           0 :         : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
     109             :     maLineSpacing.SetColor(
     110           0 :         GetSettings().GetStyleSettings().GetHighContrastMode()
     111           0 :         ? GetSettings().GetStyleSettings().GetMenuColor()
     112           0 :         : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
     113             :     maLineSpacing.SetBackground(
     114           0 :         GetSettings().GetStyleSettings().GetHighContrastMode()
     115           0 :         ? GetSettings().GetStyleSettings().GetMenuColor()
     116           0 :         : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
     117             : 
     118           0 :     mpImg = new Image[4];
     119           0 :     mpImg[0] = maSpacing1;
     120           0 :     mpImg[1] = maSpacing115;
     121           0 :     mpImg[2] = maSpacing15;
     122           0 :     mpImg[3] = maSpacing2;
     123             : 
     124           0 :     mpImgSel = new Image[4];
     125           0 :     mpImgSel[0] = maSelSpacing1;
     126           0 :     mpImgSel[1] = maSelSpacing115;
     127           0 :     mpImgSel[2] = maSelSpacing15;
     128           0 :     mpImgSel[3] = maSelSpacing2;
     129             : 
     130           0 :     mpStr = new OUString[4];
     131           0 :     mpStr[0] = SVX_RESSTR(STR_SPACING1);
     132           0 :     mpStr[1] = SVX_RESSTR(STR_SPACING115);
     133           0 :     mpStr[2] = SVX_RESSTR(STR_SPACING15);
     134           0 :     mpStr[3] = SVX_RESSTR(STR_SPACING2);
     135             : 
     136           0 :     mpStrTip = new OUString[4];
     137           0 :     mpStrTip[0] = SVX_RESSTR(STR_LS_SINGLE);
     138           0 :     mpStrTip[1] = SVX_RESSTR(STR_LS_115);
     139           0 :     mpStrTip[2] = SVX_RESSTR(STR_LS_15);
     140           0 :     mpStrTip[3] = SVX_RESSTR(STR_LS_DOUBLE);
     141           0 :     for (int i=0;i<4;i++)
     142           0 :         maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]);
     143             : 
     144           0 :     maLineSpacing.AddItem( maImgCus, 0, maStrCus, 0 );
     145             : 
     146           0 :     SetAllNoSel();
     147           0 :     Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl );
     148           0 :     maLineSpacing.SetSelectHdl(aLink);
     149           0 :     maLineSpacing.StartSelection();
     150           0 :     maLineSpacing.Show();
     151             : 
     152           0 :     aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl );
     153           0 :     aLineDist.SetSelectHdl(aLink);
     154           0 :     aLineDist.SelectEntryPos( LLINESPACE_1 ) ;
     155           0 :     aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl );
     156           0 :     aLineDistAtPercentBox.SetModifyHdl( aLink );
     157           0 :     aLineDistAtMetricBox.SetModifyHdl( aLink );
     158           0 : }
     159             : 
     160             : 
     161           0 : void ParaLineSpacingControl::PopupModeEndCallback()
     162             : {
     163           0 :     if( mbUseLineSPCustom )
     164             :     {
     165             :         //maLinePos = mpLineSPPage->maPos;
     166             :         //maLineValue = mpLineSPPage->maValue;
     167             : 
     168           0 :         SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
     169           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
     170           0 :         aSeq[0].Name = "maLinePos";
     171           0 :         aSeq[0].Value <<= ::rtl::OUString::number(maPos);
     172           0 :         aWinOpt.SetUserData( aSeq );
     173             : 
     174           0 :         SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
     175           0 :         aSeq[0].Name = "maLineValue";
     176           0 :         aSeq[0].Value <<= ::rtl::OUString::number(maValue);
     177           0 :         aWinOpt2.SetUserData( aSeq );
     178             :     }
     179           0 : }
     180             : 
     181           0 : void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext)
     182             : {
     183           0 :     SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
     184           0 :     if ( aWinOpt.Exists() )
     185             :     {
     186           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
     187           0 :         ::rtl::OUString aTmp;
     188           0 :         if ( aSeq.getLength())
     189           0 :             aSeq[0].Value >>= aTmp;
     190             : 
     191           0 :         OUString aWinData( aTmp );
     192           0 :         maPos = (sal_uInt16)aWinData.toInt32();
     193             :     }
     194             : 
     195           0 :     SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
     196           0 :     if ( aWinOpt2.Exists() )
     197             :     {
     198           0 :         ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
     199           0 :         ::rtl::OUString aTmp;
     200           0 :         if ( aSeq.getLength())
     201           0 :             aSeq[0].Value >>= aTmp;
     202             : 
     203           0 :         OUString aWinData( aTmp );
     204           0 :         maValue = (sal_uInt16)aWinData.toInt32();
     205             :     }
     206           0 :     OUString sHelpText;
     207           0 :     switch(maPos)
     208             :     {
     209             :         case LLINESPACE_1:
     210           0 :             sHelpText += mpStrTip[0];
     211           0 :             break;
     212             :         case LLINESPACE_15:
     213           0 :             sHelpText += mpStrTip[2];
     214           0 :             break;
     215             :         case LLINESPACE_2:
     216           0 :             sHelpText += mpStrTip[3];
     217           0 :             break;
     218             :         case LLINESPACE_PROP:
     219           0 :             sHelpText +=maLine;
     220           0 :             sHelpText += "Proportion: ";
     221           0 :             sHelpText += maOf;
     222           0 :             sHelpText += OUString::number( maValue );
     223           0 :             break;
     224             :         case LLINESPACE_MIN:
     225           0 :             sHelpText += maLine;
     226           0 :             sHelpText += "At Least: ";
     227           0 :             sHelpText += maOf;
     228           0 :             sHelpText += OUString::number( maValue );
     229           0 :             break;
     230             :         case LLINESPACE_DURCH:
     231           0 :             sHelpText += maLine;
     232           0 :             sHelpText += "Leading: ";
     233           0 :             sHelpText += maOf;
     234           0 :             sHelpText += OUString::number( maValue );
     235           0 :             break;
     236             :         case LLINESPACE_FIX:
     237           0 :             sHelpText += maLine;
     238           0 :             sHelpText += "Fixed: ";
     239           0 :             sHelpText += maOf;
     240           0 :             sHelpText += OUString::number( maValue );
     241           0 :             break;
     242             :     }
     243           0 :     if( !aWinOpt.Exists() && !aWinOpt2.Exists() )
     244           0 :         mbLineSPDisable = true;
     245             :     else
     246           0 :         mbLineSPDisable = false;
     247             : 
     248           0 :     if( mbLineSPDisable )
     249           0 :         maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0);
     250             :     else
     251             :     {
     252           0 :         maLineSpacing.ReplaceItemImages(5, maImgCus,0);
     253           0 :         maLineSpacing.SetItemText(5,sHelpText);
     254             :     }
     255             : 
     256           0 :     SfxItemState eState = currSPState;
     257             : 
     258           0 :     SetFieldUnit( aLineDistAtMetricBox, currMetricUnit );
     259             : 
     260             : //  mpLineSPPage->SetAllNoSel();
     261           0 :     aLineDist.Enable();
     262           0 :     pActLineDistFld->Enable();
     263           0 :     pActLineDistFld->SetText( "" );
     264             :     //bool bValueSetFocus = sal_False;        //wj
     265             : 
     266           0 :     if( eState >= SFX_ITEM_AVAILABLE )
     267             :     {
     268             :     //  SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric();
     269           0 :         SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM;
     270           0 :         m_eLNSpaceUnit = eUnit;
     271             : 
     272           0 :         switch( currSPItem->GetLineSpaceRule() )
     273             :         {
     274             :         case SVX_LINE_SPACE_AUTO:
     275             :             {
     276           0 :                 SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule();
     277             : 
     278           0 :                 switch( eInter )
     279             :                 {
     280             :                 case SVX_INTER_LINE_SPACE_OFF:
     281             :                     {
     282           0 :                         aLineDist.SelectEntryPos( LLINESPACE_1 );
     283           0 :                         pActLineDistFld->Disable();
     284           0 :                         pActLineDistFld->SetText( "" );
     285           0 :                         mbUseLineSPCustom = DO_NOT_CUSTOM;
     286           0 :                         if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
     287             :                         {
     288           0 :                             maLineSpacing.SelectItem(1);
     289             :                             //bValueSetFocus = sal_True;  //wj
     290             :                         }
     291             :                     }
     292           0 :                     break;
     293             : 
     294             :                 case SVX_INTER_LINE_SPACE_PROP:
     295             :                     {
     296           0 :                         if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
     297             :                         {
     298           0 :                             aLineDist.SelectEntryPos( LLINESPACE_1 );
     299           0 :                             pActLineDistFld->Disable();
     300           0 :                             pActLineDistFld->SetText( "" );
     301           0 :                             mbUseLineSPCustom = DO_NOT_CUSTOM;
     302           0 :                             maLineSpacing.SelectItem(1);
     303             :                             //bValueSetFocus = sal_True;  //wj
     304           0 :                             break;
     305             :                         }
     306           0 :                         if ( LINESPACE_15 == currSPItem->GetPropLineSpace() )
     307             :                         {
     308           0 :                             aLineDist.SelectEntryPos( LLINESPACE_15 );
     309           0 :                             pActLineDistFld->Disable();
     310           0 :                             pActLineDistFld->SetText( "" );
     311             : 
     312           0 :                             mbUseLineSPCustom = DO_NOT_CUSTOM;
     313           0 :                             maLineSpacing.SelectItem(3);
     314             :                             //bValueSetFocus = sal_True;  //wj
     315           0 :                             break;
     316             :                         }
     317           0 :                         if ( LINESPACE_2 == currSPItem->GetPropLineSpace() )
     318             :                         {
     319           0 :                             aLineDist.SelectEntryPos( LLINESPACE_2 );
     320           0 :                             pActLineDistFld->Disable();
     321           0 :                             pActLineDistFld->SetText( "" );
     322             : 
     323           0 :                             mbUseLineSPCustom = DO_NOT_CUSTOM;
     324           0 :                             maLineSpacing.SelectItem(4);
     325             :                             //bValueSetFocus = sal_True;  //wj
     326           0 :                             break;
     327             :                         }
     328             : 
     329           0 :                         aLineDist.SelectEntryPos( LLINESPACE_PROP );
     330           0 :                         if(pActLineDistFld != &(aLineDistAtPercentBox))
     331             :                         {
     332           0 :                             pActLineDistFld->Disable();
     333           0 :                             pActLineDistFld->Hide();
     334           0 :                             pActLineDistFld = &(aLineDistAtPercentBox);
     335             :                         }
     336             :                         else
     337             :                         {
     338           0 :                             pActLineDistFld = &(aLineDistAtMetricBox);
     339           0 :                             pActLineDistFld->Disable();
     340           0 :                             pActLineDistFld->Hide();
     341           0 :                             pActLineDistFld = &(aLineDistAtPercentBox);
     342             :                         }
     343           0 :                         pActLineDistFld->Enable();
     344           0 :                         pActLineDistFld->Show();
     345             :                         aLineDistAtPercentBox.
     346             :                             SetValue( aLineDistAtPercentBox.Normalize(
     347           0 :                             currSPItem->GetPropLineSpace() ) );
     348             : 
     349           0 :                         if( currSPItem->GetPropLineSpace() == LINESPACE_115 )
     350             :                         {
     351           0 :                             mbUseLineSPCustom = DO_NOT_CUSTOM;
     352           0 :                             maLineSpacing.SelectItem(2);
     353             :                             //bValueSetFocus = sal_True;  //wj
     354             :                         }
     355             :                         else
     356             :                         {
     357           0 :                             mbUseLineSPCustom = USE_CUSTOM;
     358           0 :                             maLineSpacing.SetNoSelection();
     359           0 :                                                  maLineSpacing.SelectItem(0);
     360             :                         }
     361             :                     }
     362           0 :                     break;
     363             : 
     364             :                 case SVX_INTER_LINE_SPACE_FIX:
     365             :                     {
     366           0 :                         if(pActLineDistFld != &(aLineDistAtMetricBox))
     367             :                         {
     368           0 :                             pActLineDistFld->Disable();
     369           0 :                             pActLineDistFld->Hide();
     370           0 :                             pActLineDistFld = &(aLineDistAtMetricBox);
     371             :                         }
     372             :                         else
     373             :                         {
     374           0 :                             pActLineDistFld = &(aLineDistAtPercentBox);
     375           0 :                             pActLineDistFld->Disable();
     376           0 :                             pActLineDistFld->Hide();
     377           0 :                             pActLineDistFld = &(aLineDistAtMetricBox);
     378             :                         }
     379           0 :                         pActLineDistFld->Enable();
     380           0 :                         pActLineDistFld->Show();
     381           0 :                         maLineSpacing.SetNoSelection();
     382           0 :                                           maLineSpacing.SelectItem(0);
     383             : 
     384             :                         SetMetricValue( aLineDistAtMetricBox,
     385           0 :                             currSPItem->GetInterLineSpace(), eUnit );
     386           0 :                         aLineDist.SelectEntryPos( LLINESPACE_DURCH );
     387             : 
     388           0 :                         mbUseLineSPCustom = USE_CUSTOM;
     389             :                     }
     390           0 :                     break;
     391             :                 default:
     392           0 :                     break;
     393             :                 }
     394             :             }
     395           0 :             break;
     396             :         case SVX_LINE_SPACE_FIX:
     397             :             {
     398           0 :                 if(pActLineDistFld != &(aLineDistAtMetricBox))
     399             :                 {
     400           0 :                     pActLineDistFld->Disable();
     401           0 :                     pActLineDistFld->Hide();
     402           0 :                     pActLineDistFld = &(aLineDistAtMetricBox);
     403             :                 }
     404             :                 else
     405             :                 {
     406           0 :                     pActLineDistFld = &(aLineDistAtPercentBox);
     407           0 :                     pActLineDistFld->Disable();
     408           0 :                     pActLineDistFld->Hide();
     409           0 :                     pActLineDistFld = &(aLineDistAtMetricBox);
     410             :                 }
     411           0 :                 pActLineDistFld->Enable();
     412           0 :                 pActLineDistFld->Show();
     413           0 :                 maLineSpacing.SetNoSelection();
     414           0 :                             maLineSpacing.SelectItem(0);
     415             : 
     416           0 :                 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
     417           0 :                 aLineDist.SelectEntryPos( LLINESPACE_FIX );
     418             : 
     419           0 :                 mbUseLineSPCustom = USE_CUSTOM;
     420             :             }
     421           0 :             break;
     422             : 
     423             :         case SVX_LINE_SPACE_MIN:
     424             :             {
     425           0 :                 if(pActLineDistFld != &(aLineDistAtMetricBox))
     426             :                 {
     427           0 :                     pActLineDistFld->Disable();
     428           0 :                     pActLineDistFld->Hide();
     429           0 :                     pActLineDistFld = &(aLineDistAtMetricBox);
     430             :                 }
     431             :                 else
     432             :                 {
     433           0 :                     pActLineDistFld = &(aLineDistAtPercentBox);
     434           0 :                     pActLineDistFld->Disable();
     435           0 :                     pActLineDistFld->Hide();
     436           0 :                     pActLineDistFld = &(aLineDistAtMetricBox);
     437             :                 }
     438           0 :                 pActLineDistFld->Enable();
     439           0 :                 pActLineDistFld->Show();
     440           0 :                 maLineSpacing.SetNoSelection();
     441           0 :                             maLineSpacing.SelectItem(0);
     442             : 
     443           0 :                 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
     444           0 :                 aLineDist.SelectEntryPos( LLINESPACE_MIN );
     445           0 :                 mbUseLineSPCustom = USE_CUSTOM;
     446             :             }
     447           0 :             break;
     448             :         default:
     449           0 :             break;
     450             :         }
     451             :     }
     452           0 :     else if( eState == SFX_ITEM_DISABLED )
     453             :     {
     454           0 :         aLineDist.Disable();
     455           0 :         pActLineDistFld->Enable(false);
     456           0 :         pActLineDistFld->SetText( "" );
     457           0 :         maLineSpacing.SetNoSelection();
     458           0 :               maLineSpacing.SelectItem(0);
     459             : 
     460           0 :         mbUseLineSPCustom = DO_NOT_CUSTOM;
     461             :     }
     462             :     else
     463             :     {
     464           0 :         pActLineDistFld->Enable(false);
     465           0 :         pActLineDistFld->SetText( "" );
     466           0 :         aLineDist.SetNoSelection();
     467           0 :         maLineSpacing.SetNoSelection();
     468           0 :               maLineSpacing.SelectItem(0);
     469           0 :         mbUseLineSPCustom = DO_NOT_CUSTOM;
     470             :     }
     471             : 
     472           0 :     aLineDist.SaveValue();
     473             : 
     474           0 :     const sal_uInt16 uCount = aLineDist.GetEntryCount();
     475           0 :     if( uCount == LLINESPACE_FIX + 1 )
     476             :     {
     477           0 :         switch (currentContext.GetCombinedContext_DI())
     478             :         {
     479             :         case CombinedEnumContext(Application_DrawImpress, Context_Table):
     480             :         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
     481             :         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
     482             :         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
     483             :         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
     484             :         case CombinedEnumContext(Application_Calc, Context_DrawText):
     485             :         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
     486             :         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
     487             :             {
     488           0 :                 aLineDist.RemoveEntry(LLINESPACE_FIX);
     489             :             }
     490             :         }
     491             :     }
     492           0 :     else if( uCount == LLINESPACE_FIX)
     493             :     {
     494           0 :         switch (currentContext.GetCombinedContext_DI())
     495             :         {
     496             :             case CombinedEnumContext(Application_WriterVariants, Context_Default):
     497             :             case CombinedEnumContext(Application_WriterVariants, Context_Text):
     498             :             case CombinedEnumContext(Application_WriterVariants, Context_Table):
     499             :             {
     500           0 :                 aLineDist.InsertEntry(OUString("Fixed"), LLINESPACE_FIX);
     501             :             }
     502             :         }
     503             :     }
     504           0 :     maLineSpacing.Format();
     505           0 :     maLineSpacing.StartSelection();
     506           0 : }
     507             : 
     508           0 : void ParaLineSpacingControl::SetAllNoSel()
     509             : {
     510           0 :     maLineSpacing.SelectItem(1);
     511           0 :     maLineSpacing.SetNoSelection();
     512           0 : }
     513             : 
     514           0 : IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox )
     515             : {
     516           0 :     maLineSpacing.SetNoSelection();
     517           0 :        maLineSpacing.SelectItem(0);
     518           0 :     maLineSpacing.Format();
     519           0 :     maLineSpacing.StartSelection();
     520             : 
     521           0 :     switch( pBox->GetSelectEntryPos() )
     522             :     {
     523             :         case LLINESPACE_1:
     524             :         case LLINESPACE_15:
     525             :         case LLINESPACE_2:
     526           0 :             pActLineDistFld->Enable(false);
     527           0 :             pActLineDistFld->SetText( "" );
     528           0 :             break;
     529             : 
     530             :         case LLINESPACE_DURCH:
     531           0 :             aLineDistAtPercentBox.Hide();
     532           0 :             pActLineDistFld = &aLineDistAtMetricBox;
     533           0 :             aLineDistAtMetricBox.SetMin(0);
     534             : 
     535             : 
     536           0 :             if ( aLineDistAtMetricBox.GetText().isEmpty() )
     537             :                 aLineDistAtMetricBox.SetValue(
     538           0 :                     aLineDistAtMetricBox.Normalize( 0 ) );
     539           0 :             aLineDistAtPercentBox.Hide();
     540           0 :             pActLineDistFld->Show();
     541           0 :             pActLineDistFld->Enable();
     542           0 :             break;
     543             : 
     544             :         case LLINESPACE_MIN:
     545           0 :             aLineDistAtPercentBox.Hide();
     546           0 :             pActLineDistFld = &aLineDistAtMetricBox;
     547           0 :             aLineDistAtMetricBox.SetMin(0);
     548             : 
     549           0 :             if ( aLineDistAtMetricBox.GetText().isEmpty() )
     550             :                 aLineDistAtMetricBox.SetValue(
     551           0 :                     aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP );
     552           0 :             aLineDistAtPercentBox.Hide();
     553           0 :             pActLineDistFld->Show();
     554           0 :             pActLineDistFld->Enable();
     555           0 :             break;
     556             : 
     557             :         case LLINESPACE_PROP:
     558           0 :             aLineDistAtMetricBox.Hide();
     559           0 :             pActLineDistFld = &aLineDistAtPercentBox;
     560             : 
     561           0 :             if ( aLineDistAtPercentBox.GetText().isEmpty() )
     562             :                 aLineDistAtPercentBox.SetValue(
     563           0 :                     aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP );
     564           0 :             aLineDistAtMetricBox.Hide();
     565           0 :             pActLineDistFld->Show();
     566           0 :             pActLineDistFld->Enable();
     567           0 :             break;
     568             :         case LLINESPACE_FIX:
     569             :         {
     570           0 :             aLineDistAtPercentBox.Hide();
     571           0 :             pActLineDistFld = &aLineDistAtMetricBox;
     572           0 :             sal_Int64 nTemp = aLineDistAtMetricBox.GetValue();
     573           0 :             aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP);
     574             : 
     575           0 :             if ( aLineDistAtMetricBox.GetValue() != nTemp )
     576             :                 SetMetricValue( aLineDistAtMetricBox,
     577           0 :                                     FIX_DIST_DEF, SFX_MAPUNIT_TWIP );
     578           0 :             aLineDistAtPercentBox.Hide();
     579           0 :             pActLineDistFld->Show();
     580           0 :             pActLineDistFld->Enable();
     581             :         }
     582           0 :         break;
     583             :     }
     584           0 :     ExecuteLineSpace();
     585           0 :     return 0;
     586             : }
     587             : 
     588           0 : IMPL_LINK_NOARG( ParaLineSpacingControl, LineSPDistAtHdl_Impl )
     589             : {
     590           0 :     ExecuteLineSpace();
     591           0 :     return (0L);
     592             : }
     593             : 
     594           0 : void ParaLineSpacingControl::ExecuteLineSpace()
     595             : {
     596           0 :     aLineDist.SaveValue();
     597           0 :     maLineSpacing.SetNoSelection();
     598             : 
     599           0 :     SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
     600           0 :     sal_uInt16 nPos = aLineDist.GetSelectEntryPos();
     601             : 
     602           0 :     switch ( nPos )
     603             :     {
     604             :         case LLINESPACE_1:
     605             :         case LLINESPACE_15:
     606             :         case LLINESPACE_2:
     607             :             {
     608           0 :                 SetLineSpace( aSpacing, nPos );
     609           0 :                 maPos = nPos;
     610             :             }
     611           0 :             break;
     612             : 
     613             :         case LLINESPACE_PROP:
     614             :             {
     615             :                 SetLineSpace( aSpacing, nPos,
     616             :                     aLineDistAtPercentBox.Denormalize(
     617           0 :                     (long)aLineDistAtPercentBox.GetValue() ) );
     618           0 :                 maPos = nPos;
     619           0 :                 maValue =aLineDistAtPercentBox.GetValue();
     620             :             }
     621           0 :             break;
     622             : 
     623             :         case LLINESPACE_MIN:
     624             :         case LLINESPACE_DURCH:
     625             :         case LLINESPACE_FIX:
     626             :             {
     627             :                 SetLineSpace( aSpacing, nPos,
     628           0 :                     GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) );
     629           0 :                 maPos = nPos;
     630           0 :                 maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit );
     631             :             }
     632           0 :         break;
     633             : 
     634             :         default:
     635             :             OSL_ENSURE(false, "error!!");
     636           0 :             break;
     637             :     }
     638             : 
     639             :     mpBindings->GetDispatcher()->Execute(
     640           0 :             SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
     641             : 
     642           0 :     mbUseLineSPCustom = USE_CUSTOM;
     643           0 : }
     644             : 
     645           0 : void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace,
     646             :                         int eSpace, long lValue )
     647             : {
     648           0 :     switch ( eSpace )
     649             :     {
     650             :         case LLINESPACE_1:
     651           0 :             rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     652           0 :             rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
     653           0 :             break;
     654             : 
     655             :         case LLINESPACE_15:
     656           0 :             rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     657           0 :             rLineSpace.SetPropLineSpace( LINESPACE_15 );
     658           0 :             break;
     659             : 
     660             :         case LLINESPACE_2:
     661           0 :             rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     662           0 :             rLineSpace.SetPropLineSpace( LINESPACE_2 );
     663           0 :             break;
     664             : 
     665             :         case LLINESPACE_PROP:
     666           0 :             rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     667           0 :             rLineSpace.SetPropLineSpace( (sal_uInt8)lValue );
     668           0 :             break;
     669             : 
     670             :         case LLINESPACE_MIN:
     671           0 :             rLineSpace.SetLineHeight( (sal_uInt16)lValue );
     672           0 :             rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
     673           0 :             break;
     674             : 
     675             :         case LLINESPACE_DURCH:
     676           0 :             rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     677           0 :             rLineSpace.SetInterLineSpace( (sal_uInt16)lValue );
     678           0 :             break;
     679             : 
     680             :         case LLINESPACE_FIX:
     681           0 :             rLineSpace.SetLineHeight((sal_uInt16)lValue);
     682           0 :             rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
     683           0 :             rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
     684           0 :         break;
     685             :     }
     686           0 : }
     687             : 
     688           0 : IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl)
     689             : {
     690           0 :     maLineSpacing.SetNoSelection();
     691           0 :     bool bClosePop = true;
     692           0 :     if(pControl == &maLineSpacing)
     693             :     {
     694           0 :         sal_uInt16 iPos = maLineSpacing.GetSelectItemId();
     695           0 :         switch ( iPos )
     696             :         {
     697             :             case 1:
     698           0 :                 ExecuteLineSpacing( false, 0 );
     699           0 :                 break;
     700             :             case 2:
     701           0 :                 ExecuteLineSpacing( false, 3 );
     702           0 :                 break;
     703             :             case 3:
     704           0 :                 ExecuteLineSpacing( false, 1 );
     705           0 :                 break;
     706             :             case 4:
     707           0 :                 ExecuteLineSpacing( false, 2 );
     708           0 :                 break;
     709             :             case 5:
     710             :                 {
     711           0 :                     if(!(mbLineSPDisable))
     712             :                     {
     713             :                         //maPos = mrParaPropertyPanel.maLinePos;
     714           0 :                         aLineDist.SelectEntryPos( maPos ) ;
     715           0 :                         aLineDist.SaveValue();
     716             :                         //maValue = mrParaPropertyPanel.maLineValue;
     717             : 
     718           0 :                         SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
     719           0 :                         switch(maPos)
     720             :                         {
     721             :                         case LLINESPACE_1:
     722             :                         case LLINESPACE_15:
     723             :                         case LLINESPACE_2:
     724           0 :                             SetLineSpace( aSpacing, maPos );
     725           0 :                             break;
     726             : 
     727             :                         case LLINESPACE_PROP:
     728             :                             SetLineSpace( aSpacing, maPos,
     729           0 :                                 aLineDistAtPercentBox.Denormalize( (long)maValue ) );
     730           0 :                             break;
     731             : 
     732             :                         case LLINESPACE_MIN:
     733             :                         case LLINESPACE_DURCH:
     734             :                         case LLINESPACE_FIX:
     735           0 :                             SetLineSpace( aSpacing, maPos, (long)maValue );
     736           0 :                             break;
     737             :                         }
     738             : 
     739             :                         mpBindings->GetDispatcher()->Execute(
     740           0 :                             SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
     741             : 
     742           0 :                         ExecuteLineSpacing( USE_CUSTOM, 0 );
     743             :                     }
     744             :                     else
     745           0 :                         bClosePop = false;
     746             :                 }
     747           0 :                 break;
     748             :         }
     749             :     }
     750           0 :     if(bClosePop)
     751           0 :         mrParaPropertyPanel.EndSpacingPopupMode();
     752           0 :     return 0;
     753             : }
     754             : 
     755           0 : void ParaLineSpacingControl::ExecuteLineSpacing( bool aIsCustom, sal_uInt16 aEntry )
     756             : {
     757           0 :     if( !aIsCustom )
     758             :     {
     759           0 :         aLineDist.SelectEntryPos( aEntry ) ;
     760           0 :         aLineDist.SaveValue();
     761           0 :         SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
     762           0 :         sal_uInt16 nPos = aEntry;
     763           0 :         if( aEntry == LLINESPACE_PROP )
     764           0 :             SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) );
     765             :         else
     766           0 :             SetLineSpace( aSpacing, nPos );
     767             : 
     768             :         mpBindings->GetDispatcher()->Execute(
     769           0 :             SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
     770             :     }
     771             : 
     772           0 :     if( !aIsCustom )
     773             :     {
     774           0 :         mbUseLineSPCustom = DO_NOT_CUSTOM;
     775           0 :         mrParaPropertyPanel.EndSpacingPopupMode();
     776             :     }
     777           0 :     maLineSpacing.SetNoSelection();
     778           0 : }
     779             : 
     780             : }} // end of namespace sidebar
     781             : 

Generated by: LCOV version 1.10