LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpfribsection.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 181 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  *  The Contents of this file are made available subject to the terms of
       5             :  *  either of the following licenses
       6             :  *
       7             :  *         - GNU Lesser General Public License Version 2.1
       8             :  *         - Sun Industry Standards Source License Version 1.1
       9             :  *
      10             :  *  Sun Microsystems Inc., October, 2000
      11             :  *
      12             :  *  GNU Lesser General Public License Version 2.1
      13             :  *  =============================================
      14             :  *  Copyright 2000 by Sun Microsystems, Inc.
      15             :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16             :  *
      17             :  *  This library is free software; you can redistribute it and/or
      18             :  *  modify it under the terms of the GNU Lesser General Public
      19             :  *  License version 2.1, as published by the Free Software Foundation.
      20             :  *
      21             :  *  This library is distributed in the hope that it will be useful,
      22             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :  *  Lesser General Public License for more details.
      25             :  *
      26             :  *  You should have received a copy of the GNU Lesser General Public
      27             :  *  License along with this library; if not, write to the Free Software
      28             :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29             :  *  MA  02111-1307  USA
      30             :  *
      31             :  *
      32             :  *  Sun Industry Standards Source License Version 1.1
      33             :  *  =================================================
      34             :  *  The contents of this file are subject to the Sun Industry Standards
      35             :  *  Source License Version 1.1 (the "License"); You may not use this file
      36             :  *  except in compliance with the License. You may obtain a copy of the
      37             :  *  License at http://www.openoffice.org/license.html.
      38             :  *
      39             :  *  Software provided under this License is provided on an "AS IS" basis,
      40             :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41             :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42             :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43             :  *  See the License for the specific provisions governing your rights and
      44             :  *  obligations concerning the Software.
      45             :  *
      46             :  *  The Initial Developer of the Original Code is: IBM Corporation
      47             :  *
      48             :  *  Copyright: 2008 by IBM Corporation
      49             :  *
      50             :  *  All Rights Reserved.
      51             :  *
      52             :  *  Contributor(s): _______________________________________
      53             :  *
      54             :  *
      55             :  ************************************************************************/
      56             : /*************************************************************************
      57             :  * @file
      58             :  *  the class for section frib and process section and page layout
      59             :  ************************************************************************/
      60             : /*************************************************************************
      61             :  * Change History
      62             : Jan 2005        Created
      63             :  ************************************************************************/
      64             : #include "lwpfribsection.hxx"
      65             : #include "lwpfribbreaks.hxx"
      66             : #include "lwpstory.hxx"
      67             : #include "lwpsection.hxx"
      68             : #include "xfilter/xfstylemanager.hxx"
      69             : #include "xfilter/xfsectionstyle.hxx"
      70             : #include "xfilter/xfsection.hxx"
      71             : #include "xfilter/xfindex.hxx"
      72             : #include "lwpfribptr.hxx"
      73             : #include "lwpglobalmgr.hxx"
      74             : 
      75           0 : LwpFribSection::LwpFribSection(LwpPara *pPara)
      76           0 :      : LwpFrib(pPara),m_pMasterPage(NULL)
      77             : {
      78             : 
      79           0 : }
      80             : 
      81           0 : LwpFribSection::~LwpFribSection()
      82             : {
      83           0 :     if(m_pMasterPage)
      84             :     {
      85           0 :         delete m_pMasterPage;
      86           0 :         m_pMasterPage = NULL;
      87             :     }
      88           0 : }
      89             : 
      90             : /**
      91             :  * @descr:  Read section frib information
      92             :  *
      93             :  */
      94           0 : void LwpFribSection::Read(LwpObjectStream *pObjStrm, sal_uInt16 /*len*/)
      95             : {
      96           0 :     m_Section.ReadIndexed(pObjStrm);
      97           0 : }
      98             : 
      99             : /**
     100             :  * @descr:  Get section pointer
     101             :  *
     102             :  */
     103           0 : LwpSection* LwpFribSection::GetSection()
     104             : {
     105           0 :     return static_cast<LwpSection*>(m_Section.obj().get());
     106             : }
     107             : 
     108             : /**
     109             :  * @descr:  Register section style
     110             :  *
     111             :  */
     112           0 : void LwpFribSection::RegisterSectionStyle()
     113             : {
     114           0 :     LwpPageLayout* pLayout = GetPageLayout();
     115           0 :     if(pLayout)
     116             :     {
     117           0 :         m_pMasterPage = new LwpMasterPage(m_pPara, pLayout);
     118           0 :         m_pMasterPage->RegisterMasterPage(this);
     119             :     }
     120           0 : }
     121             : 
     122             : /**
     123             :  * @descr:  Register section style
     124             :  *
     125             :  */
     126           0 : void LwpFribSection::SetSectionName()
     127             : {
     128           0 :     LwpSection* pSection = GetSection();
     129           0 :     if(pSection)
     130             :     {
     131           0 :         LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
     132           0 :         pStory->SetSectionName(pSection->GetSectionName());
     133             :     }
     134           0 : }
     135             : 
     136             : /**
     137             :  * @descr:  Get page layout that current section points
     138             :  *
     139             :  */
     140           0 : LwpPageLayout* LwpFribSection::GetPageLayout()
     141             : {
     142           0 :     if(GetSection())
     143           0 :         return GetSection()->GetPageLayout();
     144           0 :     return NULL;
     145             : }
     146             : 
     147             : /**
     148             :  * @descr:  XFConvert section
     149             :  *
     150             :  */
     151           0 : void LwpFribSection::ParseSection()
     152             : {
     153           0 :     LwpPageLayout* pLayout = GetPageLayout();
     154           0 :     if(pLayout)
     155             :     {
     156             :         // StartWithinColume not support now
     157           0 :         LwpLayout::UseWhenType eSectionType = pLayout->GetUseWhenType();
     158           0 :         if(eSectionType==LwpLayout::StartWithinColume)
     159             :         {
     160           0 :             return;
     161             :         }
     162           0 :         if(m_pMasterPage)
     163             :         {
     164           0 :             m_pMasterPage->ParseSection(this);
     165             :         }
     166             :     }
     167             :     else
     168             :     {
     169           0 :         LwpStory* pStory = static_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() );
     170           0 :         if (m_Section.obj()->GetTag() == VO_INDEXSECTION)
     171             :         {
     172             :             //create a new section and add it to container
     173           0 :             XFIndex* pIndex = new XFIndex;
     174           0 :             pIndex->SetIndexType(enumXFIndexAlphabetical);
     175             :             /*
     176             :             sal_Bool bRunin = sal_False;
     177             :             sal_Bool bSeparator = sal_False;
     178             :             LwpIndexSection* pIndexSection = static_cast<LwpIndexSection*>(m_Section.obj());
     179             :             if (pIndexSection->IsFormatRunin())
     180             :                 bRunin = sal_True;
     181             :             if (pIndexSection->IsFormatSeparator())
     182             :                 bSeparator = sal_True;
     183             :             pIndex->SetDefaultAlphaIndex("",bRunin,bSeparator);
     184             :             */
     185           0 :             SetDefaultAlphaIndex(pIndex);
     186             : 
     187           0 :             pStory->AddXFContent( pIndex );
     188           0 :             m_pPara->SetXFContainer( pIndex );
     189             :         }
     190             :         else
     191             :         {
     192           0 :             XFContentContainer* pContent = pStory->GetXFContent();
     193           0 :             m_pPara->SetXFContainer( pContent );
     194             :         }
     195             :     }
     196             : }
     197             : 
     198           0 : void LwpFribSection::SetDefaultAlphaIndex(XFIndex * pXFIndex)
     199             : {
     200           0 :     LwpFoundry* pFoundry = m_pPara->GetFoundry();
     201           0 :     OUString styleName = pFoundry->FindActuralStyleName("Separator");
     202             : 
     203           0 :     LwpIndexSection* pIndexSection = static_cast<LwpIndexSection*>(m_Section.obj().get());
     204           0 :     XFIndexTemplate * pTemplateSep = new XFIndexTemplate();
     205           0 :     if (pIndexSection->IsFormatSeparator())
     206             :     {
     207           0 :         pXFIndex->SetSeparator(true);
     208           0 :         pTemplateSep->AddEntry(enumXFIndexTemplateText,"");
     209             :     }
     210             :     //pXFIndex->AddTemplate("separator","Separator",pTemplateSep);
     211           0 :     pXFIndex->AddTemplate("separator",styleName,pTemplateSep);
     212             : 
     213           0 :     styleName = pFoundry->FindActuralStyleName("Primary");
     214             : 
     215           0 :     XFIndexTemplate * pTemplate1 = new XFIndexTemplate();
     216           0 :     pTemplate1->AddEntry(enumXFIndexTemplateText,"");
     217           0 :     pTemplate1->AddEntry(enumXFIndexTemplateTab,"");
     218           0 :     pTemplate1->AddEntry(enumXFIndexTemplatePage,"");
     219             :     //pXFIndex->AddTemplate(OUString::number(1),"Primary",pTemplate1);
     220           0 :     pXFIndex->AddTemplate(OUString::number(1),styleName,pTemplate1);
     221             : 
     222           0 :     XFIndexTemplate * pTemplate2 = new XFIndexTemplate();
     223           0 :     pTemplate2->AddEntry(enumXFIndexTemplateText,"");
     224           0 :     pTemplate2->AddEntry(enumXFIndexTemplateTab,"");
     225           0 :     pTemplate2->AddEntry(enumXFIndexTemplatePage,"");
     226           0 :     XFIndexTemplate * pTemplate3 = new XFIndexTemplate();
     227           0 :     pTemplate3->AddEntry(enumXFIndexTemplateText,"");
     228           0 :     pTemplate3->AddEntry(enumXFIndexTemplateTab,"");
     229           0 :     pTemplate3->AddEntry(enumXFIndexTemplatePage,"");
     230             : 
     231           0 :     if (pIndexSection->IsFormatRunin())
     232             :     {
     233             :         //pXFIndex->AddTemplate(OUString::number(2),"Primary",pTemplate2);
     234             :         //pXFIndex->AddTemplate(OUString::number(3),"Primary",pTemplate3);
     235           0 :         pXFIndex->AddTemplate(OUString::number(2),styleName,pTemplate2);
     236           0 :         pXFIndex->AddTemplate(OUString::number(3),styleName,pTemplate3);
     237             :     }
     238             :     else
     239             :     {
     240             :         //pXFIndex->AddTemplate(OUString::number(2),"Secondary",pTemplate2);
     241             :         //pXFIndex->AddTemplate(OUString::number(3),"Secondary",pTemplate3);
     242           0 :         styleName = pFoundry->FindActuralStyleName("Secondary");
     243           0 :         pXFIndex->AddTemplate(OUString::number(2),styleName,pTemplate2);
     244           0 :         pXFIndex->AddTemplate(OUString::number(3),styleName,pTemplate3);
     245           0 :     }
     246           0 : }
     247             : 
     248           0 : LwpMasterPage::LwpMasterPage(LwpPara* pPara, LwpPageLayout* pLayout)
     249           0 :     :m_bNewSection(false),m_pPara(pPara),m_pLayout(pLayout)
     250             : {
     251           0 : }
     252             : 
     253             : /**
     254             :  * @descr:  Register master page style for para style and register section style if necessary
     255             :  *
     256             :  */
     257           0 : bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
     258             : {
     259             :     //if there is no other frib after current firb, register master page in starting para of next page
     260           0 :     if(IsNextPageType()&&(!pFrib->HasNextFrib()))
     261             :     {
     262           0 :         LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
     263           0 :         pStory->SetCurrentLayout(m_pLayout);
     264           0 :         RegisterFillerPageStyle();
     265           0 :         return false;
     266             :     }
     267             : 
     268           0 :     m_bNewSection = false;
     269             :     //sal_Bool bSectionColumns = sal_False;
     270             : 
     271           0 :     XFParaStyle* pOverStyle = new XFParaStyle;
     272           0 :     *pOverStyle = *(m_pPara->GetXFParaStyle());
     273           0 :     pOverStyle->SetStyleName("");
     274             : 
     275           0 :     LwpLayout::UseWhenType eUserType = m_pLayout->GetUseWhenType();
     276           0 :     switch(eUserType)
     277             :     {
     278             :         case LwpLayout::StartWithinColume://not support now
     279             :         {
     280           0 :             m_bNewSection = false;
     281           0 :             break;
     282             :         }
     283             :         case LwpLayout::StartWithinPage:
     284             :         {
     285           0 :             m_bNewSection = true;
     286             :             //bSectionColumns = sal_True;
     287           0 :             break;
     288             :         }
     289             :         case LwpLayout::StartOnNextPage://fall through
     290             :         case LwpLayout::StartOnOddPage: //fall through
     291             :         case LwpLayout::StartOnEvenPage:
     292             :         {
     293           0 :             LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
     294           0 :             pStory->SetCurrentLayout(m_pLayout);
     295             :             //get odd page layout when the current pagelayout is mirror
     296           0 :             m_pLayout = pStory->GetCurrentLayout();
     297           0 :             m_bNewSection = IsNeedSection();
     298             :             //bSectionColumns = m_bNewSection;
     299           0 :             pOverStyle->SetMasterPage( m_pLayout->GetStyleName());
     300           0 :             RegisterFillerPageStyle();
     301           0 :             break;
     302             :         }
     303             :         default:
     304           0 :             break;
     305             :     }
     306             : 
     307             :     //register tab style;
     308           0 :     LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
     309           0 :     pStory->SetTabLayout(m_pLayout);
     310           0 :     m_pPara->RegisterTabStyle(pOverStyle);
     311             : 
     312           0 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     313           0 :     m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
     314             :     //register section style here
     315           0 :     if(m_bNewSection)
     316             :     {
     317           0 :         XFSectionStyle* pSectStyle= new XFSectionStyle();
     318             :         //set margin
     319           0 :         pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
     320           0 :         if(pStory)
     321             :         {
     322           0 :             LwpPageLayout* pCurrentLayout = pStory->GetCurrentLayout();
     323           0 :             double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT)- pCurrentLayout->GetMarginsValue(MARGIN_LEFT);
     324           0 :             double fRight = m_pLayout->GetMarginsValue(MARGIN_RIGHT)- pCurrentLayout->GetMarginsValue(MARGIN_RIGHT);
     325           0 :             pSectStyle->SetMarginLeft(fLeft);
     326           0 :             pSectStyle->SetMarginRight(fRight);
     327             :         }
     328             : 
     329             :         //if(bSectionColumns)
     330             :         //{
     331             :             //set columns
     332           0 :             XFColumns* pColumns = m_pLayout->GetXFColumns();
     333           0 :             if(pColumns)
     334             :             {
     335           0 :                 pSectStyle->SetColumns(pColumns);
     336             :             }
     337             :         //}
     338           0 :         m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName();
     339             :     }
     340           0 :     return false;
     341             : }
     342             : 
     343             : /**
     344             :  * @descr:  Whether it need create a new section
     345             :  *
     346             :  */
     347           0 : bool LwpMasterPage::IsNeedSection()
     348             : {
     349           0 :     bool bNewSection = false;
     350             :     //get story
     351           0 :     LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
     352             :     //if pagelayout is modified, register the pagelayout
     353           0 :     if(pStory->IsPMModified())
     354             :     {
     355           0 :         bNewSection = pStory->IsNeedSection();
     356             :     }
     357           0 :     return bNewSection;
     358             : }
     359             : 
     360             : /**
     361             :  * @descr:  Create XFSection if necessary
     362             :  *
     363             :  */
     364           0 : XFSection* LwpMasterPage::CreateXFSection()
     365             : {
     366           0 :     if(m_bNewSection)
     367             :     {
     368             :         //new a section
     369           0 :         XFSection* pXFSection = new XFSection();
     370           0 :         pXFSection->SetStyleName(m_SectionStyleName);
     371           0 :         return pXFSection;
     372             :     }
     373           0 :     return NULL;
     374             : }
     375             : 
     376             : /**
     377             :  * @descr:  Parse section
     378             :  *
     379             :  */
     380           0 : void LwpMasterPage::ParseSection(LwpFrib* pFrib)
     381             : {
     382           0 :     LwpFribPtr& rFribPtr = m_pPara->GetFribs();
     383             :     //XFParagraph * pXFPara = rFribPtr.GetXFPara();
     384             : 
     385             :     //parse fillerpage text
     386           0 :     if(m_pLayout->HasFillerPageText(m_pPara->GetFoundry()))
     387             :     {
     388           0 :         XFParagraph *pPara = new XFParagraph();
     389           0 :         pPara->SetStyleName(GetFillerPageStyleName());
     390           0 :         m_pPara->AddXFContent(pPara);
     391           0 :         rFribPtr.SetXFPara(pPara);
     392             : 
     393           0 :         m_pLayout->ConvertFillerPageText(m_pPara->GetXFContainer());
     394             :     }
     395             :     //create a new section and add it to container
     396           0 :     XFContentContainer* pContent = CreateXFSection();
     397           0 :     if(pContent)
     398             :     {
     399           0 :         LwpStory* pStory = static_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() );
     400             :         //delete the additional blank para, 06/28/2005
     401           0 :         XFParagraph* pCurrPara = rFribPtr.GetXFPara();
     402           0 :         if(!pCurrPara->HasContents())
     403             :         {
     404           0 :             XFContentContainer* pCurrContainer = m_pPara->GetXFContainer();
     405           0 :             if(pFrib->HasNextFrib() && (pCurrContainer->GetLastContent() == pCurrPara))
     406             :             {
     407           0 :                 pCurrContainer->RemoveLastContent();
     408             :             }
     409             :         }
     410             :         //end,06/28/2005
     411           0 :         pStory->AddXFContent( pContent );
     412             :     }
     413             :     else
     414             :     {
     415           0 :         LwpStory* pStory = static_cast<LwpStory*> ( m_pPara->GetStoryID().obj().get() );
     416           0 :         pContent = pStory->GetXFContent();
     417             :     }
     418           0 :     if(pContent)
     419             :     {
     420           0 :         m_pPara->SetXFContainer( pContent );
     421             :     }
     422             :     //out put the contents after the section frib in the same para.
     423           0 :     if(pFrib->HasNextFrib())
     424             :     {
     425           0 :         XFParagraph *pNextPara = new XFParagraph();
     426           0 :         pNextPara->SetStyleName(GetStyleName());
     427           0 :         m_pPara->AddXFContent(pNextPara);
     428           0 :         rFribPtr.SetXFPara(pNextPara);
     429             :     }
     430             : 
     431           0 : }
     432             : 
     433             : /**
     434             :  * @descr:  Register filler page text style
     435             :  *
     436             :  */
     437           0 : void LwpMasterPage::RegisterFillerPageStyle()
     438             : {
     439           0 :     LwpLayout::UseWhenType eUserType = m_pLayout->GetUseWhenType();
     440           0 :     if(eUserType==LwpLayout::StartOnOddPage
     441           0 :             ||eUserType==LwpLayout::StartOnEvenPage)
     442             :     {
     443           0 :         if(m_pLayout->HasFillerPageText(m_pPara->GetFoundry()))
     444             :         {
     445           0 :             XFParaStyle* pPagebreakStyle = new XFParaStyle;
     446           0 :             *pPagebreakStyle = *(m_pPara->GetXFParaStyle());
     447           0 :             pPagebreakStyle->SetStyleName("");
     448           0 :             pPagebreakStyle->SetBreaks(enumXFBreakAftPage);
     449           0 :             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     450           0 :             m_FillerPageStyleName= pXFStyleManager->AddStyle(pPagebreakStyle).m_pStyle->GetStyleName();
     451             :         }
     452             :     }
     453           0 : }
     454             : 
     455             : /**
     456             :  * @descr:  Whether the layout is next page type
     457             :  *
     458             :  */
     459           0 : bool LwpMasterPage::IsNextPageType()
     460             : {
     461           0 :     LwpLayout::UseWhenType eUserType = m_pLayout->GetUseWhenType();
     462           0 :     if(eUserType == LwpLayout::StartOnNextPage
     463           0 :         || eUserType == LwpLayout::StartOnOddPage
     464           0 :         || eUserType == LwpLayout::StartOnEvenPage )
     465             :     {
     466           0 :         return true;
     467             :     }
     468           0 :     return false;
     469             : }
     470             : 
     471             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11