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
,
36 : SfxTabDialogController(pParent
, "cui/ui/areadialog.ui", "AreaDialog", pAttr
)
37 , mpDrawModel ( pModel
),
38 mpColorList ( pModel
->GetColorList() ),
39 mpNewColorList ( pModel
->GetColorList() ),
40 mpGradientList ( pModel
->GetGradientList() ),
41 mpNewGradientList ( pModel
->GetGradientList() ),
42 mpHatchingList ( pModel
->GetHatchList() ),
43 mpNewHatchingList ( pModel
->GetHatchList() ),
44 mpBitmapList ( pModel
->GetBitmapList() ),
45 mpNewBitmapList ( pModel
->GetBitmapList() ),
46 mpPatternList ( pModel
->GetPatternList() ),
47 mpNewPatternList ( pModel
->GetPatternList() ),
49 mnColorListState ( ChangeType::NONE
),
50 mnBitmapListState ( ChangeType::NONE
),
51 mnPatternListState ( ChangeType::NONE
),
52 mnGradientListState ( ChangeType::NONE
),
53 mnHatchingListState ( ChangeType::NONE
)
55 AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create
, nullptr);
59 AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create
, nullptr);
63 RemoveTabPage( "RID_SVXPAGE_SHADOW" );
66 AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create
, nullptr);
68 weld::Button
& rBtnCancel
= GetCancelButton();
69 rBtnCancel
.connect_clicked(LINK(this, SvxAreaTabDialog
, CancelHdlImpl
));
72 void SvxAreaTabDialog::SavePalettes()
74 SfxObjectShell
* pShell
= SfxObjectShell::Current();
75 if( mpNewColorList
!= mpDrawModel
->GetColorList() )
77 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewColorList
.get()) );
78 SvxColorListItem
aColorListItem( mpNewColorList
, SID_COLOR_TABLE
);
80 pShell
->PutItem( aColorListItem
);
82 mpDrawModel
->GetItemPool().Put(aColorListItem
,SID_COLOR_TABLE
);
83 mpColorList
= mpDrawModel
->GetColorList();
85 if( mpNewGradientList
!= mpDrawModel
->GetGradientList() )
87 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewGradientList
.get()) );
88 SvxGradientListItem
aItem( mpNewGradientList
, SID_GRADIENT_LIST
);
90 pShell
->PutItem( aItem
);
92 mpDrawModel
->GetItemPool().Put(aItem
,SID_GRADIENT_LIST
);
93 mpGradientList
= mpDrawModel
->GetGradientList();
95 if( mpNewHatchingList
!= mpDrawModel
->GetHatchList() )
97 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewHatchingList
.get()) );
98 SvxHatchListItem
aItem( mpNewHatchingList
, SID_HATCH_LIST
);
100 pShell
->PutItem( aItem
);
102 mpDrawModel
->GetItemPool().Put(aItem
,SID_HATCH_LIST
);
103 mpHatchingList
= mpDrawModel
->GetHatchList();
105 if( mpNewBitmapList
!= mpDrawModel
->GetBitmapList() )
107 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewBitmapList
.get()) );
108 SvxBitmapListItem
aItem( mpNewBitmapList
, SID_BITMAP_LIST
);
110 pShell
->PutItem( aItem
);
112 mpDrawModel
->GetItemPool().Put(aItem
,SID_BITMAP_LIST
);
113 mpBitmapList
= mpDrawModel
->GetBitmapList();
115 if( mpNewPatternList
!= mpDrawModel
->GetPatternList() )
117 mpDrawModel
->SetPropertyList( static_cast<XPropertyList
*>(mpNewPatternList
.get()) );
118 SvxPatternListItem
aItem( mpNewPatternList
, SID_PATTERN_LIST
);
120 pShell
->PutItem( aItem
);
122 mpDrawModel
->GetItemPool().Put(aItem
,SID_PATTERN_LIST
);
123 mpPatternList
= mpDrawModel
->GetPatternList();
126 // save the tables when they have been changed
128 OUString
aPalettePath(SvtPathOptions().GetPalettePath());
130 sal_Int32 nIndex
= 0;
133 aPath
= aPalettePath
.getToken(0, ';', nIndex
);
137 if( mnHatchingListState
& ChangeType::MODIFIED
)
139 mpHatchingList
->SetPath( aPath
);
140 mpHatchingList
->Save();
142 SvxHatchListItem
aItem( mpHatchingList
, SID_HATCH_LIST
);
143 // ToolBoxControls are informed:
145 pShell
->PutItem( aItem
);
147 mpDrawModel
->GetItemPool().Put(aItem
);
150 if( mnBitmapListState
& ChangeType::MODIFIED
)
152 mpBitmapList
->SetPath( aPath
);
153 mpBitmapList
->Save();
155 SvxBitmapListItem
aItem( mpBitmapList
, SID_BITMAP_LIST
);
156 // ToolBoxControls are informed:
158 pShell
->PutItem( aItem
);
161 mpDrawModel
->GetItemPool().Put(aItem
);
165 if( mnPatternListState
& ChangeType::MODIFIED
)
167 mpPatternList
->SetPath( aPath
);
168 mpPatternList
->Save();
170 SvxPatternListItem
aItem( mpPatternList
, SID_PATTERN_LIST
);
171 // ToolBoxControls are informed:
173 pShell
->PutItem( aItem
);
175 mpDrawModel
->GetItemPool().Put(aItem
);
178 if( mnGradientListState
& ChangeType::MODIFIED
)
180 mpGradientList
->SetPath( aPath
);
181 mpGradientList
->Save();
183 SvxGradientListItem
aItem( mpGradientList
, SID_GRADIENT_LIST
);
184 // ToolBoxControls are informed:
186 pShell
->PutItem( aItem
);
189 mpDrawModel
->GetItemPool().Put(aItem
);
193 if (mnColorListState
& ChangeType::MODIFIED
&& mpColorList
.is())
195 SvxColorListItem
aItem( mpColorList
, SID_COLOR_TABLE
);
196 // ToolBoxControls are informed:
198 pShell
->PutItem( aItem
);
201 mpDrawModel
->GetItemPool().Put(aItem
);
206 short SvxAreaTabDialog::Ok()
209 // RET_OK is returned, if at least one
210 // TabPage returns sal_True in FillItemSet().
211 // This happens by default at the moment.
212 return SfxTabDialogController::Ok();
215 IMPL_LINK_NOARG(SvxAreaTabDialog
, CancelHdlImpl
, weld::Button
&, void)
218 m_xDialog
->response(RET_CANCEL
);
221 void SvxAreaTabDialog::PageCreated(const OString
& rId
, SfxTabPage
&rPage
)
223 if (rId
== "RID_SVXPAGE_AREA")
225 static_cast<SvxAreaTabPage
&>(rPage
).SetColorList( mpColorList
);
226 static_cast<SvxAreaTabPage
&>(rPage
).SetGradientList( mpGradientList
);
227 static_cast<SvxAreaTabPage
&>(rPage
).SetHatchingList( mpHatchingList
);
228 static_cast<SvxAreaTabPage
&>(rPage
).SetBitmapList( mpBitmapList
);
229 static_cast<SvxAreaTabPage
&>(rPage
).SetPatternList( mpPatternList
);
230 static_cast<SvxAreaTabPage
&>(rPage
).SetGrdChgd( &mnGradientListState
);
231 static_cast<SvxAreaTabPage
&>(rPage
).SetHtchChgd( &mnHatchingListState
);
232 static_cast<SvxAreaTabPage
&>(rPage
).SetBmpChgd( &mnBitmapListState
);
233 static_cast<SvxAreaTabPage
&>(rPage
).SetPtrnChgd( &mnPatternListState
);
234 static_cast<SvxAreaTabPage
&>(rPage
).SetColorChgd( &mnColorListState
);
236 else if (rId
== "RID_SVXPAGE_SHADOW")
238 static_cast<SvxShadowTabPage
&>(rPage
).SetColorList( mpColorList
);
239 static_cast<SvxShadowTabPage
&>(rPage
).SetColorChgd( &mnColorListState
);
241 else if (rId
== "RID_SVXPAGE_TRANSPARENCE")
243 static_cast<SvxTransparenceTabPage
&>(rPage
).SetPageType( PageType::Area
);
244 static_cast<SvxTransparenceTabPage
&>(rPage
).SetDlgType( 0 );
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */