bump product version to 6.3.0.0.beta1
[LibreOffice.git] / cui / source / tabpages / tabarea.cxx
blob25748c947c5ac5706ce1e7a701e104c809d022e1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/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>
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>
36 SvxAreaTabDialog::SvxAreaTabDialog
38 weld::Window* pParent,
39 const SfxItemSet* pAttr,
40 SdrModel* pModel,
41 bool bShadow
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() ),
56 mnColorListState ( ChangeType::NONE ),
57 mnBitmapListState ( ChangeType::NONE ),
58 mnPatternListState ( ChangeType::NONE ),
59 mnGradientListState ( ChangeType::NONE ),
60 mnHatchingListState ( ChangeType::NONE )
62 AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr);
64 if (bShadow)
66 AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, nullptr);
68 else
70 RemoveTabPage( "RID_SVXPAGE_SHADOW" );
73 AddTabPage( "RID_SVXPAGE_TRANSPARENCE", SvxTransparenceTabPage::Create, nullptr);
75 weld::Button& rBtnCancel = GetCancelButton();
76 rBtnCancel.connect_clicked(LINK(this, SvxAreaTabDialog, CancelHdlImpl));
79 void SvxAreaTabDialog::SavePalettes()
81 SfxObjectShell* pShell = SfxObjectShell::Current();
82 if( mpNewColorList != mpDrawModel->GetColorList() )
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);
90 mpColorList = mpDrawModel->GetColorList();
92 if( mpNewGradientList != mpDrawModel->GetGradientList() )
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);
100 mpGradientList = mpDrawModel->GetGradientList();
102 if( mpNewHatchingList != mpDrawModel->GetHatchList() )
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);
110 mpHatchingList = mpDrawModel->GetHatchList();
112 if( mpNewBitmapList != mpDrawModel->GetBitmapList() )
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);
120 mpBitmapList = mpDrawModel->GetBitmapList();
122 if( mpNewPatternList != mpDrawModel->GetPatternList() )
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);
130 mpPatternList = mpDrawModel->GetPatternList();
133 // save the tables when they have been changed
135 OUString aPalettePath(SvtPathOptions().GetPalettePath());
136 OUString aPath;
137 sal_Int32 nIndex = 0;
140 aPath = aPalettePath.getToken(0, ';', nIndex);
142 while (nIndex >= 0);
144 if( mnHatchingListState & ChangeType::MODIFIED )
146 mpHatchingList->SetPath( aPath );
147 mpHatchingList->Save();
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);
157 if( mnBitmapListState & ChangeType::MODIFIED )
159 mpBitmapList->SetPath( aPath );
160 mpBitmapList->Save();
162 SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST );
163 // ToolBoxControls are informed:
164 if ( pShell )
165 pShell->PutItem( aItem );
166 else
168 mpDrawModel->GetItemPool().Put(aItem);
172 if( mnPatternListState & ChangeType::MODIFIED )
174 mpPatternList->SetPath( aPath );
175 mpPatternList->Save();
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);
185 if( mnGradientListState & ChangeType::MODIFIED )
187 mpGradientList->SetPath( aPath );
188 mpGradientList->Save();
190 SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST );
191 // ToolBoxControls are informed:
192 if ( pShell )
193 pShell->PutItem( aItem );
194 else
196 mpDrawModel->GetItemPool().Put(aItem);
200 if (mnColorListState & ChangeType::MODIFIED && mpColorList.is())
202 SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE );
203 // ToolBoxControls are informed:
204 if ( pShell )
205 pShell->PutItem( aItem );
206 else
208 mpDrawModel->GetItemPool().Put(aItem);
213 short SvxAreaTabDialog::Ok()
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.
219 return SfxTabDialogController::Ok();
222 IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button&, void)
224 SavePalettes();
225 m_xDialog->response(RET_CANCEL);
228 void SvxAreaTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
230 if (rId == "RID_SVXPAGE_AREA")
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 );
243 else if (rId == "RID_SVXPAGE_SHADOW")
245 static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
246 static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
248 else if (rId == "RID_SVXPAGE_TRANSPARENCE")
250 static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( PageType::Area );
251 static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */