LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfframestyle.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 76 116 65.5 %
Date: 2015-06-13 12:38:46 Functions: 6 9 66.7 %
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             :  *
       4             :  *  The Contents of this file are made available subject to the terms of
       5             :  *  either of the following licenses
       6             :  *
       7             :  *         - GNU Lesser General Public License Version 2.1
       8             :  *         - Sun Industry Standards Source License Version 1.1
       9             :  *
      10             :  *  Sun Microsystems Inc., October, 2000
      11             :  *
      12             :  *  GNU Lesser General Public License Version 2.1
      13             :  *  =============================================
      14             :  *  Copyright 2000 by Sun Microsystems, Inc.
      15             :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16             :  *
      17             :  *  This library is free software; you can redistribute it and/or
      18             :  *  modify it under the terms of the GNU Lesser General Public
      19             :  *  License version 2.1, as published by the Free Software Foundation.
      20             :  *
      21             :  *  This library is distributed in the hope that it will be useful,
      22             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :  *  Lesser General Public License for more details.
      25             :  *
      26             :  *  You should have received a copy of the GNU Lesser General Public
      27             :  *  License along with this library; if not, write to the Free Software
      28             :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29             :  *  MA  02111-1307  USA
      30             :  *
      31             :  *
      32             :  *  Sun Industry Standards Source License Version 1.1
      33             :  *  =================================================
      34             :  *  The contents of this file are subject to the Sun Industry Standards
      35             :  *  Source License Version 1.1 (the "License"); You may not use this file
      36             :  *  except in compliance with the License. You may obtain a copy of the
      37             :  *  License at http://www.openoffice.org/license.html.
      38             :  *
      39             :  *  Software provided under this License is provided on an "AS IS" basis,
      40             :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41             :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42             :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43             :  *  See the License for the specific provisions governing your rights and
      44             :  *  obligations concerning the Software.
      45             :  *
      46             :  *  The Initial Developer of the Original Code is: IBM Corporation
      47             :  *
      48             :  *  Copyright: 2008 by IBM Corporation
      49             :  *
      50             :  *  All Rights Reserved.
      51             :  *
      52             :  *  Contributor(s): _______________________________________
      53             :  *
      54             :  *
      55             :  ************************************************************************/
      56             : /*************************************************************************
      57             :  * @file
      58             :  * Frame style include position,size,rotation and so on.
      59             :  ************************************************************************/
      60             : #include "xfframestyle.hxx"
      61             : #include "xfcolumns.hxx"
      62             : #include "xfborders.hxx"
      63             : #include "xfshadow.hxx"
      64             : #include "xfbgimage.hxx"
      65             : 
      66          31 : XFFrameStyle::XFFrameStyle()
      67             : {
      68          31 :     m_eWrap = enumXFWrapNone;
      69          31 :     m_nWrapLines = 0;   //not limited.
      70          31 :     m_pBorders = NULL;
      71          31 :     m_pColumns = NULL;
      72          31 :     m_pShadow = NULL;
      73          31 :     m_pBGImage = NULL;
      74             : 
      75          31 :     m_bProtectContent = false;
      76          31 :     m_bProtectSize = false;
      77          31 :     m_bProtectPos = false;
      78          31 :     m_bEditable = false;
      79          31 :     m_bPrintable = true;
      80          31 :     m_bBackground = false;
      81          31 :     m_nTransparency = 0;
      82             : 
      83          31 :     m_eTextDir = enumXFTextDirNone;
      84          31 :     m_eXPos = enumXFFrameXPosCenter;
      85          31 :     m_eXRel = enumXFFrameXRelParaContent;
      86          31 :     m_eYPos = enumXFFrameYPosTop;
      87          31 :     m_eYRel = enumXFFrameYRelPage;
      88          31 : }
      89             : 
      90          87 : XFFrameStyle::~XFFrameStyle()
      91             : {
      92          31 :     if( m_pBorders )
      93          16 :         delete m_pBorders;
      94          31 :     if( m_pColumns )
      95           0 :         delete m_pColumns;
      96          31 :     if( m_pShadow )
      97           0 :         delete m_pShadow;
      98          31 :     if( m_pBGImage )
      99           0 :         delete m_pBGImage;
     100          56 : }
     101             : 
     102          16 : void    XFFrameStyle::SetBorders(XFBorders *pBorders)
     103             : {
     104          16 :     if( m_pBorders )
     105           0 :         delete m_pBorders;
     106          16 :     m_pBorders = pBorders;
     107          16 : }
     108             : 
     109           0 : void    XFFrameStyle::SetColumns(XFColumns *pColumns)
     110             : {
     111           0 :     if( m_pColumns )
     112           0 :         delete m_pColumns;
     113           0 :     m_pColumns = pColumns;
     114           0 : }
     115             : 
     116           0 : void    XFFrameStyle::SetShadow(XFShadow *pShadow)
     117             : {
     118           0 :     if( m_pShadow )
     119           0 :         delete m_pShadow;
     120           0 :     m_pShadow = pShadow;
     121           0 : }
     122             : 
     123           0 : void    XFFrameStyle::SetBackImage(XFBGImage *image)
     124             : {
     125           0 :     if( m_pBGImage )
     126           0 :         delete m_pBGImage;
     127           0 :     m_pBGImage = image;
     128           0 : }
     129             : 
     130         465 : enumXFStyle XFFrameStyle::GetStyleFamily()
     131             : {
     132         465 :     return enumXFStyleGraphics;
     133             : }
     134             : 
     135          13 : void    XFFrameStyle::ToXml(IXFStream *pStrm)
     136             : {
     137          13 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     138             : 
     139          13 :     pAttrList->Clear();
     140          13 :     pAttrList->AddAttribute( "style:name", GetStyleName() );
     141          13 :     if( GetParentStyleName().getLength() > 0 )
     142           0 :         pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
     143          13 :     pAttrList->AddAttribute( "style:family", "graphics" );
     144             :     //parent style name ignore now.
     145          13 :     pStrm->StartElement( "style:style" );
     146             : 
     147          13 :     m_aMargins.ToXml(pStrm);
     148             : 
     149          13 :     pAttrList->Clear();
     150             : 
     151             :     /*if( m_eWrap == enumXFWrapBackground )
     152             :     {
     153             :         pAttrList->AddAttribute( "style:run-through", "background" );
     154             :     }
     155             :     else
     156             :     {*/
     157          13 :     if( m_bBackground)
     158           0 :         pAttrList->AddAttribute( "style:run-through", "background" );
     159             :     else
     160          13 :         pAttrList->AddAttribute( "style:run-through", "foreground" );
     161             : 
     162          13 :     if( m_eWrap == enumXFWrapNone )
     163           8 :         pAttrList->AddAttribute( "style:wrap", "none" );
     164           5 :     else if( m_eWrap == enumXFWrapLeft )
     165           0 :         pAttrList->AddAttribute( "style:wrap", "left" );
     166           5 :     else if( m_eWrap == enumXFWrapRight )
     167           4 :         pAttrList->AddAttribute( "style:wrap", "right" );
     168           1 :     else if( m_eWrap == enumXFWrapParallel )
     169           0 :         pAttrList->AddAttribute( "style:wrap", "parallel" );
     170           1 :     else if( m_eWrap == enumXFWrapRunThrough )
     171           1 :         pAttrList->AddAttribute( "style:wrap", "run-through" );
     172           0 :     else if( m_eWrap == enumXFWrapBest )
     173           0 :         pAttrList->AddAttribute( "style:wrap", "dynamic" );
     174             :     //}
     175             :     //background
     176          13 :     if( m_aBackColor.IsValid() )
     177             :     {
     178          13 :         pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
     179          13 :         pAttrList->AddAttribute( "style:background-transparency", OUString::number((sal_Int32)m_nTransparency) + "%");
     180             :     }
     181             : 
     182             :     //pad
     183          13 :     m_aPad.ToXml(pStrm);
     184             :     //margin:
     185          13 :     m_aMargins.ToXml(pStrm);
     186             :     //border
     187          13 :     if( m_pBorders )
     188           8 :         m_pBorders->ToXml(pStrm);
     189             :     else
     190           5 :         pAttrList->AddAttribute( "fo:border", "none" );
     191             :     //shadow
     192          13 :     if( m_pShadow )
     193           0 :         m_pShadow->ToXml(pStrm);
     194             :     //print
     195          13 :     if( m_bPrintable )
     196          13 :         pAttrList->AddAttribute( "style:print-content", "true" );
     197             :     //text directory
     198          13 :     if( m_eTextDir != enumXFTextDirNone )
     199          13 :         pAttrList->AddAttribute( "style:writing-mode", GetTextDirName(m_eTextDir) );
     200             :     //protect:
     201          13 :     if( m_bProtectContent || m_bProtectSize || m_bProtectPos )
     202             :     {
     203           0 :         OUString protect;
     204           0 :         if( m_bProtectContent )
     205           0 :             protect += "content";
     206           0 :         if( m_bProtectSize )
     207             :         {
     208           0 :             if( protect.getLength()>0 )
     209           0 :                 protect += " ";
     210           0 :             protect += "size";
     211             :         }
     212           0 :         if( m_bProtectPos )
     213             :         {
     214           0 :             if( protect.getLength()>0 )
     215           0 :                 protect += " ";
     216           0 :             protect += "position";
     217             :         }
     218           0 :         pAttrList->AddAttribute( "style:protect", protect );
     219             :     }
     220             :     //vertical pos and horizon pos:
     221          13 :     pAttrList->AddAttribute( "style:vertical-pos", GetFrameYPos(m_eYPos) );
     222          13 :     pAttrList->AddAttribute( "style:vertical-rel", GetFrameYRel(m_eYRel) );
     223          13 :     pAttrList->AddAttribute( "style:horizontal-pos", GetFrameXPos(m_eXPos) );
     224          13 :     pAttrList->AddAttribute( "style:horizontal-rel", GetFrameXRel(m_eXRel) );
     225             : 
     226          13 :     pStrm->StartElement( "style:properties" );
     227          13 :     if( m_pColumns )
     228           0 :         m_pColumns->ToXml(pStrm);
     229          13 :     if( m_pBGImage )
     230           0 :         m_pBGImage->ToXml(pStrm);
     231          13 :     pStrm->EndElement( "style:properties" );
     232             : 
     233          13 :     pStrm->EndElement( "style:style" );
     234          13 : }
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11