LCOV - code coverage report
Current view: top level - cui/source/tabpages - tabarea.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 156 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 8 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 ( ChangeType::NONE ),
      69             :     mnBitmapListState ( ChangeType::NONE ),
      70             :     mnGradientListState ( ChangeType::NONE ),
      71             :     mnHatchingListState ( ChangeType::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 : void SvxAreaTabDialog::SavePalettes()
     100             : {
     101           0 :     SfxObjectShell* pShell = SfxObjectShell::Current();
     102           0 :     if( mpNewColorList != mpDrawModel->GetColorList() )
     103             :     {
     104           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
     105           0 :         SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
     106           0 :         if ( pShell )
     107           0 :             pShell->PutItem( aColorListItem );
     108             :         else
     109           0 :             mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
     110           0 :         mpColorList = mpDrawModel->GetColorList();
     111             :     }
     112           0 :     if( mpNewGradientList != mpDrawModel->GetGradientList() )
     113             :     {
     114           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) );
     115           0 :         SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
     116           0 :         if ( pShell )
     117           0 :             pShell->PutItem( aItem );
     118             :         else
     119           0 :             mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
     120           0 :         mpGradientList = mpDrawModel->GetGradientList();
     121             :     }
     122           0 :     if( mpNewHatchingList != mpDrawModel->GetHatchList() )
     123             :     {
     124           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) );
     125           0 :         SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
     126           0 :         if ( pShell )
     127           0 :             pShell->PutItem( aItem );
     128             :         else
     129           0 :             mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
     130           0 :         mpHatchingList = mpDrawModel->GetHatchList();
     131             :     }
     132           0 :     if( mpNewBitmapList != mpDrawModel->GetBitmapList() )
     133             :     {
     134           0 :         mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) );
     135           0 :         SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
     136           0 :         if ( pShell )
     137           0 :             pShell->PutItem( aItem );
     138             :         else
     139           0 :             mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
     140           0 :         mpBitmapList = mpDrawModel->GetBitmapList();
     141             :     }
     142             : 
     143             :     // save the tables when they have been changed
     144             : 
     145           0 :     OUString aPalettePath(SvtPathOptions().GetPalettePath());
     146           0 :     OUString aPath;
     147           0 :     sal_Int32 nIndex = 0;
     148           0 :     do
     149             :     {
     150           0 :         aPath = aPalettePath.getToken(0, ';', nIndex);
     151             :     }
     152           0 :     while (nIndex >= 0);
     153             : 
     154           0 :     if( mnHatchingListState & ChangeType::MODIFIED )
     155             :     {
     156           0 :         mpHatchingList->SetPath( aPath );
     157           0 :         mpHatchingList->Save();
     158             : 
     159           0 :         SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
     160             :         // ToolBoxControls are informed:
     161           0 :         if ( pShell )
     162           0 :             pShell->PutItem( aItem );
     163             :         else
     164           0 :             mpDrawModel->GetItemPool().Put(aItem);
     165             :     }
     166             : 
     167           0 :     if( mnBitmapListState & ChangeType::MODIFIED )
     168             :     {
     169           0 :         mpBitmapList->SetPath( aPath );
     170           0 :         mpBitmapList->Save();
     171             : 
     172           0 :         SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
     173             :         // ToolBoxControls are informed:
     174           0 :         if ( pShell )
     175           0 :             pShell->PutItem( aItem );
     176             :         else
     177             :         {
     178           0 :             mpDrawModel->GetItemPool().Put(aItem);
     179           0 :         }
     180             :     }
     181             : 
     182           0 :     if( mnGradientListState & ChangeType::MODIFIED )
     183             :     {
     184           0 :         mpGradientList->SetPath( aPath );
     185           0 :         mpGradientList->Save();
     186             : 
     187           0 :         SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
     188             :         // ToolBoxControls are informed:
     189           0 :         if ( pShell )
     190           0 :             pShell->PutItem( aItem );
     191             :         else
     192             :         {
     193           0 :             mpDrawModel->GetItemPool().Put(aItem);
     194           0 :         }
     195             :     }
     196             : 
     197           0 :     if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
     198             :     {
     199           0 :         mpColorList->SetPath( aPath );
     200           0 :         mpColorList->Save();
     201             : 
     202           0 :         SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
     203             :         // ToolBoxControls are informed:
     204           0 :         if ( pShell )
     205           0 :             pShell->PutItem( aItem );
     206             :         else
     207             :         {
     208           0 :             mpDrawModel->GetItemPool().Put(aItem);
     209           0 :         }
     210           0 :     }
     211           0 : }
     212             : 
     213             : 
     214           0 : short SvxAreaTabDialog::Ok()
     215             : {
     216           0 :     SavePalettes();
     217             : 
     218             :     // RET_OK is returned, if at least one
     219             :     // TabPage returns sal_True in FillItemSet().
     220             :     // This happens by default at the moment.
     221           0 :     return( SfxTabDialog::Ok() );
     222             : }
     223             : 
     224             : 
     225             : 
     226           0 : IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl)
     227             : {
     228           0 :     SavePalettes();
     229             : 
     230           0 :     EndDialog( RET_CANCEL );
     231           0 :     return 0;
     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             :     }
     314           0 : }
     315             : 
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11