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

Generated by: LCOV version 1.10