LCOV - code coverage report
Current view: top level - sw/source/core/uibase/frmdlg - colex.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 317 0.0 %
Date: 2014-04-11 Functions: 0 13 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 "cmdid.h"
      21             : #include "hintids.hxx"
      22             : #include <algorithm>
      23             : 
      24             : #include <svl/eitem.hxx>
      25             : #include <editeng/lrspitem.hxx>
      26             : #include <editeng/ulspitem.hxx>
      27             : #include <editeng/sizeitem.hxx>
      28             : #include <svx/pageitem.hxx>
      29             : #include <editeng/brushitem.hxx>
      30             : #include <editeng/frmdiritem.hxx>
      31             : #include <vcl/bitmap.hxx>
      32             : #include <vcl/builder.hxx>
      33             : #include <vcl/graph.hxx>
      34             : #include <vcl/settings.hxx>
      35             : #include <tgrditem.hxx>
      36             : #include <viewopt.hxx>
      37             : #include "colex.hxx"
      38             : #include "colmgr.hxx"
      39             : 
      40             : /*-----------------------------------------------------------------------
      41             :     Description: Taking the updated values from the set
      42             :  -----------------------------------------------------------------------*/
      43           0 : void SwPageExample::UpdateExample( const SfxItemSet& rSet )
      44             : {
      45           0 :     SfxItemPool* pPool = rSet.GetPool();
      46           0 :     sal_uInt16 nWhich = pPool->GetWhich( SID_ATTR_PAGE );
      47             : 
      48           0 :     if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
      49             :     {
      50             :         // alignment
      51           0 :         const SvxPageItem* pPage = (const SvxPageItem*)&rSet.Get( nWhich );
      52             : 
      53           0 :         if ( pPage )
      54           0 :             SetUsage( pPage->GetPageUsage() );
      55             :     }
      56             : 
      57           0 :     nWhich = pPool->GetWhich( SID_ATTR_PAGE_SIZE );
      58             : 
      59           0 :     if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
      60             :     {
      61             :         // orientation and size from PageItem
      62           0 :         const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( nWhich );
      63           0 :         SetSize( rSize.GetSize() );
      64             :     }
      65           0 :     nWhich = RES_LR_SPACE;
      66           0 :     if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
      67             :     {
      68             :         // set left and right border
      69           0 :         const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get( nWhich );
      70             : 
      71           0 :         SetLeft( rLRSpace.GetLeft() );
      72           0 :         SetRight( rLRSpace.GetRight() );
      73             :     }
      74             :     else
      75             :     {
      76           0 :         SetLeft( 0 );
      77           0 :         SetRight( 0 );
      78             :     }
      79             : 
      80           0 :     nWhich = RES_UL_SPACE;
      81             : 
      82           0 :     if ( rSet.GetItemState( nWhich, false ) == SFX_ITEM_SET )
      83             :     {
      84             :         // set upper and lower border
      85           0 :         const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get( nWhich );
      86             : 
      87           0 :         SetTop( rULSpace.GetUpper() );
      88           0 :         SetBottom( rULSpace.GetLower() );
      89             :     }
      90             :     else
      91             :     {
      92           0 :         SetTop( 0 );
      93           0 :         SetBottom( 0 );
      94             :     }
      95             : 
      96             :     // evaluate header-attributes
      97             :     const SfxPoolItem* pItem;
      98           0 :     if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_HEADERSET),
      99           0 :             false, &pItem ) )
     100             :     {
     101           0 :         const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
     102             :         const SfxBoolItem& rHeaderOn =
     103           0 :             (const SfxBoolItem&)rHeaderSet.Get( pPool->GetWhich( SID_ATTR_PAGE_ON ) );
     104             : 
     105           0 :         if ( rHeaderOn.GetValue() )
     106             :         {
     107             :             const SvxSizeItem& rSize =
     108           0 :                 (const SvxSizeItem&)rHeaderSet.Get(pPool->GetWhich(SID_ATTR_PAGE_SIZE));
     109             : 
     110             :             const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rHeaderSet.Get(
     111           0 :                                         pPool->GetWhich(SID_ATTR_ULSPACE));
     112             :             const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rHeaderSet.Get(
     113           0 :                                         pPool->GetWhich(SID_ATTR_LRSPACE));
     114             : 
     115           0 :             SetHdHeight( rSize.GetSize().Height() - rUL.GetLower());
     116           0 :             SetHdDist( rUL.GetLower() );
     117           0 :             SetHdLeft( rLR.GetLeft() );
     118           0 :             SetHdRight( rLR.GetRight() );
     119           0 :             SetHeader( true );
     120           0 :             if ( rHeaderSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET )
     121             :             {
     122             :                 const SvxBrushItem& rItem =
     123           0 :                     (const SvxBrushItem&)rHeaderSet.Get( RES_BACKGROUND );
     124           0 :                 SetHdColor( rItem.GetColor() );
     125             :             }
     126           0 :             if ( rHeaderSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
     127             :             {
     128             :                 const SvxBoxItem& rItem =
     129           0 :                     (const SvxBoxItem&)rHeaderSet.Get( RES_BOX );
     130           0 :                 SetHdBorder( rItem );
     131             :             }
     132             :         }
     133             :         else
     134           0 :             SetHeader( false );
     135             :     }
     136             : 
     137           0 :     if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_FOOTERSET),
     138           0 :             false, &pItem ) )
     139             :     {
     140           0 :         const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
     141             :         const SfxBoolItem& rFooterOn =
     142           0 :             (const SfxBoolItem&)rFooterSet.Get( SID_ATTR_PAGE_ON );
     143             : 
     144           0 :         if ( rFooterOn.GetValue() )
     145             :         {
     146             :             const SvxSizeItem& rSize =
     147           0 :                 (const SvxSizeItem&)rFooterSet.Get( pPool->GetWhich( SID_ATTR_PAGE_SIZE ) );
     148             : 
     149             :             const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rFooterSet.Get(
     150           0 :                                         pPool->GetWhich( SID_ATTR_ULSPACE ) );
     151             :             const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rFooterSet.Get(
     152           0 :                                         pPool->GetWhich( SID_ATTR_LRSPACE ) );
     153             : 
     154           0 :             SetFtHeight( rSize.GetSize().Height() - rUL.GetUpper());
     155           0 :             SetFtDist( rUL.GetUpper() );
     156           0 :             SetFtLeft( rLR.GetLeft() );
     157           0 :             SetFtRight( rLR.GetRight() );
     158           0 :             SetFooter( true );
     159           0 :             if( rFooterSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET )
     160             :             {
     161             :                 const SvxBrushItem& rItem =
     162           0 :                     (const SvxBrushItem&)rFooterSet.Get( RES_BACKGROUND );
     163           0 :                 SetFtColor( rItem.GetColor() );
     164             :             }
     165           0 :             if( rFooterSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
     166             :             {
     167             :                 const SvxBoxItem& rItem =
     168           0 :                     (const SvxBoxItem&)rFooterSet.Get( RES_BOX );
     169           0 :                 SetFtBorder( rItem );
     170             :             }
     171             :         }
     172             :         else
     173           0 :             SetFooter( false );
     174             :     }
     175           0 :     if( SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND,
     176           0 :             false, &pItem ) )
     177             :     {
     178           0 :         SetColor( ( (const SvxBrushItem*)pItem )->GetColor() );
     179           0 :         const Graphic* pGrf = ( (const SvxBrushItem*)pItem )->GetGraphic();
     180             : 
     181           0 :         if ( pGrf )
     182             :         {
     183           0 :             Bitmap aBitmap = pGrf->GetBitmap();
     184           0 :             SetBitmap( &aBitmap );
     185             :         }
     186             :         else
     187           0 :             SetBitmap( NULL );
     188             :     }
     189             : 
     190           0 :     Invalidate();
     191           0 : }
     192             : 
     193           0 : void SwColExample::DrawPage( const Point& rOrg,
     194             :                             const bool bSecond,
     195             :                             const bool bEnabled )
     196             : {
     197           0 :     SwPageExample::DrawPage( rOrg, bSecond, bEnabled );
     198             :     sal_uInt16 nColumnCount;
     199           0 :     if( pColMgr && 0 != (nColumnCount = pColMgr->GetCount()))
     200             :     {
     201           0 :         long nL = GetLeft();
     202           0 :         long nR = GetRight();
     203             : 
     204           0 :         if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
     205             :         {
     206             :             // rotate for mirrored
     207           0 :             nL = GetRight();
     208           0 :             nR = GetLeft();
     209             :         }
     210             : 
     211           0 :         SetFillColor( Color( COL_LIGHTGRAY ) );
     212           0 :         Rectangle aRect;
     213           0 :         aRect.Right() = rOrg.X() + GetSize().Width() - nR;
     214           0 :         aRect.Left()  = rOrg.X() + nL;
     215           0 :         aRect.Top()   = rOrg.Y() + GetTop()
     216           0 :                         + GetHdHeight() + GetHdDist();
     217           0 :         aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
     218           0 :                         - GetFtHeight() - GetFtDist();
     219           0 :         DrawRect(aRect);
     220             : 
     221           0 :         if(GetColor() == Color(COL_TRANSPARENT))
     222             :         {
     223           0 :             const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     224           0 :             const Color& rFieldColor = rStyleSettings.GetFieldColor();
     225           0 :             SetFillColor( rFieldColor );
     226             :         }
     227             :         else
     228           0 :             SetFillColor( GetColor() );
     229             : 
     230             :         // #97495# make sure that the automatic column width's are always equal
     231           0 :         sal_Bool bAutoWidth = pColMgr->IsAutoWidth();
     232           0 :         sal_Int32 nAutoColWidth = 0;
     233           0 :         if(bAutoWidth)
     234             :         {
     235           0 :             sal_Int32 nColumnWidthSum = 0;
     236             :             sal_uInt16 i;
     237           0 :             for(i = 0; i < nColumnCount; ++i)
     238           0 :                 nColumnWidthSum += pColMgr->GetColWidth( i );
     239           0 :             nAutoColWidth = nColumnWidthSum / nColumnCount;
     240             :         }
     241             : 
     242             :         sal_uInt16 i;
     243           0 :         for( i = 0; i < nColumnCount; i++)
     244             :         {
     245           0 :             if(!bAutoWidth)
     246           0 :                 nAutoColWidth = pColMgr->GetColWidth( i );
     247           0 :             aRect.Right() = aRect.Left() + nAutoColWidth;
     248           0 :             DrawRect(aRect);
     249           0 :             if(i < nColumnCount - 1)
     250           0 :                 aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
     251             :         }
     252           0 :         if(pColMgr->HasLine())
     253             :         {
     254           0 :             Point aUp( rOrg.X() + nL, rOrg.Y() + GetTop() );
     255           0 :             Point aDown( rOrg.X() + nL, rOrg.Y() + GetSize().Height()
     256           0 :                         - GetBottom() - GetFtHeight() - GetFtDist() );
     257             : 
     258           0 :             if( pColMgr->GetLineHeightPercent() != 100 )
     259             :             {
     260           0 :                 long nLength = aDown.Y() - aUp.Y();
     261           0 :                 nLength -= nLength * pColMgr->GetLineHeightPercent() / 100;
     262           0 :                 switch(pColMgr->GetAdjust())
     263             :                 {
     264           0 :                     case COLADJ_BOTTOM: aUp.Y() += nLength; break;
     265           0 :                     case COLADJ_TOP: aDown.Y() -= nLength; break;
     266             :                     case COLADJ_CENTER:
     267           0 :                         aUp.Y() += nLength / 2;
     268           0 :                         aDown.Y() -= nLength / 2;
     269           0 :                     break;
     270             :                     default:; // prevent warning
     271             :                 }
     272             :             }
     273             : 
     274             :             int nDist;
     275           0 :             for( i = 0; i < nColumnCount -  1; i++)
     276             :             {
     277           0 :                 int nGutter = pColMgr->GetGutterWidth(i);
     278           0 :                 nDist = pColMgr->GetColWidth( i ) + nGutter;
     279             :                 nDist -= (i == 0) ?
     280             :                     nGutter/2 :
     281           0 :                         0;
     282           0 :                 aUp.X() += nDist;
     283           0 :                 aDown.X() += nDist;
     284           0 :                 DrawLine( aUp, aDown );
     285             : 
     286             :             }
     287             :         }
     288             :     }
     289           0 : }
     290             : 
     291           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwColExample(Window *pParent, VclBuilder::stringmap &)
     292             : {
     293           0 :     return new SwColExample(pParent);
     294             : }
     295             : 
     296           0 : SwColumnOnlyExample::SwColumnOnlyExample(Window* pParent)
     297             :     : Window(pParent)
     298           0 :     , m_aFrmSize(1,1)
     299             : {
     300           0 :     SetMapMode( MapMode( MAP_TWIP ) );
     301           0 :     m_aWinSize = GetOptimalSize();
     302           0 :     m_aWinSize.Height() -= 4;
     303           0 :     m_aWinSize.Width() -= 4;
     304             : 
     305           0 :     m_aWinSize = PixelToLogic( m_aWinSize );
     306             : 
     307           0 :     SetBorderStyle( WINDOW_BORDER_MONO );
     308             : 
     309           0 :     m_aFrmSize  = SvxPaperInfo::GetPaperSize(PAPER_A4);// DIN A4
     310           0 :     ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width());
     311             : 
     312           0 :     long nHeight = m_aFrmSize.Height();
     313           0 :     Fraction aScale( m_aWinSize.Height(), nHeight );
     314           0 :     MapMode aMapMode( GetMapMode() );
     315           0 :     aMapMode.SetScaleX( aScale );
     316           0 :     aMapMode.SetScaleY( aScale );
     317           0 :     SetMapMode( aMapMode );
     318           0 : }
     319             : 
     320           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwColumnOnlyExample(Window *pParent, VclBuilder::stringmap &)
     321             : {
     322           0 :     return new SwColumnOnlyExample(pParent);
     323             : }
     324             : 
     325           0 : void SwColumnOnlyExample::Paint( const Rectangle& /*rRect*/ )
     326             : {
     327           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     328           0 :     const Color& rFieldColor = rStyleSettings.GetFieldColor();
     329           0 :     const Color& rDlgColor = rStyleSettings.GetDialogColor();
     330           0 :     const Color& rFieldTextColor = SwViewOption::GetFontColor();
     331           0 :     Color aGrayColor(COL_LIGHTGRAY);
     332           0 :     if(rFieldColor == aGrayColor)
     333           0 :         aGrayColor.Invert();
     334             : 
     335           0 :     Size aLogSize(PixelToLogic(GetOutputSizePixel()));
     336           0 :     Rectangle aCompleteRect(Point(0,0), aLogSize);
     337           0 :     SetLineColor(rDlgColor);
     338           0 :     SetFillColor(rDlgColor);
     339           0 :     DrawRect(aCompleteRect);
     340             : 
     341           0 :     SetLineColor( rFieldTextColor );
     342           0 :     Point aTL(  (aLogSize.Width() - m_aFrmSize.Width()) / 2,
     343           0 :                 (aLogSize.Height() - m_aFrmSize.Height()) / 2);
     344           0 :     Rectangle aRect(aTL, m_aFrmSize);
     345             : 
     346             :     //draw a shadow rectangle
     347           0 :     SetFillColor( Color(COL_GRAY) );
     348           0 :     Rectangle aShadowRect(aRect);
     349           0 :     aShadowRect.Move(aTL.Y(), aTL.Y());
     350           0 :     DrawRect(aShadowRect);
     351             : 
     352           0 :     SetFillColor( rFieldColor );
     353           0 :     DrawRect(aRect);
     354             : 
     355           0 :     SetFillColor( aGrayColor );
     356             : 
     357             :     //column separator?
     358           0 :     long nLength = aLogSize.Height() - 2 * aTL.Y();
     359           0 :     Point aUp( aTL );
     360           0 :     Point aDown( aTL.X(), nLength );
     361           0 :     bool bLines = false;
     362           0 :     if(m_aCols.GetLineAdj() != COLADJ_NONE)
     363             :     {
     364           0 :         bLines = true;
     365             : 
     366           0 :         sal_uInt16 nPercent = m_aCols.GetLineHeight();
     367           0 :         if( nPercent != 100 )
     368             :         {
     369           0 :             nLength -= nLength * nPercent / 100;
     370           0 :             switch(m_aCols.GetLineAdj())
     371             :             {
     372           0 :                 case COLADJ_BOTTOM: aUp.Y() += nLength; break;
     373           0 :                 case COLADJ_TOP: aDown.Y() -= nLength; break;
     374             :                 case COLADJ_CENTER:
     375           0 :                         aUp.Y() += nLength / 2;
     376           0 :                         aDown.Y() -= nLength / 2;
     377           0 :                 break;
     378             :                 default:; //prevent warning
     379             :             }
     380             :         }
     381             : 
     382             :     }
     383           0 :     const SwColumns& rCols = m_aCols.GetColumns();
     384           0 :     sal_uInt16 nColCount = rCols.size();
     385           0 :     if( nColCount )
     386             :     {
     387           0 :         DrawRect(aRect);
     388           0 :         SetFillColor( rFieldColor );
     389           0 :         Rectangle aFrmRect(aTL, m_aFrmSize);
     390           0 :         long nSum = aTL.X();
     391           0 :         for(sal_uInt16 i = 0; i < nColCount; i++)
     392             :         {
     393           0 :             const SwColumn* pCol = &rCols[i];
     394           0 :             aFrmRect.Left()    = nSum + pCol->GetLeft();//nSum + pCol->GetLeft() + aTL.X();
     395           0 :             nSum              += pCol->GetWishWidth();
     396           0 :             aFrmRect.Right()   = nSum - pCol->GetRight();
     397           0 :             DrawRect(aFrmRect);
     398             :         }
     399           0 :         if(bLines )
     400             :         {
     401           0 :             nSum = aTL.X();
     402           0 :             for(sal_uInt16 i = 0; i < nColCount - 1; i++)
     403             :             {
     404           0 :                 nSum += rCols[i].GetWishWidth();
     405           0 :                 aUp.X() = nSum;
     406           0 :                 aDown.X() = nSum;
     407           0 :                 DrawLine(aUp, aDown);
     408             :             }
     409             :         }
     410             :     }
     411           0 : }
     412             : 
     413           0 : void  SwColumnOnlyExample::SetColumns(const SwFmtCol& rCol)
     414             : {
     415           0 :     m_aCols = rCol;
     416           0 :     sal_uInt16 nWishSum = m_aCols.GetWishWidth();
     417           0 :     long nFrmWidth = m_aFrmSize.Width();
     418           0 :     SwColumns& rCols = m_aCols.GetColumns();
     419           0 :     sal_uInt16 nColCount = rCols.size();
     420             : 
     421           0 :     for(sal_uInt16 i = 0; i < nColCount; i++)
     422             :     {
     423           0 :         SwColumn* pCol = &rCols[i];
     424           0 :         long nWish = pCol->GetWishWidth();
     425           0 :         nWish *= nFrmWidth;
     426           0 :         nWish /= nWishSum;
     427           0 :         pCol->SetWishWidth((sal_uInt16)nWish);
     428           0 :         long nLeft = pCol->GetLeft();
     429           0 :         nLeft *= nFrmWidth;
     430           0 :         nLeft /= nWishSum;
     431           0 :         pCol->SetLeft((sal_uInt16)nLeft);
     432           0 :         long nRight = pCol->GetRight();
     433           0 :         nRight *= nFrmWidth;
     434           0 :         nRight /= nWishSum;
     435           0 :         pCol->SetRight((sal_uInt16)nRight);
     436             :     }
     437             :     // #97495# make sure that the automatic column width's are always equal
     438           0 :     if(nColCount && m_aCols.IsOrtho())
     439             :     {
     440           0 :         sal_Int32 nColumnWidthSum = 0;
     441             :         sal_uInt16 i;
     442           0 :         for(i = 0; i < nColCount; ++i)
     443             :         {
     444           0 :             SwColumn* pCol = &rCols[i];
     445           0 :             nColumnWidthSum += pCol->GetWishWidth();
     446           0 :             nColumnWidthSum -= (pCol->GetRight() + pCol->GetLeft());
     447             :         }
     448           0 :         nColumnWidthSum /= nColCount;
     449           0 :         for(i = 0; i < nColCount; ++i)
     450             :         {
     451           0 :             SwColumn* pCol = &rCols[i];
     452           0 :             pCol->SetWishWidth( static_cast< sal_uInt16 >(nColumnWidthSum + pCol->GetRight() + pCol->GetLeft()));
     453             :         }
     454             :     }
     455           0 : }
     456             : 
     457           0 : Size SwColumnOnlyExample::GetOptimalSize() const
     458             : {
     459           0 :     return LogicToPixel(Size(75, 46), MapMode(MAP_APPFONT));
     460             : }
     461             : 
     462           0 : SwPageGridExample::~SwPageGridExample()
     463             : {
     464           0 :     delete pGridItem;
     465           0 : }
     466             : 
     467           0 : void SwPageGridExample::DrawPage( const Point& rOrg,
     468             :                            const bool bSecond,
     469             :                            const bool bEnabled )
     470             : {
     471           0 :     SwPageExample::DrawPage(rOrg, bSecond, bEnabled);
     472           0 :     if(pGridItem && pGridItem->GetGridType())
     473             :     {
     474             :         //paint the grid now
     475           0 :         Color aLineColor = pGridItem->GetColor();
     476           0 :         if(aLineColor.GetColor() == COL_AUTO)
     477             :         {
     478           0 :             aLineColor = GetFillColor();
     479           0 :             aLineColor.Invert();
     480             :         }
     481           0 :         SetLineColor(aLineColor);
     482           0 :         long nL = GetLeft();
     483           0 :         long nR = GetRight();
     484             : 
     485           0 :         if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
     486             :         {
     487             :             // rotate for mirrored
     488           0 :             nL = GetRight();
     489           0 :             nR = GetLeft();
     490             :         }
     491             : 
     492           0 :         Rectangle aRect;
     493           0 :         aRect.Right() = rOrg.X() + GetSize().Width() - nR;
     494           0 :         aRect.Left()  = rOrg.X() + nL;
     495           0 :         aRect.Top()   = rOrg.Y() + GetTop()
     496           0 :                         + GetHdHeight() + GetHdDist();
     497           0 :         aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
     498           0 :                         - GetFtHeight() - GetFtDist();
     499             : 
     500             :         //increase the values to get a 'viewable' preview
     501           0 :         sal_Int32 nBaseHeight = pGridItem->GetBaseHeight() * 3;
     502           0 :         sal_Int32 nRubyHeight = pGridItem->GetRubyHeight() * 3;
     503             : 
     504             :         //detect height of rectangles
     505             :         Rectangle aRubyRect(aRect.TopLeft(),
     506             :                     m_bVertical ?
     507             :                     Size(nRubyHeight, aRect.GetHeight()) :
     508           0 :                     Size(aRect.GetWidth(), nRubyHeight));
     509             :         Rectangle aCharRect(aRect.TopLeft(),
     510             :                     m_bVertical ?
     511             :                     Size(nBaseHeight, aRect.GetHeight()) :
     512           0 :                     Size(aRect.GetWidth(), nBaseHeight));
     513             : 
     514           0 :         sal_Int32 nLineHeight = nBaseHeight + nRubyHeight;
     515             : 
     516             :         //detect count of rectangles
     517           0 :         sal_Int32 nLines = (m_bVertical ? aRect.GetWidth(): aRect.GetHeight()) / nLineHeight;
     518           0 :         if(nLines > pGridItem->GetLines())
     519           0 :             nLines = pGridItem->GetLines();
     520             : 
     521             :         // determine start position
     522           0 :         if(m_bVertical)
     523             :         {
     524           0 :             sal_Int16 nXStart = static_cast< sal_Int16 >(aRect.GetWidth() / 2 - nLineHeight * nLines /2);
     525           0 :             aRubyRect.Move(nXStart, 0);
     526           0 :             aCharRect.Move(nXStart, 0);
     527             :         }
     528             :         else
     529             :         {
     530           0 :             sal_Int16 nYStart = static_cast< sal_Int16 >(aRect.GetHeight() / 2 - nLineHeight * nLines /2);
     531           0 :             aRubyRect.Move(0, nYStart);
     532           0 :             aCharRect.Move(0, nYStart);
     533             :         }
     534             : 
     535           0 :         if(pGridItem->IsRubyTextBelow())
     536           0 :             m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
     537             :         else
     538           0 :             m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
     539             : 
     540             :         //vertical lines
     541           0 :         bool bBothLines = pGridItem->GetGridType() == GRID_LINES_CHARS;
     542           0 :         SetFillColor( Color( COL_TRANSPARENT ) );
     543           0 :         sal_Int32 nXMove = m_bVertical ? nLineHeight : 0;
     544           0 :         sal_Int32 nYMove = m_bVertical ? 0 : nLineHeight;
     545           0 :         for(sal_Int32 nLine = 0; nLine < nLines; nLine++)
     546             :         {
     547           0 :             DrawRect(aRubyRect);
     548           0 :             DrawRect(aCharRect);
     549           0 :             if(bBothLines)
     550             :             {
     551           0 :                 Point aStart = aCharRect.TopLeft();
     552           0 :                 Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
     553           0 :                 while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
     554             :                 {
     555           0 :                     DrawLine(aStart, aEnd);
     556           0 :                     if(m_bVertical)
     557           0 :                         aStart.Y() = aEnd.Y() += nBaseHeight;
     558             :                     else
     559           0 :                         aStart.X() = aEnd.X() += nBaseHeight;
     560             :                 }
     561             :             }
     562           0 :             aRubyRect.Move(nXMove, nYMove);
     563           0 :             aCharRect.Move(nXMove, nYMove);
     564             :         }
     565             :     }
     566           0 : }
     567             : 
     568           0 : void SwPageGridExample::UpdateExample( const SfxItemSet& rSet )
     569             : {
     570           0 :     DELETEZ(pGridItem);
     571             :     //get the grid information
     572           0 :     if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, true))
     573           0 :         pGridItem = (SwTextGridItem*)((const SwTextGridItem&)rSet.Get(RES_TEXTGRID)).Clone();
     574           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR, true ))
     575             :     {
     576             :         const SvxFrameDirectionItem& rDirItem =
     577           0 :                     (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
     578           0 :         m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
     579           0 :                     rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
     580             :     }
     581           0 :     SwPageExample::UpdateExample(rSet);
     582           0 : }
     583             : 
     584           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwPageGridExample(Window *pParent, VclBuilder::stringmap &)
     585             : {
     586           0 :     return new SwPageGridExample(pParent);
     587             : }
     588             : 
     589             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10