LibreOffice Module sfx2 (master) 1
styledlg.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 <svl/whiter.hxx>
21#include <svl/style.hxx>
22
23#include <sfx2/styledlg.hxx>
24#include <sfx2/sfxresid.hxx>
25#include <sfx2/strings.hrc>
26
27#include "mgetempl.hxx"
28
29/* [Description]
30
31 Constructor: Add Manage TabPage, set ExampleSet from style.
32*/
34(
35 weld::Window* pParent, // Parent
36 const OUString& rUIXMLDescription, const OUString& rID,
37 SfxStyleSheetBase& rStyle // stylesheet to be processed
38)
39 : SfxTabDialogController(pParent, rUIXMLDescription, rID, &rStyle.GetItemSet(), true)
40 , m_rStyle(rStyle)
41{
42 // without ParentSupport suppress the standardButton
43 if (!rStyle.HasParentSupport())
45
46 AddTabPage("organizer", SfxManageStyleSheetPage::Create, nullptr);
47
48 // With new template always set the management page as the current page
49 if (rStyle.GetName().isEmpty())
50 SetCurPageId("organizer");
51 else
52 {
53 OUString sTxt = m_xDialog->get_title() + ": " + rStyle.GetName();
54 m_xDialog->set_title(sTxt);
55 }
56 m_xExampleSet.reset(&m_rStyle.GetItemSet()); // in SfxTabDialog::Ctor() already created, reset will delete it
57
59}
60
61/* [Description]
62
63 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
64 the Set from Style.
65*/
67{
68 // coverity[leaked_storage] - deliberate, ownership is really with m_rStyle
69 m_xExampleSet.release();
70}
71
72/* [Description]
73
74 Override so that always RET_OK is returned.
75*/
77{
79 return RET_OK;
80}
81
82/* [Description]
83
84 If the dialogue was canceled, then all selected attributes must be reset
85 again.
86*/
88{
89 SfxTabPage* pPage = GetTabPage(u"organizer");
90
91 const SfxItemSet* pInSet = GetInputSetImpl();
92 SfxWhichIter aIter(*pInSet);
93 sal_uInt16 nWhich = aIter.FirstWhich();
94
95 while (nWhich)
96 {
97 SfxItemState eState = aIter.GetItemState(false);
98
99 if (SfxItemState::DEFAULT == eState)
100 m_xExampleSet->ClearItem(nWhich);
101 else
102 m_xExampleSet->Put(pInSet->Get(nWhich));
103 nWhich = aIter.NextWhich();
104 }
105
106 if (pPage)
107 pPage->Reset(GetInputSetImpl());
108
109 m_xDialog->response(RET_CANCEL);
110}
111
113{
114 OUString aNo(SfxResId(STR_NONAME));
115 sal_uInt16 i = 1;
116 OUString aNoName = aNo + OUString::number(i);
117 while (rPool.Find(aNoName, eFam))
118 {
119 ++i;
120 aNoName = aNo + OUString::number(i);
121 }
122 return aNoName;
123}
124
125/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: mgetempl.cxx:531
virtual short Ok() override
Definition: styledlg.cxx:76
SfxStyleSheetBase & m_rStyle
Definition: styledlg.hxx:33
SfxStyleDialogController(weld::Window *pParent, const OUString &rUIXMLDescription, const OUString &rID, SfxStyleSheetBase &)
Definition: styledlg.cxx:34
static OUString GenerateUnusedName(SfxStyleSheetBasePool &rPool, SfxStyleFamily eFam)
Definition: styledlg.cxx:112
virtual ~SfxStyleDialogController() override
Definition: styledlg.cxx:66
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
const OUString & GetName() const
virtual bool HasParentSupport() const
virtual SfxItemSet & GetItemSet()
virtual short Ok()
void SetCurPageId(const OUString &rName)
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
weld::Button & GetCancelButton() const
Definition: tabdlg.hxx:146
std::unique_ptr< SfxItemSet > m_xExampleSet
Definition: tabdlg.hxx:100
virtual void Reset(const SfxItemSet *)
Definition: tabdlg.cxx:169
sal_uInt16 FirstWhich()
SfxItemState GetItemState(bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 NextWhich()
void connect_clicked(const Link< Button &, void > &rLink)
std::shared_ptr< weld::Dialog > m_xDialog
float u
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
int i
SfxItemState
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
SfxStyleFamily
IMPL_LINK_NOARG(SfxStyleDialogController, CancelHdl, weld::Button &, void)
Definition: styledlg.cxx:87
RET_OK
RET_CANCEL