LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfparastyle.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 31 34 91.2 %
Date: 2015-06-13 12:38:46 Functions: 13 13 100.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             :  *
       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             :  * Styles for paragraph.
      59             :  * Styles for paragraph may include many style,include font,indent,margin,
      60             :  * shadow,line height,and so on.
      61             :  ************************************************************************/
      62             : #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFPARASTYLE_HXX
      63             : #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFPARASTYLE_HXX
      64             : 
      65             : #include <sal/config.h>
      66             : 
      67             : #include <rtl/ref.hxx>
      68             : 
      69             : #include "xffont.hxx"
      70             : #include "xfglobal.hxx"
      71             : #include "xfstyle.hxx"
      72             : #include "xfcolor.hxx"
      73             : #include "xfmargins.hxx"
      74             : #include "xfbreaks.hxx"
      75             : #include "xfpadding.hxx"
      76             : #include "xfshadow.hxx"
      77             : #include "xfdropcap.hxx"
      78             : #include "xfstylecont.hxx"
      79             : #include "xflineheight.hxx"
      80             : 
      81             : #define     XFPARA_FLAG_FONT        0X00000001
      82             : #define     XFPARA_FLAG_DROPCAP     0X00000002
      83             : #define     XFPARA_FLAG_BACKCOLOR   0X00000004
      84             : 
      85             : class XFBorders;
      86             : class XFBGImage;
      87             : 
      88             : /**
      89             :  * @brief
      90             :  * Style object for aragraph.
      91             :  */
      92             : class XFParaStyle : public XFStyle
      93             : {
      94             : public:
      95             :     XFParaStyle();
      96             : 
      97             :     XFParaStyle(const XFParaStyle& other);
      98             : 
      99             :     XFParaStyle& operator=(const XFParaStyle& other);
     100             : 
     101             :     virtual ~XFParaStyle();
     102             : 
     103             : public:
     104             :     /**
     105             :      * @descr   Set layout for the paragraph.When such property was setted, this paragraph will
     106             :      *          start at an new page.
     107             :      */
     108             :     void    SetMasterPage(const OUString& master);
     109             : 
     110             :     OUString GetMasterPage();
     111             : 
     112             :     /**
     113             :      * @descr   set the paragraph default font.
     114             :      * @param   font font object to be setted.Font object are deleted by font-factory,so
     115             :      *          dont't delete it in the destructure function of para style.
     116             :      */
     117             :     void    SetFont(rtl::Reference<XFFont> const & font);
     118             : 
     119             :     /**
     120             :      * @descr   get the font object.
     121             :      */
     122         272 :     rtl::Reference<XFFont> GetFont(){ return m_pFont; }
     123             : 
     124             :     /**
     125             :      * @descr   Set the indent of the paragraph.This is the indent for
     126             :                 the first line.
     127             :      * @param   indent value of the first-line indent.
     128             :      */
     129             :     void    SetIndent(double indent );
     130             : 
     131             :     /**
     132             :      * @descr   Set line number style.
     133             :      */
     134             :     void    SetLineNumber(bool show, sal_Int32 restart=1);
     135             :     /**
     136             :      * @descr   Set the pading of the paragraph.This is the distance
     137             :                 between the border and the top of the text.
     138             :      * @param   indent value of the padding.
     139             :      */
     140             :     void    SetPadding(double left, double right = -1, double top = -1, double bottom = -1);
     141             : 
     142             :     /**
     143             :      * @descr   Set the Margins of the paragraph.
     144             :      * @param   -1:     don't change.
     145             :                 other:  set value.
     146             :      */
     147             :     void    SetMargins(double left, double right=-1,double top=-1, double bottom=-1);
     148             : 
     149             :     /**
     150             :      * @descr   Set alignment property of the paragraph.
     151             :      * @param   eAlign alignment type,left,right,center or justify.
     152             :      */
     153             :     void    SetAlignType(enumXFAlignType eAlign);
     154             : 
     155             :     enumXFAlignType GetAlighType();
     156             : 
     157             :     /**
     158             :      * @descr   Set last line alignment property of the paragraph.
     159             :      * @param   eAlign alignment type,left,right,center or justify.
     160             :                 eJustSingleWord If chars of the last-line'word should be
     161             :                 stretched.
     162             :      */
     163             :     void    SetLastLineAlign(enumXFAlignType align,bool bJustSingleWord = false);
     164             : 
     165             :     /**
     166             :      * @descr   Set the shadow of the paragraph.there is 4 positions, you
     167             :                 can find it in the definition of enumShadowPos.
     168             :      * @param   pos
     169             :      * @param   offset the distance between the paragraph border and the shadow.
     170             :      * @param   color color to fill the shadow.
     171             :      */
     172             :     void    SetShadow(enumXFShadowPos pos, double offset, XFColor& color);
     173             : 
     174             :     /**
     175             :      * @descr   The borders is complex,so you have to create one before use.
     176             :                 Very few paragraphs will readly have borders property,this way
     177             :                 we can save much memory.
     178             :      * @param   pBorders borders of the paragraph,please reference the XFBorders.
     179             :      */
     180             :     void    SetBorders(XFBorders *pBorders);
     181             : 
     182             :     /**
     183             :      * @descr   Set drop caption of the paragraph.
     184             :      * @param   nLength number of chars to be dropped.
     185             :      * @param   nLines line of which the dropped chars will occupy.
     186             :      */
     187             :     void    SetDropCap(sal_Int16 nLength = 1,sal_Int16 nLines = 3,double fDistance = 0);
     188             : 
     189             :     /**
     190             :      * @descr   Set line height of the paragraph.
     191             :      * @param   type type of line height,fixed,space,percent or cm.
     192             :      * @param   value value of the line height
     193             :      */
     194             :     void    SetLineHeight(enumLHType type, double value);
     195             : 
     196             :     /**
     197             :      * @descr   Set background color of the paragraph.
     198             :      * @param   color value of the back color.
     199             :      */
     200             :     void    SetBackColor(XFColor& color);
     201             : 
     202             :     /**
     203             :      * @descr   Set background image of the paragraph.
     204             :      * @param   image the background image to set.
     205             :      */
     206             :     void    SetBackImage(XFBGImage *image);
     207             : 
     208             :     /**
     209             :      * descr    You can only set one break property for every para style object.
     210             :      */
     211             :     void    SetBreaks(enumXFBreaks breaks);
     212             : 
     213             :     /**
     214             :      * @descr   For paragraph numbering.
     215             :      */
     216             :     void    SetPageNumber(sal_Int32 num);
     217             : 
     218             :     /**
     219             :      * @descr   Add a tab style.
     220             :      */
     221             :     void    AddTabStyle(enumXFTab type, double len, sal_Unicode leader = '*', sal_Unicode delimiter='.');
     222             : 
     223             :     /**
     224             :      * @descr   for para style copy operator,sometimes you may need to override tab styles.
     225             :      */
     226             :     void    ClearTabStyles();
     227             : 
     228             :     /**
     229             :      * descr    set the paragraph to be in the same page with the next paragraph.
     230             :      *          If that can't be insured,the paragraph will start with a new page.
     231             :      */
     232             :     void    SetKeepWithNext(bool keepWithNext);
     233             : 
     234             :     sal_uInt32 GetFlag(){ return m_nFlag; }
     235             : 
     236           6 :     XFMargins& GetMargins(){return m_aMargin;}
     237             : 
     238             :     virtual enumXFStyle GetStyleFamily() SAL_OVERRIDE;
     239             : 
     240             :     virtual bool Equal(IXFStyle *pStyle) SAL_OVERRIDE;
     241             : 
     242             :     virtual void    ToXml(IXFStream *strm) SAL_OVERRIDE;
     243             : 
     244          28 :     void SetNumberRight(bool bFlag){m_bNumberRight = bFlag;}
     245           1 :     bool GetNumberRight(){return m_bNumberRight;}
     246             : 
     247             : protected:
     248             :     OUString   m_strMasterPage;
     249             :     enumXFAlignType m_eAlignType;
     250             :     enumXFAlignType m_eLastLineAlign;
     251             :     bool        m_bJustSingleWord;
     252             :     bool        m_bKeepWithNext;
     253             : 
     254             :     double      m_fTextIndent;
     255             :     XFColor     m_aBackColor;
     256             :     XFMargins   m_aMargin;
     257             :     XFPadding   m_aPadding;
     258             :     XFStyleContainer m_aTabs;
     259             :     rtl::Reference<XFFont> m_pFont;
     260             :     XFShadow    m_aShadow;
     261             :     XFBorders   *m_pBorders;
     262             :     XFBGImage   *m_pBGImage;
     263             :     XFDropcap   m_aDropcap;
     264             :     XFLineHeight m_aLineHeight;
     265             :     XFBreaks    m_aBreaks;
     266             :     sal_Int32   m_nPageNumber;
     267             :     bool    m_bNumberLines;
     268             :     sal_Int32   m_nLineNumberRestart;
     269             : 
     270             :     sal_uInt32  m_nFlag;
     271             :     bool m_bNumberRight;
     272             : };
     273             : 
     274          13 : inline void XFParaStyle::SetMasterPage(const OUString& master)
     275             : {
     276          13 :     m_strMasterPage = master;
     277          13 : }
     278             : 
     279          13 : inline void XFParaStyle::SetBreaks(enumXFBreaks breaks)
     280             : {
     281          13 :     m_aBreaks.SetBreakType(breaks);
     282          13 : }
     283             : 
     284             : inline void XFParaStyle::SetPageNumber(sal_Int32 num)
     285             : {
     286             :     assert(num>0);
     287             :     m_nPageNumber = num;
     288             : }
     289             : 
     290             : inline void XFParaStyle::SetLineNumber(bool show, sal_Int32 restart)
     291             : {
     292             :     m_bNumberLines = show;
     293             :     m_nLineNumberRestart = restart;
     294             : }
     295             : 
     296           2 : inline void XFParaStyle::SetPadding(double left, double right, double top, double bottom)
     297             : {
     298           2 :     m_aPadding.SetLeft(left);
     299           2 :     if( right == -1 )
     300           0 :         m_aPadding.SetRight(left);
     301             :     else
     302           2 :         m_aPadding.SetRight(right);
     303           2 :     if( top == -1 )
     304           0 :         m_aPadding.SetTop(left);
     305             :     else
     306           2 :         m_aPadding.SetTop(top);
     307           2 :     if( bottom == -1 )
     308           0 :         m_aPadding.SetBottom(left);
     309             :     else
     310           2 :         m_aPadding.SetBottom(bottom);
     311           2 : }
     312             : 
     313          24 : inline void XFParaStyle::SetAlignType(enumXFAlignType eAlign)
     314             : {
     315          24 :     m_eAlignType = eAlign;
     316          24 : }
     317             : 
     318             : inline void XFParaStyle::SetLastLineAlign(enumXFAlignType align, bool   bJustSingleWord)
     319             : {
     320             :     m_eLastLineAlign = align;
     321             :     m_bJustSingleWord = bJustSingleWord;
     322             : }
     323             : 
     324             : inline void XFParaStyle::SetKeepWithNext(bool keep)
     325             : {
     326             :     m_bKeepWithNext = keep;
     327             : }
     328             : 
     329           5 : inline void XFParaStyle::ClearTabStyles()
     330             : {
     331           5 :     m_aTabs.Reset();
     332           5 : }
     333             : 
     334          11 : inline  OUString XFParaStyle::GetMasterPage()
     335             : {
     336          11 :     return m_strMasterPage;
     337             : }
     338             : 
     339             : inline enumXFAlignType XFParaStyle::GetAlighType()
     340             : {
     341             :     return m_eAlignType;
     342             : }
     343             : 
     344           8 : class XFDefaultParaStyle : public XFStyle
     345             : {
     346             : public:
     347             :     XFDefaultParaStyle();
     348             :     void SetTabDistance(double len);
     349             :     enumXFStyle GetStyleFamily() SAL_OVERRIDE;
     350             :     virtual void    ToXml(IXFStream *pStrm) SAL_OVERRIDE;
     351             : private:
     352             :     double m_fTabDistance;
     353             : };
     354             : 
     355           4 : inline void XFDefaultParaStyle::SetTabDistance(double len)
     356             : {
     357           4 :     m_fTabDistance = len;
     358           4 : }
     359             : 
     360             : #endif
     361             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11