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