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/app.hxx>
21 #include <sfx2/objsh.hxx>
22 #include <unotools/pathoptions.hxx>
23 #include <svx/svdmark.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdview.hxx>
26 #include <svx/dialogs.hrc>
27 #include <svx/svxids.hrc>
28 
29 #include <svx/xtable.hxx>
30 #include <svx/globl3d.hxx>
31 #include <svx/svdmodel.hxx>
32 #include <svx/drawitem.hxx>
33 #include <cuitabarea.hxx>
34 #include <dlgname.hxx>
35 
37 (
38  weld::Window* pParent,
39  const SfxItemSet* pAttr,
40  SdrModel* pModel,
41  bool bShadow
42 )
43  : SfxTabDialogController(pParent, "cui/ui/areadialog.ui", "AreaDialog", pAttr)
44  , mpDrawModel ( pModel ),
45  mpColorList ( pModel->GetColorList() ),
46  mpNewColorList ( pModel->GetColorList() ),
47  mpGradientList ( pModel->GetGradientList() ),
48  mpNewGradientList ( pModel->GetGradientList() ),
49  mpHatchingList ( pModel->GetHatchList() ),
50  mpNewHatchingList ( pModel->GetHatchList() ),
51  mpBitmapList ( pModel->GetBitmapList() ),
52  mpNewBitmapList ( pModel->GetBitmapList() ),
53  mpPatternList ( pModel->GetPatternList() ),
54  mpNewPatternList ( pModel->GetPatternList() ),
55 
56  mnColorListState ( ChangeType::NONE ),
57  mnBitmapListState ( ChangeType::NONE ),
58  mnPatternListState ( ChangeType::NONE ),
59  mnGradientListState ( ChangeType::NONE ),
60  mnHatchingListState ( ChangeType::NONE )
61 {
62  AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr);
63 
64  if (bShadow)
65  {
66  AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, nullptr);
67  }
68  else
69  {
70  RemoveTabPage( "RID_SVXPAGE_SHADOW" );
71  }
72 
73  AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, nullptr);
74 
75  weld::Button& rBtnCancel = GetCancelButton();
76  rBtnCancel.connect_clicked(LINK(this, SvxAreaTabDialog, CancelHdlImpl));
77 }
78 
80 {
83  {
84  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
85  SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
86  if ( pShell )
87  pShell->PutItem( aColorListItem );
88  else
89  mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
91  }
93  {
94  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) );
95  SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
96  if ( pShell )
97  pShell->PutItem( aItem );
98  else
99  mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
101  }
103  {
104  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) );
105  SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
106  if ( pShell )
107  pShell->PutItem( aItem );
108  else
109  mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
111  }
113  {
114  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) );
115  SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
116  if ( pShell )
117  pShell->PutItem( aItem );
118  else
119  mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
121  }
123  {
124  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewPatternList.get()) );
125  SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST );
126  if( pShell )
127  pShell->PutItem( aItem );
128  else
129  mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST);
131  }
132 
133  // save the tables when they have been changed
134 
135  OUString aPalettePath(SvtPathOptions().GetPalettePath());
136  OUString aPath;
137  sal_Int32 nIndex = 0;
138  do
139  {
140  aPath = aPalettePath.getToken(0, ';', nIndex);
141  }
142  while (nIndex >= 0);
143 
144  if( mnHatchingListState & ChangeType::MODIFIED )
145  {
146  mpHatchingList->SetPath( aPath );
147  mpHatchingList->Save();
148 
149  SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
150  // ToolBoxControls are informed:
151  if ( pShell )
152  pShell->PutItem( aItem );
153  else
154  mpDrawModel->GetItemPool().Put(aItem);
155  }
156 
157  if( mnBitmapListState & ChangeType::MODIFIED )
158  {
159  mpBitmapList->SetPath( aPath );
160  mpBitmapList->Save();
161 
162  SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
163  // ToolBoxControls are informed:
164  if ( pShell )
165  pShell->PutItem( aItem );
166  else
167  {
168  mpDrawModel->GetItemPool().Put(aItem);
169  }
170  }
171 
172  if( mnPatternListState & ChangeType::MODIFIED )
173  {
174  mpPatternList->SetPath( aPath );
175  mpPatternList->Save();
176 
177  SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST );
178  // ToolBoxControls are informed:
179  if( pShell )
180  pShell->PutItem( aItem );
181  else
182  mpDrawModel->GetItemPool().Put(aItem);
183  }
184 
185  if( mnGradientListState & ChangeType::MODIFIED )
186  {
187  mpGradientList->SetPath( aPath );
188  mpGradientList->Save();
189 
190  SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
191  // ToolBoxControls are informed:
192  if ( pShell )
193  pShell->PutItem( aItem );
194  else
195  {
196  mpDrawModel->GetItemPool().Put(aItem);
197  }
198  }
199 
200  if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
201  {
202  SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
203  // ToolBoxControls are informed:
204  if ( pShell )
205  pShell->PutItem( aItem );
206  else
207  {
208  mpDrawModel->GetItemPool().Put(aItem);
209  }
210  }
211 }
212 
214 {
215  SavePalettes();
216  // RET_OK is returned, if at least one
217  // TabPage returns sal_True in FillItemSet().
218  // This happens by default at the moment.
220 }
221 
223 {
224  SavePalettes();
225  m_xDialog->response(RET_CANCEL);
226 }
227 
228 void SvxAreaTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
229 {
230  if (rId == "RID_SVXPAGE_AREA")
231  {
232  static_cast<SvxAreaTabPage&>(rPage).SetColorList( mpColorList );
233  static_cast<SvxAreaTabPage&>(rPage).SetGradientList( mpGradientList );
234  static_cast<SvxAreaTabPage&>(rPage).SetHatchingList( mpHatchingList );
235  static_cast<SvxAreaTabPage&>(rPage).SetBitmapList( mpBitmapList );
236  static_cast<SvxAreaTabPage&>(rPage).SetPatternList( mpPatternList );
237  static_cast<SvxAreaTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
238  static_cast<SvxAreaTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
239  static_cast<SvxAreaTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
240  static_cast<SvxAreaTabPage&>(rPage).SetPtrnChgd( &mnPatternListState );
241  static_cast<SvxAreaTabPage&>(rPage).SetColorChgd( &mnColorListState );
242  }
243  else if (rId == "RID_SVXPAGE_SHADOW")
244  {
245  static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
246  static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
247  }
248  else if (rId == "RID_SVXPAGE_TRANSPARENCE")
249  {
250  static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( PageType::Area );
251  static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
252  }
253 }
254 
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ChangeType mnGradientListState
Definition: cuitabarea.hxx:110
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: tabarea.cxx:228
ChangeType mnPatternListState
Definition: cuitabarea.hxx:109
XPatternListRef mpPatternList
Definition: cuitabarea.hxx:104
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tpshadow.cxx:427
static SfxObjectShell * Current()
void SavePalettes()
Definition: tabarea.cxx:79
XGradientListRef mpNewGradientList
Definition: cuitabarea.hxx:99
XPatternListRef mpNewPatternList
Definition: cuitabarea.hxx:105
XColorListRef mpColorList
Definition: cuitabarea.hxx:96
void PutItem(const SfxPoolItem &rItem)
RET_CANCEL
XPatternListRef GetPatternList() const
virtual short Ok()
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tparea.cxx:354
ChangeType mnHatchingListState
Definition: cuitabarea.hxx:111
ChangeType mnColorListState
Definition: cuitabarea.hxx:107
IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button &, void)
Definition: tabarea.cxx:222
XColorListRef mpNewColorList
Definition: cuitabarea.hxx:97
void connect_clicked(const Link< Button &, void > &rLink)
virtual short Ok() override
Definition: tabarea.cxx:213
XGradientListRef GetGradientList() const
XHatchListRef mpHatchingList
Definition: cuitabarea.hxx:100
XBitmapListRef mpBitmapList
Definition: cuitabarea.hxx:102
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tptrans.cxx:262
XBitmapListRef mpNewBitmapList
Definition: cuitabarea.hxx:103
XHatchListRef GetHatchList() const
ChangeType mnBitmapListState
Definition: cuitabarea.hxx:108
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
SvxAreaTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, bool bShadow)
Definition: tabarea.cxx:37
XBitmapListRef GetBitmapList() const
XGradientListRef mpGradientList
Definition: cuitabarea.hxx:98
const SfxItemPool & GetItemPool() const
XColorListRef GetColorList() const
XHatchListRef mpNewHatchingList
Definition: cuitabarea.hxx:101
void SetPropertyList(XPropertyListRef const &p)
SdrModel * mpDrawModel
Definition: cuitabarea.hxx:94