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