LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - dlgassim.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 91 0.0 %
Date: 2012-12-27 Functions: 0 12 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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #ifdef SD_DLLIMPLEMENTATION
      22             : #undef SD_DLLIMPLEMENTATION
      23             : #endif
      24             : #include <sfx2/docfile.hxx>
      25             : #include <unotools/pathoptions.hxx>
      26             : 
      27             : #include "sdpage.hxx"
      28             : #include "Outliner.hxx"
      29             : #include "res_bmp.hrc"
      30             : 
      31             : #include <vcl/svapp.hxx>
      32             : #include "svtools/svlbitm.hxx"
      33             : #include "svtools/treelistentry.hxx"
      34             : 
      35             : #include "dlgassim.hxx"
      36             : 
      37           0 : SdPageListControl::SdPageListControl(
      38             :     ::Window* pParent,
      39             :     const ResId& rResId )
      40           0 :     : SvTreeListBox(pParent, rResId)
      41             : {
      42             :     // Tree-ListBox mit Linien versehen
      43           0 :     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
      44             :                             WB_HASBUTTONS |  WB_HASLINESATROOT |
      45             :                             WB_HSCROLL |
      46           0 :                             WB_HASBUTTONSATROOT );
      47             : 
      48           0 :     SetNodeDefaultImages ();
      49           0 :     m_pCheckButton = new SvLBoxButtonData(this);
      50           0 :     EnableCheckButton (m_pCheckButton);
      51             : 
      52           0 :     SetCheckButtonHdl( LINK(this,SdPageListControl,CheckButtonClickHdl) );
      53           0 : }
      54             : 
      55           0 : IMPL_LINK_NOARG(SdPageListControl, CheckButtonClickHdl)
      56             : {
      57           0 :     SvTreeList* pTreeModel = GetModel();
      58           0 :     SvTreeListEntry* pEntry = pTreeModel->First();
      59             : 
      60           0 :     while( pEntry )
      61             :     {
      62           0 :         if(pTreeModel->IsAtRootDepth(pEntry) && GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED )
      63           0 :             return 0;
      64           0 :         pEntry = pTreeModel->Next( pEntry );
      65             :     }
      66             : 
      67           0 :     pEntry = pTreeModel->First();
      68           0 :     SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
      69             : 
      70           0 :     return 0;
      71             : }
      72             : 
      73           0 : SdPageListControl::~SdPageListControl()
      74             : {
      75           0 :     delete m_pCheckButton;
      76           0 : }
      77             : 
      78           0 : void SdPageListControl::Clear()
      79             : {
      80           0 :     SvTreeListBox::Clear();
      81           0 : }
      82             : 
      83           0 : SvTreeListEntry* SdPageListControl::InsertPage( const String& rPageName )
      84             : {
      85           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
      86             : 
      87             :     pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox,
      88           0 :                                        0, m_pCheckButton));
      89           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));    // Sonst Puff!
      90           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rPageName ) );
      91             : 
      92           0 :     GetModel()->Insert( pEntry );
      93             : 
      94           0 :     return pEntry;
      95             : }
      96             : 
      97           0 : void SdPageListControl::InsertTitle( SvTreeListEntry* pParent, const String& rTitle )
      98             : {
      99           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     100           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, String() ) );
     101           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));    // Sonst Puff!
     102           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rTitle ) );
     103           0 :     GetModel()->Insert( pEntry,pParent );
     104           0 : }
     105             : 
     106           0 : void SdPageListControl::Fill( SdDrawDocument* pDoc )
     107             : {
     108           0 :     Outliner* pOutliner = pDoc->GetInternalOutliner();
     109             : 
     110           0 :     sal_uInt16 nPage = 0;
     111           0 :     const sal_uInt16 nMaxPages = pDoc->GetPageCount();
     112           0 :     while( nPage < nMaxPages )
     113             :     {
     114           0 :         SdPage* pPage = (SdPage*) pDoc->GetPage( nPage );
     115           0 :         if( pPage->GetPageKind() == PK_STANDARD )
     116             :         {
     117           0 :             SvTreeListEntry* pEntry = InsertPage( pPage->GetName() );
     118           0 :             SetCheckButtonState(pEntry, SvButtonState( SV_BUTTON_CHECKED ) );
     119             : 
     120           0 :             SdrTextObj* pTO = (SdrTextObj*)pPage->GetPresObj(PRESOBJ_TEXT);
     121           0 :             if(!pTO)
     122             :             {
     123             :                 // Ermittelt das SdrTextObject mit dem Layout Text dieser Seite
     124           0 :                 const sal_uLong nObjectCount = pPage->GetObjCount();
     125           0 :                 for (sal_uLong nObject = 0; nObject < nObjectCount; nObject++)
     126             :                 {
     127           0 :                     SdrObject* pObject = pPage->GetObj(nObject);
     128           0 :                     if (pObject->GetObjInventor() == SdrInventor && pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
     129             :                     {
     130           0 :                         pTO = (SdrTextObj*)pObject;
     131           0 :                         break;
     132             :                     }
     133             :                 }
     134             :             }
     135             : 
     136           0 :             if (pTO && !pTO->IsEmptyPresObj())
     137             :             {
     138           0 :                 OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
     139           0 :                 if (pOPO)
     140             :                 {
     141           0 :                     pOutliner->Clear();
     142           0 :                     pOutliner->SetText( *pOPO );
     143             : 
     144           0 :                     sal_uLong nCount = pOutliner->GetParagraphCount();
     145             : 
     146           0 :                     Paragraph* pPara = NULL;
     147             : 
     148           0 :                     for (sal_uLong nPara = 0; nPara < nCount; nPara++)
     149             :                     {
     150           0 :                         pPara = pOutliner->GetParagraph(nPara);
     151           0 :                         if(pPara && pOutliner->GetDepth( (sal_uInt16) nPara ) == 0 )
     152             :                         {
     153           0 :                             String aParaText = pOutliner->GetText(pPara);
     154           0 :                             if(aParaText.Len() != 0)
     155           0 :                                 InsertTitle( pEntry, aParaText );
     156             :                         }
     157             :                     }
     158             :                 }
     159             :             }
     160             :         }
     161           0 :         nPage++;
     162             :     }
     163             : 
     164           0 :     pOutliner->Clear();
     165           0 : }
     166             : 
     167           0 : sal_uInt16 SdPageListControl::GetSelectedPage()
     168             : {
     169           0 :     SvTreeListEntry* pSelEntry = GetCurEntry();
     170           0 :     sal_uInt16 nPage = 0;
     171             : 
     172           0 :     if ( pSelEntry )
     173             :     {
     174           0 :         SvTreeList* pTreeModel = GetModel();
     175           0 :         SvTreeListEntry* pEntry = pTreeModel->First();
     176             : 
     177           0 :         while( pEntry && pEntry != pSelEntry )
     178             :         {
     179           0 :             if(pTreeModel->IsAtRootDepth(pEntry))
     180           0 :                 nPage++;
     181           0 :             pEntry = pTreeModel->Next( pEntry );
     182             :         }
     183             : 
     184           0 :         if(!pTreeModel->IsAtRootDepth(pSelEntry))
     185           0 :             nPage--;
     186             :     }
     187           0 :     return nPage;
     188             : }
     189             : 
     190           0 : sal_Bool SdPageListControl::IsPageChecked( sal_uInt16 nPage )
     191             : {
     192           0 :     SvTreeListEntry* pEntry = GetModel()->GetEntry(nPage);
     193           0 :     return pEntry?(sal_Bool)(GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED): sal_False;
     194             : }
     195             : 
     196           0 : void SdPageListControl::DataChanged( const DataChangedEvent& rDCEvt )
     197             : {
     198           0 :     SvTreeListBox::DataChanged( rDCEvt );
     199           0 : }
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10