1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <svl/whiter.hxx>
21 #include <svl/style.hxx>
23 #include <sfx2/styledlg.hxx>
24 #include <sfx2/sfxresid.hxx>
25 #include <sfx2/strings.hrc>
27 #include "mgetempl.hxx"
31 Constructor: Add Manage TabPage, set ExampleSet from style.
33 SfxStyleDialogController::SfxStyleDialogController
35 weld::Window
* pParent
, // Parent
36 const OUString
& rUIXMLDescription
, const OString
& rID
,
37 SfxStyleSheetBase
& rStyle
// stylesheet to be processed
39 : SfxTabDialogController(pParent
, rUIXMLDescription
, rID
, &rStyle
.GetItemSet(), true)
42 // without ParentSupport suppress the standardButton
43 if (!rStyle
.HasParentSupport())
44 RemoveStandardButton();
46 AddTabPage("organizer", SfxManageStyleSheetPage::Create
, nullptr);
48 // With new template always set the management page as the current page
49 if (rStyle
.GetName().isEmpty())
50 SetCurPageId("organizer");
53 OUString sTxt
= m_xDialog
->get_title() + ": " + rStyle
.GetName();
54 m_xDialog
->set_title(sTxt
);
56 m_xExampleSet
.reset(&m_rStyle
.GetItemSet()); // in SfxTabDialog::Ctor() already created, reset will delete it
58 GetCancelButton().connect_clicked(LINK(this, SfxStyleDialogController
, CancelHdl
));
63 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
66 SfxStyleDialogController::~SfxStyleDialogController()
68 m_xExampleSet
.release();
73 Override so that always RET_OK is returned.
75 short SfxStyleDialogController::Ok()
77 SfxTabDialogController::Ok();
83 If the dialogue was canceled, then all selected attributes must be reset
86 IMPL_LINK_NOARG(SfxStyleDialogController
, CancelHdl
, weld::Button
&, void)
88 SfxTabPage
* pPage
= GetTabPage("organizer");
90 const SfxItemSet
* pInSet
= GetInputSetImpl();
91 SfxWhichIter
aIter(*pInSet
);
92 sal_uInt16 nWhich
= aIter
.FirstWhich();
96 SfxItemState eState
= pInSet
->GetItemState(nWhich
, false);
98 if (SfxItemState::DEFAULT
== eState
)
99 m_xExampleSet
->ClearItem(nWhich
);
101 m_xExampleSet
->Put(pInSet
->Get(nWhich
));
102 nWhich
= aIter
.NextWhich();
106 pPage
->Reset(GetInputSetImpl());
108 m_xDialog
->response(RET_CANCEL
);
111 OUString
SfxStyleDialogController::GenerateUnusedName(SfxStyleSheetBasePool
&rPool
, SfxStyleFamily eFam
)
113 OUString
aNo(SfxResId(STR_NONAME
));
115 OUString aNoName
= aNo
+ OUString::number(i
);
116 while (rPool
.Find(aNoName
, eFam
))
119 aNoName
= aNo
+ OUString::number(i
);
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */