LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgassim.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 91 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #ifdef SD_DLLIMPLEMENTATION
      31                 :            : #undef SD_DLLIMPLEMENTATION
      32                 :            : #endif
      33                 :            : #include <sfx2/docfile.hxx>
      34                 :            : #include <unotools/pathoptions.hxx>
      35                 :            : 
      36                 :            : #include "sdpage.hxx"
      37                 :            : #include "Outliner.hxx"
      38                 :            : #include "res_bmp.hrc"
      39                 :            : 
      40                 :            : #include <vcl/svapp.hxx>
      41                 :            : 
      42                 :            : #include "dlgassim.hxx"
      43                 :            : 
      44                 :          0 : SdPageListControl::SdPageListControl(
      45                 :            :     ::Window* pParent,
      46                 :            :     const ResId& rResId )
      47                 :          0 :     : SvTreeListBox(pParent, rResId)
      48                 :            : {
      49                 :            :     // Tree-ListBox mit Linien versehen
      50                 :          0 :     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
      51                 :            :                             WB_HASBUTTONS |  WB_HASLINESATROOT |
      52                 :            :                             WB_HSCROLL |
      53                 :          0 :                             WB_HASBUTTONSATROOT );
      54                 :            : 
      55                 :          0 :     SetNodeDefaultImages ();
      56                 :          0 :     m_pCheckButton = new SvLBoxButtonData(this);
      57                 :          0 :     EnableCheckButton (m_pCheckButton);
      58                 :            : 
      59                 :          0 :     SetCheckButtonHdl( LINK(this,SdPageListControl,CheckButtonClickHdl) );
      60                 :          0 : }
      61                 :            : 
      62                 :          0 : IMPL_LINK_NOARG(SdPageListControl, CheckButtonClickHdl)
      63                 :            : {
      64                 :          0 :     SvLBoxTreeList* pTreeModel = GetModel();
      65                 :          0 :     SvLBoxEntry* pEntry = pTreeModel->First();
      66                 :            : 
      67                 :          0 :     while( pEntry )
      68                 :            :     {
      69                 :          0 :         if(pTreeModel->IsAtRootDepth(pEntry) && GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED )
      70                 :          0 :             return 0;
      71                 :          0 :         pEntry = pTreeModel->Next( pEntry );
      72                 :            :     }
      73                 :            : 
      74                 :          0 :     pEntry = pTreeModel->First();
      75                 :          0 :     SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
      76                 :            : 
      77                 :          0 :     return 0;
      78                 :            : }
      79                 :            : 
      80                 :          0 : SdPageListControl::~SdPageListControl()
      81                 :            : {
      82                 :          0 :     delete m_pCheckButton;
      83                 :          0 : }
      84                 :            : 
      85                 :          0 : void SdPageListControl::Clear()
      86                 :            : {
      87                 :          0 :     SvTreeListBox::Clear();
      88                 :          0 : }
      89                 :            : 
      90                 :          0 : SvLBoxEntry* SdPageListControl::InsertPage( const String& rPageName )
      91                 :            : {
      92                 :          0 :     SvLBoxEntry* pEntry = new SvLBoxEntry;
      93                 :            : 
      94                 :            :     pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox,
      95                 :          0 :                                        0, m_pCheckButton));
      96                 :          0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));    // Sonst Puff!
      97                 :          0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rPageName ) );
      98                 :            : 
      99                 :          0 :     GetModel()->Insert( pEntry );
     100                 :            : 
     101                 :          0 :     return pEntry;
     102                 :            : }
     103                 :            : 
     104                 :          0 : void SdPageListControl::InsertTitle( SvLBoxEntry* pParent, const String& rTitle )
     105                 :            : {
     106                 :          0 :     SvLBoxEntry* pEntry = new SvLBoxEntry;
     107                 :          0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, String() ) );
     108                 :          0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));    // Sonst Puff!
     109                 :          0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rTitle ) );
     110                 :          0 :     GetModel()->Insert( pEntry,pParent );
     111                 :          0 : }
     112                 :            : 
     113                 :          0 : void SdPageListControl::Fill( SdDrawDocument* pDoc )
     114                 :            : {
     115                 :          0 :     Outliner* pOutliner = pDoc->GetInternalOutliner();
     116                 :            : 
     117                 :          0 :     sal_uInt16 nPage = 0;
     118                 :          0 :     const sal_uInt16 nMaxPages = pDoc->GetPageCount();
     119                 :          0 :     while( nPage < nMaxPages )
     120                 :            :     {
     121                 :          0 :         SdPage* pPage = (SdPage*) pDoc->GetPage( nPage );
     122                 :          0 :         if( pPage->GetPageKind() == PK_STANDARD )
     123                 :            :         {
     124                 :          0 :             SvLBoxEntry* pEntry = InsertPage( pPage->GetName() );
     125                 :          0 :             SetCheckButtonState(pEntry, SvButtonState( SV_BUTTON_CHECKED ) );
     126                 :            : 
     127                 :          0 :             SdrTextObj* pTO = (SdrTextObj*)pPage->GetPresObj(PRESOBJ_TEXT);
     128                 :          0 :             if(!pTO)
     129                 :            :             {
     130                 :            :                 // Ermittelt das SdrTextObject mit dem Layout Text dieser Seite
     131                 :          0 :                 const sal_uLong nObjectCount = pPage->GetObjCount();
     132                 :          0 :                 for (sal_uLong nObject = 0; nObject < nObjectCount; nObject++)
     133                 :            :                 {
     134                 :          0 :                     SdrObject* pObject = pPage->GetObj(nObject);
     135                 :          0 :                     if (pObject->GetObjInventor() == SdrInventor && pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
     136                 :            :                     {
     137                 :          0 :                         pTO = (SdrTextObj*)pObject;
     138                 :          0 :                         break;
     139                 :            :                     }
     140                 :            :                 }
     141                 :            :             }
     142                 :            : 
     143                 :          0 :             if (pTO && !pTO->IsEmptyPresObj())
     144                 :            :             {
     145                 :          0 :                 OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
     146                 :          0 :                 if (pOPO)
     147                 :            :                 {
     148                 :          0 :                     pOutliner->Clear();
     149                 :          0 :                     pOutliner->SetText( *pOPO );
     150                 :            : 
     151                 :          0 :                     sal_uLong nCount = pOutliner->GetParagraphCount();
     152                 :            : 
     153                 :          0 :                     Paragraph* pPara = NULL;
     154                 :            : 
     155                 :          0 :                     for (sal_uLong nPara = 0; nPara < nCount; nPara++)
     156                 :            :                     {
     157                 :          0 :                         pPara = pOutliner->GetParagraph(nPara);
     158                 :          0 :                         if(pPara && pOutliner->GetDepth( (sal_uInt16) nPara ) == 0 )
     159                 :            :                         {
     160                 :          0 :                             String aParaText = pOutliner->GetText(pPara);
     161                 :          0 :                             if(aParaText.Len() != 0)
     162                 :          0 :                                 InsertTitle( pEntry, aParaText );
     163                 :            :                         }
     164                 :            :                     }
     165                 :            :                 }
     166                 :            :             }
     167                 :            :         }
     168                 :          0 :         nPage++;
     169                 :            :     }
     170                 :            : 
     171                 :          0 :     pOutliner->Clear();
     172                 :          0 : }
     173                 :            : 
     174                 :          0 : sal_uInt16 SdPageListControl::GetSelectedPage()
     175                 :            : {
     176                 :          0 :     SvLBoxEntry* pSelEntry = GetCurEntry();
     177                 :          0 :     sal_uInt16 nPage = 0;
     178                 :            : 
     179                 :          0 :     if ( pSelEntry )
     180                 :            :     {
     181                 :          0 :         SvLBoxTreeList* pTreeModel = GetModel();
     182                 :          0 :         SvLBoxEntry* pEntry = pTreeModel->First();
     183                 :            : 
     184                 :          0 :         while( pEntry && pEntry != pSelEntry )
     185                 :            :         {
     186                 :          0 :             if(pTreeModel->IsAtRootDepth(pEntry))
     187                 :          0 :                 nPage++;
     188                 :          0 :             pEntry = pTreeModel->Next( pEntry );
     189                 :            :         }
     190                 :            : 
     191                 :          0 :         if(!pTreeModel->IsAtRootDepth(pSelEntry))
     192                 :          0 :             nPage--;
     193                 :            :     }
     194                 :          0 :     return nPage;
     195                 :            : }
     196                 :            : 
     197                 :          0 : sal_Bool SdPageListControl::IsPageChecked( sal_uInt16 nPage )
     198                 :            : {
     199                 :          0 :     SvLBoxEntry* pEntry = GetModel()->GetEntry(nPage);
     200                 :          0 :     return pEntry?(sal_Bool)(GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED): sal_False;
     201                 :            : }
     202                 :            : 
     203                 :          0 : void SdPageListControl::DataChanged( const DataChangedEvent& rDCEvt )
     204                 :            : {
     205                 :          0 :     SvTreeListBox::DataChanged( rDCEvt );
     206                 :          0 : }
     207                 :            : 
     208                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10