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

Generated by: LCOV version 1.11