LCOV - code coverage report
Current view: top level - cui/source/tabpages - tabline.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 102 0.0 %
Date: 2014-04-14 Functions: 0 10 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 <tools/shl.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <unotools/pathoptions.hxx>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : #include <svx/dialogs.hrc>
      26             : 
      27             : #include <cuires.hrc>
      28             : 
      29             : #include "cuitabarea.hxx"
      30             : #include "cuitabline.hxx"
      31             : #include "dlgname.hxx"
      32             : #include <dialmgr.hxx>
      33             : #include <svx/svdmodel.hxx>
      34             : #include <svx/xtable.hxx>
      35             : #include "svx/drawitem.hxx"
      36             : 
      37           0 : SvxLineTabDialog::SvxLineTabDialog
      38             : (
      39             :     Window* pParent,
      40             :     const SfxItemSet* pAttr,
      41             :     SdrModel* pModel,
      42             :     const SdrObject* pSdrObj,
      43             :     sal_Bool bHasObj
      44             : ) :
      45             : 
      46             :     SfxTabDialog    ( pParent
      47             :                       , "LineDialog"
      48             :                       , "cui/ui/linedialog.ui"
      49             :                       , pAttr ),
      50             :     m_nLineTabPage(0),
      51             :     m_nShadowTabPage(0),
      52             :     m_nStyleTabPage(0),
      53             :     m_nEndTabPage(0),
      54             :     pDrawModel      ( pModel ),
      55             :     pObj            ( pSdrObj ),
      56             :     rOutAttrs       ( *pAttr ),
      57             :     pColorList      ( pModel->GetColorList() ),
      58             :     mpNewColorList  ( pModel->GetColorList() ),
      59             :     pDashList       ( pModel->GetDashList() ),
      60             :     pNewDashList    ( pModel->GetDashList() ),
      61             :     pLineEndList    ( pModel->GetLineEndList() ),
      62             :     pNewLineEndList ( pModel->GetLineEndList() ),
      63             :     bObjSelected    ( bHasObj ),
      64             :     nLineEndListState( CT_NONE ),
      65             :     nDashListState( CT_NONE ),
      66             :     mnColorListState( CT_NONE ),
      67             :     nPageType( 0 ), // We use it here primarily to get the right attributes with FillItemSet
      68             :     nPosDashLb( 0 ),
      69             :     nPosLineEndLb( 0 ),
      70           0 :     mbAreaTP( sal_False )
      71             : {
      72           0 :     bool bLineOnly = false;
      73           0 :     if( pObj && pObj->GetObjInventor() == SdrInventor )
      74             :     {
      75           0 :         switch( pObj->GetObjIdentifier() )
      76             :         {
      77             :         case OBJ_LINE:
      78             :         case OBJ_PLIN:
      79             :         case OBJ_PATHLINE:
      80             :         case OBJ_FREELINE:
      81             :         case OBJ_MEASURE:
      82             :         case OBJ_EDGE:
      83           0 :             bLineOnly = true;
      84             : 
      85             :         default:
      86           0 :             break;
      87             :         }
      88             : 
      89             :     }
      90             : 
      91           0 :     m_nLineTabPage = AddTabPage( "RID_SVXPAGE_LINE", SvxLineTabPage::Create, 0);
      92           0 :     if( bLineOnly )
      93           0 :         m_nShadowTabPage = AddTabPage( "RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, 0 );
      94             :     else
      95           0 :         RemoveTabPage( "RID_SVXPAGE_SHADOW" );
      96             : 
      97           0 :     m_nStyleTabPage = AddTabPage( "RID_SVXPAGE_LINE_DEF", SvxLineDefTabPage::Create, 0);
      98           0 :     m_nEndTabPage = AddTabPage( "RID_SVXPAGE_LINEEND_DEF", SvxLineEndDefTabPage::Create, 0);
      99             : 
     100           0 :     SetCurPageId( "RID_SVXPAGE_LINE" );
     101             : 
     102           0 :     CancelButton& rBtnCancel = GetCancelButton();
     103           0 :     rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
     104           0 : }
     105             : 
     106             : 
     107             : 
     108           0 : SvxLineTabDialog::~SvxLineTabDialog()
     109             : {
     110           0 : }
     111             : 
     112             : 
     113             : 
     114           0 : void SvxLineTabDialog::SavePalettes()
     115             : {
     116           0 :     SfxObjectShell* pShell = SfxObjectShell::Current();
     117           0 :     if( mpNewColorList != pDrawModel->GetColorList() )
     118             :     {
     119           0 :         pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
     120           0 :         if ( pShell )
     121           0 :             pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
     122           0 :         pColorList = pDrawModel->GetColorList();
     123             :     }
     124           0 :     if( pNewDashList != pDrawModel->GetDashList() )
     125             :     {
     126           0 :         pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
     127           0 :         if ( pShell )
     128           0 :             pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
     129           0 :         pDashList = pDrawModel->GetDashList();
     130             :     }
     131           0 :     if( pNewLineEndList != pDrawModel->GetLineEndList() )
     132             :     {
     133           0 :         pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
     134           0 :         if ( pShell )
     135           0 :             pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
     136           0 :         pLineEndList = pDrawModel->GetLineEndList();
     137             :     }
     138             : 
     139             :     // Save the tables when they have been changed
     140             : 
     141           0 :     const OUString aPath( SvtPathOptions().GetPalettePath() );
     142             : 
     143           0 :     if( nDashListState & CT_MODIFIED )
     144             :     {
     145           0 :         pDashList->SetPath( aPath );
     146           0 :         pDashList->Save();
     147             : 
     148             :         // Notify ToolBoxControls
     149           0 :         if ( pShell )
     150           0 :             pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
     151             :     }
     152             : 
     153           0 :     if( nLineEndListState & CT_MODIFIED )
     154             :     {
     155           0 :         pLineEndList->SetPath( aPath );
     156           0 :         pLineEndList->Save();
     157             : 
     158             :         // Notify ToolBoxControls
     159           0 :         if ( pShell )
     160           0 :             pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
     161             :     }
     162             : 
     163           0 :     if( mnColorListState & CT_MODIFIED )
     164             :     {
     165           0 :         pColorList->SetPath( aPath );
     166           0 :         pColorList->Save();
     167             : 
     168             :         // Notify ToolBoxControls
     169           0 :         if ( pShell )
     170           0 :             pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
     171           0 :     }
     172           0 : }
     173             : 
     174             : 
     175             : 
     176           0 : short SvxLineTabDialog::Ok()
     177             : {
     178           0 :     SavePalettes();
     179             : 
     180             :     // We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
     181             :     // We do this by default at the moment.
     182           0 :     return( SfxTabDialog::Ok() );
     183             : }
     184             : 
     185             : 
     186             : 
     187           0 : IMPL_LINK_NOARG_INLINE_START(SvxLineTabDialog, CancelHdlImpl)
     188             : {
     189           0 :     SavePalettes();
     190             : 
     191           0 :     EndDialog( RET_CANCEL );
     192           0 :     return 0;
     193             : }
     194           0 : IMPL_LINK_NOARG_INLINE_END(SvxLineTabDialog, CancelHdlImpl)
     195             : 
     196             : 
     197             : 
     198           0 : void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     199             : {
     200           0 :     if( nId ==  m_nLineTabPage)
     201             :     {
     202           0 :         ( (SvxLineTabPage&) rPage ).SetColorList( pColorList );
     203           0 :         ( (SvxLineTabPage&) rPage ).SetDashList( pDashList );
     204           0 :         ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList );
     205           0 :         ( (SvxLineTabPage&) rPage ).SetDlgType( 0 );
     206           0 :         ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );
     207           0 :         ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
     208           0 :         ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
     209           0 :         ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
     210           0 :         ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
     211           0 :         ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
     212           0 :         ( (SvxLineTabPage&) rPage ).Construct();
     213           0 :         ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorListState );
     214             :         // ActivatePage() is not called the first time
     215           0 :         ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
     216             :     }
     217           0 :     else if(nId == m_nStyleTabPage)
     218             :     {
     219           0 :         ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList );
     220           0 :         ( (SvxLineDefTabPage&) rPage ).SetDlgType( 0 );
     221           0 :         ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
     222           0 :         ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
     223           0 :         ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
     224           0 :         ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
     225           0 :         ( (SvxLineDefTabPage&) rPage ).Construct();
     226             :     }
     227           0 :     else if(nId == m_nEndTabPage)
     228             :     {
     229           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList );
     230           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
     231           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( 0 );
     232           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
     233           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
     234           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
     235           0 :         ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
     236           0 :         ( (SvxLineEndDefTabPage&) rPage ).Construct();
     237             :     }
     238           0 :     else if (nId == m_nShadowTabPage)
     239             :     {
     240           0 :         ( (SvxShadowTabPage&) rPage ).SetColorList( pColorList );
     241           0 :         ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
     242           0 :         ( (SvxShadowTabPage&) rPage ).SetDlgType( 0 );
     243           0 :         ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
     244           0 :         ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorListState );
     245           0 :         ( (SvxShadowTabPage&) rPage ).Construct();
     246             :     }
     247           0 : }
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10