LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/misc - pggrid.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 310 0.0 %
Date: 2013-07-09 Functions: 0 24 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             : 
      22             : #include <cmdid.h>
      23             : #include <hintids.hxx>
      24             : #include <swtypes.hxx>
      25             : #include <globals.hrc>
      26             : #include <svx/xtable.hxx>
      27             : #include <uitool.hxx>
      28             : #include <editeng/sizeitem.hxx>
      29             : #include <editeng/lrspitem.hxx>
      30             : #include <editeng/ulspitem.hxx>
      31             : #include <editeng/boxitem.hxx>
      32             : #include <editeng/frmdiritem.hxx>
      33             : #include <svx/ruler.hxx>
      34             : #include <pggrid.hxx>
      35             : #include <tgrditem.hxx>
      36             : 
      37             : #include "wrtsh.hxx"
      38             : #include "doc.hxx"
      39             : #include "uiitems.hxx"
      40             : #include "swmodule.hxx"
      41             : #include "view.hxx"
      42             : 
      43           0 : SwTextGridPage::SwTextGridPage(Window *pParent, const SfxItemSet &rSet) :
      44             :     SfxTabPage(pParent, "TextGridPage", "modules/swriter/ui/textgridpage.ui", rSet),
      45             :     m_nRubyUserValue(0),
      46             :     m_bRubyUserValue(sal_False),
      47             :     m_aPageSize(MM50, MM50),
      48             :     m_bVertical(false),
      49             :     m_bSquaredMode(sal_False),
      50             :     m_bHRulerChanged( sal_False ),
      51           0 :     m_bVRulerChanged( sal_False )
      52             : {
      53           0 :     get(m_pNoGridRB,"radioRB_NOGRID");
      54           0 :     get(m_pLinesGridRB,"radioRB_LINESGRID");
      55           0 :     get(m_pCharsGridRB,"radioRB_CHARSGRID");
      56           0 :     get(m_pSnapToCharsCB,"checkCB_SNAPTOCHARS");
      57             : 
      58           0 :     get(m_pExampleWN,"drawingareaWN_EXAMPLE");
      59           0 :     get(m_pLayoutFL,"frameFL_LAYOUT");
      60             : 
      61           0 :     get(m_pLinesPerPageNF,"spinNF_LINESPERPAGE");
      62           0 :     get(m_pLinesRangeFT,"labelFT_LINERANGE");
      63             : 
      64           0 :     get(m_pTextSizeMF,"spinMF_TEXTSIZE");
      65           0 :     get(m_pCharsPerLineFT,"labelFT_CHARSPERLINE");
      66           0 :     get(m_pCharsPerLineNF,"spinNF_CHARSPERLINE");
      67           0 :     get(m_pCharsRangeFT,"labelFT_CHARRANGE");
      68           0 :     get(m_pCharWidthFT,"labelFT_CHARWIDTH");
      69           0 :     get(m_pCharWidthMF,"spinMF_CHARWIDTH");
      70           0 :     get(m_pRubySizeFT,"labelFT_RUBYSIZE");
      71           0 :     get(m_pRubySizeMF,"spinMF_RUBYSIZE");
      72           0 :     get(m_pRubyBelowCB,"checkCB_RUBYBELOW");
      73             : 
      74           0 :     get(m_pDisplayFL,"frameFL_DISPLAY");
      75           0 :     get(m_pDisplayCB,"checkCB_DISPLAY");
      76           0 :     get(m_pPrintCB,"checkCB_PRINT");
      77           0 :     get(m_pColorLB,"listLB_COLOR");
      78             : 
      79           0 :     Link aLink = LINK(this, SwTextGridPage, CharorLineChangedHdl);
      80           0 :     m_pCharsPerLineNF->SetUpHdl(aLink);
      81           0 :     m_pCharsPerLineNF->SetDownHdl(aLink);
      82           0 :     m_pCharsPerLineNF->SetLoseFocusHdl(aLink);
      83           0 :     m_pLinesPerPageNF->SetUpHdl(aLink);
      84           0 :     m_pLinesPerPageNF->SetDownHdl(aLink);
      85           0 :     m_pLinesPerPageNF->SetLoseFocusHdl(aLink);
      86             : 
      87           0 :     Link aSizeLink = LINK(this, SwTextGridPage, TextSizeChangedHdl);
      88           0 :     m_pTextSizeMF->SetUpHdl(aSizeLink);
      89           0 :     m_pTextSizeMF->SetDownHdl(aSizeLink);
      90           0 :     m_pTextSizeMF->SetLoseFocusHdl(aSizeLink);
      91           0 :     m_pRubySizeMF->SetUpHdl(aSizeLink);
      92           0 :     m_pRubySizeMF->SetDownHdl(aSizeLink);
      93           0 :     m_pRubySizeMF->SetLoseFocusHdl(aSizeLink);
      94           0 :     m_pCharWidthMF->SetUpHdl(aSizeLink);
      95           0 :     m_pCharWidthMF->SetDownHdl(aSizeLink);
      96           0 :     m_pCharWidthMF->SetLoseFocusHdl(aSizeLink);
      97             : 
      98           0 :     Link aGridTypeHdl = LINK(this, SwTextGridPage, GridTypeHdl);
      99           0 :     m_pNoGridRB->SetClickHdl(aGridTypeHdl);
     100           0 :     m_pLinesGridRB->SetClickHdl(aGridTypeHdl);
     101           0 :     m_pCharsGridRB->SetClickHdl(aGridTypeHdl);
     102             : 
     103           0 :     Link aModifyLk = LINK(this, SwTextGridPage, GridModifyHdl);
     104           0 :     m_pColorLB->SetSelectHdl(aModifyLk);
     105           0 :     m_pPrintCB->SetClickHdl(aModifyLk);
     106           0 :     m_pRubyBelowCB->SetClickHdl(aModifyLk);
     107             : 
     108           0 :     m_pDisplayCB->SetClickHdl(LINK(this, SwTextGridPage, DisplayGridHdl));
     109             : 
     110           0 :     XColorListRef pColorLst = XColorList::GetStdColorList();
     111           0 :     m_pColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
     112           0 :     for( sal_uInt16 i = 0; i < pColorLst->Count(); ++i )
     113             :     {
     114           0 :         XColorEntry* pEntry = pColorLst->GetColor( i );
     115           0 :         Color aColor = pEntry->GetColor();
     116           0 :         String sName = pEntry->GetName();
     117           0 :         m_pColorLB->InsertEntry( aColor, sName );
     118           0 :     }
     119           0 :     m_pColorLB->SetUpdateMode( sal_True );
     120             :     //Get the default paper mode
     121           0 :     SwView *pView   = ::GetActiveView();
     122           0 :     if( pView )
     123             :     {
     124           0 :         SwWrtShell* pSh = pView->GetWrtShellPtr();
     125           0 :         if( pSh )
     126             :         {
     127           0 :             m_bSquaredMode = pSh->GetDoc()->IsSquaredPageMode();
     128             :         }
     129             :     }
     130           0 :     if( m_bSquaredMode )
     131             :     {
     132             : 
     133           0 :         m_pRubySizeFT->Show();
     134           0 :         m_pRubySizeMF->Show();
     135           0 :         m_pRubyBelowCB->Show();
     136           0 :         m_pSnapToCharsCB->Hide();
     137           0 :         m_pCharWidthFT->Hide();
     138           0 :         m_pCharWidthMF->Hide();
     139             :     }
     140             :     else
     141             :     {
     142           0 :         m_pRubySizeFT->Hide();
     143           0 :         m_pRubySizeMF->Hide();
     144           0 :         m_pRubyBelowCB->Hide();
     145           0 :         m_pSnapToCharsCB->Show();
     146           0 :         m_pCharWidthFT->Show();
     147           0 :         m_pCharWidthMF->Show();
     148           0 :     }
     149           0 : }
     150             : 
     151           0 : SwTextGridPage::~SwTextGridPage()
     152             : {
     153           0 : }
     154             : 
     155           0 : SfxTabPage *SwTextGridPage::Create(Window *pParent, const SfxItemSet &rSet)
     156             : {
     157           0 :     return new SwTextGridPage(pParent, rSet);
     158             : }
     159             : 
     160           0 : sal_Bool    SwTextGridPage::FillItemSet(SfxItemSet &rSet)
     161             : {
     162           0 :     sal_Bool bRet = sal_False;
     163           0 :     if(m_pNoGridRB->GetSavedValue() != m_pNoGridRB->IsChecked()||
     164           0 :         m_pLinesGridRB->GetSavedValue() != m_pLinesGridRB->IsChecked()||
     165           0 :         m_pLinesPerPageNF->GetSavedValue().toInt32()
     166           0 :            != m_pLinesPerPageNF->GetValue()||
     167           0 :         m_pTextSizeMF->GetSavedValue().toInt32() != m_pTextSizeMF->GetValue()||
     168           0 :         m_pCharsPerLineNF->GetSavedValue().toInt32()
     169           0 :            != m_pCharsPerLineNF->GetValue()||
     170           0 :         m_pSnapToCharsCB->GetSavedValue() != m_pSnapToCharsCB->IsChecked() ||
     171           0 :         m_pRubySizeMF->GetSavedValue().toInt32() != m_pRubySizeMF->GetValue()||
     172           0 :         m_pCharWidthMF->GetSavedValue().toInt32() != m_pCharWidthMF->GetValue()||
     173           0 :         m_pRubyBelowCB->GetSavedValue() != m_pRubyBelowCB->IsChecked()||
     174           0 :         m_pDisplayCB->GetSavedValue() != m_pDisplayCB->IsChecked()||
     175           0 :         m_pPrintCB->GetSavedValue() != m_pPrintCB->IsChecked()||
     176           0 :         m_pColorLB->GetSavedValue() != m_pColorLB->GetSelectEntryPos())
     177             :     {
     178           0 :         PutGridItem(rSet);
     179           0 :         bRet = sal_True;
     180             :     }
     181             : 
     182             :     // draw ticks of ruler
     183           0 :     SwView * pView = ::GetActiveView();
     184           0 :     if ( m_bHRulerChanged )
     185           0 :         pView->GetHRuler().DrawTicks();
     186           0 :     if ( m_bVRulerChanged )
     187           0 :         pView->GetVRuler().DrawTicks();
     188           0 :     return bRet;
     189             : }
     190             : 
     191           0 : void    SwTextGridPage::Reset(const SfxItemSet &rSet)
     192             : {
     193           0 :     if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, sal_True))
     194             :     {
     195           0 :         const SwTextGridItem& rGridItem = (const SwTextGridItem&)rSet.Get(RES_TEXTGRID);
     196           0 :         RadioButton* pButton = 0;
     197           0 :         switch(rGridItem.GetGridType())
     198             :         {
     199           0 :             case GRID_NONE :        pButton = m_pNoGridRB;    break;
     200           0 :             case GRID_LINES_ONLY  : pButton = m_pLinesGridRB; break;
     201           0 :             default:                pButton = m_pCharsGridRB;
     202             :         }
     203           0 :         pButton->Check();
     204           0 :         m_pDisplayCB->Check(rGridItem.IsDisplayGrid());
     205           0 :         GridTypeHdl(pButton);
     206           0 :         m_pSnapToCharsCB->Check(rGridItem.IsSnapToChars());
     207           0 :         m_pLinesPerPageNF->SetValue(rGridItem.GetLines());
     208           0 :         SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     209           0 :         m_nRubyUserValue = rGridItem.GetBaseHeight();
     210           0 :         m_bRubyUserValue = sal_True;
     211           0 :         m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(m_nRubyUserValue), FUNIT_TWIP);
     212           0 :         m_pRubySizeMF->SetValue(m_pRubySizeMF->Normalize(rGridItem.GetRubyHeight()), FUNIT_TWIP);
     213           0 :         m_pCharWidthMF->SetValue(m_pCharWidthMF->Normalize(rGridItem.GetBaseWidth()), FUNIT_TWIP);
     214           0 :         m_pRubyBelowCB->Check(rGridItem.IsRubyTextBelow());
     215           0 :         m_pPrintCB->Check(rGridItem.IsPrintGrid());
     216           0 :         m_pColorLB->SelectEntry(rGridItem.GetColor());
     217             :     }
     218           0 :     UpdatePageSize(rSet);
     219             : 
     220           0 :     m_pNoGridRB->SaveValue();
     221           0 :     m_pLinesGridRB->SaveValue();
     222           0 :     m_pSnapToCharsCB->SaveValue();
     223           0 :     m_pLinesPerPageNF->SaveValue();
     224           0 :     m_pTextSizeMF->SaveValue();
     225           0 :     m_pCharsPerLineNF->SaveValue();
     226           0 :     m_pRubySizeMF->SaveValue();
     227           0 :     m_pCharWidthMF->SaveValue();
     228           0 :     m_pRubyBelowCB->SaveValue();
     229           0 :     m_pDisplayCB->SaveValue();
     230           0 :     m_pPrintCB->SaveValue();
     231           0 :     m_pColorLB->SaveValue();
     232           0 : }
     233             : 
     234           0 : void    SwTextGridPage::ActivatePage( const SfxItemSet& rSet )
     235             : {
     236           0 :     m_pExampleWN->Hide();
     237           0 :     m_pExampleWN->UpdateExample( rSet );
     238           0 :     UpdatePageSize(rSet);
     239           0 :     m_pExampleWN->Show();
     240           0 :     m_pExampleWN->Invalidate();
     241           0 : }
     242             : 
     243           0 : int SwTextGridPage::DeactivatePage( SfxItemSet* )
     244             : {
     245           0 :     return LEAVE_PAGE;
     246             : }
     247             : 
     248           0 : void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
     249             : {
     250           0 :         SwTextGridItem aGridItem;
     251           0 :         aGridItem.SetGridType(m_pNoGridRB->IsChecked() ? GRID_NONE :
     252           0 :             m_pLinesGridRB->IsChecked() ? GRID_LINES_ONLY : GRID_LINES_CHARS );
     253           0 :         aGridItem.SetSnapToChars(m_pSnapToCharsCB->IsChecked());
     254           0 :         aGridItem.SetLines( static_cast< sal_uInt16 >(m_pLinesPerPageNF->GetValue()) );
     255             :         aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
     256             :             m_bRubyUserValue ? m_nRubyUserValue :
     257           0 :                 m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP))) );
     258           0 :         aGridItem.SetRubyHeight( static_cast< sal_uInt16 >(m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))) );
     259           0 :         aGridItem.SetBaseWidth( static_cast< sal_uInt16 >(m_pCharWidthMF->Denormalize(m_pCharWidthMF->GetValue(FUNIT_TWIP))) );
     260           0 :         aGridItem.SetRubyTextBelow(m_pRubyBelowCB->IsChecked());
     261           0 :         aGridItem.SetSquaredMode(m_bSquaredMode);
     262           0 :         aGridItem.SetDisplayGrid(m_pDisplayCB->IsChecked());
     263           0 :         aGridItem.SetPrintGrid(m_pPrintCB->IsChecked());
     264           0 :         aGridItem.SetColor(m_pColorLB->GetSelectEntryColor());
     265           0 :         rSet.Put(aGridItem);
     266             : 
     267           0 :         SwView * pView = ::GetActiveView();
     268           0 :         if ( aGridItem.GetGridType() != GRID_NONE )
     269             :         {
     270           0 :             if ( aGridItem.GetGridType() == GRID_LINES_CHARS )
     271             :             {
     272           0 :                 m_bHRulerChanged = sal_True;
     273             :             }
     274           0 :             m_bVRulerChanged = sal_True;
     275           0 :             pView->GetHRuler().SetCharWidth((long)(m_pCharWidthMF->GetValue(FUNIT_TWIP)/56.7));
     276           0 :             pView->GetVRuler().SetLineHeight((long)(m_pTextSizeMF->GetValue(FUNIT_TWIP)/56.7));
     277           0 :         }
     278           0 : }
     279             : 
     280           0 : void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet)
     281             : {
     282           0 :     if( SFX_ITEM_UNKNOWN !=  rSet.GetItemState( RES_FRAMEDIR, sal_True ))
     283             :     {
     284             :         const SvxFrameDirectionItem& rDirItem =
     285           0 :                     (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
     286           0 :         m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
     287           0 :                     rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
     288             :     }
     289             : 
     290           0 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
     291             :     {
     292             :         const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(
     293           0 :                                             SID_ATTR_PAGE_SIZE);
     294             :         const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
     295           0 :                                                             RES_LR_SPACE );
     296             :         const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get(
     297           0 :                                                             RES_UL_SPACE );
     298           0 :         const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
     299           0 :         sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight();
     300           0 :         sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower();
     301             : 
     302           0 :         sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL -
     303           0 :                 rBox.GetDistance(BOX_LINE_TOP) -
     304           0 :                                     rBox.GetDistance(BOX_LINE_BOTTOM);
     305           0 :         sal_Int32 nValue2 = rSize.GetSize().Width() - nDistanceLR -
     306           0 :                 rBox.GetDistance(BOX_LINE_LEFT) -
     307           0 :                                     rBox.GetDistance(BOX_LINE_RIGHT);
     308           0 :         if(m_bVertical)
     309             :         {
     310           0 :             m_aPageSize.Width() = nValue1;
     311           0 :             m_aPageSize.Height() = nValue2;
     312             :         }
     313             :         else
     314             :         {
     315           0 :             m_aPageSize.Width() = nValue2;
     316           0 :             m_aPageSize.Height() = nValue1;
     317             :         }
     318             : 
     319             :         sal_Int32 nTextSize = static_cast< sal_Int32 >(m_bRubyUserValue ?
     320             :                     m_nRubyUserValue :
     321           0 :                         m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)));
     322             : 
     323           0 :         if ( m_bSquaredMode )
     324             :         {
     325           0 :             m_pCharsPerLineNF->SetValue(m_aPageSize.Width() / nTextSize);
     326           0 :         m_pCharsPerLineNF->SetMax( m_pCharsPerLineNF->GetValue() );
     327           0 :             m_pLinesPerPageNF->SetMax( m_aPageSize.Height() /
     328           0 :         (   m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)) +
     329           0 :                     m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))));
     330           0 :             SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     331           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     332             :         }
     333             :         else
     334             :         {
     335           0 :             sal_Int32 nTextWidth = static_cast< sal_Int32 >(m_pCharWidthMF->Denormalize(m_pCharWidthMF->GetValue(FUNIT_TWIP)));
     336           0 :             m_pLinesPerPageNF->SetValue(m_aPageSize.Height() / nTextSize);
     337           0 :             if (nTextWidth)
     338           0 :                 m_pCharsPerLineNF->SetValue(m_aPageSize.Width() / nTextWidth);
     339             :             else
     340           0 :                 m_pCharsPerLineNF->SetValue( 45 );
     341           0 :         SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     342           0 :         SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     343             :         }
     344             :     }
     345           0 : }
     346             : 
     347           0 : void SwTextGridPage::SetLinesOrCharsRanges(FixedText & rField, const sal_Int32 nValue )
     348             : {
     349           0 :     OUString aFieldStr("( 1 -");
     350           0 :     aFieldStr += OUString::number(nValue);
     351           0 :     aFieldStr += " )";
     352           0 :     rField.SetText( aFieldStr );
     353           0 : }
     354             : 
     355           0 : sal_uInt16* SwTextGridPage::GetRanges()
     356             : {
     357             :     static sal_uInt16 aPageRg[] = {
     358             :         RES_TEXTGRID, RES_TEXTGRID,
     359             :         0};
     360           0 :     return aPageRg;
     361             : }
     362             : 
     363           0 : IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField*, pField)
     364             : {
     365             :     //if in squared mode
     366           0 :     if ( m_bSquaredMode )
     367             :     {
     368           0 :         if(m_pCharsPerLineNF == pField)
     369             :         {
     370           0 :             long nWidth = (long)(m_aPageSize.Width() / m_pCharsPerLineNF->GetValue());
     371           0 :             m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(nWidth), FUNIT_TWIP);
     372             :             //prevent rounding errors in the MetricField by saving the used value
     373           0 :             m_nRubyUserValue = nWidth;
     374           0 :             m_bRubyUserValue = sal_True;
     375             : 
     376             :         }
     377             :         //set maximum line per page
     378             :         {
     379           0 :             sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
     380           0 :                 (   m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)) +
     381           0 :                     m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))));
     382           0 :             m_pLinesPerPageNF->SetMax(nMaxLines);
     383             :         }
     384           0 :         SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     385           0 :     SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     386             :     }
     387             :     else//in normal mode
     388             :     {
     389           0 :         if(m_pLinesPerPageNF == pField)
     390             :         {
     391           0 :             long nHeight = static_cast< sal_Int32 >(m_aPageSize.Height() / m_pLinesPerPageNF->GetValue());
     392           0 :             m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(nHeight), FUNIT_TWIP);
     393           0 :             m_pRubySizeMF->SetValue(0, FUNIT_TWIP);
     394           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     395             : 
     396           0 :             m_nRubyUserValue = nHeight;
     397           0 :             m_bRubyUserValue = sal_True;
     398             :         }
     399           0 :         else if (m_pCharsPerLineNF == pField)
     400             :         {
     401           0 :             long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / m_pCharsPerLineNF->GetValue());
     402           0 :             m_pCharWidthMF->SetValue(m_pCharWidthMF->Normalize(nWidth), FUNIT_TWIP);
     403           0 :             SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     404             :         }
     405             :     }
     406           0 :     GridModifyHdl(0);
     407           0 :     return 0;
     408             : }
     409             : 
     410           0 : IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, SpinField*, pField)
     411             : {
     412             :     //if in squared mode
     413           0 :     if( m_bSquaredMode )
     414             :     {
     415           0 :         if (m_pTextSizeMF == pField)
     416             :         {
     417           0 :             m_bRubyUserValue = sal_False;
     418             : 
     419             :             // fdo#50941: set maximum characters per line
     420           0 :             sal_Int32 nTextSize = static_cast< sal_Int32 >(m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)));
     421           0 :             if (nTextSize > 0)
     422             :             {
     423           0 :                 sal_Int32 nMaxChars = m_aPageSize.Width() / nTextSize;
     424           0 :                 m_pCharsPerLineNF->SetValue(nMaxChars);
     425           0 :                 m_pCharsPerLineNF->SetMax(nMaxChars);
     426           0 :                 SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     427             :             }
     428             :         }
     429             :         //set maximum line per page
     430             :         {
     431           0 :             sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
     432           0 :                 (   m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)) +
     433           0 :                     m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))));
     434           0 :             m_pLinesPerPageNF->SetMax(nMaxLines);
     435           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     436             :         }
     437             :     }
     438             :     else
     439             :     {
     440           0 :         if (m_pTextSizeMF == pField)
     441             :         {
     442           0 :             sal_Int32 nTextSize = static_cast< sal_Int32 >(m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)));
     443           0 :             m_pLinesPerPageNF->SetValue(m_aPageSize.Height() / nTextSize);
     444           0 :             m_bRubyUserValue = sal_False;
     445           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     446             :         }
     447           0 :         else if (m_pCharWidthMF == pField)
     448             :         {
     449           0 :             sal_Int32 nTextWidth = static_cast< sal_Int32 >(m_pCharWidthMF->Denormalize(m_pCharWidthMF->GetValue(FUNIT_TWIP)));
     450           0 :             sal_Int32 nMaxChar = 45 ;
     451           0 :             if (nTextWidth)
     452           0 :                 nMaxChar = m_aPageSize.Width() / nTextWidth;
     453           0 :             m_pCharsPerLineNF->SetValue( nMaxChar );
     454           0 :             SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     455             :         }
     456             :         //rubySize is disabled
     457             :     }
     458           0 :     GridModifyHdl(0);
     459           0 :     return 0;
     460             : }
     461             : 
     462           0 : IMPL_LINK(SwTextGridPage, GridTypeHdl, RadioButton*, pButton)
     463             : {
     464           0 :     sal_Bool bEnable = m_pNoGridRB != pButton;
     465           0 :     m_pLayoutFL->Enable(bEnable);
     466           0 :     m_pDisplayFL->Enable(bEnable);
     467             : 
     468             :     //one special case
     469           0 :     if(bEnable)
     470           0 :         DisplayGridHdl(m_pDisplayCB);
     471             : 
     472           0 :     bEnable = m_pCharsGridRB == pButton;
     473           0 :     m_pSnapToCharsCB->Enable(bEnable);
     474             : 
     475           0 :     bEnable = m_pLinesGridRB == pButton;
     476           0 :     if(bEnable && !m_bSquaredMode )
     477             :     {
     478           0 :         m_pCharsPerLineFT->Enable(sal_False);
     479           0 :         m_pCharsPerLineNF->Enable(sal_False);
     480           0 :         m_pCharsRangeFT->Enable(sal_False);
     481           0 :         m_pCharWidthFT->Enable(sal_False);
     482           0 :         m_pCharWidthMF->Enable(sal_False);
     483             :     }
     484             : 
     485           0 :     GridModifyHdl(0);
     486           0 :     return 0;
     487             : }
     488             : 
     489           0 : IMPL_LINK_NOARG(SwTextGridPage, DisplayGridHdl)
     490             : {
     491           0 :     sal_Bool bChecked = m_pDisplayCB->IsChecked();
     492           0 :     m_pPrintCB->Enable(bChecked);
     493           0 :     m_pPrintCB->Check(bChecked);
     494           0 :     return 0;
     495             : }
     496             : 
     497           0 : IMPL_LINK_NOARG(SwTextGridPage, GridModifyHdl)
     498             : {
     499           0 :     const SfxItemSet& rOldSet = GetItemSet();
     500           0 :     SfxItemSet aSet(rOldSet);
     501           0 :     const SfxItemSet* pExSet = GetTabDialog()->GetExampleSet();
     502           0 :     if(pExSet)
     503           0 :         aSet.Put(*pExSet);
     504           0 :     PutGridItem(aSet);
     505           0 :     m_pExampleWN->UpdateExample(aSet);
     506           0 :     return 0;
     507           0 : }
     508             : 
     509             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10