LCOV - code coverage report
Current view: top level - sw/source/ui/misc - pggrid.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 311 0.0 %
Date: 2014-04-11 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 :     const long nCount = pColorLst->Count();
     113           0 :     for( long i = 0; i < nCount; ++i )
     114             :     {
     115           0 :         XColorEntry* pEntry = pColorLst->GetColor( i );
     116           0 :         Color aColor = pEntry->GetColor();
     117           0 :         OUString sName = pEntry->GetName();
     118           0 :         m_pColorLB->InsertEntry( aColor, sName );
     119           0 :     }
     120           0 :     m_pColorLB->SetUpdateMode( true );
     121             :     //Get the default paper mode
     122           0 :     SwView *pView   = ::GetActiveView();
     123           0 :     if( pView )
     124             :     {
     125           0 :         SwWrtShell* pSh = pView->GetWrtShellPtr();
     126           0 :         if( pSh )
     127             :         {
     128           0 :             m_bSquaredMode = pSh->GetDoc()->IsSquaredPageMode();
     129             :         }
     130             :     }
     131           0 :     if( m_bSquaredMode )
     132             :     {
     133             : 
     134           0 :         m_pRubySizeFT->Show();
     135           0 :         m_pRubySizeMF->Show();
     136           0 :         m_pRubyBelowCB->Show();
     137           0 :         m_pSnapToCharsCB->Hide();
     138           0 :         m_pCharWidthFT->Hide();
     139           0 :         m_pCharWidthMF->Hide();
     140             :     }
     141             :     else
     142             :     {
     143           0 :         m_pRubySizeFT->Hide();
     144           0 :         m_pRubySizeMF->Hide();
     145           0 :         m_pRubyBelowCB->Hide();
     146           0 :         m_pSnapToCharsCB->Show();
     147           0 :         m_pCharWidthFT->Show();
     148           0 :         m_pCharWidthMF->Show();
     149           0 :     }
     150           0 : }
     151             : 
     152           0 : SwTextGridPage::~SwTextGridPage()
     153             : {
     154           0 : }
     155             : 
     156           0 : SfxTabPage *SwTextGridPage::Create(Window *pParent, const SfxItemSet &rSet)
     157             : {
     158           0 :     return new SwTextGridPage(pParent, rSet);
     159             : }
     160             : 
     161           0 : bool    SwTextGridPage::FillItemSet(SfxItemSet &rSet)
     162             : {
     163           0 :     sal_Bool bRet = sal_False;
     164           0 :     if(m_pNoGridRB->GetSavedValue() != m_pNoGridRB->IsChecked()||
     165           0 :         m_pLinesGridRB->GetSavedValue() != m_pLinesGridRB->IsChecked()||
     166           0 :         m_pLinesPerPageNF->GetSavedValue().toInt32()
     167           0 :            != m_pLinesPerPageNF->GetValue()||
     168           0 :         m_pTextSizeMF->GetSavedValue().toInt32() != m_pTextSizeMF->GetValue()||
     169           0 :         m_pCharsPerLineNF->GetSavedValue().toInt32()
     170           0 :            != m_pCharsPerLineNF->GetValue()||
     171           0 :         m_pSnapToCharsCB->GetSavedValue() != TriState(m_pSnapToCharsCB->IsChecked()) ||
     172           0 :         m_pRubySizeMF->GetSavedValue().toInt32() != m_pRubySizeMF->GetValue()||
     173           0 :         m_pCharWidthMF->GetSavedValue().toInt32() != m_pCharWidthMF->GetValue()||
     174           0 :         m_pRubyBelowCB->GetSavedValue() != TriState(m_pRubyBelowCB->IsChecked())||
     175           0 :         m_pDisplayCB->GetSavedValue() != TriState(m_pDisplayCB->IsChecked())||
     176           0 :         m_pPrintCB->GetSavedValue() != TriState(m_pPrintCB->IsChecked())||
     177           0 :         m_pColorLB->GetSavedValue() != m_pColorLB->GetSelectEntryPos())
     178             :     {
     179           0 :         PutGridItem(rSet);
     180           0 :         bRet = sal_True;
     181             :     }
     182             : 
     183             :     // draw ticks of ruler
     184           0 :     SwView * pView = ::GetActiveView();
     185           0 :     if ( m_bHRulerChanged )
     186           0 :         pView->GetHRuler().DrawTicks();
     187           0 :     if ( m_bVRulerChanged )
     188           0 :         pView->GetVRuler().DrawTicks();
     189           0 :     return bRet;
     190             : }
     191             : 
     192           0 : void    SwTextGridPage::Reset(const SfxItemSet &rSet)
     193             : {
     194           0 :     if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, true))
     195             :     {
     196           0 :         const SwTextGridItem& rGridItem = (const SwTextGridItem&)rSet.Get(RES_TEXTGRID);
     197           0 :         RadioButton* pButton = 0;
     198           0 :         switch(rGridItem.GetGridType())
     199             :         {
     200           0 :             case GRID_NONE :        pButton = m_pNoGridRB;    break;
     201           0 :             case GRID_LINES_ONLY  : pButton = m_pLinesGridRB; break;
     202           0 :             default:                pButton = m_pCharsGridRB;
     203             :         }
     204           0 :         pButton->Check();
     205           0 :         m_pDisplayCB->Check(rGridItem.IsDisplayGrid());
     206           0 :         GridTypeHdl(pButton);
     207           0 :         m_pSnapToCharsCB->Check(rGridItem.IsSnapToChars());
     208           0 :         m_pLinesPerPageNF->SetValue(rGridItem.GetLines());
     209           0 :         SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     210           0 :         m_nRubyUserValue = rGridItem.GetBaseHeight();
     211           0 :         m_bRubyUserValue = sal_True;
     212           0 :         m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(m_nRubyUserValue), FUNIT_TWIP);
     213           0 :         m_pRubySizeMF->SetValue(m_pRubySizeMF->Normalize(rGridItem.GetRubyHeight()), FUNIT_TWIP);
     214           0 :         m_pCharWidthMF->SetValue(m_pCharWidthMF->Normalize(rGridItem.GetBaseWidth()), FUNIT_TWIP);
     215           0 :         m_pRubyBelowCB->Check(rGridItem.IsRubyTextBelow());
     216           0 :         m_pPrintCB->Check(rGridItem.IsPrintGrid());
     217           0 :         m_pColorLB->SelectEntry(rGridItem.GetColor());
     218             :     }
     219           0 :     UpdatePageSize(rSet);
     220             : 
     221           0 :     m_pNoGridRB->SaveValue();
     222           0 :     m_pLinesGridRB->SaveValue();
     223           0 :     m_pSnapToCharsCB->SaveValue();
     224           0 :     m_pLinesPerPageNF->SaveValue();
     225           0 :     m_pTextSizeMF->SaveValue();
     226           0 :     m_pCharsPerLineNF->SaveValue();
     227           0 :     m_pRubySizeMF->SaveValue();
     228           0 :     m_pCharWidthMF->SaveValue();
     229           0 :     m_pRubyBelowCB->SaveValue();
     230           0 :     m_pDisplayCB->SaveValue();
     231           0 :     m_pPrintCB->SaveValue();
     232           0 :     m_pColorLB->SaveValue();
     233           0 : }
     234             : 
     235           0 : void    SwTextGridPage::ActivatePage( const SfxItemSet& rSet )
     236             : {
     237           0 :     m_pExampleWN->Hide();
     238           0 :     m_pExampleWN->UpdateExample( rSet );
     239           0 :     UpdatePageSize(rSet);
     240           0 :     m_pExampleWN->Show();
     241           0 :     m_pExampleWN->Invalidate();
     242           0 : }
     243             : 
     244           0 : int SwTextGridPage::DeactivatePage( SfxItemSet* )
     245             : {
     246           0 :     return LEAVE_PAGE;
     247             : }
     248             : 
     249           0 : void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
     250             : {
     251           0 :         SwTextGridItem aGridItem;
     252           0 :         aGridItem.SetGridType(m_pNoGridRB->IsChecked() ? GRID_NONE :
     253           0 :             m_pLinesGridRB->IsChecked() ? GRID_LINES_ONLY : GRID_LINES_CHARS );
     254           0 :         aGridItem.SetSnapToChars(m_pSnapToCharsCB->IsChecked());
     255           0 :         aGridItem.SetLines( static_cast< sal_uInt16 >(m_pLinesPerPageNF->GetValue()) );
     256             :         aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
     257             :             m_bRubyUserValue ? m_nRubyUserValue :
     258           0 :                 m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP))) );
     259           0 :         aGridItem.SetRubyHeight( static_cast< sal_uInt16 >(m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))) );
     260           0 :         aGridItem.SetBaseWidth( static_cast< sal_uInt16 >(m_pCharWidthMF->Denormalize(m_pCharWidthMF->GetValue(FUNIT_TWIP))) );
     261           0 :         aGridItem.SetRubyTextBelow(m_pRubyBelowCB->IsChecked());
     262           0 :         aGridItem.SetSquaredMode(m_bSquaredMode);
     263           0 :         aGridItem.SetDisplayGrid(m_pDisplayCB->IsChecked());
     264           0 :         aGridItem.SetPrintGrid(m_pPrintCB->IsChecked());
     265           0 :         aGridItem.SetColor(m_pColorLB->GetSelectEntryColor());
     266           0 :         rSet.Put(aGridItem);
     267             : 
     268           0 :         SwView * pView = ::GetActiveView();
     269           0 :         if ( aGridItem.GetGridType() != GRID_NONE )
     270             :         {
     271           0 :             if ( aGridItem.GetGridType() == GRID_LINES_CHARS )
     272             :             {
     273           0 :                 m_bHRulerChanged = sal_True;
     274             :             }
     275           0 :             m_bVRulerChanged = sal_True;
     276           0 :             pView->GetHRuler().SetCharWidth((long)(m_pCharWidthMF->GetValue(FUNIT_TWIP)/56.7));
     277           0 :             pView->GetVRuler().SetLineHeight((long)(m_pTextSizeMF->GetValue(FUNIT_TWIP)/56.7));
     278           0 :         }
     279           0 : }
     280             : 
     281           0 : void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet)
     282             : {
     283           0 :     if( SFX_ITEM_UNKNOWN !=  rSet.GetItemState( RES_FRAMEDIR, true ))
     284             :     {
     285             :         const SvxFrameDirectionItem& rDirItem =
     286           0 :                     (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
     287           0 :         m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
     288           0 :                     rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
     289             :     }
     290             : 
     291           0 :     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
     292             :     {
     293             :         const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(
     294           0 :                                             SID_ATTR_PAGE_SIZE);
     295             :         const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
     296           0 :                                                             RES_LR_SPACE );
     297             :         const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get(
     298           0 :                                                             RES_UL_SPACE );
     299           0 :         const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
     300           0 :         sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight();
     301           0 :         sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower();
     302             : 
     303           0 :         sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL -
     304           0 :                 rBox.GetDistance(BOX_LINE_TOP) -
     305           0 :                                     rBox.GetDistance(BOX_LINE_BOTTOM);
     306           0 :         sal_Int32 nValue2 = rSize.GetSize().Width() - nDistanceLR -
     307           0 :                 rBox.GetDistance(BOX_LINE_LEFT) -
     308           0 :                                     rBox.GetDistance(BOX_LINE_RIGHT);
     309           0 :         if(m_bVertical)
     310             :         {
     311           0 :             m_aPageSize.Width() = nValue1;
     312           0 :             m_aPageSize.Height() = nValue2;
     313             :         }
     314             :         else
     315             :         {
     316           0 :             m_aPageSize.Width() = nValue2;
     317           0 :             m_aPageSize.Height() = nValue1;
     318             :         }
     319             : 
     320             :         sal_Int32 nTextSize = static_cast< sal_Int32 >(m_bRubyUserValue ?
     321             :                     m_nRubyUserValue :
     322           0 :                         m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)));
     323             : 
     324           0 :         if ( m_bSquaredMode )
     325             :         {
     326           0 :             m_pCharsPerLineNF->SetValue(m_aPageSize.Width() / nTextSize);
     327           0 :         m_pCharsPerLineNF->SetMax( m_pCharsPerLineNF->GetValue() );
     328           0 :             m_pLinesPerPageNF->SetMax( m_aPageSize.Height() /
     329           0 :         (   m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)) +
     330           0 :                     m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))));
     331           0 :             SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     332           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     333             :         }
     334             :         else
     335             :         {
     336           0 :             sal_Int32 nTextWidth = static_cast< sal_Int32 >(m_pCharWidthMF->Denormalize(m_pCharWidthMF->GetValue(FUNIT_TWIP)));
     337           0 :             m_pLinesPerPageNF->SetValue(m_aPageSize.Height() / nTextSize);
     338           0 :             if (nTextWidth)
     339           0 :                 m_pCharsPerLineNF->SetValue(m_aPageSize.Width() / nTextWidth);
     340             :             else
     341           0 :                 m_pCharsPerLineNF->SetValue( 45 );
     342           0 :         SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     343           0 :         SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     344             :         }
     345             :     }
     346           0 : }
     347             : 
     348           0 : void SwTextGridPage::SetLinesOrCharsRanges(FixedText & rField, const sal_Int32 nValue )
     349             : {
     350           0 :     OUString aFieldStr("( 1 -");
     351           0 :     aFieldStr += OUString::number(nValue);
     352           0 :     aFieldStr += " )";
     353           0 :     rField.SetText( aFieldStr );
     354           0 : }
     355             : 
     356           0 : sal_uInt16* SwTextGridPage::GetRanges()
     357             : {
     358             :     static sal_uInt16 aPageRg[] = {
     359             :         RES_TEXTGRID, RES_TEXTGRID,
     360             :         0};
     361           0 :     return aPageRg;
     362             : }
     363             : 
     364           0 : IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField*, pField)
     365             : {
     366             :     //if in squared mode
     367           0 :     if ( m_bSquaredMode )
     368             :     {
     369           0 :         if(m_pCharsPerLineNF == pField)
     370             :         {
     371           0 :             long nWidth = (long)(m_aPageSize.Width() / m_pCharsPerLineNF->GetValue());
     372           0 :             m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(nWidth), FUNIT_TWIP);
     373             :             //prevent rounding errors in the MetricField by saving the used value
     374           0 :             m_nRubyUserValue = nWidth;
     375           0 :             m_bRubyUserValue = sal_True;
     376             : 
     377             :         }
     378             :         //set maximum line per page
     379             :         {
     380           0 :             sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
     381           0 :                 (   m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)) +
     382           0 :                     m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))));
     383           0 :             m_pLinesPerPageNF->SetMax(nMaxLines);
     384             :         }
     385           0 :         SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     386           0 :     SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     387             :     }
     388             :     else//in normal mode
     389             :     {
     390           0 :         if(m_pLinesPerPageNF == pField)
     391             :         {
     392           0 :             long nHeight = static_cast< sal_Int32 >(m_aPageSize.Height() / m_pLinesPerPageNF->GetValue());
     393           0 :             m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(nHeight), FUNIT_TWIP);
     394           0 :             m_pRubySizeMF->SetValue(0, FUNIT_TWIP);
     395           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     396             : 
     397           0 :             m_nRubyUserValue = nHeight;
     398           0 :             m_bRubyUserValue = sal_True;
     399             :         }
     400           0 :         else if (m_pCharsPerLineNF == pField)
     401             :         {
     402           0 :             long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / m_pCharsPerLineNF->GetValue());
     403           0 :             m_pCharWidthMF->SetValue(m_pCharWidthMF->Normalize(nWidth), FUNIT_TWIP);
     404           0 :             SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     405             :         }
     406             :     }
     407           0 :     GridModifyHdl(0);
     408           0 :     return 0;
     409             : }
     410             : 
     411           0 : IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, SpinField*, pField)
     412             : {
     413             :     //if in squared mode
     414           0 :     if( m_bSquaredMode )
     415             :     {
     416           0 :         if (m_pTextSizeMF == pField)
     417             :         {
     418           0 :             m_bRubyUserValue = sal_False;
     419             : 
     420             :             // fdo#50941: set maximum characters per line
     421           0 :             sal_Int32 nTextSize = static_cast< sal_Int32 >(m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)));
     422           0 :             if (nTextSize > 0)
     423             :             {
     424           0 :                 sal_Int32 nMaxChars = m_aPageSize.Width() / nTextSize;
     425           0 :                 m_pCharsPerLineNF->SetValue(nMaxChars);
     426           0 :                 m_pCharsPerLineNF->SetMax(nMaxChars);
     427           0 :                 SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     428             :             }
     429             :         }
     430             :         //set maximum line per page
     431             :         {
     432           0 :             sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
     433           0 :                 (   m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)) +
     434           0 :                     m_pRubySizeMF->Denormalize(m_pRubySizeMF->GetValue(FUNIT_TWIP))));
     435           0 :             m_pLinesPerPageNF->SetMax(nMaxLines);
     436           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     437             :         }
     438             :     }
     439             :     else
     440             :     {
     441           0 :         if (m_pTextSizeMF == pField)
     442             :         {
     443           0 :             sal_Int32 nTextSize = static_cast< sal_Int32 >(m_pTextSizeMF->Denormalize(m_pTextSizeMF->GetValue(FUNIT_TWIP)));
     444           0 :             m_pLinesPerPageNF->SetValue(m_aPageSize.Height() / nTextSize);
     445           0 :             m_bRubyUserValue = sal_False;
     446           0 :             SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() );
     447             :         }
     448           0 :         else if (m_pCharWidthMF == pField)
     449             :         {
     450           0 :             sal_Int32 nTextWidth = static_cast< sal_Int32 >(m_pCharWidthMF->Denormalize(m_pCharWidthMF->GetValue(FUNIT_TWIP)));
     451           0 :             sal_Int32 nMaxChar = 45 ;
     452           0 :             if (nTextWidth)
     453           0 :                 nMaxChar = m_aPageSize.Width() / nTextWidth;
     454           0 :             m_pCharsPerLineNF->SetValue( nMaxChar );
     455           0 :             SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
     456             :         }
     457             :         //rubySize is disabled
     458             :     }
     459           0 :     GridModifyHdl(0);
     460           0 :     return 0;
     461             : }
     462             : 
     463           0 : IMPL_LINK(SwTextGridPage, GridTypeHdl, RadioButton*, pButton)
     464             : {
     465           0 :     sal_Bool bEnable = m_pNoGridRB != pButton;
     466           0 :     m_pLayoutFL->Enable(bEnable);
     467           0 :     m_pDisplayFL->Enable(bEnable);
     468             : 
     469             :     //one special case
     470           0 :     if(bEnable)
     471           0 :         DisplayGridHdl(m_pDisplayCB);
     472             : 
     473           0 :     bEnable = m_pCharsGridRB == pButton;
     474           0 :     m_pSnapToCharsCB->Enable(bEnable);
     475             : 
     476           0 :     bEnable = m_pLinesGridRB == pButton;
     477           0 :     if(bEnable && !m_bSquaredMode )
     478             :     {
     479           0 :         m_pCharsPerLineFT->Enable(false);
     480           0 :         m_pCharsPerLineNF->Enable(false);
     481           0 :         m_pCharsRangeFT->Enable(false);
     482           0 :         m_pCharWidthFT->Enable(false);
     483           0 :         m_pCharWidthMF->Enable(false);
     484             :     }
     485             : 
     486           0 :     GridModifyHdl(0);
     487           0 :     return 0;
     488             : }
     489             : 
     490           0 : IMPL_LINK_NOARG(SwTextGridPage, DisplayGridHdl)
     491             : {
     492           0 :     sal_Bool bChecked = m_pDisplayCB->IsChecked();
     493           0 :     m_pPrintCB->Enable(bChecked);
     494           0 :     m_pPrintCB->Check(bChecked);
     495           0 :     return 0;
     496             : }
     497             : 
     498           0 : IMPL_LINK_NOARG(SwTextGridPage, GridModifyHdl)
     499             : {
     500           0 :     const SfxItemSet& rOldSet = GetItemSet();
     501           0 :     SfxItemSet aSet(rOldSet);
     502           0 :     const SfxItemSet* pExSet = GetTabDialog()->GetExampleSet();
     503           0 :     if(pExSet)
     504           0 :         aSet.Put(*pExSet);
     505           0 :     PutGridItem(aSet);
     506           0 :     m_pExampleWN->UpdateExample(aSet);
     507           0 :     return 0;
     508           0 : }
     509             : 
     510             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10