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/objsh.hxx>
21 #include <unotools/pathoptions.hxx>
22 #include <svx/svxids.hrc>
24 #include <svx/xtable.hxx>
25 #include <svx/svdmodel.hxx>
26 #include <svx/drawitem.hxx>
27 #include <cuitabarea.hxx>
29 SvxAreaTabDialog::SvxAreaTabDialog
31 weld::Window
* pParent
,
32 const SfxItemSet
* pAttr
,
37 : SfxTabDialogController(pParent
, "cui/ui/areadialog.ui", "AreaDialog", pAttr
)
38 , mpDrawModel ( pModel
),
39 mpColorList ( pModel
->GetColorList() ),
40 mpNewColorList ( pModel
->GetColorList() ),
41 mpGradientList ( pModel
->GetGradientList() ),
42 mpNewGradientList ( pModel
->GetGradientList() ),
43 mpHatchingList ( pModel
->GetHatchList() ),
44 mpNewHatchingList ( pModel
->GetHatchList() ),
45 mpBitmapList ( pModel
->GetBitmapList() ),
46 mpNewBitmapList ( pModel
->GetBitmapList() ),
47 mpPatternList ( pModel
->GetPatternList() ),
48 mpNewPatternList ( pModel
->GetPatternList() ),
50 mnColorListState ( ChangeType::NONE
),
51 mnBitmapListState ( ChangeType::NONE
),
52 mnPatternListState ( ChangeType::NONE
),
53 mnGradientListState ( ChangeType::NONE
),
54 mnHatchingListState ( ChangeType::NONE
)
57 AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::CreateWithSlideBackground
, nullptr);
59 AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create
, nullptr);
63 AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create
, nullptr);
67 RemoveTabPage( "RID_SVXPAGE_SHADOW" );
70 AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create
, nullptr);
72 weld::Button
& rBtnCancel
= GetCancelButton();
73 rBtnCancel
.connect_clicked(LINK(this, SvxAreaTabDialog
, CancelHdlImpl
));
76 void SvxAreaTabDialog::SavePalettes()
78 SfxObjectShell
* pShell
= SfxObjectShell::Current();
79 if( mpNewColorList
!= mpDrawModel
->GetColorList() )
81 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewColorList
.get()) );
82 SvxColorListItem
aColorListItem( mpNewColorList
, SID_COLOR_TABLE
);
84 pShell
->PutItem( aColorListItem
);
86 mpDrawModel
->GetItemPool().Put(aColorListItem
,SID_COLOR_TABLE
);
87 mpColorList
= mpDrawModel
->GetColorList();
89 if( mpNewGradientList
!= mpDrawModel
->GetGradientList() )
91 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewGradientList
.get()) );
92 SvxGradientListItem
aItem( mpNewGradientList
, SID_GRADIENT_LIST
);
94 pShell
->PutItem( aItem
);
96 mpDrawModel
->GetItemPool().Put(aItem
,SID_GRADIENT_LIST
);
97 mpGradientList
= mpDrawModel
->GetGradientList();
99 if( mpNewHatchingList
!= mpDrawModel
->GetHatchList() )
101 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewHatchingList
.get()) );
102 SvxHatchListItem
aItem( mpNewHatchingList
, SID_HATCH_LIST
);
104 pShell
->PutItem( aItem
);
106 mpDrawModel
->GetItemPool().Put(aItem
,SID_HATCH_LIST
);
107 mpHatchingList
= mpDrawModel
->GetHatchList();
109 if( mpNewBitmapList
!= mpDrawModel
->GetBitmapList() )
111 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewBitmapList
.get()) );
112 SvxBitmapListItem
aItem( mpNewBitmapList
, SID_BITMAP_LIST
);
114 pShell
->PutItem( aItem
);
116 mpDrawModel
->GetItemPool().Put(aItem
,SID_BITMAP_LIST
);
117 mpBitmapList
= mpDrawModel
->GetBitmapList();
119 if( mpNewPatternList
!= mpDrawModel
->GetPatternList() )
121 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewPatternList
.get()) );
122 SvxPatternListItem
aItem( mpNewPatternList
, SID_PATTERN_LIST
);
124 pShell
->PutItem( aItem
);
126 mpDrawModel
->GetItemPool().Put(aItem
,SID_PATTERN_LIST
);
127 mpPatternList
= mpDrawModel
->GetPatternList();
130 // save the tables when they have been changed
132 OUString
aPalettePath(SvtPathOptions().GetPalettePath());
134 sal_Int32 nIndex
= 0;
137 aPath
= aPalettePath
.getToken(0, ';', nIndex
);
141 if( mnHatchingListState
& ChangeType::MODIFIED
)
143 mpHatchingList
->SetPath( aPath
);
144 mpHatchingList
->Save();
146 SvxHatchListItem
aItem( mpHatchingList
, SID_HATCH_LIST
);
147 // ToolBoxControls are informed:
149 pShell
->PutItem( aItem
);
151 mpDrawModel
->GetItemPool().Put(aItem
);
154 if( mnBitmapListState
& ChangeType::MODIFIED
)
156 mpBitmapList
->SetPath( aPath
);
157 mpBitmapList
->Save();
159 SvxBitmapListItem
aItem( mpBitmapList
, SID_BITMAP_LIST
);
160 // ToolBoxControls are informed:
162 pShell
->PutItem( aItem
);
165 mpDrawModel
->GetItemPool().Put(aItem
);
169 if( mnPatternListState
& ChangeType::MODIFIED
)
171 mpPatternList
->SetPath( aPath
);
172 mpPatternList
->Save();
174 SvxPatternListItem
aItem( mpPatternList
, SID_PATTERN_LIST
);
175 // ToolBoxControls are informed:
177 pShell
->PutItem( aItem
);
179 mpDrawModel
->GetItemPool().Put(aItem
);
182 if( mnGradientListState
& ChangeType::MODIFIED
)
184 mpGradientList
->SetPath( aPath
);
185 mpGradientList
->Save();
187 SvxGradientListItem
aItem( mpGradientList
, SID_GRADIENT_LIST
);
188 // ToolBoxControls are informed:
190 pShell
->PutItem( aItem
);
193 mpDrawModel
->GetItemPool().Put(aItem
);
197 if (mnColorListState
& ChangeType::MODIFIED
&& mpColorList
.is())
199 SvxColorListItem
aItem( mpColorList
, SID_COLOR_TABLE
);
200 // ToolBoxControls are informed:
202 pShell
->PutItem( aItem
);
205 mpDrawModel
->GetItemPool().Put(aItem
);
210 short SvxAreaTabDialog::Ok()
213 // RET_OK is returned, if at least one
214 // TabPage returns sal_True in FillItemSet().
215 // This happens by default at the moment.
216 return SfxTabDialogController::Ok();
219 IMPL_LINK_NOARG(SvxAreaTabDialog
, CancelHdlImpl
, weld::Button
&, void)
222 m_xDialog
->response(RET_CANCEL
);
225 void SvxAreaTabDialog::PageCreated(const OUString
& rId
, SfxTabPage
&rPage
)
227 if (rId
== "RID_SVXPAGE_AREA")
229 static_cast<SvxAreaTabPage
&>(rPage
).SetColorList( mpColorList
);
230 static_cast<SvxAreaTabPage
&>(rPage
).SetGradientList( mpGradientList
);
231 static_cast<SvxAreaTabPage
&>(rPage
).SetHatchingList( mpHatchingList
);
232 static_cast<SvxAreaTabPage
&>(rPage
).SetBitmapList( mpBitmapList
);
233 static_cast<SvxAreaTabPage
&>(rPage
).SetPatternList( mpPatternList
);
234 static_cast<SvxAreaTabPage
&>(rPage
).SetGrdChgd( &mnGradientListState
);
235 static_cast<SvxAreaTabPage
&>(rPage
).SetHtchChgd( &mnHatchingListState
);
236 static_cast<SvxAreaTabPage
&>(rPage
).SetBmpChgd( &mnBitmapListState
);
237 static_cast<SvxAreaTabPage
&>(rPage
).SetPtrnChgd( &mnPatternListState
);
238 static_cast<SvxAreaTabPage
&>(rPage
).SetColorChgd( &mnColorListState
);
240 else if (rId
== "RID_SVXPAGE_SHADOW")
242 static_cast<SvxShadowTabPage
&>(rPage
).SetColorList( mpColorList
);
243 static_cast<SvxShadowTabPage
&>(rPage
).SetColorChgd( &mnColorListState
);
245 else if (rId
== "RID_SVXPAGE_TRANSPARENCE")
247 static_cast<SvxTransparenceTabPage
&>(rPage
).SetPageType( PageType::Area
);
248 static_cast<SvxTransparenceTabPage
&>(rPage
).SetDlgType( 0 );
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */