LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgassim.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 101 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 16 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             : #include <sfx2/docfile.hxx>
      21             : #include <unotools/pathoptions.hxx>
      22             : 
      23             : #include "sdpage.hxx"
      24             : #include "Outliner.hxx"
      25             : #include "res_bmp.hrc"
      26             : 
      27             : #include <vcl/svapp.hxx>
      28             : #include <vcl/builderfactory.hxx>
      29             : #include "svtools/svlbitm.hxx"
      30             : #include "svtools/treelistentry.hxx"
      31             : 
      32             : #include "dlgassim.hxx"
      33             : 
      34           0 : SdPageListControl::SdPageListControl(
      35             :     vcl::Window* pParent,
      36             :     const WinBits nStyle )
      37           0 :     : SvTreeListBox(pParent, nStyle)
      38             : {
      39             :     // add lines to tree listbox
      40           0 :     SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
      41             :                             WB_HASBUTTONS |  WB_HASLINESATROOT |
      42             :                             WB_HSCROLL |
      43           0 :                             WB_HASBUTTONSATROOT );
      44             : 
      45           0 :     SetNodeDefaultImages ();
      46           0 :     m_pCheckButton = new SvLBoxButtonData(this);
      47           0 :     EnableCheckButton (m_pCheckButton);
      48             : 
      49           0 :     SetCheckButtonHdl( LINK(this,SdPageListControl,CheckButtonClickHdl) );
      50           0 : }
      51             : 
      52           0 : VCL_BUILDER_DECL_FACTORY(SdPageListControl)
      53             : {
      54           0 :     WinBits nWinStyle = WB_TABSTOP;
      55           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
      56           0 :     if (!sBorder.isEmpty())
      57           0 :         nWinStyle |= WB_BORDER;
      58           0 :     rRet = VclPtr<SdPageListControl>::Create(pParent, nWinStyle);
      59           0 : }
      60             : 
      61           0 : IMPL_LINK_NOARG(SdPageListControl, CheckButtonClickHdl)
      62             : {
      63           0 :     SvTreeList* pTreeModel = GetModel();
      64           0 :     SvTreeListEntry* pEntry = pTreeModel->First();
      65             : 
      66           0 :     while( pEntry )
      67             :     {
      68           0 :         if(pTreeModel->IsAtRootDepth(pEntry) && GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED )
      69           0 :             return 0;
      70           0 :         pEntry = pTreeModel->Next( pEntry );
      71             :     }
      72             : 
      73           0 :     pEntry = pTreeModel->First();
      74           0 :     SetCheckButtonState( pEntry, SV_BUTTON_CHECKED );
      75             : 
      76           0 :     return 0;
      77             : }
      78             : 
      79           0 : SdPageListControl::~SdPageListControl()
      80             : {
      81           0 :     disposeOnce();
      82           0 : }
      83             : 
      84           0 : void SdPageListControl::dispose()
      85             : {
      86           0 :     delete m_pCheckButton;
      87           0 :     SvTreeListBox::dispose();
      88           0 : }
      89             : 
      90           0 : void SdPageListControl::Clear()
      91             : {
      92           0 :     SvTreeListBox::Clear();
      93           0 : }
      94             : 
      95           0 : SvTreeListEntry* SdPageListControl::InsertPage( const OUString& rPageName )
      96             : {
      97           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
      98             : 
      99             :     pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox,
     100           0 :                                        0, m_pCheckButton));
     101           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), false));    // otherwise boom!
     102           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rPageName ) );
     103             : 
     104           0 :     GetModel()->Insert( pEntry );
     105             : 
     106           0 :     return pEntry;
     107             : }
     108             : 
     109           0 : void SdPageListControl::InsertTitle( SvTreeListEntry* pParent, const OUString& rTitle )
     110             : {
     111           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     112           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, OUString() ) );
     113           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), false));    // otherwise boom!
     114           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rTitle ) );
     115           0 :     GetModel()->Insert( pEntry,pParent );
     116           0 : }
     117             : 
     118           0 : void SdPageListControl::Fill( SdDrawDocument* pDoc )
     119             : {
     120           0 :     Outliner* pOutliner = pDoc->GetInternalOutliner();
     121             : 
     122           0 :     sal_uInt16 nPage = 0;
     123           0 :     const sal_uInt16 nMaxPages = pDoc->GetPageCount();
     124           0 :     while( nPage < nMaxPages )
     125             :     {
     126           0 :         SdPage* pPage = static_cast<SdPage*>( pDoc->GetPage( nPage ) );
     127           0 :         if( pPage->GetPageKind() == PK_STANDARD )
     128             :         {
     129           0 :             SvTreeListEntry* pEntry = InsertPage( pPage->GetName() );
     130           0 :             SetCheckButtonState(pEntry, SvButtonState( SV_BUTTON_CHECKED ) );
     131             : 
     132           0 :             SdrTextObj* pTO = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT));
     133           0 :             if(!pTO)
     134             :             {
     135             :                 // determines the SdrTextObject with the layout text of this page
     136           0 :                 const size_t nObjectCount = pPage->GetObjCount();
     137           0 :                 for (size_t nObject = 0; nObject < nObjectCount; ++nObject)
     138             :                 {
     139           0 :                     SdrObject* pObject = pPage->GetObj(nObject);
     140           0 :                     if (pObject->GetObjInventor() == SdrInventor && pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
     141             :                     {
     142           0 :                         pTO = static_cast<SdrTextObj*>(pObject);
     143           0 :                         break;
     144             :                     }
     145             :                 }
     146             :             }
     147             : 
     148           0 :             if (pTO && !pTO->IsEmptyPresObj())
     149             :             {
     150           0 :                 OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
     151           0 :                 if (pOPO)
     152             :                 {
     153           0 :                     pOutliner->Clear();
     154           0 :                     pOutliner->SetText( *pOPO );
     155             : 
     156           0 :                     sal_Int32 nCount = pOutliner->GetParagraphCount();
     157             : 
     158             : 
     159           0 :                     for (sal_Int32 nPara = 0; nPara < nCount; nPara++)
     160             :                     {
     161           0 :                         Paragraph* pPara = pOutliner->GetParagraph(nPara);
     162           0 :                         if(pPara && pOutliner->GetDepth( nPara ) == 0 )
     163             :                         {
     164           0 :                             OUString aParaText = pOutliner->GetText(pPara);
     165           0 :                             if (!aParaText.isEmpty())
     166           0 :                                 InsertTitle( pEntry, aParaText );
     167             :                         }
     168             :                     }
     169             :                 }
     170             :             }
     171             :         }
     172           0 :         nPage++;
     173             :     }
     174             : 
     175           0 :     pOutliner->Clear();
     176           0 : }
     177             : 
     178           0 : sal_uInt16 SdPageListControl::GetSelectedPage()
     179             : {
     180           0 :     SvTreeListEntry* pSelEntry = GetCurEntry();
     181           0 :     sal_uInt16 nPage = 0;
     182             : 
     183           0 :     if ( pSelEntry )
     184             :     {
     185           0 :         SvTreeList* pTreeModel = GetModel();
     186           0 :         SvTreeListEntry* pEntry = pTreeModel->First();
     187             : 
     188           0 :         while( pEntry && pEntry != pSelEntry )
     189             :         {
     190           0 :             if(pTreeModel->IsAtRootDepth(pEntry))
     191           0 :                 nPage++;
     192           0 :             pEntry = pTreeModel->Next( pEntry );
     193             :         }
     194             : 
     195           0 :         if(!pTreeModel->IsAtRootDepth(pSelEntry))
     196           0 :             nPage--;
     197             :     }
     198           0 :     return nPage;
     199             : }
     200             : 
     201           0 : bool SdPageListControl::IsPageChecked( sal_uInt16 nPage )
     202             : {
     203           0 :     SvTreeListEntry* pEntry = GetModel()->GetEntry(nPage);
     204           0 :     return pEntry && (GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED);
     205             : }
     206             : 
     207           0 : void SdPageListControl::DataChanged( const DataChangedEvent& rDCEvt )
     208             : {
     209           0 :     SvTreeListBox::DataChanged( rDCEvt );
     210           0 : }
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11