LibreOffice Module cui (master) 1
tabarea.cxx
Go to the documentation of this file.
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/objsh.hxx>
22#include <svx/svxids.hrc>
23
24#include <svx/xtable.hxx>
25#include <svx/svdmodel.hxx>
26#include <svx/drawitem.hxx>
27#include <cuitabarea.hxx>
28
30(
31 weld::Window* pParent,
32 const SfxItemSet* pAttr,
33 SdrModel* pModel,
34 bool bShadow,
35 bool bSlideBackground
36)
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() ),
49
50 mnColorListState ( ChangeType::NONE ),
51 mnBitmapListState ( ChangeType::NONE ),
52 mnPatternListState ( ChangeType::NONE ),
53 mnGradientListState ( ChangeType::NONE ),
54 mnHatchingListState ( ChangeType::NONE )
55{
56 if (bSlideBackground)
57 AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::CreateWithSlideBackground, nullptr);
58 else
59 AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr);
60
61 if (bShadow)
62 {
63 AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, nullptr);
64 }
65 else
66 {
67 RemoveTabPage( "RID_SVXPAGE_SHADOW" );
68 }
69
70 AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, nullptr);
71
72 weld::Button& rBtnCancel = GetCancelButton();
73 rBtnCancel.connect_clicked(LINK(this, SvxAreaTabDialog, CancelHdlImpl));
74}
75
77{
80 {
82 SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
83 if ( pShell )
84 pShell->PutItem( aColorListItem );
85 else
86 mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
88 }
90 {
92 SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
93 if ( pShell )
94 pShell->PutItem( aItem );
95 else
96 mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
98 }
100 {
102 SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
103 if ( pShell )
104 pShell->PutItem( aItem );
105 else
106 mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
108 }
110 {
112 SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
113 if ( pShell )
114 pShell->PutItem( aItem );
115 else
116 mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
118 }
120 {
122 SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST );
123 if( pShell )
124 pShell->PutItem( aItem );
125 else
126 mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST);
128 }
129
130 // save the tables when they have been changed
131
132 OUString aPalettePath(SvtPathOptions().GetPalettePath());
133 OUString aPath;
134 sal_Int32 nIndex = 0;
135 do
136 {
137 aPath = aPalettePath.getToken(0, ';', nIndex);
138 }
139 while (nIndex >= 0);
140
141 if( mnHatchingListState & ChangeType::MODIFIED )
142 {
143 mpHatchingList->SetPath( aPath );
144 mpHatchingList->Save();
145
146 SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
147 // ToolBoxControls are informed:
148 if ( pShell )
149 pShell->PutItem( aItem );
150 else
151 mpDrawModel->GetItemPool().Put(aItem);
152 }
153
154 if( mnBitmapListState & ChangeType::MODIFIED )
155 {
156 mpBitmapList->SetPath( aPath );
157 mpBitmapList->Save();
158
159 SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
160 // ToolBoxControls are informed:
161 if ( pShell )
162 pShell->PutItem( aItem );
163 else
164 {
165 mpDrawModel->GetItemPool().Put(aItem);
166 }
167 }
168
169 if( mnPatternListState & ChangeType::MODIFIED )
170 {
171 mpPatternList->SetPath( aPath );
172 mpPatternList->Save();
173
174 SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST );
175 // ToolBoxControls are informed:
176 if( pShell )
177 pShell->PutItem( aItem );
178 else
179 mpDrawModel->GetItemPool().Put(aItem);
180 }
181
182 if( mnGradientListState & ChangeType::MODIFIED )
183 {
184 mpGradientList->SetPath( aPath );
185 mpGradientList->Save();
186
187 SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
188 // ToolBoxControls are informed:
189 if ( pShell )
190 pShell->PutItem( aItem );
191 else
192 {
193 mpDrawModel->GetItemPool().Put(aItem);
194 }
195 }
196
197 if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
198 {
199 SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
200 // ToolBoxControls are informed:
201 if ( pShell )
202 pShell->PutItem( aItem );
203 else
204 {
205 mpDrawModel->GetItemPool().Put(aItem);
206 }
207 }
208}
209
211{
212 SavePalettes();
213 // RET_OK is returned, if at least one
214 // TabPage returns sal_True in FillItemSet().
215 // This happens by default at the moment.
217}
218
220{
221 SavePalettes();
222 m_xDialog->response(RET_CANCEL);
223}
224
225void SvxAreaTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage)
226{
227 if (rId == "RID_SVXPAGE_AREA")
228 {
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 );
239 }
240 else if (rId == "RID_SVXPAGE_SHADOW")
241 {
242 static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
243 static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
244 }
245 else if (rId == "RID_SVXPAGE_TRANSPARENCE")
246 {
247 static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( PageType::Area );
248 static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
249 }
250}
251
252/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
XBitmapListRef GetBitmapList() const
XGradientListRef GetGradientList() const
XPatternListRef GetPatternList() const
const SfxItemPool & GetItemPool() const
XColorListRef GetColorList() const
XHatchListRef GetHatchList() const
void SetPropertyList(XPropertyListRef const &p)
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
void PutItem(const SfxPoolItem &rItem)
virtual short Ok()
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
weld::Button & GetCancelButton() const
void RemoveTabPage(const OUString &rName)
ChangeType mnBitmapListState
Definition: cuitabarea.hxx:106
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: tabarea.cxx:225
ChangeType mnColorListState
Definition: cuitabarea.hxx:105
XHatchListRef mpNewHatchingList
Definition: cuitabarea.hxx:99
XColorListRef mpNewColorList
Definition: cuitabarea.hxx:95
XPatternListRef mpPatternList
Definition: cuitabarea.hxx:102
XGradientListRef mpGradientList
Definition: cuitabarea.hxx:96
ChangeType mnHatchingListState
Definition: cuitabarea.hxx:109
XGradientListRef mpNewGradientList
Definition: cuitabarea.hxx:97
XPatternListRef mpNewPatternList
Definition: cuitabarea.hxx:103
SvxAreaTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, bool bShadow, bool bSlideBackground)
Definition: tabarea.cxx:30
XColorListRef mpColorList
Definition: cuitabarea.hxx:94
SdrModel * mpDrawModel
Definition: cuitabarea.hxx:92
XBitmapListRef mpNewBitmapList
Definition: cuitabarea.hxx:101
XBitmapListRef mpBitmapList
Definition: cuitabarea.hxx:100
ChangeType mnPatternListState
Definition: cuitabarea.hxx:107
XHatchListRef mpHatchingList
Definition: cuitabarea.hxx:98
void SavePalettes()
Definition: tabarea.cxx:76
ChangeType mnGradientListState
Definition: cuitabarea.hxx:108
virtual short Ok() override
Definition: tabarea.cxx:210
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tparea.cxx:368
static std::unique_ptr< SfxTabPage > CreateWithSlideBackground(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tparea.cxx:375
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tpshadow.cxx:435
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tptrans.cxx:239
void connect_clicked(const Link< Button &, void > &rLink)
sal_Int32 nIndex
NONE
IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button &, void)
Definition: tabarea.cxx:219
ChangeType
RET_CANCEL