bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / tabpages / tabarea.cxx
blob7ecc83618bbd83c971f553839a116fa742fd2ada
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
38 SvxAreaTabDialog::SvxAreaTabDialog
40 vcl::Window* pParent,
41 const SfxItemSet* pAttr,
42 SdrModel* pModel,
43 bool bShadow
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)
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 ),
68 mnColorListState ( ChangeType::NONE ),
69 mnBitmapListState ( ChangeType::NONE ),
70 mnGradientListState ( ChangeType::NONE ),
71 mnHatchingListState ( ChangeType::NONE ),
72 mnPageType( PT_AREA ),
73 mnPos( 0 ),
74 mbAreaTP( false )
76 m_nAreaTabPage = AddTabPage( "RID_SVXPAGE_AREA", SvxAreaTabPage::Create, 0 );
78 if(bShadow)
80 m_nShadowTabPage = AddTabPage( "RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, 0 );
82 else
84 RemoveTabPage( "RID_SVXPAGE_SHADOW" );
87 m_nTransparenceTabPage = AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, 0);
88 m_nColorTabPage = AddTabPage( "RID_SVXPAGE_COLOR", SvxColorTabPage::Create, 0 );
89 m_nGradientTabPage = AddTabPage( "RID_SVXPAGE_GRADIENT", SvxGradientTabPage::Create, 0 );
90 m_nHatchTabPage = AddTabPage( "RID_SVXPAGE_HATCH", SvxHatchTabPage::Create, 0 );
91 m_nBitmapTabPage = AddTabPage( "RID_SVXPAGE_BITMAP", SvxBitmapTabPage::Create, 0);
93 SetCurPageId( "RID_SVXPAGE_AREA" );
95 CancelButton& rBtnCancel = GetCancelButton();
96 rBtnCancel.SetClickHdl( LINK( this, SvxAreaTabDialog, CancelHdlImpl ) );
99 void SvxAreaTabDialog::SavePalettes()
101 SfxObjectShell* pShell = SfxObjectShell::Current();
102 if( mpNewColorList != mpDrawModel->GetColorList() )
104 mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
105 SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
106 if ( pShell )
107 pShell->PutItem( aColorListItem );
108 else
109 mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
110 mpColorList = mpDrawModel->GetColorList();
112 if( mpNewGradientList != mpDrawModel->GetGradientList() )
114 mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) );
115 SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
116 if ( pShell )
117 pShell->PutItem( aItem );
118 else
119 mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
120 mpGradientList = mpDrawModel->GetGradientList();
122 if( mpNewHatchingList != mpDrawModel->GetHatchList() )
124 mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) );
125 SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
126 if ( pShell )
127 pShell->PutItem( aItem );
128 else
129 mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
130 mpHatchingList = mpDrawModel->GetHatchList();
132 if( mpNewBitmapList != mpDrawModel->GetBitmapList() )
134 mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) );
135 SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
136 if ( pShell )
137 pShell->PutItem( aItem );
138 else
139 mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
140 mpBitmapList = mpDrawModel->GetBitmapList();
143 // save the tables when they have been changed
145 const OUString aPath( SvtPathOptions().GetPalettePath() );
147 if( mnHatchingListState & ChangeType::MODIFIED )
149 mpHatchingList->SetPath( aPath );
150 mpHatchingList->Save();
152 SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
153 // ToolBoxControls are informed:
154 if ( pShell )
155 pShell->PutItem( aItem );
156 else
157 mpDrawModel->GetItemPool().Put(aItem);
160 if( mnBitmapListState & ChangeType::MODIFIED )
162 mpBitmapList->SetPath( aPath );
163 mpBitmapList->Save();
165 SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
166 // ToolBoxControls are informed:
167 if ( pShell )
168 pShell->PutItem( aItem );
169 else
171 mpDrawModel->GetItemPool().Put(aItem);
175 if( mnGradientListState & ChangeType::MODIFIED )
177 mpGradientList->SetPath( aPath );
178 mpGradientList->Save();
180 SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
181 // ToolBoxControls are informed:
182 if ( pShell )
183 pShell->PutItem( aItem );
184 else
186 mpDrawModel->GetItemPool().Put(aItem);
190 if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
192 mpColorList->SetPath( aPath );
193 mpColorList->Save();
195 SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
196 // ToolBoxControls are informed:
197 if ( pShell )
198 pShell->PutItem( aItem );
199 else
201 mpDrawModel->GetItemPool().Put(aItem);
207 short SvxAreaTabDialog::Ok()
209 SavePalettes();
211 // RET_OK is returned, if at least one
212 // TabPage returns sal_True in FillItemSet().
213 // This happens by default at the moment.
214 return( SfxTabDialog::Ok() );
219 IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl)
221 SavePalettes();
223 EndDialog( RET_CANCEL );
224 return 0;
227 void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
229 if (nId == m_nAreaTabPage )
231 static_cast<SvxAreaTabPage&>(rPage).SetColorList( mpColorList );
232 static_cast<SvxAreaTabPage&>(rPage).SetGradientList( mpGradientList );
233 static_cast<SvxAreaTabPage&>(rPage).SetHatchingList( mpHatchingList );
234 static_cast<SvxAreaTabPage&>(rPage).SetBitmapList( mpBitmapList );
235 static_cast<SvxAreaTabPage&>(rPage).SetPageType( mnPageType );
236 static_cast<SvxAreaTabPage&>(rPage).SetDlgType( 0 );
237 static_cast<SvxAreaTabPage&>(rPage).SetPos( mnPos );
238 static_cast<SvxAreaTabPage&>(rPage).SetAreaTP( &mbAreaTP );
239 static_cast<SvxAreaTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
240 static_cast<SvxAreaTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
241 static_cast<SvxAreaTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
242 static_cast<SvxAreaTabPage&>(rPage).SetColorChgd( &mnColorListState );
243 static_cast<SvxAreaTabPage&>(rPage).Construct();
244 // ActivatePge() is not called the first time
245 static_cast<SvxAreaTabPage&>(rPage).ActivatePage( mrOutAttrs );
247 else if (nId == m_nShadowTabPage)
249 static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
250 static_cast<SvxShadowTabPage&>(rPage).SetPageType( mnPageType );
251 static_cast<SvxShadowTabPage&>(rPage).SetDlgType( 0 );
252 static_cast<SvxShadowTabPage&>(rPage).SetAreaTP( &mbAreaTP );
253 static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
254 static_cast<SvxShadowTabPage&>(rPage).Construct();
256 else if (nId == m_nGradientTabPage)
258 static_cast<SvxGradientTabPage&>(rPage).SetColorList( mpColorList );
259 static_cast<SvxGradientTabPage&>(rPage).SetGradientList( mpGradientList );
260 static_cast<SvxGradientTabPage&>(rPage).SetPageType( &mnPageType );
261 static_cast<SvxGradientTabPage&>(rPage).SetDlgType( 0 );
262 static_cast<SvxGradientTabPage&>(rPage).SetPos( &mnPos );
263 static_cast<SvxGradientTabPage&>(rPage).SetAreaTP( &mbAreaTP );
264 static_cast<SvxGradientTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
265 static_cast<SvxGradientTabPage&>(rPage).SetColorChgd( &mnColorListState );
266 static_cast<SvxGradientTabPage&>(rPage).Construct();
268 else if (nId == m_nHatchTabPage)
270 static_cast<SvxHatchTabPage&>(rPage).SetColorList( mpColorList );
271 static_cast<SvxHatchTabPage&>(rPage).SetHatchingList( mpHatchingList );
272 static_cast<SvxHatchTabPage&>(rPage).SetPageType( &mnPageType );
273 static_cast<SvxHatchTabPage&>(rPage).SetDlgType( 0 );
274 static_cast<SvxHatchTabPage&>(rPage).SetPos( &mnPos );
275 static_cast<SvxHatchTabPage&>(rPage).SetAreaTP( &mbAreaTP );
276 static_cast<SvxHatchTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
277 static_cast<SvxHatchTabPage&>(rPage).SetColorChgd( &mnColorListState );
278 static_cast<SvxHatchTabPage&>(rPage).Construct();
280 else if (nId == m_nBitmapTabPage)
282 static_cast<SvxBitmapTabPage&>(rPage).SetColorList( mpColorList );
283 static_cast<SvxBitmapTabPage&>(rPage).SetBitmapList( mpBitmapList );
284 static_cast<SvxBitmapTabPage&>(rPage).SetPageType( &mnPageType );
285 static_cast<SvxBitmapTabPage&>(rPage).SetDlgType( 0 );
286 static_cast<SvxBitmapTabPage&>(rPage).SetPos( &mnPos );
287 static_cast<SvxBitmapTabPage&>(rPage).SetAreaTP( &mbAreaTP );
288 static_cast<SvxBitmapTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
289 static_cast<SvxBitmapTabPage&>(rPage).SetColorChgd( &mnColorListState );
290 static_cast<SvxBitmapTabPage&>(rPage).Construct();
292 else if (nId == m_nColorTabPage)
294 static_cast<SvxColorTabPage&>(rPage).SetColorList( mpColorList );
295 static_cast<SvxColorTabPage&>(rPage).SetPageType( &mnPageType );
296 static_cast<SvxColorTabPage&>(rPage).SetDlgType( 0 );
297 static_cast<SvxColorTabPage&>(rPage).SetPos( &mnPos );
298 static_cast<SvxColorTabPage&>(rPage).SetAreaTP( &mbAreaTP );
299 static_cast<SvxColorTabPage&>(rPage).SetColorChgd( &mnColorListState );
300 static_cast<SvxColorTabPage&>(rPage).Construct();
302 else if (nId == m_nTransparenceTabPage)
304 static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( mnPageType );
305 static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */