LCOV - code coverage report
Current view: top level - sw/source/core/uibase/frmdlg - colmgr.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 59 0.0 %
Date: 2014-04-14 Functions: 0 12 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 "hintids.hxx"
      21             : #include <editeng/lrspitem.hxx>
      22             : 
      23             : #include "frmmgr.hxx"
      24             : #include "frmfmt.hxx"
      25             : #include "colmgr.hxx"
      26             : 
      27             : // private methods
      28             : /*------------------------------------------------------------------------
      29             :  Description:   set column width to current width
      30             : ------------------------------------------------------------------------*/
      31           0 : void FitToActualSize(SwFmtCol& rCol, sal_uInt16 nWidth)
      32             : {
      33           0 :     const sal_uInt16 nCount = rCol.GetColumns().size();
      34           0 :     for(sal_uInt16 i = 0; i < nCount; ++i)
      35             :     {
      36           0 :         const sal_uInt16 nTmp = rCol.CalcColWidth(i, nWidth);
      37           0 :         rCol.GetColumns()[i].SetWishWidth(nTmp);
      38             :     }
      39           0 :     rCol.SetWishWidth(nWidth);
      40           0 : }
      41             : 
      42             : // public methods
      43             : /*------------------------------------------------------------------------
      44             :  Description:   set column quantity and Gutterwidth
      45             : ------------------------------------------------------------------------*/
      46           0 : void SwColMgr::SetCount(sal_uInt16 nCount, sal_uInt16  nGutterWidth)
      47             : {
      48           0 :     aFmtCol.Init(nCount, nGutterWidth, nWidth);
      49           0 :     aFmtCol.SetWishWidth(nWidth);
      50           0 :     aFmtCol.SetGutterWidth(nGutterWidth, nWidth);
      51           0 : }
      52             : 
      53           0 : sal_uInt16 SwColMgr::GetGutterWidth( sal_uInt16 nPos ) const
      54             : {
      55             :     sal_uInt16 nRet;
      56           0 :     if(nPos == USHRT_MAX )
      57           0 :         nRet = GetCount() > 1 ? aFmtCol.GetGutterWidth() : DEF_GUTTER_WIDTH;
      58             :     else
      59             :     {
      60             :         OSL_ENSURE(nPos < GetCount() - 1, "Spalte ueberindiziert" );
      61           0 :         const SwColumns& rCols = aFmtCol.GetColumns();
      62           0 :         nRet = rCols[nPos].GetRight() + rCols[nPos + 1].GetLeft();
      63             :     }
      64           0 :     return nRet;
      65             : }
      66             : 
      67           0 : void SwColMgr::SetGutterWidth(sal_uInt16 nGutterWidth, sal_uInt16 nPos )
      68             : {
      69           0 :     if(nPos == USHRT_MAX)
      70           0 :         aFmtCol.SetGutterWidth(nGutterWidth, nWidth);
      71             :     else
      72             :     {
      73             :         OSL_ENSURE(nPos < GetCount() - 1, "Spalte ueberindiziert" );
      74           0 :         SwColumns& rCols = aFmtCol.GetColumns();
      75           0 :         sal_uInt16 nGutterWidth2 = nGutterWidth / 2;
      76           0 :         rCols[nPos].SetRight(nGutterWidth2);
      77           0 :         rCols[nPos + 1].SetLeft(nGutterWidth2);
      78             :     }
      79           0 : }
      80             : 
      81             : /*------------------------------------------------------------------------
      82             :  Description:   height separation line
      83             : ------------------------------------------------------------------------*/
      84           0 : short SwColMgr::GetLineHeightPercent() const
      85             : {
      86           0 :     return (short)aFmtCol.GetLineHeight();
      87             : }
      88             : 
      89           0 : void SwColMgr::SetLineHeightPercent(short nPercent)
      90             : {
      91             :     OSL_ENSURE(nPercent <= 100, "line height may be at most 100 %");
      92           0 :     aFmtCol.SetLineHeight((sal_uInt8)nPercent);
      93           0 : }
      94             : 
      95             : /*------------------------------------------------------------------------
      96             :  Description:   column width
      97             : ------------------------------------------------------------------------*/
      98           0 : sal_uInt16 SwColMgr::GetColWidth(sal_uInt16 nIdx) const
      99             : {
     100             :     OSL_ENSURE(nIdx < GetCount(), "Spaltenarray ueberindiziert.");
     101           0 :     return aFmtCol.CalcPrtColWidth(nIdx, nWidth);
     102             : }
     103             : 
     104           0 : void SwColMgr::SetColWidth(sal_uInt16 nIdx, sal_uInt16 nWd)
     105             : {
     106             :     OSL_ENSURE(nIdx < GetCount(), "Spaltenarray ueberindiziert.");
     107           0 :     aFmtCol.GetColumns()[nIdx].SetWishWidth(nWd);
     108             : 
     109           0 : }
     110             : 
     111             : /*--------------------------------------------------------------------
     112             :     Description:    newly set size
     113             :  --------------------------------------------------------------------*/
     114           0 : void SwColMgr::SetActualWidth(sal_uInt16 nW)
     115             : {
     116           0 :     nWidth = nW;
     117           0 :     ::FitToActualSize(aFmtCol, nW);
     118           0 : }
     119             : 
     120             : /*--------------------------------------------------------------------
     121             :     Description: ctor
     122             :  --------------------------------------------------------------------*/
     123           0 : SwColMgr::SwColMgr(const SfxItemSet& rSet, sal_uInt16 nActWidth) :
     124           0 :     aFmtCol((const SwFmtCol&)rSet.Get(RES_COL)),
     125           0 :     nWidth(nActWidth)
     126             : {
     127           0 :     if(nWidth == USHRT_MAX)
     128             :     {
     129           0 :         nWidth = (sal_uInt16)((const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE)).GetWidth();
     130           0 :         if (nWidth < MINLAY)
     131           0 :             nWidth = USHRT_MAX;
     132           0 :         const SvxLRSpaceItem &rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
     133           0 :         nWidth = nWidth - (sal_uInt16)rLR.GetLeft();
     134           0 :         nWidth = nWidth - (sal_uInt16)rLR.GetRight();
     135             :     }
     136           0 :     ::FitToActualSize(aFmtCol, nWidth);
     137           0 : }
     138             : 
     139           0 : SwColMgr::~SwColMgr()
     140             : {
     141           0 : }
     142             : 
     143           0 : void SwColMgr::SetLineWidthAndColor(::editeng::SvxBorderStyle eStyle, sal_uLong nLWidth, const Color& rCol)
     144             : {
     145           0 :     aFmtCol.SetLineStyle(eStyle);
     146           0 :     aFmtCol.SetLineWidth(nLWidth);
     147           0 :     aFmtCol.SetLineColor(rCol);
     148           0 : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10