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>
21 #include <unotools/pathoptions.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 )
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() ),
48 
49  mnColorListState ( ChangeType::NONE ),
50  mnBitmapListState ( ChangeType::NONE ),
51  mnPatternListState ( ChangeType::NONE ),
52  mnGradientListState ( ChangeType::NONE ),
53  mnHatchingListState ( ChangeType::NONE )
54 {
55  AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr);
56 
57  if (bShadow)
58  {
59  AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, nullptr);
60  }
61  else
62  {
63  RemoveTabPage( "RID_SVXPAGE_SHADOW" );
64  }
65 
66  AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, nullptr);
67 
68  weld::Button& rBtnCancel = GetCancelButton();
69  rBtnCancel.connect_clicked(LINK(this, SvxAreaTabDialog, CancelHdlImpl));
70 }
71 
73 {
76  {
77  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
78  SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE );
79  if ( pShell )
80  pShell->PutItem( aColorListItem );
81  else
82  mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE);
84  }
86  {
87  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) );
88  SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST );
89  if ( pShell )
90  pShell->PutItem( aItem );
91  else
92  mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST);
94  }
96  {
97  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) );
98  SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST );
99  if ( pShell )
100  pShell->PutItem( aItem );
101  else
102  mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST);
104  }
106  {
107  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) );
108  SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST );
109  if ( pShell )
110  pShell->PutItem( aItem );
111  else
112  mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST);
114  }
116  {
117  mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewPatternList.get()) );
118  SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST );
119  if( pShell )
120  pShell->PutItem( aItem );
121  else
122  mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST);
124  }
125 
126  // save the tables when they have been changed
127 
128  OUString aPalettePath(SvtPathOptions().GetPalettePath());
129  OUString aPath;
130  sal_Int32 nIndex = 0;
131  do
132  {
133  aPath = aPalettePath.getToken(0, ';', nIndex);
134  }
135  while (nIndex >= 0);
136 
137  if( mnHatchingListState & ChangeType::MODIFIED )
138  {
139  mpHatchingList->SetPath( aPath );
140  mpHatchingList->Save();
141 
142  SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST );
143  // ToolBoxControls are informed:
144  if ( pShell )
145  pShell->PutItem( aItem );
146  else
147  mpDrawModel->GetItemPool().Put(aItem);
148  }
149 
150  if( mnBitmapListState & ChangeType::MODIFIED )
151  {
152  mpBitmapList->SetPath( aPath );
153  mpBitmapList->Save();
154 
155  SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
156  // ToolBoxControls are informed:
157  if ( pShell )
158  pShell->PutItem( aItem );
159  else
160  {
161  mpDrawModel->GetItemPool().Put(aItem);
162  }
163  }
164 
165  if( mnPatternListState & ChangeType::MODIFIED )
166  {
167  mpPatternList->SetPath( aPath );
168  mpPatternList->Save();
169 
170  SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST );
171  // ToolBoxControls are informed:
172  if( pShell )
173  pShell->PutItem( aItem );
174  else
175  mpDrawModel->GetItemPool().Put(aItem);
176  }
177 
178  if( mnGradientListState & ChangeType::MODIFIED )
179  {
180  mpGradientList->SetPath( aPath );
181  mpGradientList->Save();
182 
183  SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
184  // ToolBoxControls are informed:
185  if ( pShell )
186  pShell->PutItem( aItem );
187  else
188  {
189  mpDrawModel->GetItemPool().Put(aItem);
190  }
191  }
192 
193  if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
194  {
195  SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
196  // ToolBoxControls are informed:
197  if ( pShell )
198  pShell->PutItem( aItem );
199  else
200  {
201  mpDrawModel->GetItemPool().Put(aItem);
202  }
203  }
204 }
205 
207 {
208  SavePalettes();
209  // RET_OK is returned, if at least one
210  // TabPage returns sal_True in FillItemSet().
211  // This happens by default at the moment.
213 }
214 
216 {
217  SavePalettes();
218  m_xDialog->response(RET_CANCEL);
219 }
220 
221 void SvxAreaTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
222 {
223  if (rId == "RID_SVXPAGE_AREA")
224  {
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 );
235  }
236  else if (rId == "RID_SVXPAGE_SHADOW")
237  {
238  static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
239  static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
240  }
241  else if (rId == "RID_SVXPAGE_TRANSPARENCE")
242  {
243  static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( PageType::Area );
244  static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
245  }
246 }
247 
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tpshadow.cxx:415
ChangeType mnGradientListState
Definition: cuitabarea.hxx:110
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: tabarea.cxx:221
ChangeType mnPatternListState
Definition: cuitabarea.hxx:109
XPatternListRef mpPatternList
Definition: cuitabarea.hxx:104
static SfxObjectShell * Current()
void SavePalettes()
Definition: tabarea.cxx:72
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()
ChangeType mnHatchingListState
Definition: cuitabarea.hxx:111
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tptrans.cxx:247
ChangeType mnColorListState
Definition: cuitabarea.hxx:107
IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button &, void)
Definition: tabarea.cxx:215
XColorListRef mpNewColorList
Definition: cuitabarea.hxx:97
void connect_clicked(const Link< Button &, void > &rLink)
virtual short Ok() override
Definition: tabarea.cxx:206
XGradientListRef GetGradientList() const
XHatchListRef mpHatchingList
Definition: cuitabarea.hxx:100
XBitmapListRef mpBitmapList
Definition: cuitabarea.hxx:102
XBitmapListRef mpNewBitmapList
Definition: cuitabarea.hxx:103
XHatchListRef GetHatchList() const
ChangeType mnBitmapListState
Definition: cuitabarea.hxx:108
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tparea.cxx:328
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:30
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