bump product version to 6.3.0.0.beta1
[LibreOffice.git] / cui / source / tabpages / tabline.cxx
blobac02b2ef4e357e8cef551df6b30004faee498422
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 <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>
32 SvxLineTabDialog::SvxLineTabDialog(weld::Window* pParent, const SfxItemSet* pAttr,
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)
51 bool bLineOnly = false;
52 if( pObj && pObj->GetObjInventor() == SdrInventor::Default )
54 switch( pObj->GetObjIdentifier() )
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;
65 default:
66 break;
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" );
77 AddTabPage("RID_SVXPAGE_LINE_DEF", SvxLineDefTabPage::Create, nullptr);
78 AddTabPage("RID_SVXPAGE_LINEEND_DEF", SvxLineEndDefTabPage::Create, nullptr);
80 weld::Button& rBtnCancel = GetCancelButton();
81 rBtnCancel.connect_clicked(LINK(this, SvxLineTabDialog, CancelHdlImpl));
84 void SvxLineTabDialog::SavePalettes()
86 SfxObjectShell* pShell = SfxObjectShell::Current();
87 if( mpNewColorList != pDrawModel->GetColorList() )
89 pDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) );
90 if ( pShell )
91 pShell->PutItem( SvxColorListItem( mpNewColorList, SID_COLOR_TABLE ) );
92 pColorList = pDrawModel->GetColorList();
94 if( pNewDashList != pDrawModel->GetDashList() )
96 pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewDashList.get()) );
97 if ( pShell )
98 pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
99 pDashList = pDrawModel->GetDashList();
101 if( pNewLineEndList != pDrawModel->GetLineEndList() )
103 pDrawModel->SetPropertyList( static_cast<XPropertyList *>(pNewLineEndList.get()) );
104 if ( pShell )
105 pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
106 pLineEndList = pDrawModel->GetLineEndList();
109 // Save the tables when they have been changed
110 OUString aPalettePath(SvtPathOptions().GetPalettePath());
111 OUString aPath;
112 sal_Int32 nIndex = 0;
115 aPath = aPalettePath.getToken(0, ';', nIndex);
117 while (nIndex >= 0);
119 if( nDashListState & ChangeType::MODIFIED )
121 pDashList->SetPath( aPath );
122 pDashList->Save();
124 // Notify ToolBoxControls
125 if ( pShell )
126 pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
129 if( nLineEndListState & ChangeType::MODIFIED )
131 pLineEndList->SetPath( aPath );
132 pLineEndList->Save();
134 // Notify ToolBoxControls
135 if ( pShell )
136 pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
139 if( mnColorListState & ChangeType::MODIFIED )
141 pColorList->SetPath( aPath );
142 pColorList->Save();
144 // Notify ToolBoxControls
145 if ( pShell )
146 pShell->PutItem( SvxColorListItem( pColorList, SID_COLOR_TABLE ) );
150 short SvxLineTabDialog::Ok()
152 SavePalettes();
154 // We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
155 // We do this by default at the moment.
156 return SfxTabDialogController::Ok();
159 IMPL_LINK_NOARG(SvxLineTabDialog, CancelHdlImpl, weld::Button&, void)
161 SavePalettes();
163 m_xDialog->response(RET_CANCEL);
166 void SvxLineTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
168 if (rId == "RID_SVXPAGE_LINE")
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 );
182 else if (rId == "RID_SVXPAGE_LINE_DEF")
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();
191 else if (rId == "RID_SVXPAGE_LINEEND_DEF")
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();
201 else if (rId == "RID_SVXPAGE_SHADOW")
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 );
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */