LCOV - code coverage report
Current view: top level - cui/source/tabpages - tabarea.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 155 0.0 %
Date: 2014-11-03 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 <sfx2/app.hxx>
      21             : #include <sfx2/objsh.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <unotools/pathoptions.hxx>
      24             : #include <svx/svdmark.hxx>
      25             : #include <svx/svdobj.hxx>
      26             : #include <svx/svdview.hxx>
      27             : #include <svx/dialogs.hrc>
      28             : 
      29             : #include <cuires.hrc>
      30             : #include <svx/xtable.hxx>
      31             : #include "svx/globl3d.hxx"
      32             : #include <svx/svdmodel.hxx>
      33             : #include "svx/drawitem.hxx"
      34             : #include "cuitabarea.hxx"
      35             : #include "dlgname.hxx"
      36             : #include <dialmgr.hxx>
      37             : 
      38           0 : SvxAreaTabDialog::SvxAreaTabDialog
      39             : (
      40             :     vcl::Window* pParent,
      41             :     const SfxItemSet* pAttr,
      42             :     SdrModel* pModel,
      43             :     bool bShadow
      44             : )
      45             :     : SfxTabDialog( pParent,
      46             :                   "AreaDialog",
      47             :                   "cui/ui/areadialog.ui",
      48             :                   pAttr )
      49             :     , m_nAreaTabPage(0)
      50             :     , m_nShadowTabPage(0)
      51             :     , m_nTransparenceTabPage(0)
      52             :     , m_nColorTabPage(0)
      53             :     , m_nGradientTabPage(0)
      54             :     , m_nHatchTabPage(0)
      55             :     , m_nBitmapTabPage(0)
      56             : 
      57             :     , mpDrawModel          ( pModel ),
      58             :     mpColorList          ( pModel->GetColorList() ),
      59             :     mpNewColorList       ( pModel->GetColorList() ),
      60             :     mpGradientList       ( pModel->GetGradientList() ),
      61             :     mpNewGradientList    ( pModel->GetGradientList() ),
      62             :     mpHatchingList       ( pModel->GetHatchList() ),
      63             :     mpNewHatchingList    ( pModel->GetHatchList() ),
      64             :     mpBitmapList         ( pModel->GetBitmapList() ),
      65             :     mpNewBitmapList      ( pModel->GetBitmapList() ),
      66             :     mrOutAttrs           ( *pAttr ),
      67             : 
      68             :     mnColorListState ( CT_NONE ),
      69             :     mnBitmapListState ( CT_NONE ),
      70             :     mnGradientListState ( CT_NONE ),
      71             :     mnHatchingListState ( CT_NONE ),
      72             :     mnPageType( PT_AREA ),
      73             :     mnPos( 0 ),
      74           0 :     mbAreaTP( false )
      75             : {
      76           0 :     m_nAreaTabPage = AddTabPage( "RID_SVXPAGE_AREA", SvxAreaTabPage::Create, 0 );
      77             : 
      78           0 :     if(bShadow)
      79             :     {
      80           0 :         m_nShadowTabPage = AddTabPage( "RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, 0 );
      81             :     }
      82             :     else
      83             :     {
      84           0 :         RemoveTabPage( "RID_SVXPAGE_SHADOW" );
      85             :     }
      86             : 
      87           0 :     m_nTransparenceTabPage = AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create,  0);
      88           0 :     m_nColorTabPage = AddTabPage( "RID_SVXPAGE_COLOR", SvxColorTabPage::Create, 0 );
      89           0 :     m_nGradientTabPage = AddTabPage( "RID_SVXPAGE_GRADIENT", SvxGradientTabPage::Create, 0 );
      90           0 :     m_nHatchTabPage = AddTabPage( "RID_SVXPAGE_HATCH", SvxHatchTabPage::Create, 0 );
      91           0 :     m_nBitmapTabPage = AddTabPage( "RID_SVXPAGE_BITMAP", SvxBitmapTabPage::Create,  0);
      92             : 
      93           0 :     SetCurPageId( "RID_SVXPAGE_AREA" );
      94             : 
      95           0 :     CancelButton& rBtnCancel = GetCancelButton();
      96           0 :     rBtnCancel.SetClickHdl( LINK( this, SvxAreaTabDialog, CancelHdlImpl ) );
      97           0 : }
      98             : 
      99           0 : SvxAreaTabDialog::~SvxAreaTabDialog()
     100             : {
     101           0 : }
     102             : 
     103           0 : void SvxAreaTabDialog::SavePalettes()
     104             : {
     105           0 :     SfxObjectShell* pShell = SfxObjectShell::Current();
     106           0 :     if( mpNewColorList != mpDrawModel->GetColorList() )
     107             :     {
     108           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
     109           0 :         SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
     110           0 :         if ( pShell )
     111           0 :             pShell->PutItem( aColorListItem );
     112             :         else
     113           0 :             mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
     114           0 :         mpColorList = mpDrawModel->GetColorList();
     115             :     }
     116           0 :     if( mpNewGradientList != mpDrawModel->GetGradientList() )
     117             :     {
     118           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) );
     119           0 :         SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
     120           0 :         if ( pShell )
     121           0 :             pShell->PutItem( aItem );
     122             :         else
     123           0 :             mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
     124           0 :         mpGradientList = mpDrawModel->GetGradientList();
     125             :     }
     126           0 :     if( mpNewHatchingList != mpDrawModel->GetHatchList() )
     127             :     {
     128           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) );
     129           0 :         SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
     130           0 :         if ( pShell )
     131           0 :             pShell->PutItem( aItem );
     132             :         else
     133           0 :             mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
     134           0 :         mpHatchingList = mpDrawModel->GetHatchList();
     135             :     }
     136           0 :     if( mpNewBitmapList != mpDrawModel->GetBitmapList() )
     137             :     {
     138           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) );
     139           0 :         SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
     140           0 :         if ( pShell )
     141           0 :             pShell->PutItem( aItem );
     142             :         else
     143           0 :             mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
     144           0 :         mpBitmapList = mpDrawModel->GetBitmapList();
     145             :     }
     146             : 
     147             :     // save the tables when they have been changed
     148             : 
     149           0 :     const OUString aPath( SvtPathOptions().GetPalettePath() );
     150             : 
     151           0 :     if( mnHatchingListState & CT_MODIFIED )
     152             :     {
     153           0 :         mpHatchingList->SetPath( aPath );
     154           0 :         mpHatchingList->Save();
     155             : 
     156           0 :         SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
     157             :         // ToolBoxControls are informed:
     158           0 :         if ( pShell )
     159           0 :             pShell->PutItem( aItem );
     160             :         else
     161           0 :             mpDrawModel->GetItemPool().Put(aItem);
     162             :     }
     163             : 
     164           0 :     if( mnBitmapListState & CT_MODIFIED )
     165             :     {
     166           0 :         mpBitmapList->SetPath( aPath );
     167           0 :         mpBitmapList->Save();
     168             : 
     169           0 :         SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
     170             :         // ToolBoxControls are informed:
     171           0 :         if ( pShell )
     172           0 :             pShell->PutItem( aItem );
     173             :         else
     174             :         {
     175           0 :             mpDrawModel->GetItemPool().Put(aItem);
     176           0 :         }
     177             :     }
     178             : 
     179           0 :     if( mnGradientListState & CT_MODIFIED )
     180             :     {
     181           0 :         mpGradientList->SetPath( aPath );
     182           0 :         mpGradientList->Save();
     183             : 
     184           0 :         SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
     185             :         // ToolBoxControls are informed:
     186           0 :         if ( pShell )
     187           0 :             pShell->PutItem( aItem );
     188             :         else
     189             :         {
     190           0 :             mpDrawModel->GetItemPool().Put(aItem);
     191           0 :         }
     192             :     }
     193             : 
     194           0 :     if (mnColorListState & CT_MODIFIED && mpColorList.is())
     195             :     {
     196           0 :         mpColorList->SetPath( aPath );
     197           0 :         mpColorList->Save();
     198             : 
     199           0 :         SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
     200             :         // ToolBoxControls are informed:
     201           0 :         if ( pShell )
     202           0 :             pShell->PutItem( aItem );
     203             :         else
     204             :         {
     205           0 :             mpDrawModel->GetItemPool().Put(aItem);
     206           0 :         }
     207           0 :     }
     208           0 : }
     209             : 
     210             : 
     211           0 : short SvxAreaTabDialog::Ok()
     212             : {
     213           0 :     SavePalettes();
     214             : 
     215             :     // RET_OK is returned, if at least one
     216             :     // TabPage returns sal_True in FillItemSet().
     217             :     // This happens by default at the moment.
     218           0 :     return( SfxTabDialog::Ok() );
     219             : }
     220             : 
     221             : 
     222             : 
     223           0 : IMPL_LINK_NOARG_INLINE_START(SvxAreaTabDialog, CancelHdlImpl)
     224             : {
     225           0 :     SavePalettes();
     226             : 
     227           0 :     EndDialog( RET_CANCEL );
     228           0 :     return 0;
     229             : }
     230           0 : IMPL_LINK_INLINE_END( SvxAreaTabDialog, CancelHdlImpl, void *, p )
     231             : 
     232             : 
     233             : 
     234           0 : void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     235             : {
     236           0 :     if (nId == m_nAreaTabPage )
     237             :     {
     238           0 :             static_cast<SvxAreaTabPage&>(rPage).SetColorList( mpColorList );
     239           0 :             static_cast<SvxAreaTabPage&>(rPage).SetGradientList( mpGradientList );
     240           0 :             static_cast<SvxAreaTabPage&>(rPage).SetHatchingList( mpHatchingList );
     241           0 :             static_cast<SvxAreaTabPage&>(rPage).SetBitmapList( mpBitmapList );
     242           0 :             static_cast<SvxAreaTabPage&>(rPage).SetPageType( mnPageType );
     243           0 :             static_cast<SvxAreaTabPage&>(rPage).SetDlgType( 0 );
     244           0 :             static_cast<SvxAreaTabPage&>(rPage).SetPos( mnPos );
     245           0 :             static_cast<SvxAreaTabPage&>(rPage).SetAreaTP( &mbAreaTP );
     246           0 :             static_cast<SvxAreaTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
     247           0 :             static_cast<SvxAreaTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
     248           0 :             static_cast<SvxAreaTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
     249           0 :             static_cast<SvxAreaTabPage&>(rPage).SetColorChgd( &mnColorListState );
     250           0 :             static_cast<SvxAreaTabPage&>(rPage).Construct();
     251             :             // ActivatePge() is not called the first time
     252           0 :             static_cast<SvxAreaTabPage&>(rPage).ActivatePage( mrOutAttrs );
     253             :     }
     254           0 :     else if (nId == m_nShadowTabPage)
     255             :     {
     256           0 :             static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
     257           0 :             static_cast<SvxShadowTabPage&>(rPage).SetPageType( mnPageType );
     258           0 :             static_cast<SvxShadowTabPage&>(rPage).SetDlgType( 0 );
     259           0 :             static_cast<SvxShadowTabPage&>(rPage).SetAreaTP( &mbAreaTP );
     260           0 :             static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
     261           0 :             static_cast<SvxShadowTabPage&>(rPage).Construct();
     262             :     }
     263           0 :     else if (nId == m_nGradientTabPage)
     264             :     {
     265           0 :             static_cast<SvxGradientTabPage&>(rPage).SetColorList( mpColorList );
     266           0 :             static_cast<SvxGradientTabPage&>(rPage).SetGradientList( mpGradientList );
     267           0 :             static_cast<SvxGradientTabPage&>(rPage).SetPageType( &mnPageType );
     268           0 :             static_cast<SvxGradientTabPage&>(rPage).SetDlgType( 0 );
     269           0 :             static_cast<SvxGradientTabPage&>(rPage).SetPos( &mnPos );
     270           0 :             static_cast<SvxGradientTabPage&>(rPage).SetAreaTP( &mbAreaTP );
     271           0 :             static_cast<SvxGradientTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
     272           0 :             static_cast<SvxGradientTabPage&>(rPage).SetColorChgd( &mnColorListState );
     273           0 :             static_cast<SvxGradientTabPage&>(rPage).Construct();
     274             :     }
     275           0 :     else if (nId == m_nHatchTabPage)
     276             :     {
     277           0 :             static_cast<SvxHatchTabPage&>(rPage).SetColorList( mpColorList );
     278           0 :             static_cast<SvxHatchTabPage&>(rPage).SetHatchingList( mpHatchingList );
     279           0 :             static_cast<SvxHatchTabPage&>(rPage).SetPageType( &mnPageType );
     280           0 :             static_cast<SvxHatchTabPage&>(rPage).SetDlgType( 0 );
     281           0 :             static_cast<SvxHatchTabPage&>(rPage).SetPos( &mnPos );
     282           0 :             static_cast<SvxHatchTabPage&>(rPage).SetAreaTP( &mbAreaTP );
     283           0 :             static_cast<SvxHatchTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
     284           0 :             static_cast<SvxHatchTabPage&>(rPage).SetColorChgd( &mnColorListState );
     285           0 :             static_cast<SvxHatchTabPage&>(rPage).Construct();
     286             :     }
     287           0 :     else if (nId == m_nBitmapTabPage)
     288             :     {
     289           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetColorList( mpColorList );
     290           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetBitmapList( mpBitmapList );
     291           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetPageType( &mnPageType );
     292           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetDlgType( 0 );
     293           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetPos( &mnPos );
     294           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetAreaTP( &mbAreaTP );
     295           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
     296           0 :             static_cast<SvxBitmapTabPage&>(rPage).SetColorChgd( &mnColorListState );
     297           0 :             static_cast<SvxBitmapTabPage&>(rPage).Construct();
     298             :     }
     299           0 :     else if (nId == m_nColorTabPage)
     300             :     {
     301           0 :             static_cast<SvxColorTabPage&>(rPage).SetColorList( mpColorList );
     302           0 :             static_cast<SvxColorTabPage&>(rPage).SetPageType( &mnPageType );
     303           0 :             static_cast<SvxColorTabPage&>(rPage).SetDlgType( 0 );
     304           0 :             static_cast<SvxColorTabPage&>(rPage).SetPos( &mnPos );
     305           0 :             static_cast<SvxColorTabPage&>(rPage).SetAreaTP( &mbAreaTP );
     306           0 :             static_cast<SvxColorTabPage&>(rPage).SetColorChgd( &mnColorListState );
     307           0 :             static_cast<SvxColorTabPage&>(rPage).Construct();
     308             :     }
     309           0 :     else if (nId == m_nTransparenceTabPage)
     310             :     {
     311           0 :             static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( mnPageType );
     312           0 :             static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
     313           0 :             static_cast<SvxTransparenceTabPage&>(rPage).Construct();
     314             :     }
     315           0 : }
     316             : 
     317             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10