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