1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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 "tabarea.hrc"
36 #include "dlgname.hxx"
37 #include <dialmgr.hxx>
39 SvxAreaTabDialog::SvxAreaTabDialog
42 const SfxItemSet
* pAttr
,
44 const SdrView
* /* pSdrView */
47 SfxTabDialog( pParent
, CUI_RES( RID_SVXDLG_AREA
), pAttr
),
49 mpDrawModel ( pModel
),
50 mpColorList ( pModel
->GetColorList() ),
51 mpNewColorList ( pModel
->GetColorList() ),
52 mpGradientList ( pModel
->GetGradientList() ),
53 mpNewGradientList ( pModel
->GetGradientList() ),
54 mpHatchingList ( pModel
->GetHatchList() ),
55 mpNewHatchingList ( pModel
->GetHatchList() ),
56 mpBitmapList ( pModel
->GetBitmapList() ),
57 mpNewBitmapList ( pModel
->GetBitmapList() ),
58 mrOutAttrs ( *pAttr
),
59 mnColorListState ( CT_NONE
),
60 mnBitmapListState ( CT_NONE
),
61 mnGradientListState ( CT_NONE
),
62 mnHatchingListState ( CT_NONE
),
63 mnPageType( PT_AREA
),
69 AddTabPage( RID_SVXPAGE_AREA
, SvxAreaTabPage::Create
, 0 );
70 AddTabPage( RID_SVXPAGE_SHADOW
, SvxShadowTabPage::Create
, 0 );
71 AddTabPage( RID_SVXPAGE_TRANSPARENCE
, SvxTransparenceTabPage::Create
, 0);
72 AddTabPage( RID_SVXPAGE_COLOR
, SvxColorTabPage::Create
, 0 );
73 AddTabPage( RID_SVXPAGE_GRADIENT
, SvxGradientTabPage::Create
, 0 );
74 AddTabPage( RID_SVXPAGE_HATCH
, SvxHatchTabPage::Create
, 0 );
75 AddTabPage( RID_SVXPAGE_BITMAP
, SvxBitmapTabPage::Create
, 0);
77 SetCurPageId( RID_SVXPAGE_AREA
);
79 CancelButton
& rBtnCancel
= GetCancelButton();
80 rBtnCancel
.SetClickHdl( LINK( this, SvxAreaTabDialog
, CancelHdlImpl
) );
83 // -----------------------------------------------------------------------
85 SvxAreaTabDialog::~SvxAreaTabDialog()
90 // -----------------------------------------------------------------------
92 void SvxAreaTabDialog::SavePalettes()
94 SfxObjectShell
* pShell
= SfxObjectShell::Current();
95 if( mpNewColorList
!= mpDrawModel
->GetColorList() )
97 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewColorList
.get()) );
98 SvxColorListItem
aColorListItem( mpNewColorList
, SID_COLOR_TABLE
);
100 pShell
->PutItem( aColorListItem
);
102 mpDrawModel
->GetItemPool().Put(aColorListItem
,SID_COLOR_TABLE
);
103 mpColorList
= mpDrawModel
->GetColorList();
105 if( mpNewGradientList
!= mpDrawModel
->GetGradientList() )
107 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewGradientList
.get()) );
108 SvxGradientListItem
aItem( mpNewGradientList
, SID_GRADIENT_LIST
);
110 pShell
->PutItem( aItem
);
112 mpDrawModel
->GetItemPool().Put(aItem
,SID_GRADIENT_LIST
);
113 mpGradientList
= mpDrawModel
->GetGradientList();
115 if( mpNewHatchingList
!= mpDrawModel
->GetHatchList() )
117 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewHatchingList
.get()) );
118 SvxHatchListItem
aItem( mpNewHatchingList
, SID_HATCH_LIST
);
120 pShell
->PutItem( aItem
);
122 mpDrawModel
->GetItemPool().Put(aItem
,SID_HATCH_LIST
);
123 mpHatchingList
= mpDrawModel
->GetHatchList();
125 if( mpNewBitmapList
!= mpDrawModel
->GetBitmapList() )
127 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewBitmapList
.get()) );
128 SvxBitmapListItem
aItem( mpNewBitmapList
, SID_BITMAP_LIST
);
130 pShell
->PutItem( aItem
);
132 mpDrawModel
->GetItemPool().Put(aItem
,SID_BITMAP_LIST
);
133 mpBitmapList
= mpDrawModel
->GetBitmapList();
136 // save the tables when they have been changed
138 const OUString
aPath( SvtPathOptions().GetPalettePath() );
140 if( mnHatchingListState
& CT_MODIFIED
)
142 mpHatchingList
->SetPath( aPath
);
143 mpHatchingList
->Save();
145 SvxHatchListItem
aItem( mpHatchingList
, SID_HATCH_LIST
);
146 // ToolBoxControls are informed:
148 pShell
->PutItem( aItem
);
150 mpDrawModel
->GetItemPool().Put(aItem
);
153 if( mnBitmapListState
& CT_MODIFIED
)
155 mpBitmapList
->SetPath( aPath
);
156 mpBitmapList
->Save();
158 SvxBitmapListItem
aItem( mpBitmapList
, SID_BITMAP_LIST
);
159 // ToolBoxControls are informed:
161 pShell
->PutItem( aItem
);
164 mpDrawModel
->GetItemPool().Put(aItem
);
168 if( mnGradientListState
& CT_MODIFIED
)
170 mpGradientList
->SetPath( aPath
);
171 mpGradientList
->Save();
173 SvxGradientListItem
aItem( mpGradientList
, SID_GRADIENT_LIST
);
174 // ToolBoxControls are informed:
176 pShell
->PutItem( aItem
);
179 mpDrawModel
->GetItemPool().Put(aItem
);
183 if( mnColorListState
& CT_MODIFIED
)
185 mpColorList
->SetPath( aPath
);
188 SvxColorListItem
aItem( mpColorList
, SID_COLOR_TABLE
);
189 // ToolBoxControls are informed:
191 pShell
->PutItem( aItem
);
194 mpDrawModel
->GetItemPool().Put(aItem
);
198 // -----------------------------------------------------------------------
200 short SvxAreaTabDialog::Ok()
204 // RET_OK is returned, if at least one
205 // TabPage returns sal_True in FillItemSet().
206 // This happens by default at the moment.
207 return( SfxTabDialog::Ok() );
210 // -----------------------------------------------------------------------
212 IMPL_LINK_NOARG_INLINE_START(SvxAreaTabDialog
, CancelHdlImpl
)
216 EndDialog( RET_CANCEL
);
219 IMPL_LINK_INLINE_END( SvxAreaTabDialog
, CancelHdlImpl
, void *, p
)
221 // -----------------------------------------------------------------------
223 void SvxAreaTabDialog::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
227 case RID_SVXPAGE_AREA
:
228 ( (SvxAreaTabPage
&) rPage
).SetColorList( mpColorList
);
229 ( (SvxAreaTabPage
&) rPage
).SetGradientList( mpGradientList
);
230 ( (SvxAreaTabPage
&) rPage
).SetHatchingList( mpHatchingList
);
231 ( (SvxAreaTabPage
&) rPage
).SetBitmapList( mpBitmapList
);
232 ( (SvxAreaTabPage
&) rPage
).SetPageType( mnPageType
);
233 ( (SvxAreaTabPage
&) rPage
).SetDlgType( mnDlgType
);
234 ( (SvxAreaTabPage
&) rPage
).SetPos( mnPos
);
235 ( (SvxAreaTabPage
&) rPage
).SetAreaTP( &mbAreaTP
);
236 ( (SvxAreaTabPage
&) rPage
).SetGrdChgd( &mnGradientListState
);
237 ( (SvxAreaTabPage
&) rPage
).SetHtchChgd( &mnHatchingListState
);
238 ( (SvxAreaTabPage
&) rPage
).SetBmpChgd( &mnBitmapListState
);
239 ( (SvxAreaTabPage
&) rPage
).SetColorChgd( &mnColorListState
);
240 ( (SvxAreaTabPage
&) rPage
).Construct();
241 // ActivatePage() is not called the first time
242 ( (SvxAreaTabPage
&) rPage
).ActivatePage( mrOutAttrs
);
246 case RID_SVXPAGE_SHADOW
:
248 ( (SvxShadowTabPage
&) rPage
).SetColorList( mpColorList
);
249 ( (SvxShadowTabPage
&) rPage
).SetPageType( mnPageType
);
250 ( (SvxShadowTabPage
&) rPage
).SetDlgType( mnDlgType
);
251 ( (SvxShadowTabPage
&) rPage
).SetAreaTP( &mbAreaTP
);
252 ( (SvxShadowTabPage
&) rPage
).SetColorChgd( &mnColorListState
);
253 ( (SvxShadowTabPage
&) rPage
).Construct();
257 case RID_SVXPAGE_GRADIENT
:
258 ( (SvxGradientTabPage
&) rPage
).SetColorList( mpColorList
);
259 ( (SvxGradientTabPage
&) rPage
).SetGradientList( mpGradientList
);
260 ( (SvxGradientTabPage
&) rPage
).SetPageType( &mnPageType
);
261 ( (SvxGradientTabPage
&) rPage
).SetDlgType( &mnDlgType
);
262 ( (SvxGradientTabPage
&) rPage
).SetPos( &mnPos
);
263 ( (SvxGradientTabPage
&) rPage
).SetAreaTP( &mbAreaTP
);
264 ( (SvxGradientTabPage
&) rPage
).SetGrdChgd( &mnGradientListState
);
265 ( (SvxGradientTabPage
&) rPage
).SetColorChgd( &mnColorListState
);
266 ( (SvxGradientTabPage
&) rPage
).Construct();
269 case RID_SVXPAGE_HATCH
:
270 ( (SvxHatchTabPage
&) rPage
).SetColorList( mpColorList
);
271 ( (SvxHatchTabPage
&) rPage
).SetHatchingList( mpHatchingList
);
272 ( (SvxHatchTabPage
&) rPage
).SetPageType( &mnPageType
);
273 ( (SvxHatchTabPage
&) rPage
).SetDlgType( &mnDlgType
);
274 ( (SvxHatchTabPage
&) rPage
).SetPos( &mnPos
);
275 ( (SvxHatchTabPage
&) rPage
).SetAreaTP( &mbAreaTP
);
276 ( (SvxHatchTabPage
&) rPage
).SetHtchChgd( &mnHatchingListState
);
277 ( (SvxHatchTabPage
&) rPage
).SetColorChgd( &mnColorListState
);
278 ( (SvxHatchTabPage
&) rPage
).Construct();
281 case RID_SVXPAGE_BITMAP
:
282 ( (SvxBitmapTabPage
&) rPage
).SetColorList( mpColorList
);
283 ( (SvxBitmapTabPage
&) rPage
).SetBitmapList( mpBitmapList
);
284 ( (SvxBitmapTabPage
&) rPage
).SetPageType( &mnPageType
);
285 ( (SvxBitmapTabPage
&) rPage
).SetDlgType( &mnDlgType
);
286 ( (SvxBitmapTabPage
&) rPage
).SetPos( &mnPos
);
287 ( (SvxBitmapTabPage
&) rPage
).SetAreaTP( &mbAreaTP
);
288 ( (SvxBitmapTabPage
&) rPage
).SetBmpChgd( &mnBitmapListState
);
289 ( (SvxBitmapTabPage
&) rPage
).SetColorChgd( &mnColorListState
);
290 ( (SvxBitmapTabPage
&) rPage
).Construct();
293 case RID_SVXPAGE_COLOR
:
294 ( (SvxColorTabPage
&) rPage
).SetColorList( mpColorList
);
295 ( (SvxColorTabPage
&) rPage
).SetPageType( &mnPageType
);
296 ( (SvxColorTabPage
&) rPage
).SetDlgType( &mnDlgType
);
297 ( (SvxColorTabPage
&) rPage
).SetPos( &mnPos
);
298 ( (SvxColorTabPage
&) rPage
).SetAreaTP( &mbAreaTP
);
299 ( (SvxColorTabPage
&) rPage
).SetColorChgd( &mnColorListState
);
300 ( (SvxColorTabPage
&) rPage
).Construct();
303 case RID_SVXPAGE_TRANSPARENCE
:
304 ( (SvxTransparenceTabPage
&) rPage
).SetPageType( mnPageType
);
305 ( (SvxTransparenceTabPage
&) rPage
).SetDlgType( mnDlgType
);
306 ( (SvxTransparenceTabPage
&) rPage
).Construct();
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */