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

Generated by: LCOV version 1.10