/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include "svx/globl3d.hxx" #include #include "svx/drawitem.hxx" #include "cuitabarea.hxx" #include "dlgname.hxx" #include SvxAreaTabDialog::SvxAreaTabDialog ( vcl::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, bool bShadow ) : SfxTabDialog( pParent, "AreaDialog", "cui/ui/areadialog.ui", pAttr ) , m_nAreaTabPage(0) , m_nShadowTabPage(0) , m_nTransparenceTabPage(0) , m_nColorTabPage(0) , m_nGradientTabPage(0) , m_nHatchTabPage(0) , m_nBitmapTabPage(0) , mpDrawModel ( pModel ), mpColorList ( pModel->GetColorList() ), mpNewColorList ( pModel->GetColorList() ), mpGradientList ( pModel->GetGradientList() ), mpNewGradientList ( pModel->GetGradientList() ), mpHatchingList ( pModel->GetHatchList() ), mpNewHatchingList ( pModel->GetHatchList() ), mpBitmapList ( pModel->GetBitmapList() ), mpNewBitmapList ( pModel->GetBitmapList() ), mrOutAttrs ( *pAttr ), mnColorListState ( ChangeType::NONE ), mnBitmapListState ( ChangeType::NONE ), mnGradientListState ( ChangeType::NONE ), mnHatchingListState ( ChangeType::NONE ), mnPageType( PT_AREA ), mnPos( 0 ), mbAreaTP( false ) { m_nAreaTabPage = AddTabPage( "RID_SVXPAGE_AREA", SvxAreaTabPage::Create, 0 ); if(bShadow) { m_nShadowTabPage = AddTabPage( "RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, 0 ); } else { RemoveTabPage( "RID_SVXPAGE_SHADOW" ); } m_nTransparenceTabPage = AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, 0); m_nColorTabPage = AddTabPage( "RID_SVXPAGE_COLOR", SvxColorTabPage::Create, 0 ); m_nGradientTabPage = AddTabPage( "RID_SVXPAGE_GRADIENT", SvxGradientTabPage::Create, 0 ); m_nHatchTabPage = AddTabPage( "RID_SVXPAGE_HATCH", SvxHatchTabPage::Create, 0 ); m_nBitmapTabPage = AddTabPage( "RID_SVXPAGE_BITMAP", SvxBitmapTabPage::Create, 0); SetCurPageId( "RID_SVXPAGE_AREA" ); CancelButton& rBtnCancel = GetCancelButton(); rBtnCancel.SetClickHdl( LINK( this, SvxAreaTabDialog, CancelHdlImpl ) ); } void SvxAreaTabDialog::SavePalettes() { SfxObjectShell* pShell = SfxObjectShell::Current(); if( mpNewColorList != mpDrawModel->GetColorList() ) { mpDrawModel->SetPropertyList( static_cast(mpNewColorList.get()) ); SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE ); if ( pShell ) pShell->PutItem( aColorListItem ); else mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE); mpColorList = mpDrawModel->GetColorList(); } if( mpNewGradientList != mpDrawModel->GetGradientList() ) { mpDrawModel->SetPropertyList( static_cast(mpNewGradientList.get()) ); SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST ); if ( pShell ) pShell->PutItem( aItem ); else mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST); mpGradientList = mpDrawModel->GetGradientList(); } if( mpNewHatchingList != mpDrawModel->GetHatchList() ) { mpDrawModel->SetPropertyList( static_cast(mpNewHatchingList.get()) ); SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST ); if ( pShell ) pShell->PutItem( aItem ); else mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST); mpHatchingList = mpDrawModel->GetHatchList(); } if( mpNewBitmapList != mpDrawModel->GetBitmapList() ) { mpDrawModel->SetPropertyList( static_cast(mpNewBitmapList.get()) ); SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST ); if ( pShell ) pShell->PutItem( aItem ); else mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST); mpBitmapList = mpDrawModel->GetBitmapList(); } // save the tables when they have been changed const OUString aPath( SvtPathOptions().GetPalettePath() ); if( mnHatchingListState & ChangeType::MODIFIED ) { mpHatchingList->SetPath( aPath ); mpHatchingList->Save(); SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST ); // ToolBoxControls are informed: if ( pShell ) pShell->PutItem( aItem ); else mpDrawModel->GetItemPool().Put(aItem); } if( mnBitmapListState & ChangeType::MODIFIED ) { mpBitmapList->SetPath( aPath ); mpBitmapList->Save(); SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST ); // ToolBoxControls are informed: if ( pShell ) pShell->PutItem( aItem ); else { mpDrawModel->GetItemPool().Put(aItem); } } if( mnGradientListState & ChangeType::MODIFIED ) { mpGradientList->SetPath( aPath ); mpGradientList->Save(); SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST ); // ToolBoxControls are informed: if ( pShell ) pShell->PutItem( aItem ); else { mpDrawModel->GetItemPool().Put(aItem); } } if (mnColorListState & ChangeType::MODIFIED && mpColorList.is()) { mpColorList->SetPath( aPath ); mpColorList->Save(); SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE ); // ToolBoxControls are informed: if ( pShell ) pShell->PutItem( aItem ); else { mpDrawModel->GetItemPool().Put(aItem); } } } short SvxAreaTabDialog::Ok() { SavePalettes(); // RET_OK is returned, if at least one // TabPage returns sal_True in FillItemSet(). // This happens by default at the moment. return( SfxTabDialog::Ok() ); } IMPL_LINK_NOARG_INLINE_START(SvxAreaTabDialog, CancelHdlImpl) { SavePalettes(); EndDialog( RET_CANCEL ); return 0; } IMPL_LINK_INLINE_END( SvxAreaTabDialog, CancelHdlImpl, void *, p ) void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) { if (nId == m_nAreaTabPage ) { static_cast(rPage).SetColorList( mpColorList ); static_cast(rPage).SetGradientList( mpGradientList ); static_cast(rPage).SetHatchingList( mpHatchingList ); static_cast(rPage).SetBitmapList( mpBitmapList ); static_cast(rPage).SetPageType( mnPageType ); static_cast(rPage).SetDlgType( 0 ); static_cast(rPage).SetPos( mnPos ); static_cast(rPage).SetAreaTP( &mbAreaTP ); static_cast(rPage).SetGrdChgd( &mnGradientListState ); static_cast(rPage).SetHtchChgd( &mnHatchingListState ); static_cast(rPage).SetBmpChgd( &mnBitmapListState ); static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); // ActivatePge() is not called the first time static_cast(rPage).ActivatePage( mrOutAttrs ); } else if (nId == m_nShadowTabPage) { static_cast(rPage).SetColorList( mpColorList ); static_cast(rPage).SetPageType( mnPageType ); static_cast(rPage).SetDlgType( 0 ); static_cast(rPage).SetAreaTP( &mbAreaTP ); static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); } else if (nId == m_nGradientTabPage) { static_cast(rPage).SetColorList( mpColorList ); static_cast(rPage).SetGradientList( mpGradientList ); static_cast(rPage).SetPageType( &mnPageType ); static_cast(rPage).SetDlgType( 0 ); static_cast(rPage).SetPos( &mnPos ); static_cast(rPage).SetAreaTP( &mbAreaTP ); static_cast(rPage).SetGrdChgd( &mnGradientListState ); static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); } else if (nId == m_nHatchTabPage) { static_cast(rPage).SetColorList( mpColorList ); static_cast(rPage).SetHatchingList( mpHatchingList ); static_cast(rPage).SetPageType( &mnPageType ); static_cast(rPage).SetDlgType( 0 ); static_cast(rPage).SetPos( &mnPos ); static_cast(rPage).SetAreaTP( &mbAreaTP ); static_cast(rPage).SetHtchChgd( &mnHatchingListState ); static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); } else if (nId == m_nBitmapTabPage) { static_cast(rPage).SetColorList( mpColorList ); static_cast(rPage).SetBitmapList( mpBitmapList ); static_cast(rPage).SetPageType( &mnPageType ); static_cast(rPage).SetDlgType( 0 ); static_cast(rPage).SetPos( &mnPos ); static_cast(rPage).SetAreaTP( &mbAreaTP ); static_cast(rPage).SetBmpChgd( &mnBitmapListState ); static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); } else if (nId == m_nColorTabPage) { static_cast(rPage).SetColorList( mpColorList ); static_cast(rPage).SetPageType( &mnPageType ); static_cast(rPage).SetDlgType( 0 ); static_cast(rPage).SetPos( &mnPos ); static_cast(rPage).SetAreaTP( &mbAreaTP ); static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); } else if (nId == m_nTransparenceTabPage) { static_cast(rPage).SetPageType( mnPageType ); static_cast(rPage).SetDlgType( 0 ); } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */