LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwplayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 529 865 61.2 %
Date: 2012-08-25 Functions: 90 118 76.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 379 979 38.7 %

           Branch data     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                 :            :  *  For LWP filter architecture prototype
      59                 :            :  ************************************************************************/
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  Jan 2005           Created
      63                 :            :  Feb 2005           Process gemotry, margins
      64                 :            :  ************************************************************************/
      65                 :            : 
      66                 :            : #include "lwplayout.hxx"
      67                 :            : #include "lwpusewhen.hxx"
      68                 :            : #include "lwptools.hxx"
      69                 :            : #include "xfilter/xfcolumns.hxx"
      70                 :            : #include "lwpstory.hxx"
      71                 :            : #include "lwpparastyle.hxx"
      72                 :            : #include "lwpholder.hxx"
      73                 :            : #include "lwpdoc.hxx"
      74                 :            : #include "lwppagehint.hxx"
      75                 :            : #include "lwpdivinfo.hxx"
      76                 :            : #include "lwpgrfobj.hxx"
      77                 :            : #include <osl/thread.h>
      78                 :            : 
      79                 :        399 : LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      80 [ +  - ][ +  - ]:        399 :     : LwpDLNFPVList(objHdr, pStrm)
      81                 :            : {
      82                 :        399 : }
      83                 :            : 
      84                 :        399 : void LwpVirtualLayout::Read()
      85                 :            : {
      86                 :        399 :     LwpDLNFPVList::Read();
      87                 :            : 
      88                 :        399 :     LwpObjectStream* pStrm = m_pObjStrm;
      89                 :        399 :     m_nAttributes = pStrm->QuickReaduInt32();
      90                 :        399 :     m_nAttributes2 = pStrm->QuickReaduInt32();
      91                 :        399 :     m_nAttributes3 = pStrm->QuickReaduInt32();
      92                 :        399 :     m_nOverrideFlag = pStrm->QuickReaduInt32();
      93                 :        399 :     m_nDirection = pStrm->QuickReaduInt16();
      94                 :            : 
      95                 :            :     //Note that two bytes is read into m_nEditorID instead of one byte.
      96                 :        399 :     m_nEditorID = pStrm->QuickReaduInt16();
      97                 :            : 
      98                 :        399 :     m_NextEnumerated.ReadIndexed(pStrm);
      99                 :        399 :     m_PreviousEnumerated.ReadIndexed(pStrm);
     100                 :            : 
     101                 :        399 :     pStrm->SkipExtra();
     102                 :        399 : }
     103                 :            : 
     104                 :       3069 : sal_Bool LwpVirtualLayout::MarginsSameAsParent()
     105                 :            : {
     106         [ +  + ]:       3069 :     return m_nAttributes2 & STYLE2_MARGINSSAMEASPARENT ? sal_True : sal_False;
     107                 :            : }
     108                 :            : 
     109                 :            : /**
     110                 :            : * @descr:   Get column width
     111                 :            : *
     112                 :            : */
     113                 :          0 : double LwpVirtualLayout::GetColWidth(sal_uInt16 /*nIndex*/)
     114                 :            : {
     115                 :            :     //return GetContentWidth(); //not support now
     116                 :            :     //return LwpTools::ConvertToMetric(5); //test
     117                 :          0 :     return 0; //test
     118                 :            : }
     119                 :            : 
     120                 :            : /**
     121                 :            : * @descr:   Get the gap between columns
     122                 :            : *
     123                 :            : */
     124                 :          0 : double LwpVirtualLayout::GetColGap(sal_uInt16 /*nIndex*/)
     125                 :            : {
     126                 :            :     //return DEFAULTGAPSIZE;
     127                 :            :     //return LwpTools::ConvertToMetric(0.17);//DEFAULTGAPSIZE=0.17
     128                 :          0 :     return LwpTools::ConvertToMetric(0.17);
     129                 :            : }
     130                 :            : 
     131                 :            : /**
     132                 :            : * @descr:   Whether it is honoring protection
     133                 :            : *
     134                 :            : */
     135                 :        369 : sal_Bool LwpVirtualLayout::HonorProtection()
     136                 :            : {
     137         [ -  + ]:        369 :     if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
     138                 :          0 :         return sal_False;
     139                 :            : 
     140         [ +  + ]:        369 :     LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
     141 [ +  + ][ +  - ]:        369 :     if(pParent && !pParent->IsHeader())
                 [ +  + ]
     142                 :            :     {
     143                 :          9 :         return pParent->HonorProtection();
     144                 :            :     }
     145                 :            : 
     146         [ +  + ]:        360 :     if(m_pFoundry)//is null now
     147                 :            :     {
     148                 :        354 :         LwpDocument* pDoc = m_pFoundry->GetDocument();
     149                 :            :         /*if(pDoc)
     150                 :            :         {
     151                 :            :             return pDoc->HonorProtection();
     152                 :            :         }*/
     153 [ +  - ][ +  - ]:        354 :         if(pDoc && pDoc->GetRootDocument())
                 [ +  - ]
     154                 :        354 :             return pDoc->GetRootDocument()->HonorProtection();
     155                 :            :     }
     156                 :            : 
     157                 :        369 :     return sal_True;
     158                 :            : }
     159                 :            : 
     160                 :            : /**
     161                 :            : * @descr:   Whether it is protected
     162                 :            : *
     163                 :            : */
     164                 :        351 : sal_Bool LwpVirtualLayout::IsProtected()
     165                 :            : {
     166                 :        351 :     sal_Bool bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
     167                 :            : 
     168         [ +  + ]:        351 :     LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
     169 [ +  + ][ +  - ]:        351 :     if(pParent && !pParent->IsHeader())
                 [ +  + ]
     170                 :            :     {
     171 [ +  - ][ +  - ]:          9 :         if(pParent->HonorProtection()&&(pParent->HasProtection()||bProtected))
         [ -  + ][ -  + ]
     172                 :            :         {
     173                 :          0 :             return sal_True;
     174                 :            :         }
     175                 :            :     }
     176         [ +  + ]:        342 :     else if(m_pFoundry)//is null now
     177                 :            :     {
     178                 :        336 :         LwpDocument* pDoc = m_pFoundry->GetDocument();
     179         [ +  - ]:        336 :         if(pDoc)
     180                 :            :         {
     181 [ +  - ][ -  + ]:        336 :             if (pDoc->HonorProtection() && bProtected)
                 [ -  + ]
     182                 :            :             {
     183                 :          0 :                 return sal_True;
     184                 :            :             }
     185                 :            :         }
     186                 :            :     }
     187                 :            : 
     188                 :        351 :     return sal_False;
     189                 :            : }
     190                 :            : 
     191                 :            : /**
     192                 :            : * @descr:   Whether it has protection
     193                 :            : *
     194                 :            : */
     195                 :         27 : sal_Bool LwpVirtualLayout::HasProtection()
     196                 :            : {
     197         [ -  + ]:         27 :     if(m_nAttributes & STYLE_PROTECTED)
     198                 :          0 :         return sal_True;
     199                 :            : 
     200         [ +  + ]:         27 :     LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
     201 [ +  + ][ +  - ]:         27 :     if(pParent && !pParent->IsHeader())
                 [ +  + ]
     202                 :            :     {
     203                 :         18 :         return pParent->HasProtection();
     204                 :            :     }
     205                 :            : 
     206                 :         27 :     return sal_False;
     207                 :            : }
     208                 :            : 
     209                 :            : /**
     210                 :            : * @descr:   Whether it is a mirror layout
     211                 :            : *
     212                 :            : */
     213                 :         36 : sal_Bool LwpVirtualLayout::IsComplex()
     214                 :            : {
     215         [ -  + ]:         36 :     return m_nAttributes & STYLE_COMPLEX ? sal_True : sal_False;
     216                 :            : }
     217                 :            : 
     218                 :            : /**
     219                 :            : * @descr:   Get usewhen pointer
     220                 :            : *
     221                 :            : */
     222                 :         36 : LwpUseWhen* LwpVirtualLayout::GetUseWhen()
     223                 :            : {
     224                 :            :     /*
     225                 :            :         If we have a parent, and I'm not a page layout,
     226                 :            :         use my parents information.
     227                 :            :     */
     228         [ -  + ]:         36 :     if(GetLayoutType()!=LWP_PAGE_LAYOUT)
     229                 :            :     {
     230                 :            :         //get parent
     231         [ #  # ]:          0 :         LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
     232 [ #  # ][ #  # ]:          0 :         if(pParent && !pParent->IsHeader()&& (pParent->GetLayoutType()!=LWP_PAGE_LAYOUT))
         [ #  # ][ #  # ]
     233                 :          0 :             return pParent->GetUseWhen();
     234                 :            : 
     235                 :            :     }
     236                 :            : 
     237                 :         36 :     return VirtualGetUseWhen();
     238                 :            : }
     239                 :            : /**
     240                 :            :  * @descr:  Whether this layout is page layout or not
     241                 :            :  * @param:
     242                 :            :  * @return:
     243                 :            : */
     244                 :         99 : sal_Bool LwpVirtualLayout::IsPage()
     245                 :            : {
     246                 :         99 :     return (GetLayoutType() == LWP_PAGE_LAYOUT);
     247                 :            : }
     248                 :            : /**
     249                 :            :  * @descr:  Whether this layout is heaer layout or not
     250                 :            :  * @param:
     251                 :            :  * @return:
     252                 :            : */
     253                 :        546 : sal_Bool LwpVirtualLayout::IsHeader()
     254                 :            : {
     255                 :        546 :     return (GetLayoutType() == LWP_HEADER_LAYOUT);
     256                 :            : }
     257                 :            : /**
     258                 :            :  * @descr:  Whether this layout is footer layout or not
     259                 :            :  * @param:
     260                 :            :  * @return:
     261                 :            : */
     262                 :         18 : sal_Bool LwpVirtualLayout::IsFooter()
     263                 :            : {
     264                 :         18 :     return (GetLayoutType() == LWP_FOOTER_LAYOUT);
     265                 :            : }
     266                 :            : /**
     267                 :            :  * @descr:  Whether this layout is frame layout or not
     268                 :            :  * @param:
     269                 :            :  * @return:
     270                 :            : */
     271                 :        135 : sal_Bool LwpVirtualLayout::IsFrame()
     272                 :            : {
     273                 :        135 :     return (GetLayoutType() == LWP_FRAME_LAYOUT);
     274                 :            : }
     275                 :            : 
     276                 :            : /**
     277                 :            :  * @descr:  Whether this layout is cell layout or not
     278                 :            :  * @param:
     279                 :            :  * @return:
     280                 :            : */
     281                 :        846 : sal_Bool LwpVirtualLayout::IsCell()
     282                 :            : {
     283                 :        846 :     return (GetLayoutType() == LWP_CELL_LAYOUT
     284                 :        834 :         || GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT
     285         [ -  + ]:       1680 :         || GetLayoutType() == LWP_HIDDEN_CELL_LAYOUT);
           [ +  +  +  - ]
     286                 :            : }
     287                 :            : /**
     288                 :            :  * @descr:  Whether this layout is supertable layout or not
     289                 :            :  * @param:
     290                 :            :  * @return:
     291                 :            : */
     292                 :         18 : sal_Bool LwpVirtualLayout::IsSuperTable()
     293                 :            : {
     294                 :         18 :     return (GetLayoutType() == LWP_SUPERTABLE_LAYOUT);
     295                 :            : }
     296                 :            : /**
     297                 :            :  * @descr:  Whether this layout is group layout or not
     298                 :            :  * @param:
     299                 :            :  * @return:
     300                 :            : */
     301                 :         75 : sal_Bool LwpVirtualLayout::IsGroupHead()
     302                 :            : {
     303                 :         75 :     return (GetLayoutType() == LWP_GROUP_LAYOUT);
     304                 :            : }
     305                 :            : /**
     306                 :            :  * @descr:  get the relative type
     307                 :            :  * @param:
     308                 :            :  * @return:
     309                 :            : */
     310                 :         81 : sal_uInt8 LwpVirtualLayout::GetRelativeType()
     311                 :            : {
     312                 :         81 :     return LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE;
     313                 :            : }
     314                 :            : /**
     315                 :            :  * @descr:  whether it is relative anchored layout
     316                 :            :  * @param:
     317                 :            :  * @return:
     318                 :            : */
     319                 :        528 : sal_Bool LwpVirtualLayout::IsRelativeAnchored()
     320                 :            : {
     321                 :            :     sal_uInt8 nType;
     322                 :            : 
     323                 :        528 :     nType = GetRelativeType();
     324                 :            :     return (nType == LwpLayoutRelativityGuts::LAY_PARA_RELATIVE) || (nType == LwpLayoutRelativityGuts::LAY_INLINE)
     325 [ +  - ][ +  + ]:        528 :     || (nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE) || (nType == LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL);
         [ +  + ][ +  + ]
     326                 :            : }
     327                 :            : /**
     328                 :            :  * @descr:  whether it is MinimumHeight layout
     329                 :            :  * @param:
     330                 :            :  * @return:
     331                 :            : */
     332                 :          0 : sal_Bool LwpVirtualLayout::IsMinimumHeight()
     333                 :            : {
     334                 :          0 :     return ((m_nAttributes3& STYLE3_MINHEIGHTVALID) != 0);
     335                 :            : }
     336                 :            : 
     337                 :            : /**
     338                 :            : * @descr:   Get parent layout
     339                 :            : *
     340                 :            : */
     341                 :         84 : LwpVirtualLayout* LwpVirtualLayout::GetParentLayout()
     342                 :            : {
     343         [ +  - ]:         84 :     return dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
     344                 :            : }
     345                 :            : 
     346                 :            : /**
     347                 :            : * @descr:   Register child layout style
     348                 :            : *
     349                 :            : */
     350                 :        153 : void LwpVirtualLayout::RegisterChildStyle()
     351                 :            : {
     352                 :            :     //Register all children styles
     353         [ +  + ]:        153 :     LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
     354         [ +  + ]:        201 :     while(pLayout)
     355                 :            :     {
     356                 :         48 :         pLayout->SetFoundry(m_pFoundry);
     357                 :         48 :         pLayout->RegisterStyle();
     358         [ +  + ]:         48 :         pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
     359                 :            :     }
     360                 :        153 : }
     361                 :            : 
     362                 :          0 : sal_Bool LwpVirtualLayout::NoContentReference()
     363                 :            : {
     364                 :          0 :     return (m_nAttributes2 & STYLE2_NOCONTENTREFERENCE) != 0;
     365                 :            : }
     366                 :            : 
     367                 :          0 : sal_Bool LwpVirtualLayout::IsStyleLayout()
     368                 :            : {
     369         [ #  # ]:          0 :     if (m_nAttributes3 & STYLE3_STYLELAYOUT)
     370                 :          0 :         return sal_True;
     371                 :            : 
     372         [ #  # ]:          0 :     LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*>(GetParent()->obj());
     373         [ #  # ]:          0 :     if (pParent)
     374                 :          0 :         return pParent->IsStyleLayout();
     375                 :          0 :     return sal_False;
     376                 :            : }
     377                 :            : 
     378                 :            : /**
     379                 :            : * @descr:   Find child layout by layout type
     380                 :            : *
     381                 :            : */
     382                 :          0 : LwpVirtualLayout* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType)
     383                 :            : {
     384                 :          0 :     LwpObjectID *pID = GetChildHead();
     385                 :            : 
     386 [ #  # ][ #  # ]:          0 :     while(pID && !pID->IsNull())
                 [ #  # ]
     387                 :            :     {
     388         [ #  # ]:          0 :         LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(pID->obj());
     389         [ #  # ]:          0 :         if(!pLayout)
     390                 :            :         {
     391                 :          0 :             break;
     392                 :            :         }
     393                 :            : 
     394 [ #  # ][ #  # ]:          0 :         if (pLayout && pLayout->GetLayoutType() == eType)
                 [ #  # ]
     395                 :            :         {
     396                 :          0 :             return pLayout;
     397                 :            :         }
     398                 :          0 :         pID = pLayout->GetNext();
     399                 :            :     }
     400                 :            : 
     401                 :          0 :     return NULL;
     402                 :            : }
     403                 :            : 
     404                 :            : /**
     405                 :            : * @descr:   Whether the size of layout is fit the graphic
     406                 :            : *
     407                 :            : */
     408                 :         75 : sal_Bool LwpVirtualLayout::IsFitGraphic()
     409                 :            : {
     410 [ +  + ][ +  - ]:         75 :     return IsAutoGrowRight() && !IsAutoGrowLeft() && IsAutoGrowDown();
                 [ +  - ]
     411                 :            : }
     412                 :            : 
     413                 :            : /**
     414                 :            : * @descr:   Whether the width of layout is auto grow
     415                 :            : *
     416                 :            : */
     417                 :          0 : sal_Bool LwpVirtualLayout::IsAutoGrowWidth()
     418                 :            : {
     419 [ #  # ][ #  # ]:          0 :     return IsAutoGrowLeft() || IsAutoGrowRight();
     420                 :            : }
     421                 :            : 
     422                 :            : /**
     423                 :            : * @descr:   Determine whether the layout width is to margin
     424                 :            : *
     425                 :            : */
     426                 :        126 : sal_Bool LwpVirtualLayout::IsInlineToMargin()
     427                 :            : {
     428                 :        126 :     return (m_nAttributes3 & STYLE3_INLINETOMARGIN) != 0;
     429                 :            : }
     430                 :            : 
     431                 :        258 : void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm)
     432                 :            : {
     433                 :        258 :     m_OnlyLayout.ReadIndexed(pStrm);
     434                 :        258 :     m_Layouts.Read(pStrm);
     435                 :        258 :     pStrm->SkipExtra();
     436                 :        258 : }
     437                 :            : 
     438                 :            : /**
     439                 :            : * @descr:   Looking for the layout which follows the pStartLayout
     440                 :            : * @param:   pStartLayout - the layout which is used for looking for its following layout
     441                 :            : */
     442                 :       1440 : LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout)
     443                 :            : {
     444                 :       1440 :     LwpVirtualLayout* pLayout = NULL;
     445                 :            : 
     446 [ +  + ][ +  + ]:       1440 :     if (!pStartLayout && !m_OnlyLayout.IsNull())
                 [ +  + ]
     447                 :            :         /* Looking for the first layout and there's only one layout in  the list.*/
     448         [ +  - ]:       1152 :         return dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj());
     449                 :            : 
     450         [ +  - ]:        288 :     LwpObjectHolder* pObjHolder = dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead()->obj());
     451         [ -  + ]:        288 :     if(pObjHolder)
     452                 :            :     {
     453         [ #  # ]:          0 :         pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
     454         [ #  # ]:          0 :         if(!pStartLayout )
     455                 :          0 :             return pLayout;
     456                 :            : 
     457 [ #  # ][ #  # ]:          0 :         while(pObjHolder && pStartLayout != pLayout)
                 [ #  # ]
     458                 :            :         {
     459         [ #  # ]:          0 :             pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
     460         [ #  # ]:          0 :             if(pObjHolder)
     461                 :            :             {
     462         [ #  # ]:          0 :                 pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
     463                 :            :             }
     464                 :            :         }
     465                 :            : 
     466         [ #  # ]:          0 :         if(pObjHolder)
     467                 :            :         {
     468         [ #  # ]:          0 :             pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
     469         [ #  # ]:          0 :             if(pObjHolder)
     470                 :            :             {
     471         [ #  # ]:          0 :                 pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
     472                 :          0 :                 return pLayout;
     473                 :            :             }
     474                 :            :         }
     475                 :            : 
     476                 :            :         //return pLayout;
     477                 :            :     }
     478                 :            : 
     479                 :       1440 :     return NULL;
     480                 :            : }
     481                 :            : 
     482                 :         96 : LwpHeadLayout::LwpHeadLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     483                 :         96 :     : LwpVirtualLayout(objHdr, pStrm)
     484                 :         96 : {}
     485                 :            : 
     486                 :         96 : void LwpHeadLayout::Read()
     487                 :            : {
     488                 :         96 :     LwpVirtualLayout::Read();
     489                 :            :     //For PermissiveLayout
     490                 :         96 :     m_pObjStrm->SkipExtra();
     491                 :            :     //For me
     492                 :         96 :     m_pObjStrm->SkipExtra();
     493                 :         96 : }
     494                 :            : 
     495                 :         96 : void LwpHeadLayout::RegisterStyle()
     496                 :            : {
     497                 :            :     //Register all children styles
     498         [ +  + ]:         96 :     LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
     499         [ +  + ]:        312 :     while(pLayout)
     500                 :            :     {
     501                 :        216 :         pLayout->SetFoundry(m_pFoundry);
     502                 :            :         //if the layout is relative to para, the layout will be registered in para
     503         [ +  + ]:        216 :         if(!pLayout->IsRelativeAnchored())
     504                 :            :         {
     505         [ -  + ]:        105 :             if (pLayout == this)
     506                 :            :             {
     507                 :            :                 OSL_FAIL("Layout points to itself");
     508                 :          0 :                 break;
     509                 :            :             }
     510                 :        105 :             pLayout->RegisterStyle();
     511                 :            :         }
     512         [ +  + ]:        216 :         LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
     513         [ -  + ]:        216 :         if (pNext == pLayout)
     514                 :            :         {
     515                 :            :             OSL_FAIL("Layout points to itself");
     516                 :          0 :             break;
     517                 :            :         }
     518                 :        216 :         pLayout = pNext;
     519                 :            :     }
     520                 :         96 : }
     521                 :            : 
     522                 :            : /**
     523                 :            :  * @descr   find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
     524                 :            :  * @return pointer to endnote supertable layout
     525                 :            :  */
     526                 :         21 : LwpVirtualLayout* LwpHeadLayout::FindEnSuperTableLayout()
     527                 :            : {
     528         [ -  + ]:         21 :     LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
     529         [ +  + ]:        162 :     while(pLayout)
     530                 :            :     {
     531         [ -  + ]:        141 :         if(pLayout->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT)
     532                 :            :         {
     533                 :          0 :             return pLayout;
     534                 :            :         }
     535         [ +  + ]:        141 :         pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
     536                 :            :     }
     537                 :         21 :     return NULL;
     538                 :            : }
     539                 :            : 
     540                 :        285 : LwpLayoutStyle::LwpLayoutStyle()
     541                 :            :     : m_nStyleDefinition(0)
     542         [ +  - ]:        285 :     , m_pDescription(new LwpAtomHolder)
     543                 :        285 :     , m_nKey(0)
     544                 :            : {
     545                 :        285 : }
     546                 :            : 
     547                 :        570 : LwpLayoutStyle::~LwpLayoutStyle()
     548                 :            : {
     549         [ +  - ]:        285 :     delete m_pDescription;
     550         [ -  + ]:        570 : }
     551                 :            : 
     552                 :         84 : void LwpLayoutStyle::Read(LwpObjectStream* pStrm)
     553                 :            : {
     554                 :         84 :     m_nStyleDefinition = pStrm->QuickReaduInt32();
     555                 :         84 :     m_pDescription->Read(pStrm);
     556         [ +  + ]:         84 :     if (pStrm->CheckExtra())
     557                 :            :     {
     558                 :         63 :         m_nKey = pStrm->QuickReaduInt16();
     559                 :         63 :         pStrm->SkipExtra();
     560                 :            :     }
     561                 :         84 : }
     562                 :            : 
     563                 :        285 : LwpLayoutMisc::LwpLayoutMisc() :
     564                 :            : m_nGridDistance(0), m_nGridType(0),
     565         [ +  - ]:        285 : m_pContentStyle(new LwpAtomHolder)
     566                 :            : {
     567                 :        285 : }
     568                 :            : 
     569                 :        570 : LwpLayoutMisc::~LwpLayoutMisc()
     570                 :            : {
     571         [ +  - ]:        285 :     if (m_pContentStyle)
     572                 :            :     {
     573         [ +  - ]:        285 :         delete m_pContentStyle;
     574                 :            :     }
     575         [ -  + ]:        570 : }
     576                 :            : 
     577                 :        117 : void LwpLayoutMisc::Read(LwpObjectStream* pStrm)
     578                 :            : {
     579                 :        117 :     m_nGridType = pStrm->QuickReaduInt16();
     580                 :        117 :     m_nGridDistance = pStrm->QuickReadInt32();
     581                 :        117 :     m_pContentStyle->Read(pStrm);
     582                 :        117 :     pStrm->SkipExtra();
     583                 :        117 : }
     584                 :            : 
     585                 :        285 : LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm )
     586                 :            :     : LwpVirtualLayout(objHdr, pStrm),
     587 [ +  - ][ +  - ]:        285 :       m_pStyleStuff(new LwpLayoutStyle), m_pMiscStuff(new LwpLayoutMisc)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     588                 :        285 : {}
     589                 :            : 
     590                 :        285 : LwpMiddleLayout::~LwpMiddleLayout()
     591                 :            : {
     592         [ +  - ]:        285 :     if (m_pStyleStuff)
     593                 :            :     {
     594 [ +  - ][ +  - ]:        285 :         delete m_pStyleStuff;
     595                 :            :     }
     596         [ +  - ]:        285 :     if (m_pMiscStuff)
     597                 :            :     {
     598 [ +  - ][ +  - ]:        285 :         delete m_pMiscStuff;
     599                 :            :     }
     600         [ -  + ]:        285 : }
     601                 :        285 : void LwpMiddleLayout::Read()
     602                 :            : {
     603                 :        285 :     LwpObjectStream* pStrm = m_pObjStrm;
     604                 :            : 
     605         [ +  - ]:        285 :     LwpVirtualLayout::Read();
     606                 :            : 
     607                 :            :     //skip CLiteLayout data;
     608         [ +  - ]:        285 :     LwpAtomHolder ContentClass;
     609         [ +  - ]:        285 :     ContentClass.Read(pStrm);
     610         [ +  - ]:        285 :     pStrm->SkipExtra();
     611                 :            : 
     612                 :            :     // before layout hierarchy rework
     613         [ -  + ]:        285 :     if(LwpFileHeader::m_nFileRevision < 0x000B)
     614                 :        285 :         return;
     615                 :            : 
     616         [ +  - ]:        285 :     m_Content.ReadIndexed(pStrm);
     617                 :            : 
     618                 :            :     // 01/20/2005
     619         [ +  - ]:        285 :     m_BasedOnStyle.ReadIndexed(pStrm);
     620         [ +  - ]:        285 :     m_TabPiece.ReadIndexed(pStrm);
     621                 :            : 
     622         [ +  - ]:        285 :     sal_uInt8 nWhatsItGot = pStrm->QuickReaduInt8();
     623                 :            : 
     624         [ +  + ]:        285 :     if (nWhatsItGot & DISK_GOT_STYLE_STUFF)
     625                 :            :     {
     626         [ +  - ]:         84 :         m_pStyleStuff->Read(pStrm);
     627                 :            :     }
     628         [ +  + ]:        285 :     if (nWhatsItGot & DISK_GOT_MISC_STUFF)
     629                 :            :     {
     630         [ +  - ]:        117 :         m_pMiscStuff->Read(pStrm);
     631                 :            :     }
     632                 :            : 
     633         [ +  - ]:        285 :     m_LayGeometry.ReadIndexed(pStrm);
     634         [ +  - ]:        285 :     m_LayScale.ReadIndexed(pStrm);
     635         [ +  - ]:        285 :     m_LayMargins.ReadIndexed(pStrm);
     636         [ +  - ]:        285 :     m_LayBorderStuff.ReadIndexed(pStrm);
     637         [ +  - ]:        285 :     m_LayBackgroundStuff.ReadIndexed(pStrm);
     638                 :            : 
     639 [ +  - ][ +  + ]:        285 :     if (pStrm->CheckExtra())
     640                 :            :     {
     641         [ +  - ]:        237 :         m_LayExtBorderStuff.ReadIndexed(pStrm);
     642         [ +  - ]:        285 :         pStrm->SkipExtra();
     643 [ +  - ][ +  - ]:        285 :     }
     644                 :            :     //end
     645                 :            : }
     646                 :            : 
     647                 :            : #include "lwplaypiece.hxx"
     648                 :            : 
     649                 :            : /**
     650                 :            : * @descr:   Get the geometry of current layout
     651                 :            : *
     652                 :            : */
     653                 :        924 : LwpLayoutGeometry* LwpMiddleLayout::GetGeometry()
     654                 :            : {
     655         [ +  + ]:        924 :     if( !m_LayGeometry.IsNull() )
     656                 :            :     {
     657         [ +  - ]:        717 :         return ( dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj()) );
     658                 :            :     }
     659         [ +  - ]:        207 :     else if( !m_BasedOnStyle.IsNull() )
     660                 :            :     {
     661         [ -  + ]:        207 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
     662         [ +  - ]:        207 :         return pLay ? pLay->GetGeometry() : NULL;
     663                 :            :     }
     664                 :        924 :     return NULL;
     665                 :            : }
     666                 :            : 
     667                 :            : /**
     668                 :            : * @descr:   Get layout height, measured by "cm"
     669                 :            : *
     670                 :            : */
     671                 :        195 : double LwpMiddleLayout::GetGeometryHeight()
     672                 :            : {
     673                 :        195 :     LwpLayoutGeometry* pGeo = GetGeometry();
     674         [ +  - ]:        195 :     if(pGeo)
     675                 :            :     {
     676                 :        195 :         return ( LwpTools::ConvertFromUnitsToMetric( pGeo->GetHeight() ) );
     677                 :            :     }
     678                 :            :     else
     679                 :        195 :         return -1;
     680                 :            : }
     681                 :            : 
     682                 :            : /**
     683                 :            : * @descr:   Get layout width, measured by "cm"
     684                 :            : *
     685                 :            : */
     686                 :        216 : double LwpMiddleLayout::GetGeometryWidth()
     687                 :            : {
     688                 :        216 :     LwpLayoutGeometry* pGeo = GetGeometry();
     689         [ +  - ]:        216 :     if(pGeo)
     690                 :            :     {
     691                 :        216 :         return ( LwpTools::ConvertFromUnitsToMetric( pGeo->GetWidth() ) );
     692                 :            :     }
     693                 :            :     else
     694                 :        216 :         return -1;
     695                 :            : }
     696                 :            : 
     697                 :            : /**
     698                 :            : * @descr:   Whether the margins is same as parent layout
     699                 :            : *
     700                 :            : */
     701                 :       3069 : sal_Bool LwpMiddleLayout::MarginsSameAsParent()
     702                 :            : {
     703         [ +  + ]:       3069 :     if(m_nOverrideFlag & OVER_MARGINS)
     704                 :            :     {
     705                 :       1956 :         return LwpVirtualLayout::MarginsSameAsParent();
     706                 :            :     }
     707         [ +  + ]:       1113 :     if(!m_BasedOnStyle.IsNull())
     708                 :            :     {
     709         [ -  + ]:       1083 :         LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
     710         [ +  - ]:       1083 :         if (pLay)
     711                 :       1083 :             pLay->MarginsSameAsParent();
     712                 :            :     }
     713                 :       3069 :     return LwpVirtualLayout::MarginsSameAsParent();
     714                 :            : 
     715                 :            : }
     716                 :            : 
     717                 :            : /**
     718                 :            : * @descr:   Get margin
     719                 :            : * @param:   nWhichSide - 0: left, 1: right, 2:top, 3: bottom
     720                 :            : */
     721                 :       3588 : double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide)
     722                 :            : {
     723                 :       3588 :     double fValue = 0;
     724 [ +  + ][ +  + ]:       3588 :     if((nWhichSide==MARGIN_LEFT)||(nWhichSide==MARGIN_RIGHT))
     725                 :            :     {
     726         [ +  + ]:       1986 :         if ( MarginsSameAsParent() )
     727                 :            :         {
     728         [ -  + ]:        102 :             LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
     729 [ +  - ][ +  - ]:        102 :             if(pParent && !pParent->IsHeader())
                 [ +  - ]
     730                 :            :             {
     731                 :        102 :                 fValue = pParent->GetMarginsValue(nWhichSide);
     732                 :        102 :                 return fValue;
     733                 :            :             }
     734                 :            :         }
     735                 :            :     }
     736                 :            : 
     737         [ +  + ]:       3486 :     if(m_nOverrideFlag & OVER_MARGINS)
     738                 :            :     {
     739         [ -  + ]:       2067 :         LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*> (m_LayMargins.obj());
     740         [ +  - ]:       2067 :         if(pMar1)
     741                 :            :         {
     742                 :       2067 :             fValue = pMar1->GetMargins()->GetMarginsValue(nWhichSide);
     743                 :       2067 :             return fValue;
     744                 :            :         }
     745                 :            :     }
     746         [ +  + ]:       1419 :     LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
     747         [ +  + ]:       1419 :     if(pStyle)
     748                 :            :     {
     749                 :       1404 :         fValue = pStyle->GetMarginsValue(nWhichSide);
     750                 :       1404 :         return fValue;
     751                 :            :     }
     752                 :       3588 :     return LwpVirtualLayout::GetMarginsValue(nWhichSide);
     753                 :            : }
     754                 :            : /**
     755                 :            :  * @descr:  Get extmargin value
     756                 :            :  * @param:  nWhichSide - 0: left, 1: right, 2:top, 3: bottom
     757                 :            :  * @param:
     758                 :            :  * @return:
     759                 :            : */
     760                 :       1152 : double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8 &nWhichSide)
     761                 :            : {
     762                 :       1152 :     double fValue = 0;
     763         [ +  + ]:       1152 :     if(m_nOverrideFlag & OVER_MARGINS)
     764                 :            :     {
     765         [ -  + ]:        432 :         LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*> (m_LayMargins.obj());
     766         [ +  - ]:        432 :         if(pMar1)
     767                 :            :         {
     768                 :        432 :             fValue = pMar1->GetExtMargins()->GetMarginsValue(nWhichSide);
     769                 :        432 :             return fValue;
     770                 :            :         }
     771                 :            :     }
     772         [ -  + ]:        720 :     LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
     773         [ +  - ]:        720 :     if(pStyle)
     774                 :            :     {
     775                 :        720 :         fValue = pStyle->GetExtMarginsValue(nWhichSide);
     776                 :        720 :         return fValue;
     777                 :            :     }
     778                 :       1152 :     return LwpVirtualLayout::GetExtMarginsValue(nWhichSide);
     779                 :            : }
     780                 :            : /**
     781                 :            :  * @descr:  Get the LwpBorderStuff object according to m_LayBorderStuff id.
     782                 :            :  * @param:
     783                 :            :  * @param:
     784                 :            :  * @return:
     785                 :            : */
     786                 :        642 : LwpBorderStuff* LwpMiddleLayout::GetBorderStuff()
     787                 :            : {
     788         [ +  + ]:        642 :     if(m_nOverrideFlag & OVER_BORDERS)
     789                 :            :     {
     790         [ -  + ]:        381 :         LwpLayoutBorder* pLayoutBorder = dynamic_cast<LwpLayoutBorder*>(m_LayBorderStuff.obj());
     791         [ +  - ]:        381 :         return pLayoutBorder ? pLayoutBorder->GetBorderStuff() : NULL;
     792                 :            :     }
     793         [ +  + ]:        261 :     else if( !m_BasedOnStyle.IsNull() )
     794                 :            :     {
     795         [ -  + ]:        117 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
     796         [ +  - ]:        117 :         return pLay ? pLay->GetBorderStuff() :  NULL;
     797                 :            :     }
     798                 :        642 :     return NULL;
     799                 :            : }
     800                 :            : 
     801                 :            : /**
     802                 :            :  * @descr:  Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
     803                 :            :  * @param:
     804                 :            :  * @param:
     805                 :            :  * @return:
     806                 :            : */
     807                 :        996 : LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
     808                 :            : {
     809         [ +  + ]:        996 :     if(m_nOverrideFlag & OVER_BACKGROUND)
     810                 :            :     {
     811         [ -  + ]:        540 :         LwpLayoutBackground* pLayoutBackground = dynamic_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj());
     812         [ +  - ]:        540 :         return pLayoutBackground ? pLayoutBackground->GetBackgoudStuff() : NULL;
     813                 :            :     }
     814         [ +  - ]:        456 :     else if( !m_BasedOnStyle.IsNull() )
     815                 :            :     {
     816         [ -  + ]:        456 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
     817         [ +  - ]:        456 :         return pLay ? pLay->GetBackgroundStuff() : NULL;
     818                 :            :     }
     819                 :        996 :     return NULL;
     820                 :            : }
     821                 :            : /**
     822                 :            :  * @descr:  create xfborder.
     823                 :            :  * @param:
     824                 :            :  * @param:
     825                 :            :  * @return:
     826                 :            : */
     827                 :        525 : XFBorders* LwpMiddleLayout::GetXFBorders()
     828                 :            : {
     829                 :        525 :     LwpBorderStuff* pBorderStuff = GetBorderStuff();
     830 [ +  + ][ +  + ]:        525 :     if(pBorderStuff&&pBorderStuff->GetSide() != 0)
                 [ +  + ]
     831                 :            :     {
     832                 :            :         //copy from lwpparastyle.
     833 [ +  - ][ +  - ]:        258 :         XFBorders   *pXFBorders = new XFBorders();
     834                 :            :         // apply 4 borders respectively
     835                 :            :         LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
     836                 :        258 :             LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
     837                 :            : 
     838         [ +  + ]:       1290 :         for (sal_uInt8 nC = 0; nC < 4; nC++)
     839                 :            :         {
     840 [ +  - ][ +  - ]:       1032 :             if (pBorderStuff->HasSide(pType[nC]))
     841                 :            :             {
     842         [ +  - ]:       1032 :                 LwpParaStyle::ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
     843                 :            :             }
     844                 :            :         }
     845                 :        258 :         return pXFBorders;
     846                 :            :     }
     847                 :        525 :     return NULL;
     848                 :            : }
     849                 :            : 
     850                 :            : /**
     851                 :            :  * @descr:  Get text direction settings.
     852                 :            :  * @param:
     853                 :            :  * @param:
     854                 :            :  * @return:
     855                 :            : */
     856                 :         99 : enumXFTextDir LwpMiddleLayout::GetTextDirection()
     857                 :            : {
     858                 :         99 :     enumXFTextDir eTextDir = enumXFTextDirNone;
     859                 :         99 :     sal_uInt8 nDirection = GetContentOrientation();
     860   [ +  -  -  -  :         99 :     switch(nDirection)
                      - ]
     861                 :            :     {
     862                 :            :         case TEXT_ORIENT_LRTB:
     863                 :            :         {
     864                 :         99 :             eTextDir = enumXFTextDirLR_TB;
     865                 :         99 :             break;
     866                 :            :         }
     867                 :            :         case TEXT_ORIENT_TBRL:
     868                 :            :         {
     869                 :          0 :             eTextDir = enumXFTextDirTB_RL;
     870                 :          0 :             break;
     871                 :            :         }
     872                 :            :         case TEXT_ORIENT_RLBT: // not supported now
     873                 :            :         {
     874                 :          0 :             eTextDir = enumXFTextDirNone;
     875                 :          0 :             break;
     876                 :            :         }
     877                 :            :         case TEXT_ORIENT_BTLR: // not supported now
     878                 :            :         {
     879                 :          0 :             eTextDir = enumXFTextDirNone;
     880                 :          0 :             break;
     881                 :            :         }
     882                 :            :         default:
     883                 :          0 :             break;
     884                 :            :     }
     885                 :         99 :     return eTextDir;
     886                 :            : }
     887                 :            : /**
     888                 :            :  * @descr: Get back ground color.
     889                 :            :  * @param:
     890                 :            :  * @param:
     891                 :            :  * @return:
     892                 :            : */
     893                 :        381 : LwpColor* LwpMiddleLayout::GetBackColor()
     894                 :            : {
     895                 :        381 :     LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
     896 [ +  + ][ +  + ]:        381 :     if(pBackgroundStuff && !pBackgroundStuff->IsTransparent())
                 [ +  - ]
     897                 :            :     {
     898                 :        105 :         LwpColor* pColor = pBackgroundStuff->GetFillColor();
     899         [ +  - ]:        105 :         if(pColor->IsValidColor())
     900                 :            :         {
     901                 :        105 :             return pColor;
     902                 :            :         }
     903                 :            :     }
     904                 :        381 :     return NULL;
     905                 :            : }
     906                 :            : 
     907                 :            : /**
     908                 :            :  * @descr:  Add back color settings into xfpagemaster.
     909                 :            :  * @param:
     910                 :            :  * @param:
     911                 :            :  * @return:
     912                 :            : */
     913                 :         75 : LwpTabOverride* LwpMiddleLayout::GetTabOverride()
     914                 :            : {
     915         [ +  - ]:         75 :     if(m_nAttributes & OVER_TABS)
     916                 :            :     {
     917         [ +  + ]:         75 :         if(!m_TabPiece.IsNull())
     918         [ -  + ]:         15 :             return (LwpTabOverride*) dynamic_cast<LwpTabPiece*>(m_TabPiece.obj())->GetOverride();
     919                 :         60 :         return NULL;
     920                 :            :     }
     921         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
     922                 :            :     {
     923         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
     924         [ #  # ]:          0 :         return pLay ? pLay->GetTabOverride() : NULL;
     925                 :            :     }
     926                 :         75 :     return NULL;
     927                 :            : }
     928                 :            : 
     929                 :            : /**
     930                 :            :  * @descr:   Layscale for graphic & watermark
     931                 :            :  * @param:
     932                 :            :  * @param:
     933                 :            :  * @return:
     934                 :            : */
     935                 :          0 : sal_uInt16 LwpMiddleLayout::GetScaleMode(void)
     936                 :            : {
     937 [ #  # ][ #  # ]:          0 :     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
                 [ #  # ]
     938                 :          0 :         return GetLayoutScale()->GetScaleMode();
     939         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
     940         [ #  # ]:          0 :         return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleMode();
     941                 :            :     else
     942                 :          0 :         return (LwpLayoutScale::FIT_IN_FRAME | LwpLayoutScale::MAINTAIN_ASPECT_RATIO);
     943                 :            : }
     944                 :            : 
     945                 :          9 : sal_uInt16 LwpMiddleLayout::GetScaleTile(void)
     946                 :            : {
     947 [ +  - ][ +  - ]:          9 :     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
                 [ +  - ]
     948                 :          9 :         return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED)
     949         [ -  + ]:          9 :             ? 1 : 0;
     950         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
     951         [ #  # ]:          0 :         return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleTile();
     952                 :            :     else
     953                 :          9 :         return 0;
     954                 :            : }
     955                 :            : 
     956                 :         18 : sal_uInt16 LwpMiddleLayout::GetScaleCenter(void)
     957                 :            : {
     958 [ +  - ][ +  - ]:         18 :     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
                 [ +  - ]
     959                 :         18 :         return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED)
     960                 :         18 :             ? 1 : 0;
     961         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
     962         [ #  # ]:          0 :         return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleCenter();
     963                 :            :     else
     964                 :         18 :         return 0;
     965                 :            : }
     966                 :            : 
     967                 :          0 : sal_uInt32 LwpMiddleLayout::GetScalePercentage(void)
     968                 :            : {
     969 [ #  # ][ #  # ]:          0 :     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
                 [ #  # ]
     970                 :          0 :         return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
     971         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
     972         [ #  # ]:          0 :         return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScalePercentage();
     973                 :            :     else
     974                 :          0 :         return 100;
     975                 :            : }
     976                 :            : 
     977                 :          0 : double LwpMiddleLayout::GetScaleWidth(void)
     978                 :            : {
     979 [ #  # ][ #  # ]:          0 :     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
                 [ #  # ]
     980                 :          0 :         return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
     981         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
     982         [ #  # ]:          0 :         return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleWidth();
     983                 :            :     else
     984                 :          0 :         return 0;
     985                 :            : }
     986                 :            : 
     987                 :          0 : double LwpMiddleLayout::GetScaleHeight(void)
     988                 :            : {
     989 [ #  # ][ #  # ]:          0 :     if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
                 [ #  # ]
     990                 :          0 :         return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
     991         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
     992         [ #  # ]:          0 :         return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleHeight();
     993                 :            :     else
     994                 :          0 :         return 0;
     995                 :            : }
     996                 :         12 : sal_Bool LwpMiddleLayout::CanSizeRight(void)
     997                 :            : {
     998                 :         12 :     sal_uInt8 RelType = GetRelativeType();
     999                 :            : 
    1000 [ +  - ][ -  + ]:         12 :     if (RelType == LwpLayoutRelativityGuts::LAY_INLINE || RelType == LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
                 [ +  - ]
    1001                 :            :     || RelType == LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL)
    1002                 :            :     {
    1003                 :          0 :         return sal_False;
    1004                 :            :     }
    1005                 :         12 :     return sal_True;
    1006                 :            : }
    1007                 :          6 : sal_Int32 LwpMiddleLayout::GetMinimumWidth()
    1008                 :            : {
    1009 [ +  - ][ +  - ]:          6 :     if (((m_nAttributes3 & STYLE3_WIDTHVALID) != 0) && GetGeometry())
                 [ +  - ]
    1010                 :            :     {
    1011                 :          6 :         return GetGeometry()->GetWidth();
    1012                 :            :     }
    1013         [ #  # ]:          0 :     else if (m_nOverrideFlag & OVER_SIZE)
    1014                 :            :     {
    1015                 :          0 :         return DetermineWidth();
    1016                 :            :     }
    1017                 :          6 :     return 0;
    1018                 :            : }
    1019                 :          0 : sal_Int32 LwpMiddleLayout::DetermineWidth()
    1020                 :            : {
    1021         [ #  # ]:          0 :     if (IsSizeRightToContent())
    1022                 :            :     {
    1023                 :            :         assert(sal_False);
    1024                 :            :     }
    1025         [ #  # ]:          0 :     else if (IsSizeRightToContainer())
    1026                 :            :     {
    1027                 :            :         assert(sal_False);
    1028                 :            :     }
    1029                 :            :     else
    1030                 :            :     {
    1031                 :          0 :         m_nAttributes3 |= STYLE3_WIDTHVALID;
    1032                 :          0 :         return GetGeometry()->GetWidth();
    1033                 :            :     }
    1034                 :          0 :     return 0;
    1035                 :            : }
    1036                 :          0 : sal_Bool LwpMiddleLayout::IsSizeRightToContainer(void)
    1037                 :            : {
    1038         [ #  # ]:          0 :     if (!CanSizeRight())
    1039                 :          0 :         return sal_False;
    1040                 :            : 
    1041         [ #  # ]:          0 :     if (m_nOverrideFlag & OVER_SIZE)
    1042                 :            :     {
    1043                 :            :         return (m_nDirection & ((LAY_USEDIRECTION|LAY_AUTOSIZE|LAY_TOCONTAINER)
    1044                 :            :                         << SHIFT_RIGHT))
    1045                 :          0 :         == ((LAY_USEDIRECTION | LAY_TOCONTAINER | LAY_AUTOSIZE) << SHIFT_RIGHT);
    1046                 :            :     }
    1047         [ #  # ]:          0 :     else if (m_BasedOnStyle.obj())
    1048                 :            :     {
    1049         [ #  # ]:          0 :         LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
    1050         [ #  # ]:          0 :         return pLayout ? pLayout->IsSizeRightToContainer() : sal_False;
    1051                 :            :     }
    1052                 :            :     else
    1053                 :          0 :         return sal_False;
    1054                 :            : }
    1055                 :         12 : sal_Bool LwpMiddleLayout::IsSizeRightToContent(void)
    1056                 :            : {
    1057         [ -  + ]:         12 :     if (!CanSizeRight())
    1058                 :          0 :         return sal_False;
    1059                 :            : 
    1060         [ +  + ]:         12 :     if (m_nOverrideFlag & OVER_SIZE)
    1061                 :            :     {
    1062                 :            :         return (m_nDirection & ((LAY_USEDIRECTION|LAY_AUTOSIZE|LAY_TOCONTAINER)
    1063                 :            :                             << SHIFT_RIGHT))
    1064                 :          6 :                 == ((LAY_USEDIRECTION | LAY_AUTOSIZE) << SHIFT_RIGHT);
    1065                 :            :     }
    1066         [ +  - ]:          6 :     else if (m_BasedOnStyle.obj())
    1067                 :            :     {
    1068         [ -  + ]:          6 :         LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
    1069         [ +  - ]:          6 :         return pLayout ? pLayout->IsSizeRightToContent() : sal_False;
    1070                 :            :     }
    1071                 :            :     else
    1072                 :         12 :         return sal_False;
    1073                 :            : }
    1074                 :            : 
    1075                 :            : /**
    1076                 :            : * @descr:   Get layout height
    1077                 :            : *
    1078                 :            : */
    1079                 :         60 : double LwpMiddleLayout::GetHeight()
    1080                 :            : {
    1081                 :         60 :     return GetGeometryHeight();
    1082                 :            : }
    1083                 :            : 
    1084                 :            : /**
    1085                 :            : * @descr:   Get layout height
    1086                 :            : *
    1087                 :            : */
    1088                 :        129 : double LwpMiddleLayout::GetWidth()
    1089                 :            : {
    1090                 :        129 :     return GetGeometryWidth();
    1091                 :            : }
    1092                 :            : /**
    1093                 :            : * @descr:   Get layout orgin point
    1094                 :            : *
    1095                 :            : */
    1096                 :         66 : LwpPoint LwpMiddleLayout::GetOrigin()
    1097                 :            : {
    1098                 :         66 :     LwpLayoutGeometry* pGeo = GetGeometry();
    1099         [ +  - ]:         66 :     if(pGeo)
    1100                 :            :     {
    1101                 :         66 :         sal_uInt8 nType = GetRelativeType();
    1102 [ +  + ][ +  - ]:         66 :         if(nType == LwpLayoutRelativityGuts::LAY_INLINE
    1103                 :            :             || nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE )
    1104                 :            :         {
    1105                 :         48 :             return pGeo->GetAbsoluteOrigin();
    1106                 :            :         }
    1107                 :            :         else
    1108                 :         18 :             return pGeo->GetOrigin();
    1109                 :            : 
    1110                 :            :     }
    1111                 :            : 
    1112                 :         66 :     return LwpPoint();
    1113                 :            : }
    1114                 :            : 
    1115                 :            : /**
    1116                 :            : * @descr:   Whether the fill is pattern fill or not
    1117                 :            : * @return:  True if yes, false if not.
    1118                 :            : */
    1119                 :        159 : sal_Bool LwpMiddleLayout::IsPatternFill()
    1120                 :            : {
    1121                 :        159 :     LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
    1122         [ +  - ]:        159 :     if (pBackgroundStuff)
    1123                 :            :     {
    1124                 :        159 :         return pBackgroundStuff->IsPatternFill();
    1125                 :            :     }
    1126                 :            : 
    1127                 :        159 :     return sal_False;
    1128                 :            : }
    1129                 :            : 
    1130                 :            : /**
    1131                 :            : * @descr:   Get the fill pattern style. Data are saved in a XFBGImage object
    1132                 :            : * @return:  the fill pattern style.
    1133                 :            : */
    1134                 :          0 : XFBGImage* LwpMiddleLayout::GetFillPattern()
    1135                 :            : {
    1136                 :          0 :     LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
    1137         [ #  # ]:          0 :     if (pBackgroundStuff)
    1138                 :            :     {
    1139                 :          0 :         return pBackgroundStuff->GetFillPattern();
    1140                 :            :     }
    1141                 :            : 
    1142                 :          0 :     return NULL;
    1143                 :            : 
    1144                 :            : }
    1145                 :            : 
    1146                 :            : /**
    1147                 :            : * @descr:   Whether the height and width of layout is auto grow
    1148                 :            : *
    1149                 :            : */
    1150                 :         39 : sal_Bool LwpMiddleLayout::IsAutoGrow()
    1151                 :            : {
    1152         [ +  - ]:         39 :     if(m_nOverrideFlag & OVER_SIZE)
    1153                 :            :     {
    1154                 :            :         return m_nDirection &
    1155                 :            :             ((LAY_AUTOGROW << SHIFT_UP) | (LAY_AUTOGROW << SHIFT_DOWN) |
    1156                 :            :             (LAY_AUTOGROW << SHIFT_RIGHT) | (LAY_AUTOGROW << SHIFT_LEFT))
    1157         [ +  + ]:         39 :             ? sal_True : sal_False;
    1158                 :            :     }
    1159         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1160                 :            :     {
    1161         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1162         [ #  # ]:          0 :         return pLay ? pLay->IsAutoGrow() : sal_False;
    1163                 :            :     }
    1164                 :         39 :     return LwpVirtualLayout::IsAutoGrow();
    1165                 :            : }
    1166                 :            : 
    1167                 :            : /**
    1168                 :            : * @descr:   Whether the height of layout is auto grow down
    1169                 :            : *
    1170                 :            : */
    1171                 :         63 : sal_Bool LwpMiddleLayout::IsAutoGrowDown()
    1172                 :            : {
    1173         [ +  - ]:         63 :     if(m_nOverrideFlag & OVER_SIZE)
    1174                 :            :     {
    1175         [ +  + ]:         63 :         return m_nDirection & (LAY_AUTOGROW << SHIFT_DOWN) ? sal_True : sal_False;
    1176                 :            :     }
    1177         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1178                 :            :     {
    1179         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1180         [ #  # ]:          0 :         return pLay ? pLay->IsAutoGrowDown() : sal_False;
    1181                 :            :     }
    1182                 :         63 :     return LwpVirtualLayout::IsAutoGrowDown();
    1183                 :            : }
    1184                 :            : 
    1185                 :            : /**
    1186                 :            : * @descr:   Whether the height of layout is auto grow up
    1187                 :            : *
    1188                 :            : */
    1189                 :         45 : sal_Bool LwpMiddleLayout::IsAutoGrowUp()
    1190                 :            : {
    1191         [ +  - ]:         45 :     if(m_nOverrideFlag & OVER_SIZE)
    1192                 :            :     {
    1193         [ -  + ]:         45 :         return m_nDirection & (LAY_AUTOGROW << SHIFT_UP) ? sal_True : sal_False;
    1194                 :            :     }
    1195         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1196                 :            :     {
    1197         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1198         [ #  # ]:          0 :         return pLay ? pLay->IsAutoGrowUp() : sal_False;
    1199                 :            :     }
    1200                 :         45 :     return LwpVirtualLayout::IsAutoGrowUp();
    1201                 :            : }
    1202                 :            : 
    1203                 :            : /**
    1204                 :            : * @descr:   Whether the height of layout is auto grow down
    1205                 :            : *
    1206                 :            : */
    1207                 :         39 : sal_Bool LwpMiddleLayout::IsAutoGrowLeft()
    1208                 :            : {
    1209         [ +  - ]:         39 :     if(m_nOverrideFlag & OVER_SIZE)
    1210                 :            :     {
    1211         [ -  + ]:         39 :         return m_nDirection & (LAY_AUTOGROW << SHIFT_LEFT) ? sal_True : sal_False;
    1212                 :            :     }
    1213         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1214                 :            :     {
    1215         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1216         [ #  # ]:          0 :         if (pLay)
    1217                 :          0 :             return pLay->IsAutoGrowLeft();
    1218                 :            :     }
    1219                 :         39 :     return LwpVirtualLayout::IsAutoGrowLeft();
    1220                 :            : }
    1221                 :            : 
    1222                 :            : /**
    1223                 :            : * @descr:   Whether the height of layout is auto grow down
    1224                 :            : *
    1225                 :            : */
    1226                 :         96 : sal_Bool LwpMiddleLayout::IsAutoGrowRight()
    1227                 :            : {
    1228         [ +  - ]:         96 :     if(m_nOverrideFlag & OVER_SIZE)
    1229                 :            :     {
    1230         [ +  + ]:         96 :         return m_nDirection & (LAY_AUTOGROW << SHIFT_RIGHT) ? sal_True : sal_False;
    1231                 :            :     }
    1232         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1233                 :            :     {
    1234         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1235         [ #  # ]:          0 :         return pLay ? pLay->IsAutoGrowRight() : sal_False;
    1236                 :            :     }
    1237                 :         96 :     return LwpVirtualLayout::IsAutoGrowRight();
    1238                 :            : }
    1239                 :            : 
    1240                 :            : 
    1241                 :            : /**
    1242                 :            : * @descr:   Get contents orientation
    1243                 :            : *
    1244                 :            : */
    1245                 :        249 : sal_uInt8 LwpMiddleLayout::GetContentOrientation()
    1246                 :            : {
    1247                 :            :     //content orientation in Graphic objects and OLE objects not supported now
    1248 [ +  + ][ +  - ]:        249 :     if((m_nOverrideFlag & OVER_ROTATION)&& !m_LayGeometry.IsNull())
                 [ +  + ]
    1249                 :            :     {
    1250         [ -  + ]:         99 :         LwpLayoutGeometry* pLayGeometry = dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj());
    1251         [ +  - ]:         99 :         if (pLayGeometry)
    1252                 :         99 :             return pLayGeometry->GetContentOrientation();
    1253                 :            :     }
    1254         [ +  - ]:        150 :     else if( !m_BasedOnStyle.IsNull() )
    1255                 :            :     {
    1256         [ -  + ]:        150 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1257         [ +  - ]:        150 :         if (pLay)
    1258                 :        150 :             return pLay->GetContentOrientation();
    1259                 :            :     }
    1260                 :        249 :     return LwpVirtualLayout::GetContentOrientation();
    1261                 :            : }
    1262                 :            : 
    1263                 :            : /**
    1264                 :            : * @descr:   Whether it is honoring protection
    1265                 :            : *
    1266                 :            : */
    1267                 :         36 : sal_Bool LwpMiddleLayout::HonorProtection()
    1268                 :            : {
    1269         [ +  - ]:         36 :     if(m_nOverrideFlag & OVER_MISC)
    1270                 :            :     {
    1271         [ -  + ]:         36 :         if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
    1272                 :          0 :             return sal_False;
    1273                 :            : 
    1274         [ -  + ]:         36 :         LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
    1275 [ +  - ][ +  - ]:         36 :         if(pParent && !pParent->IsHeader())
                 [ +  - ]
    1276                 :            :         {
    1277                 :         36 :             return pParent->HonorProtection();
    1278                 :            :         }
    1279                 :            : 
    1280         [ #  # ]:          0 :         if(m_pFoundry)//is null now
    1281                 :            :         {
    1282                 :          0 :             LwpDocument* pDoc = m_pFoundry->GetDocument();
    1283         [ #  # ]:          0 :             if(pDoc)
    1284                 :            :             {
    1285                 :          0 :                 return pDoc->HonorProtection();
    1286                 :            :             }
    1287                 :            :         }
    1288                 :            :     }
    1289         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1290                 :            :     {
    1291         [ #  # ]:          0 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1292         [ #  # ]:          0 :         if (pLay)
    1293                 :          0 :             return pLay->HonorProtection();
    1294                 :            :     }
    1295                 :            : 
    1296                 :         36 :     return LwpVirtualLayout::HonorProtection();
    1297                 :            : }
    1298                 :            : 
    1299                 :            : /**
    1300                 :            : * @descr:   Whether it is pretected
    1301                 :            : *
    1302                 :            : */
    1303                 :        351 : sal_Bool LwpMiddleLayout::IsProtected()
    1304                 :            : {
    1305                 :        351 :     sal_Bool bProtected = sal_False;
    1306         [ +  + ]:        351 :     if(m_nOverrideFlag & OVER_MISC)
    1307                 :            :     {
    1308                 :        204 :         bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
    1309                 :            :     }
    1310         [ +  - ]:        147 :     else if( !m_BasedOnStyle.IsNull() )
    1311                 :            :     {
    1312         [ -  + ]:        147 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1313         [ +  - ]:        147 :         bProtected = pLay ? pLay->IsProtected() : sal_False;
    1314                 :            :     }
    1315                 :            :     else
    1316                 :          0 :         bProtected = LwpVirtualLayout::IsProtected();
    1317                 :            : 
    1318         [ -  + ]:        351 :     LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
    1319 [ +  - ][ +  - ]:        351 :     if(pParent && !pParent->IsHeader())
                 [ +  - ]
    1320                 :            :     {
    1321                 :            :         /* If a parent's protected then none of its children can be accessed. */
    1322         [ -  + ]:        351 :         if(pParent->IsProtected())
    1323                 :          0 :             return sal_True;
    1324                 :            : 
    1325         [ +  - ]:        351 :         if(pParent->HonorProtection())
    1326                 :        351 :             return bProtected;
    1327                 :            : 
    1328                 :            :         /* If our parent isn't honoring protection then we aren't protected. */
    1329                 :          0 :         return sal_False;
    1330                 :            : 
    1331                 :            :     }
    1332         [ #  # ]:          0 :     if(m_pFoundry)//is null now
    1333                 :            :     {
    1334                 :          0 :         LwpDocument* pDoc = m_pFoundry->GetDocument();
    1335         [ #  # ]:          0 :         if(pDoc)
    1336                 :            :         {
    1337         [ #  # ]:          0 :             if (pDoc->HonorProtection())
    1338                 :          0 :                 return bProtected;
    1339                 :            : 
    1340                 :            :             /* If the document isn't honoring protection then we aren't protected.*/
    1341                 :          0 :             return sal_False;
    1342                 :            :         }
    1343                 :            :     }
    1344                 :            : 
    1345                 :        351 :     return bProtected;
    1346                 :            : }
    1347                 :            : 
    1348                 :            : /**
    1349                 :            : * @descr:   Get watermark layout
    1350                 :            : *
    1351                 :            : */
    1352                 :        375 : LwpVirtualLayout* LwpMiddleLayout::GetWaterMarkLayout()
    1353                 :            : {
    1354         [ +  + ]:        375 :     LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
    1355         [ +  + ]:        426 :     while(pLay)
    1356                 :            :     {
    1357         [ -  + ]:         51 :         if( pLay->IsForWaterMark())
    1358                 :            :         {
    1359                 :          0 :             return pLay;
    1360                 :            :         }
    1361         [ +  + ]:         51 :         pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
    1362                 :            :     }
    1363                 :        375 :     return NULL;
    1364                 :            : }
    1365                 :            : 
    1366                 :            : /**
    1367                 :            : * @descr:   Create and reture xfbgimage object for watermark
    1368                 :            : *
    1369                 :            : */
    1370                 :        375 : XFBGImage* LwpMiddleLayout::GetXFBGImage()
    1371                 :            : {
    1372                 :        375 :     LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*>(GetWaterMarkLayout());
    1373         [ -  + ]:        375 :     if(pLay)
    1374                 :            :     {
    1375                 :            :         //test BGImage
    1376         [ #  # ]:          0 :         LwpGraphicObject* pGrfObj = dynamic_cast<LwpGraphicObject*>(pLay->GetContent()->obj());
    1377         [ #  # ]:          0 :         if(pGrfObj)
    1378                 :            :         {
    1379         [ #  # ]:          0 :             XFBGImage* pXFBGImage = new XFBGImage();
    1380                 :            : 
    1381         [ #  # ]:          0 :             if(pGrfObj->IsLinked())
    1382                 :            :             {
    1383                 :            :                 //set file link
    1384                 :          0 :                 OUString linkedfilepath = pGrfObj->GetLinkedFilePath();
    1385 [ #  # ][ #  # ]:          0 :                 OUString fileURL = LwpTools::convertToFileUrl(OUStringToOString(linkedfilepath, osl_getThreadTextEncoding()));
                 [ #  # ]
    1386                 :          0 :                 pXFBGImage->SetFileLink(fileURL);
    1387                 :            :             }
    1388                 :            :             else
    1389                 :            :             {
    1390                 :          0 :                 sal_uInt8* pGrafData = NULL;
    1391         [ #  # ]:          0 :                 sal_uInt32 nDataLen = pGrfObj->GetRawGrafData(pGrafData);
    1392         [ #  # ]:          0 :                 pXFBGImage->SetImageData(pGrafData, nDataLen);
    1393         [ #  # ]:          0 :                 if(pGrafData)
    1394                 :            :                 {
    1395                 :          0 :                     delete pGrafData;
    1396                 :          0 :                     pGrafData = NULL;
    1397                 :            :                 }
    1398                 :            :             }
    1399                 :            : 
    1400                 :            : 
    1401                 :            :             //automatic, top left
    1402                 :          0 :             pXFBGImage->SetPosition(enumXFAlignStart,enumXFAlignTop);
    1403         [ #  # ]:          0 :             if(pLay->GetScaleCenter())
    1404                 :            :             {
    1405                 :            :                 //center
    1406                 :          0 :                 pXFBGImage->SetPosition(enumXFAlignCenter,enumXFAlignCenter);
    1407                 :            :             }
    1408         [ #  # ]:          0 :             else if(pLay->GetScaleTile())
    1409                 :            :             {
    1410                 :            :                 //tile
    1411                 :          0 :                 pXFBGImage->SetRepeate();
    1412                 :            :             }
    1413                 :            :             //fit type, area type
    1414         [ #  # ]:          0 :             if((pLay->GetScaleMode()& LwpLayoutScale::FIT_IN_FRAME)!=0)
    1415                 :            :             {
    1416         [ #  # ]:          0 :                 if((pLay->GetScaleMode()& LwpLayoutScale::MAINTAIN_ASPECT_RATIO)==0)
    1417                 :            :                 {
    1418                 :          0 :                     pXFBGImage->SetStretch();
    1419                 :            :                 }
    1420                 :            :             }
    1421                 :          0 :             return pXFBGImage;
    1422                 :            :         }
    1423                 :            :     }
    1424                 :        375 :     return NULL;
    1425                 :            : }
    1426                 :            : 
    1427                 :            : /**
    1428                 :            : * @descr:   Whether the page uses the printer setting
    1429                 :            : *
    1430                 :            : */
    1431                 :        156 : sal_Bool LwpMiddleLayout::GetUsePrinterSettings()
    1432                 :            : {
    1433         [ +  + ]:        156 :     if(m_nOverrideFlag & OVER_SIZE)
    1434                 :            :     {
    1435                 :         87 :         return (m_nAttributes3 & STYLE3_USEPRINTERSETTINGS) != 0;
    1436                 :            :     }
    1437         [ +  - ]:         69 :     else if( !m_BasedOnStyle.IsNull() )
    1438                 :            :     {
    1439         [ -  + ]:         69 :         LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
    1440         [ +  - ]:         69 :         return pLay ? pLay->GetUsePrinterSettings() : sal_False;
    1441                 :            :     }
    1442                 :        156 :     return sal_False;
    1443                 :            : }
    1444                 :            : 
    1445                 :            : 
    1446                 :            : //Check whether there are contents in the layout
    1447                 :          0 : sal_Bool LwpMiddleLayout::HasContent()
    1448                 :            : {
    1449                 :          0 :     LwpObject* content = m_Content.obj();
    1450         [ #  # ]:          0 :     if(content)
    1451                 :          0 :         return sal_True;
    1452                 :          0 :     return sal_False;
    1453                 :            : }
    1454                 :            : //End by
    1455                 :            : 
    1456                 :        216 : LwpLayout::LwpLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm ) :
    1457 [ +  - ][ +  - ]:        216 :     LwpMiddleLayout(objHdr, pStrm), m_pUseWhen(new LwpUseWhen)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1458                 :        216 : {}
    1459                 :            : 
    1460                 :        216 : LwpLayout::~LwpLayout()
    1461                 :            : {
    1462         [ +  - ]:        216 :     if (m_pUseWhen)
    1463                 :            :     {
    1464                 :        216 :         delete m_pUseWhen;
    1465                 :            :     }
    1466         [ -  + ]:        216 : }
    1467                 :            : 
    1468                 :        216 : void LwpLayout::Read()
    1469                 :            : {
    1470                 :        216 :     LwpObjectStream* pStrm = m_pObjStrm;
    1471                 :            : 
    1472                 :        216 :     LwpMiddleLayout::Read();
    1473         [ +  - ]:        216 :     if (LwpFileHeader::m_nFileRevision < 0x000B)
    1474                 :            :     {
    1475                 :            :         // read PreRevBLayout...
    1476                 :            :     }
    1477                 :            :     else
    1478                 :            :     {
    1479                 :        216 :         sal_uInt16 nSimple = pStrm->QuickReaduInt16();
    1480                 :            : 
    1481         [ +  + ]:        216 :         if (!nSimple)
    1482                 :            :         {
    1483                 :        207 :             m_pUseWhen->Read(pStrm);
    1484                 :            : 
    1485                 :        207 :             sal_uInt8 nFlag = pStrm->QuickReaduInt8();
    1486         [ +  + ]:        207 :             if (nFlag)
    1487                 :         78 :                 m_Positon.ReadIndexed(pStrm);
    1488                 :            :         }
    1489                 :            : 
    1490                 :        216 :         m_LayColumns.ReadIndexed(pStrm);
    1491                 :        216 :         m_LayGutterStuff.ReadIndexed(pStrm);
    1492                 :        216 :         m_LayJoinStuff.ReadIndexed(pStrm);
    1493                 :        216 :         m_LayShadow.ReadIndexed(pStrm);
    1494                 :            : 
    1495         [ +  + ]:        216 :         if (pStrm->CheckExtra())
    1496                 :            :         {
    1497                 :        180 :             m_LayExtJoinStuff.ReadIndexed(pStrm);
    1498                 :        180 :             pStrm->SkipExtra();
    1499                 :            :         }
    1500                 :            :     }
    1501                 :        216 : }
    1502                 :            : 
    1503                 :            : /**
    1504                 :            : * @descr:   Get columns number
    1505                 :            : *
    1506                 :            : */
    1507                 :        255 : sal_uInt16 LwpLayout::GetNumCols()
    1508                 :            : {
    1509         [ +  + ]:        255 :     if(m_nOverrideFlag & OVER_COLUMNS)
    1510                 :            :     {
    1511         [ -  + ]:        111 :         LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
    1512         [ +  - ]:        111 :         if(pLayColumns)
    1513                 :            :         {
    1514                 :        111 :             return pLayColumns->GetNumCols();
    1515                 :            :         }
    1516                 :            :     }
    1517                 :            : 
    1518         [ -  + ]:        144 :     LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
    1519         [ +  - ]:        144 :     if(pStyle)
    1520                 :            :     {
    1521                 :        144 :         return pStyle->GetNumCols();
    1522                 :            :     }
    1523                 :            : 
    1524                 :        255 :     return LwpVirtualLayout::GetNumCols();
    1525                 :            : 
    1526                 :            : }
    1527                 :            : 
    1528                 :            : /**
    1529                 :            : * @descr:   Get column width
    1530                 :            : * @param:   the order of column
    1531                 :            : */
    1532                 :          0 : double LwpLayout::GetColWidth(sal_uInt16 nIndex)
    1533                 :            : {
    1534 [ #  # ][ #  # ]:          0 :     if((m_nOverrideFlag & OVER_COLUMNS)||(m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
    1535                 :            :     {
    1536         [ #  # ]:          0 :         LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
    1537         [ #  # ]:          0 :         if(pLayColumns)
    1538                 :            :         {
    1539                 :          0 :             return pLayColumns->GetColWidth(nIndex);
    1540                 :            :         }
    1541                 :            :     }
    1542                 :            : 
    1543         [ #  # ]:          0 :     LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
    1544         [ #  # ]:          0 :     if(pStyle)
    1545                 :            :     {
    1546                 :          0 :         return pStyle->GetColWidth(nIndex);
    1547                 :            :     }
    1548                 :            : 
    1549                 :          0 :     return LwpVirtualLayout::GetColWidth(nIndex);
    1550                 :            : 
    1551                 :            : }
    1552                 :            : 
    1553                 :            : /**
    1554                 :            : * @descr:   Get gap between columns
    1555                 :            : * @param:   the order of column
    1556                 :            : */
    1557                 :          0 : double LwpLayout::GetColGap(sal_uInt16 nIndex)
    1558                 :            : {
    1559 [ #  # ][ #  # ]:          0 :     if((m_nOverrideFlag & OVER_COLUMNS)||(m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
    1560                 :            :     {
    1561         [ #  # ]:          0 :         LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
    1562         [ #  # ]:          0 :         if(pLayColumns)
    1563                 :            :         {
    1564                 :          0 :             return pLayColumns->GetColGap(nIndex);
    1565                 :            :         }
    1566                 :            :     }
    1567                 :            : 
    1568         [ #  # ]:          0 :     LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
    1569         [ #  # ]:          0 :     if(pStyle)
    1570                 :            :     {
    1571                 :          0 :         return pStyle->GetColGap(nIndex);
    1572                 :            :     }
    1573                 :            : 
    1574                 :          0 :     return LwpVirtualLayout::GetColGap(nIndex);
    1575                 :            : }
    1576                 :            : 
    1577                 :            : /**
    1578                 :            : * @descr:   Create and return XFColumns object
    1579                 :            : *
    1580                 :            : */
    1581                 :         99 : XFColumns* LwpLayout::GetXFColumns()
    1582                 :            : {
    1583                 :            :     //if there is only one column, do not need insert columns
    1584                 :         99 :     sal_uInt16 nCols = GetNumCols();
    1585         [ +  - ]:         99 :     if(nCols==1)
    1586                 :            :     {
    1587                 :         99 :         return NULL;
    1588                 :            :     }
    1589                 :            : 
    1590         [ #  # ]:          0 :     XFColumns* pColumns = new XFColumns();
    1591                 :            :     //set XFColumnSep
    1592                 :          0 :     XFColumnSep* pColumnSep = GetColumnSep();
    1593         [ #  # ]:          0 :     if(pColumnSep)
    1594                 :            :     {
    1595                 :          0 :         pColumns->SetSeperator(*pColumnSep);
    1596                 :            :     }
    1597                 :            : 
    1598                 :            :     //set column count and column gap
    1599                 :          0 :     pColumns->SetCount(nCols);
    1600                 :          0 :     double fGap = GetColGap(0);
    1601                 :          0 :     pColumns->SetGap(fGap);
    1602                 :            : 
    1603                 :            :     //set xfcolumn
    1604         [ #  # ]:          0 :     for(sal_uInt16 nIndex = 0; nIndex<nCols; nIndex++)
    1605                 :            :     {
    1606                 :          0 :         XFColumn* pColumn = new XFColumn();
    1607                 :          0 :         sal_Int32 nWidth = static_cast<sal_Int32>(GetColWidth(nIndex));
    1608                 :          0 :         nWidth=8305/nCols;  //relative width
    1609                 :          0 :         pColumn->SetRelWidth(nWidth);
    1610                 :            : 
    1611                 :            :         //the left and right margins is 0;
    1612                 :          0 :         double nGap = GetColGap(nIndex)/2;
    1613                 :            :         //nGap=0;
    1614                 :          0 :         pColumn->SetMargins(nGap,nGap);
    1615         [ #  # ]:          0 :         if(nIndex==0)
    1616                 :            :         {
    1617                 :          0 :             pColumn->SetMargins(0,nGap);
    1618                 :            :         }
    1619         [ #  # ]:          0 :         if(nIndex==(nCols-1))
    1620                 :            :         {
    1621                 :          0 :             pColumn->SetMargins(nGap,0);
    1622                 :            :         }
    1623                 :          0 :         pColumns->AddColumn(*pColumn);
    1624                 :            :     }
    1625                 :            : 
    1626                 :         99 :     return pColumns;
    1627                 :            : }
    1628                 :            : 
    1629                 :            : /**
    1630                 :            : * @descr:   Create and return XFColumnSep object
    1631                 :            : *
    1632                 :            : */
    1633                 :          0 : XFColumnSep* LwpLayout::GetColumnSep()
    1634                 :            : {
    1635                 :            : 
    1636                 :            :     //Get LwpLayoutGutters
    1637         [ #  # ]:          0 :     LwpLayoutGutters* pLayoutGutters = dynamic_cast<LwpLayoutGutters*>(m_LayGutterStuff.obj());
    1638         [ #  # ]:          0 :     if(!pLayoutGutters)
    1639                 :            :     {
    1640                 :          0 :         return NULL;
    1641                 :            :     }
    1642                 :            : 
    1643                 :          0 :     LwpBorderStuff* pBorderStuff = pLayoutGutters->GetBorderStuff();
    1644                 :            : 
    1645         [ #  # ]:          0 :     if(pBorderStuff)
    1646                 :            :     {
    1647                 :          0 :         LwpBorderStuff::BorderType eType = LwpBorderStuff::LEFT;
    1648         [ #  # ]:          0 :         LwpColor    aColor = pBorderStuff->GetSideColor(eType);
    1649         [ #  # ]:          0 :         double  fWidth = pBorderStuff->GetSideWidth(eType);
    1650                 :            :         //sal_uInt16    nType = pBorderStuff->GetSideType(eType);
    1651                 :            : 
    1652         [ #  # ]:          0 :         XFColumnSep* pColumnSep = new XFColumnSep();
    1653         [ #  # ]:          0 :         XFColor aXFColor(aColor.To24Color());
    1654         [ #  # ]:          0 :         pColumnSep->SetColor(aXFColor);
    1655         [ #  # ]:          0 :         pColumnSep->SetWidth(fWidth);
    1656         [ #  # ]:          0 :         pColumnSep->SetRelHeight(100);
    1657         [ #  # ]:          0 :         pColumnSep->SetVerticalAlign(enumXFAlignTop);
    1658                 :            : 
    1659                 :          0 :         return pColumnSep;
    1660                 :            :     }
    1661                 :          0 :     return NULL;
    1662                 :            : 
    1663                 :            : }
    1664                 :            : 
    1665                 :            : /**
    1666                 :            : * @descr:   Get use when type
    1667                 :            : *
    1668                 :            : */
    1669                 :         12 : LwpLayout::UseWhenType LwpLayout::GetUseWhenType()
    1670                 :            : {
    1671                 :         12 :     UseWhenType eType = StartWithinPage;
    1672                 :         12 :     LwpUseWhen* pUseWhen = GetUseWhen();
    1673         [ +  - ]:         12 :     if(pUseWhen)
    1674                 :            :     {
    1675         [ -  + ]:         12 :         if(pUseWhen->IsStartOnThisHF())
    1676                 :            :         {
    1677                 :          0 :             eType =  StartWithinColume;
    1678                 :            :         }
    1679         [ -  + ]:         12 :         else if(pUseWhen->IsStartOnThisPage())
    1680                 :            :         {
    1681                 :          0 :             eType =  StartWithinPage;
    1682                 :            :         }
    1683         [ +  - ]:         12 :         else if(pUseWhen->IsStartOnNextPage())
    1684                 :            :         {
    1685                 :         12 :             eType = StartOnNextPage;
    1686                 :            :         }
    1687         [ #  # ]:          0 :         else if(pUseWhen->IsStartOnNextOddPage())
    1688                 :            :         {
    1689                 :          0 :             eType =  StartOnOddPage;
    1690                 :            :         }
    1691         [ #  # ]:          0 :         else if(pUseWhen->IsStartOnNextEvenPage())
    1692                 :            :         {
    1693                 :          0 :             eType =   StartOnEvenPage;
    1694                 :            :         }
    1695                 :            : 
    1696                 :            :     }
    1697                 :            :     else
    1698                 :            :     {
    1699                 :          0 :         eType =   StartOnNextPage;
    1700                 :            :     }
    1701                 :         12 :     return eType;
    1702                 :            : }
    1703                 :            : 
    1704                 :            : /**
    1705                 :            : * @descr:   Get use page
    1706                 :            : *
    1707                 :            : */
    1708                 :          0 : sal_uInt16 LwpLayout::GetUsePage()
    1709                 :            : {
    1710         [ #  # ]:          0 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1711                 :            :     {
    1712                 :          0 :         LwpUseWhen* pUseWhen = GetUseWhen();
    1713         [ #  # ]:          0 :         if(pUseWhen)
    1714                 :          0 :             return pUseWhen->GetUsePage();
    1715                 :            :         else
    1716                 :          0 :             return 0;
    1717                 :            :     }
    1718         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1719                 :            :     {
    1720         [ #  # ]:          0 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1721         [ #  # ]:          0 :         return pLay ? pLay->GetUsePage() : 0;
    1722                 :            :     }
    1723                 :          0 :     return 0;
    1724                 :            : }
    1725                 :            : 
    1726                 :            : /**
    1727                 :            : * @descr:   Get usewhen pointer
    1728                 :            : *
    1729                 :            : */
    1730                 :         48 : LwpUseWhen* LwpLayout::VirtualGetUseWhen()
    1731                 :            : {
    1732         [ +  + ]:         48 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1733                 :            :     {
    1734                 :         36 :         return m_pUseWhen;
    1735                 :            :     }
    1736         [ +  - ]:         12 :     else if( !m_BasedOnStyle.IsNull() )
    1737                 :            :     {
    1738         [ -  + ]:         12 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1739         [ +  - ]:         12 :         return pLay ? pLay->VirtualGetUseWhen() : NULL;
    1740                 :            :     }
    1741                 :         48 :     return LwpVirtualLayout::VirtualGetUseWhen();
    1742                 :            : }
    1743                 :            : 
    1744                 :            : /**
    1745                 :            : * @descr:   Whether it is use on all pages
    1746                 :            : *
    1747                 :            : */
    1748                 :          0 : sal_Bool LwpLayout::IsUseOnAllPages()
    1749                 :            : {
    1750         [ #  # ]:          0 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1751                 :            :     {
    1752                 :          0 :         LwpUseWhen* pUseWhen = GetUseWhen();
    1753         [ #  # ]:          0 :         if(pUseWhen)
    1754                 :          0 :             return pUseWhen->IsUseOnAllPages();
    1755                 :            :         else
    1756                 :          0 :             return sal_False;
    1757                 :            :     }
    1758         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1759                 :            :     {
    1760         [ #  # ]:          0 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1761         [ #  # ]:          0 :         if (pLay)
    1762                 :          0 :             return pLay->IsUseOnAllPages();
    1763                 :            :     }
    1764                 :          0 :     return LwpVirtualLayout::IsUseOnAllPages();
    1765                 :            : }
    1766                 :            : 
    1767                 :            : /**
    1768                 :            : * @descr:   Whether it is use on all even pages
    1769                 :            : *
    1770                 :            : */
    1771                 :          0 : sal_Bool LwpLayout::IsUseOnAllEvenPages()
    1772                 :            : {
    1773         [ #  # ]:          0 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1774                 :            :     {
    1775                 :          0 :         LwpUseWhen* pUseWhen = GetUseWhen();
    1776         [ #  # ]:          0 :         if(pUseWhen)
    1777                 :          0 :             return pUseWhen->IsUseOnAllEvenPages();
    1778                 :            :         else
    1779                 :          0 :             return sal_False;
    1780                 :            :     }
    1781         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1782                 :            :     {
    1783         [ #  # ]:          0 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1784         [ #  # ]:          0 :         if (pLay)
    1785                 :          0 :             return pLay->IsUseOnAllEvenPages();
    1786                 :            :     }
    1787                 :          0 :     return LwpVirtualLayout::IsUseOnAllEvenPages();
    1788                 :            : }
    1789                 :            : 
    1790                 :            : /**
    1791                 :            : * @descr:   Whether it is use on all odd pages
    1792                 :            : *
    1793                 :            : */
    1794                 :          0 : sal_Bool LwpLayout::IsUseOnAllOddPages()
    1795                 :            : {
    1796         [ #  # ]:          0 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1797                 :            :     {
    1798                 :          0 :         LwpUseWhen* pUseWhen = GetUseWhen();
    1799         [ #  # ]:          0 :         if(pUseWhen)
    1800                 :          0 :             return pUseWhen->IsUseOnAllOddPages();
    1801                 :            :         else
    1802                 :          0 :             return sal_False;
    1803                 :            :     }
    1804         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1805                 :            :     {
    1806         [ #  # ]:          0 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1807         [ #  # ]:          0 :         if (pLay)
    1808                 :          0 :             return pLay->IsUseOnAllOddPages();
    1809                 :            :     }
    1810                 :          0 :     return LwpVirtualLayout::IsUseOnAllOddPages();
    1811                 :            : }
    1812                 :            : 
    1813                 :            : /**
    1814                 :            : * @descr:   Whether it is use on current page
    1815                 :            : *
    1816                 :            : */
    1817                 :          0 : sal_Bool LwpLayout::IsUseOnPage()
    1818                 :            : {
    1819         [ #  # ]:          0 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1820                 :            :     {
    1821                 :          0 :         LwpUseWhen* pUseWhen = GetUseWhen();
    1822         [ #  # ]:          0 :         if(pUseWhen)
    1823                 :          0 :             return pUseWhen->IsUseOnPage();
    1824                 :            :         else
    1825                 :          0 :             return sal_False;
    1826                 :            :     }
    1827         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1828                 :            :     {
    1829         [ #  # ]:          0 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1830         [ #  # ]:          0 :         if (pLay)
    1831                 :          0 :             return pLay->IsUseOnPage();
    1832                 :            :     }
    1833                 :          0 :     return LwpVirtualLayout::IsUseOnPage();
    1834                 :            : }
    1835                 :            : 
    1836                 :            : /**
    1837                 :            :  * @descr:  Get the LwpShadow object according to m_LayShadow id.
    1838                 :            :  * @param:
    1839                 :            :  * @param:
    1840                 :            :  * @return:
    1841                 :            : */
    1842                 :        351 : LwpShadow* LwpLayout::GetShadow()
    1843                 :            : {
    1844         [ +  + ]:        351 :     if(m_nOverrideFlag & OVER_SHADOW)
    1845                 :            :     {
    1846         [ -  + ]:        147 :         LwpLayoutShadow* pLayoutShadow = dynamic_cast<LwpLayoutShadow*>(m_LayShadow.obj());
    1847         [ +  - ]:        147 :         return pLayoutShadow ? pLayoutShadow->GetShadow() : NULL;
    1848                 :            :     }
    1849         [ +  + ]:        204 :     else if( !m_BasedOnStyle.IsNull() )
    1850                 :            :     {
    1851         [ -  + ]:        201 :         LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
    1852         [ +  - ]:        201 :         return pLay ? pLay->GetShadow() : NULL;
    1853                 :            :     }
    1854                 :        351 :     return NULL;
    1855                 :            : }
    1856                 :            : 
    1857                 :            : /**
    1858                 :            :  * @descr:  create xfshadow
    1859                 :            :  * @param:
    1860                 :            :  * @param:
    1861                 :            :  * @return:
    1862                 :            : */
    1863                 :        150 : XFShadow* LwpLayout::GetXFShadow()
    1864                 :            : {
    1865                 :        150 :     LwpShadow* pShadow = GetShadow();
    1866         [ +  + ]:        150 :     if( pShadow )
    1867                 :            :     {
    1868                 :        147 :         LwpColor color = pShadow->GetColor();
    1869                 :        147 :         double  offsetX = pShadow->GetOffsetX();
    1870                 :        147 :         double  offsetY = pShadow->GetOffsetY();
    1871                 :            : 
    1872 [ #  # ][ #  # ]:        147 :         if( offsetX && offsetY && color.IsValidColor() )
         [ -  + ][ -  + ]
    1873                 :            :         {
    1874 [ #  # ][ #  # ]:          0 :             XFShadow* pXFShadow = new XFShadow();
    1875                 :          0 :             enumXFShadowPos eXFShadowPos = enumXFShadowLeftTop;
    1876                 :          0 :             double fOffset = 0;
    1877                 :            : 
    1878                 :          0 :             sal_Bool left = sal_False;
    1879                 :          0 :             sal_Bool top = sal_False;
    1880         [ #  # ]:          0 :             if( offsetX < 0 )
    1881                 :          0 :                 left = sal_True;
    1882         [ #  # ]:          0 :             if( offsetY < 0 )
    1883                 :          0 :                 top = sal_True;
    1884         [ #  # ]:          0 :             if( left )
    1885                 :            :             {
    1886                 :          0 :                 fOffset = -offsetX;
    1887         [ #  # ]:          0 :                 if( top )
    1888                 :          0 :                     eXFShadowPos = enumXFShadowLeftTop;
    1889                 :            :                 else
    1890                 :          0 :                     eXFShadowPos = enumXFShadowLeftBottom;
    1891                 :            :             }
    1892                 :            :             else
    1893                 :            :             {
    1894                 :          0 :                 fOffset = offsetX;
    1895         [ #  # ]:          0 :                 if( top )
    1896                 :          0 :                     eXFShadowPos = enumXFShadowRightTop;
    1897                 :            :                 else
    1898                 :          0 :                     eXFShadowPos = enumXFShadowRightBottom;
    1899                 :            :             }
    1900                 :            : 
    1901                 :          0 :             pXFShadow->SetPosition(eXFShadowPos);
    1902                 :          0 :             pXFShadow->SetOffset(fOffset);
    1903         [ #  # ]:          0 :             pXFShadow->SetColor(XFColor(color.To24Color()));
    1904                 :            : 
    1905                 :        147 :             return pXFShadow;
    1906         [ +  - ]:        147 :         }
    1907                 :            :     }
    1908                 :        150 :     return NULL;
    1909                 :            : }
    1910                 :            : 
    1911                 :            : /**
    1912                 :            :  * @descr get the layout that containers the current frame layout
    1913                 :            :  *
    1914                 :            :  */
    1915                 :        201 : LwpVirtualLayout* LwpLayout::GetContainerLayout()
    1916                 :            : {
    1917         [ +  - ]:        201 :     if(IsRelativeAnchored())
    1918                 :            :     {
    1919                 :            :         //get position
    1920         [ -  + ]:        201 :         LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition()->obj());
    1921         [ +  - ]:        201 :         if(pPara)
    1922                 :            :         {
    1923                 :        201 :             LwpStory* pStory = pPara->GetStory();
    1924         [ +  + ]:        201 :             return pStory ? pStory->GetTabLayout() : NULL;
    1925                 :            :         }
    1926                 :            :     }
    1927                 :        201 :     return GetParentLayout();
    1928                 :            : }
    1929                 :            : 
    1930                 :        186 : LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm )
    1931 [ +  - ][ +  - ]:        186 :     : LwpLayout(objHdr, pStrm),m_pFont(NULL)
    1932                 :        186 : {}
    1933                 :            : 
    1934         [ +  - ]:        186 : LwpPlacableLayout::~LwpPlacableLayout()
    1935         [ -  + ]:        186 : {}
    1936                 :            : 
    1937                 :        186 : void LwpPlacableLayout::Read()
    1938                 :            : {
    1939                 :        186 :     LwpObjectStream* pStrm = m_pObjStrm;
    1940                 :        186 :     LwpLayout::Read();
    1941         [ +  - ]:        186 :     if(LwpFileHeader::m_nFileRevision < 0x000B)
    1942                 :            :     {
    1943                 :            :         assert(false);
    1944                 :            :     }
    1945                 :            :     else
    1946                 :            :     {
    1947                 :        186 :         sal_uInt16 simple = pStrm->QuickReaduInt16();
    1948         [ +  + ]:        186 :         if(!simple)
    1949                 :            :         {
    1950                 :         90 :             m_nWrapType = pStrm->QuickReaduInt8();
    1951                 :         90 :             m_nBuoyancy = pStrm->QuickReaduInt8();
    1952                 :         90 :             m_nBaseLineOffset = pStrm->QuickReadInt32();
    1953                 :         90 :             m_Script.Read( pStrm);
    1954                 :            :         }
    1955                 :            :         else
    1956                 :            :         {
    1957                 :         96 :             m_nWrapType = LAY_WRAP_AROUND;
    1958                 :         96 :             m_nBuoyancy = LAY_BUOYNEUTRAL;
    1959                 :         96 :             m_nBaseLineOffset    = 0;
    1960                 :            :         }
    1961                 :        186 :         m_LayRelativity.ReadIndexed( pStrm);
    1962         [ +  + ]:        186 :         if(pStrm->CheckExtra())
    1963                 :            :         {
    1964                 :        156 :             sal_uInt16 count = pStrm->QuickReaduInt16();
    1965         [ -  + ]:        156 :             if(count)
    1966                 :            :             {
    1967                 :            :                 // temporily added by  to avoid assertion
    1968         [ #  # ]:          0 :                 while (count)
    1969                 :            :                 {
    1970         [ #  # ]:          0 :                     LwpPoint aPoint;
    1971         [ #  # ]:          0 :                     aPoint.Read(pStrm);
    1972                 :          0 :                     count--;
    1973                 :            :                 }
    1974                 :            :                 // end added by
    1975                 :            :             }
    1976                 :        156 :             pStrm->SkipExtra();
    1977                 :            :         }
    1978                 :            :     }
    1979                 :        186 : }
    1980                 :            : /**
    1981                 :            :  * @descr:  get wrap type
    1982                 :            :  * @param:
    1983                 :            :  * @param:
    1984                 :            :  * @return:
    1985                 :            : */
    1986                 :         75 : sal_uInt8 LwpPlacableLayout::GetWrapType()
    1987                 :            : {
    1988         [ +  - ]:         75 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    1989                 :            :     {
    1990                 :         75 :         return m_nWrapType;
    1991                 :            :     }
    1992         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    1993                 :            :     {
    1994         [ #  # ]:          0 :         LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
    1995         [ #  # ]:          0 :         if (pLay)
    1996                 :          0 :             return pLay->GetWrapType();
    1997                 :            :     }
    1998                 :         75 :     return LAY_WRAP_AROUND;
    1999                 :            : }
    2000                 :            : /**
    2001                 :            :  * @descr:  get LayoutRelativity
    2002                 :            :  * @param:
    2003                 :            :  * @param:
    2004                 :            :  * @return:
    2005                 :            : */
    2006                 :        849 : LwpLayoutRelativity* LwpPlacableLayout::GetRelativityPiece()
    2007                 :            : {
    2008         [ +  - ]:        849 :     if(!m_LayRelativity.IsNull())
    2009                 :            :     {
    2010         [ +  - ]:        849 :         if(m_nOverrideFlag & OVER_PLACEMENT)
    2011                 :            :         {
    2012         [ +  - ]:        849 :             return dynamic_cast<LwpLayoutRelativity*>(m_LayRelativity.obj());
    2013                 :            :         }
    2014                 :            :     }
    2015         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    2016                 :            :     {
    2017         [ #  # ]:          0 :         LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
    2018         [ #  # ]:          0 :         return pLay ? pLay->GetRelativityPiece() : NULL;
    2019                 :            :     }
    2020                 :        849 :     return NULL;
    2021                 :            : }
    2022                 :            : /**
    2023                 :            : * @descr:   Get relative type
    2024                 :            : *
    2025                 :            : */
    2026                 :        849 : sal_uInt8 LwpPlacableLayout::GetRelativeType()
    2027                 :            : {
    2028                 :        849 :     LwpLayoutRelativity* pLayRel = GetRelativityPiece();
    2029         [ +  - ]:        849 :     if(pLayRel)
    2030                 :            :     {
    2031                 :        849 :         return pLayRel->GetRelGuts()->GetRelativeType();
    2032                 :            :     }
    2033                 :        849 :     return LwpVirtualLayout::GetRelativeType();
    2034                 :            : }
    2035                 :            : /**
    2036                 :            : * @descr:   Get offset from the baseline
    2037                 :            : *
    2038                 :            : */
    2039                 :          0 : sal_Int32 LwpPlacableLayout::GetBaseLineOffset()
    2040                 :            : {
    2041                 :            :     /* The baseline is only valid if this is flow-with-text */
    2042         [ #  # ]:          0 :     if(GetRelativeType()!=LwpLayoutRelativityGuts::LAY_INLINE)
    2043                 :            :     {
    2044                 :          0 :         return 0;
    2045                 :            :     }
    2046                 :            : 
    2047                 :            :     // First, ask our content if it has a baseline, ignore now
    2048                 :            :     /*
    2049                 :            :     if (Content && Content->GetBaseLineOffset(&Baseline))
    2050                 :            :         return Baseline;
    2051                 :            :     */
    2052                 :            : 
    2053         [ #  # ]:          0 :     if(m_nOverrideFlag & OVER_PLACEMENT)
    2054                 :            :     {
    2055                 :          0 :         return m_nBaseLineOffset;
    2056                 :            :     }
    2057         [ #  # ]:          0 :     else if( !m_BasedOnStyle.IsNull() )
    2058                 :            :     {
    2059         [ #  # ]:          0 :         LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
    2060         [ #  # ]:          0 :         return pLay ? pLay->GetBaseLineOffset() : 0;
    2061                 :            :     }
    2062                 :          0 :     return 0;
    2063                 :            : 
    2064                 :            : 
    2065                 :            : }
    2066                 :            : /**
    2067                 :            : * @descr:   whether the parent layout is page layout
    2068                 :            : *
    2069                 :            : */
    2070                 :         36 : sal_Bool LwpPlacableLayout::IsAnchorPage()
    2071                 :            : {
    2072         [ -  + ]:         36 :     if(IsRelativeAnchored())
    2073                 :          0 :         return sal_False;
    2074                 :            : 
    2075                 :         36 :     LwpVirtualLayout* pLayout = GetParentLayout();
    2076 [ -  + ][ #  # ]:         36 :     if(pLayout && (pLayout->IsPage() || pLayout->IsHeader() || pLayout->IsFooter()))
         [ #  # ][ +  - ]
                 [ +  - ]
    2077                 :            :     //if(pLayout && pLayout->IsPage())
    2078                 :            :     {
    2079                 :         36 :         return sal_True;
    2080                 :            :     }
    2081                 :         36 :     return sal_False;
    2082                 :            : }
    2083                 :            : /**
    2084                 :            : * @descr:   whether the parent layout is frame layout
    2085                 :            : *
    2086                 :            : */
    2087                 :         18 : sal_Bool LwpPlacableLayout::IsAnchorFrame()
    2088                 :            : {
    2089         [ -  + ]:         18 :     if(IsRelativeAnchored())
    2090                 :          0 :         return sal_False;
    2091                 :            : 
    2092                 :         18 :     LwpVirtualLayout* pLayout = GetParentLayout();
    2093 [ +  - ][ -  + ]:         18 :     if(pLayout && (pLayout->IsFrame()||pLayout->IsGroupHead()))
         [ -  + ][ +  - ]
    2094                 :            :     {
    2095                 :          0 :         return sal_True;
    2096                 :            :     }
    2097                 :         18 :     return sal_False;
    2098                 :            : }
    2099                 :            : /**
    2100                 :            : * @descr:   whether the parent layout is cell layout
    2101                 :            : *
    2102                 :            : */
    2103                 :         18 : sal_Bool LwpPlacableLayout::IsAnchorCell()
    2104                 :            : {
    2105         [ -  + ]:         18 :     if(IsRelativeAnchored())
    2106                 :          0 :         return sal_False;
    2107                 :            : 
    2108                 :         18 :     LwpVirtualLayout* pLayout = GetParentLayout();
    2109 [ -  + ][ -  + ]:         18 :     if(pLayout && pLayout->IsCell())
                 [ +  - ]
    2110                 :            :     {
    2111                 :          0 :         return sal_True;
    2112                 :            :     }
    2113                 :         18 :     return sal_False;
    2114                 :            : }
    2115                 :            : 
    2116                 :            : /**
    2117                 :            : * @descr:   Get font style for setting position of frame
    2118                 :            : *
    2119                 :            : */
    2120                 :          0 : XFFont* LwpPlacableLayout::GetFont()
    2121                 :            : {
    2122                 :          0 :     return m_pFont;
    2123                 :            : }
    2124                 :            : /**
    2125                 :            : * @descr:   Set font style for setting position of frame
    2126                 :            : *
    2127                 :            : */
    2128                 :         75 : void LwpPlacableLayout::SetFont(XFFont * pFont)
    2129                 :            : {
    2130                 :         75 :     m_pFont = pFont;
    2131                 :         75 : }
    2132                 :            : 
    2133                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10