LCOV - code coverage report
Current view: top level - sc/source/filter/qpro - qprostyle.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 6 61 9.8 %
Date: 2014-04-11 Functions: 1 2 50.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 <sal/config.h>
      21             : #include <stdio.h>
      22             : #include <sfx2/docfile.hxx>
      23             : 
      24             : #include "qproform.hxx"
      25             : #include "qpro.hxx"
      26             : #include "qprostyle.hxx"
      27             : 
      28             : #include <scitems.hxx>
      29             : #include <svx/algitem.hxx>
      30             : #include <editeng/udlnitem.hxx>
      31             : #include <editeng/wghtitem.hxx>
      32             : #include <editeng/postitem.hxx>
      33             : #include <editeng/crossedoutitem.hxx>
      34             : #include <editeng/fhgtitem.hxx>
      35             : #include <editeng/fontitem.hxx>
      36             : #include <editeng/justifyitem.hxx>
      37             : #include <map>
      38             : 
      39             : #include "global.hxx"
      40             : #include "scerrors.hxx"
      41             : #include "docpool.hxx"
      42             : #include "patattr.hxx"
      43             : #include "filter.hxx"
      44             : #include "document.hxx"
      45             : #include "formulacell.hxx"
      46             : 
      47           3 : ScQProStyle::ScQProStyle()
      48             : {
      49           3 :     memset (maAlign, 0, sizeof (maAlign));
      50           3 :     memset (maFont, 0, sizeof (maFont));
      51           3 :     memset (maFontRecord, 0, sizeof (maFontRecord));
      52           3 :     memset (maFontHeight, 0, sizeof (maFontHeight));
      53           3 : }
      54             : 
      55           0 : void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, SCTAB nTab, sal_uInt16 nStyle )
      56             : {
      57           0 :     if (nStyle >= maxsize)
      58           0 :         return;
      59             : 
      60           0 :     ScPatternAttr aPattern(pDoc->GetPool());
      61           0 :     SfxItemSet& rItemSet = aPattern.GetItemSet();
      62             : 
      63           0 :     sal_uInt8 nTmp = maAlign[ nStyle ];
      64           0 :     sal_uInt8 nHor = ( nTmp & 0x07 );
      65           0 :     sal_uInt8 nVer = ( nTmp & 0x18 );
      66           0 :     sal_uInt8 nOrient = ( nTmp & 0x60 );
      67             : 
      68             :     // Horizontal Alignment
      69           0 :     SvxCellHorJustify eJustify = SVX_HOR_JUSTIFY_STANDARD;
      70           0 :     switch( nHor )
      71             :     {
      72             :         case 0x00:
      73           0 :             eJustify = SVX_HOR_JUSTIFY_STANDARD;
      74           0 :             break;
      75             : 
      76             :         case 0x01:
      77           0 :             eJustify = SVX_HOR_JUSTIFY_LEFT;
      78           0 :             break;
      79             : 
      80             :         case 0x02:
      81           0 :             eJustify = SVX_HOR_JUSTIFY_CENTER;
      82           0 :             break;
      83             : 
      84             :         case 0x03:
      85           0 :             eJustify = SVX_HOR_JUSTIFY_RIGHT;
      86           0 :             break;
      87             : 
      88             :         case 0x04:
      89           0 :             eJustify = SVX_HOR_JUSTIFY_BLOCK;
      90           0 :             break;
      91             :     }
      92           0 :     rItemSet.Put( SvxHorJustifyItem( eJustify, ATTR_HOR_JUSTIFY ) );
      93             : 
      94             :     // Vertical Alignment
      95           0 :     SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
      96           0 :     switch( nVer )
      97             :     {
      98             :         case 0x00:
      99           0 :             eVerJustify = SVX_VER_JUSTIFY_BOTTOM;
     100           0 :             break;
     101             : 
     102             :         case 0x08:
     103           0 :             eVerJustify = SVX_VER_JUSTIFY_CENTER;
     104           0 :             break;
     105             : 
     106             :         case 0x10:
     107           0 :             eVerJustify = SVX_VER_JUSTIFY_TOP;
     108           0 :             break;
     109             :     }
     110             : 
     111           0 :     rItemSet.Put(SvxVerJustifyItem( eVerJustify, ATTR_VER_JUSTIFY ) );
     112             : 
     113             :     // Orientation
     114           0 :     SvxCellOrientation eOrient = SVX_ORIENTATION_STANDARD;
     115           0 :     switch( nOrient )
     116             :     {
     117             :         case 0x20:
     118           0 :             eOrient = SVX_ORIENTATION_TOPBOTTOM;
     119           0 :             break;
     120             : 
     121             :     }
     122           0 :     rItemSet.Put( SvxOrientationItem( eOrient, 0) );
     123             : 
     124             :     // Wrap cell contents
     125           0 :     if( nTmp & 0x80 )
     126             :     {
     127           0 :         SfxBoolItem aWrapItem( ATTR_LINEBREAK );
     128           0 :         aWrapItem.SetValue( true );
     129           0 :         rItemSet.Put( aWrapItem );
     130             :     }
     131             : 
     132             :     // Font Attributes
     133           0 :     sal_uInt16 nTmpFnt = maFontRecord[ maFont[ nStyle ] ];
     134             :     sal_Bool bIsBold, bIsItalic, bIsUnderLine;
     135             : 
     136           0 :     bIsBold = ( nTmpFnt & 0x0001 ) != 0;
     137           0 :     bIsItalic = ( nTmpFnt & 0x0002 ) != 0;
     138           0 :     bIsUnderLine = ( nTmpFnt & 0x0004 ) != 0;
     139             :     //(nTmpFnt & 0x0020 ) for StrikeThrough
     140             : 
     141           0 :     if( bIsBold )
     142           0 :         rItemSet.Put( SvxWeightItem( WEIGHT_BOLD,ATTR_FONT_WEIGHT) );
     143           0 :     if( bIsItalic )
     144           0 :         rItemSet.Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     145           0 :     if( bIsUnderLine )
     146           0 :         rItemSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
     147             : 
     148           0 :     if (maFontHeight[ maFont [ nStyle ] ])
     149           0 :         rItemSet.Put( SvxFontHeightItem( (sal_uLong) (20 * maFontHeight[ maFont[ nStyle ] ] ), 100, ATTR_FONT_HEIGHT ) );
     150             : 
     151           0 :     OUString fntName = maFontType[ maFont[ nStyle ] ];
     152           0 :     rItemSet.Put( SvxFontItem( FAMILY_SYSTEM, fntName, EMPTY_OUSTRING, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
     153             : 
     154           0 :     pDoc->ApplyPattern( nCol, nRow, nTab, aPattern );
     155             : }
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10