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

Generated by: LCOV version 1.10