LibreOffice Module cui (master)  1
tabline.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 <unotools/pathoptions.hxx>
21 #include <sfx2/app.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <svx/dialogs.hrc>
24 #include <svx/svxids.hrc>
25 #include <cuitabarea.hxx>
26 #include <cuitabline.hxx>
27 #include <dlgname.hxx>
28 #include <svx/svdmodel.hxx>
29 #include <svx/xtable.hxx>
30 #include <svx/drawitem.hxx>
31 
33  SdrModel* pModel, const SdrObject* pSdrObj, bool bHasObj)
34  : SfxTabDialogController(pParent, "cui/ui/linedialog.ui", "LineDialog", pAttr)
35  , pDrawModel(pModel)
36  , pObj(pSdrObj)
37  , pColorList(pModel->GetColorList())
38  , mpNewColorList(pModel->GetColorList())
39  , pDashList(pModel->GetDashList())
40  , pNewDashList(pModel->GetDashList())
41  , pLineEndList(pModel->GetLineEndList())
42  , pNewLineEndList(pModel->GetLineEndList())
43  , bObjSelected(bHasObj)
44  , nLineEndListState(ChangeType::NONE)
45  , nDashListState(ChangeType::NONE)
46  , mnColorListState(ChangeType::NONE)
47  , nPageType(PageType::Area) // We use it here primarily to get the right attributes with FillItemSet
48  , nPosDashLb(0)
49  , nPosLineEndLb(0)
50 {
51  bool bLineOnly = false;
52  if( pObj && pObj->GetObjInventor() == SdrInventor::Default )
53  {
54  switch( pObj->GetObjIdentifier() )
55  {
56  case OBJ_LINE:
57  case OBJ_PLIN:
58  case OBJ_PATHLINE:
59  case OBJ_FREELINE:
60  case OBJ_MEASURE:
61  case OBJ_EDGE:
62  bLineOnly = true;
63  break;
64 
65  default:
66  break;
67  }
68 
69  }
70 
71  AddTabPage("RID_SVXPAGE_LINE", SvxLineTabPage::Create, nullptr);
72  if( bLineOnly )
73  AddTabPage("RID_SVXPAGE_SHADOW", SvxShadowTabPage::Create, nullptr);
74  else
75  RemoveTabPage( "RID_SVXPAGE_SHADOW" );
76 
77  AddTabPage("RID_SVXPAGE_LINE_DEF", SvxLineDefTabPage::Create, nullptr);
78  AddTabPage("RID_SVXPAGE_LINEEND_DEF", SvxLineEndDefTabPage::Create, nullptr);
79 
80  weld::Button& rBtnCancel = GetCancelButton();
81  rBtnCancel.connect_clicked(LINK(this, SvxLineTabDialog, CancelHdlImpl));
82 }
83 
85 {
88  {
89  pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
90  if ( pShell )
91  pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
93  }
95  {
96  pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
97  if ( pShell )
98  pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
100  }
102  {
103  pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
104  if ( pShell )
105  pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
107  }
108 
109  // Save the tables when they have been changed
110  OUString aPalettePath(SvtPathOptions().GetPalettePath());
111  OUString aPath;
112  sal_Int32 nIndex = 0;
113  do
114  {
115  aPath = aPalettePath.getToken(0, ';', nIndex);
116  }
117  while (nIndex >= 0);
118 
119  if( nDashListState & ChangeType::MODIFIED )
120  {
121  pDashList->SetPath( aPath );
122  pDashList->Save();
123 
124  // Notify ToolBoxControls
125  if ( pShell )
126  pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
127  }
128 
129  if( nLineEndListState & ChangeType::MODIFIED )
130  {
131  pLineEndList->SetPath( aPath );
132  pLineEndList->Save();
133 
134  // Notify ToolBoxControls
135  if ( pShell )
136  pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
137  }
138 
139  if( mnColorListState & ChangeType::MODIFIED )
140  {
141  pColorList->SetPath( aPath );
142  pColorList->Save();
143 
144  // Notify ToolBoxControls
145  if ( pShell )
146  pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
147  }
148 }
149 
151 {
152  SavePalettes();
153 
154  // We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
155  // We do this by default at the moment.
157 }
158 
160 {
161  SavePalettes();
162 
163  m_xDialog->response(RET_CANCEL);
164 }
165 
166 void SvxLineTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
167 {
168  if (rId == "RID_SVXPAGE_LINE")
169  {
170  static_cast<SvxLineTabPage&>(rPage).SetDashList( pDashList );
171  static_cast<SvxLineTabPage&>(rPage).SetLineEndList( pLineEndList );
172  static_cast<SvxLineTabPage&>(rPage).SetDlgType( 0 );
173  static_cast<SvxLineTabPage&>(rPage).SetPageType( nPageType );
174  static_cast<SvxLineTabPage&>(rPage).SetPosDashLb( &nPosDashLb );
175  static_cast<SvxLineTabPage&>(rPage).SetPosLineEndLb( &nPosLineEndLb );
176  static_cast<SvxLineTabPage&>(rPage).SetDashChgd( &nDashListState );
177  static_cast<SvxLineTabPage&>(rPage).SetLineEndChgd( &nLineEndListState );
178  static_cast<SvxLineTabPage&>(rPage).SetObjSelected( bObjSelected );
179  static_cast<SvxLineTabPage&>(rPage).Construct();
180  static_cast<SvxLineTabPage&>(rPage).SetColorChgd( &mnColorListState );
181  }
182  else if (rId == "RID_SVXPAGE_LINE_DEF")
183  {
184  static_cast<SvxLineDefTabPage&>(rPage).SetDashList( pDashList );
185  static_cast<SvxLineDefTabPage&>(rPage).SetDlgType( 0 );
186  static_cast<SvxLineDefTabPage&>(rPage).SetPageType( &nPageType );
187  static_cast<SvxLineDefTabPage&>(rPage).SetPosDashLb( &nPosDashLb );
188  static_cast<SvxLineDefTabPage&>(rPage).SetDashChgd( &nDashListState );
189  static_cast<SvxLineDefTabPage&>(rPage).Construct();
190  }
191  else if (rId == "RID_SVXPAGE_LINEEND_DEF")
192  {
193  static_cast<SvxLineEndDefTabPage&>(rPage).SetLineEndList( pLineEndList );
194  static_cast<SvxLineEndDefTabPage&>(rPage).SetPolyObj( pObj );
195  static_cast<SvxLineEndDefTabPage&>(rPage).SetDlgType( 0 );
196  static_cast<SvxLineEndDefTabPage&>(rPage).SetPageType( &nPageType );
197  static_cast<SvxLineEndDefTabPage&>(rPage).SetPosLineEndLb( &nPosLineEndLb );
198  static_cast<SvxLineEndDefTabPage&>(rPage).SetLineEndChgd( &nLineEndListState );
199  static_cast<SvxLineEndDefTabPage&>(rPage).Construct();
200  }
201  else if (rId == "RID_SVXPAGE_SHADOW")
202  {
203  static_cast<SvxShadowTabPage&>(rPage).SetColorList( pColorList );
204  static_cast<SvxShadowTabPage&>(rPage).SetPageType( nPageType );
205  static_cast<SvxShadowTabPage&>(rPage).SetDlgType( 0 );
206  static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
207  }
208 }
209 
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual short Ok() override
Definition: tabline.cxx:150
void SavePalettes()
Definition: tabline.cxx:84
sal_Int32 nPosDashLb
Definition: cuitabline.hxx:54
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tplnedef.cxx:311
const SdrObject * pObj
Definition: cuitabline.hxx:39
XLineEndListRef pLineEndList
Definition: cuitabline.hxx:45
weld::Button & GetCancelButton() const
sal_Int32 nPosLineEndLb
Definition: cuitabline.hxx:55
void RemoveTabPage(const OString &rName)
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tpshadow.cxx:427
XDashListRef GetDashList() const
PageType
OBJ_EDGE
static SfxObjectShell * Current()
void PutItem(const SfxPoolItem &rItem)
RET_CANCEL
SvxLineTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, const SdrObject *pObj, bool bHasObj)
Definition: tabline.cxx:32
OBJ_PLIN
OBJ_MEASURE
virtual short Ok()
XDashListRef pNewDashList
Definition: cuitabline.hxx:44
OBJ_PATHLINE
XLineEndListRef GetLineEndList() const
PageType nPageType
Definition: cuitabline.hxx:53
ChangeType
NONE
XDashListRef pDashList
Definition: cuitabline.hxx:43
void connect_clicked(const Link< Button &, void > &rLink)
OBJ_LINE
ChangeType nDashListState
Definition: cuitabline.hxx:50
XLineEndListRef pNewLineEndList
Definition: cuitabline.hxx:46
virtual sal_uInt16 GetObjIdentifier() const
IMPL_LINK_NOARG(SvxLineTabDialog, CancelHdlImpl, weld::Button &, void)
Definition: tabline.cxx:159
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tpline.cxx:1196
SdrModel * pDrawModel
Definition: cuitabline.hxx:38
virtual SdrInventor GetObjInventor() const
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: tabline.cxx:166
OBJ_FREELINE
ChangeType mnColorListState
Definition: cuitabline.hxx:51
XColorListRef mpNewColorList
Definition: cuitabline.hxx:42
ChangeType nLineEndListState
Definition: cuitabline.hxx:49
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
static VclPtr< SfxTabPage > Create(TabPageParent, const SfxItemSet *)
Definition: tplneend.cxx:256
XColorListRef GetColorList() const
void SetPropertyList(XPropertyListRef const &p)
XColorListRef pColorList
Definition: cuitabline.hxx:41