1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sfx2/objsh.hxx>
#include <unotools/pathoptions.hxx>
#include <svx/svxids.hrc>
#include <svx/xtable.hxx>
#include <svx/svdmodel.hxx>
#include <svx/drawitem.hxx>
#include <cuitabarea.hxx>
SvxAreaTabDialog::SvxAreaTabDialog
(
weld::Window* pParent,
const SfxItemSet* pAttr,
SdrModel* pModel,
bool bShadow,
bool bSlideBackground
)
: SfxTabDialogController(pParent, "cui/ui/areadialog.ui", "AreaDialog", pAttr)
, mpDrawModel ( pModel ),
mpColorList ( pModel->GetColorList() ),
mpNewColorList ( pModel->GetColorList() ),
mpGradientList ( pModel->GetGradientList() ),
mpNewGradientList ( pModel->GetGradientList() ),
mpHatchingList ( pModel->GetHatchList() ),
mpNewHatchingList ( pModel->GetHatchList() ),
mpBitmapList ( pModel->GetBitmapList() ),
mpNewBitmapList ( pModel->GetBitmapList() ),
mpPatternList ( pModel->GetPatternList() ),
mpNewPatternList ( pModel->GetPatternList() ),
mnColorListState ( ChangeType::NONE ),
mnBitmapListState ( ChangeType::NONE ),
mnPatternListState ( ChangeType::NONE ),
mnGradientListState ( ChangeType::NONE ),
mnHatchingListState ( ChangeType::NONE )
{
if (bSlideBackground)
AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::CreateWithSlideBackground, nullptr);
else
AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr);
if (bShadow)
{
AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, nullptr);
}
else
{
RemoveTabPage( "RID_SVXPAGE_SHADOW" );
}
AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, nullptr);
weld::Button& rBtnCancel = GetCancelButton();
rBtnCancel.connect_clicked(LINK(this, SvxAreaTabDialog, CancelHdlImpl));
}
void SvxAreaTabDialog::SavePalettes()
{
SfxObjectShell* pShell = SfxObjectShell::Current();
if( mpNewColorList != mpDrawModel->GetColorList() )
{
mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
if ( pShell )
pShell->PutItem( aColorListItem );
else
mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
mpColorList = mpDrawModel->GetColorList();
}
if( mpNewGradientList != mpDrawModel->GetGradientList() )
{
mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) );
SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
if ( pShell )
pShell->PutItem( aItem );
else
mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
mpGradientList = mpDrawModel->GetGradientList();
}
if( mpNewHatchingList != mpDrawModel->GetHatchList() )
{
mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) );
SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
if ( pShell )
pShell->PutItem( aItem );
else
mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
mpHatchingList = mpDrawModel->GetHatchList();
}
if( mpNewBitmapList != mpDrawModel->GetBitmapList() )
{
mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) );
SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
if ( pShell )
pShell->PutItem( aItem );
else
mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
mpBitmapList = mpDrawModel->GetBitmapList();
}
if( mpNewPatternList != mpDrawModel->GetPatternList() )
{
mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewPatternList.get()) );
SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST );
if( pShell )
pShell->PutItem( aItem );
else
mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST);
mpPatternList = mpDrawModel->GetPatternList();
}
// save the tables when they have been changed
OUString aPalettePath(SvtPathOptions().GetPalettePath());
OUString aPath;
sal_Int32 nIndex = 0;
do
{
aPath = aPalettePath.getToken(0, ';', nIndex);
}
while (nIndex >= 0);
if( mnHatchingListState & ChangeType::MODIFIED )
{
mpHatchingList->SetPath( aPath );
mpHatchingList->Save();
SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
// ToolBoxControls are informed:
if ( pShell )
pShell->PutItem( aItem );
else
mpDrawModel->GetItemPool().Put(aItem);
}
if( mnBitmapListState & ChangeType::MODIFIED )
{
mpBitmapList->SetPath( aPath );
mpBitmapList->Save();
SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
// ToolBoxControls are informed:
if ( pShell )
pShell->PutItem( aItem );
else
{
mpDrawModel->GetItemPool().Put(aItem);
}
}
if( mnPatternListState & ChangeType::MODIFIED )
{
mpPatternList->SetPath( aPath );
mpPatternList->Save();
SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST );
// ToolBoxControls are informed:
if( pShell )
pShell->PutItem( aItem );
else
mpDrawModel->GetItemPool().Put(aItem);
}
if( mnGradientListState & ChangeType::MODIFIED )
{
mpGradientList->SetPath( aPath );
mpGradientList->Save();
SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
// ToolBoxControls are informed:
if ( pShell )
pShell->PutItem( aItem );
else
{
mpDrawModel->GetItemPool().Put(aItem);
}
}
if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
{
SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
// ToolBoxControls are informed:
if ( pShell )
pShell->PutItem( aItem );
else
{
mpDrawModel->GetItemPool().Put(aItem);
}
}
}
short SvxAreaTabDialog::Ok()
{
SavePalettes();
// RET_OK is returned, if at least one
// TabPage returns sal_True in FillItemSet().
// This happens by default at the moment.
return SfxTabDialogController::Ok();
}
IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button&, void)
{
SavePalettes();
m_xDialog->response(RET_CANCEL);
}
void SvxAreaTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
{
if (rId == "RID_SVXPAGE_AREA")
{
static_cast<SvxAreaTabPage&>(rPage).SetColorList( mpColorList );
static_cast<SvxAreaTabPage&>(rPage).SetGradientList( mpGradientList );
static_cast<SvxAreaTabPage&>(rPage).SetHatchingList( mpHatchingList );
static_cast<SvxAreaTabPage&>(rPage).SetBitmapList( mpBitmapList );
static_cast<SvxAreaTabPage&>(rPage).SetPatternList( mpPatternList );
static_cast<SvxAreaTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
static_cast<SvxAreaTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
static_cast<SvxAreaTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
static_cast<SvxAreaTabPage&>(rPage).SetPtrnChgd( &mnPatternListState );
static_cast<SvxAreaTabPage&>(rPage).SetColorChgd( &mnColorListState );
}
else if (rId == "RID_SVXPAGE_SHADOW")
{
static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
}
else if (rId == "RID_SVXPAGE_TRANSPARENCE")
{
static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( PageType::Area );
static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|