/src/libreoffice/sfx2/source/dialog/SfxTabPage.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 | | |
21 | | #include <comphelper/lok.hxx> |
22 | | #include <sfx2/SfxTabPage.hxx> |
23 | | #include <sfx2/viewsh.hxx> |
24 | | #include <vcl/weld/Builder.hxx> |
25 | | #include <vcl/weld/Dialog.hxx> |
26 | | |
27 | | void SfxTabPage::SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame) |
28 | 0 | { |
29 | 0 | mxFrame = xFrame; |
30 | 0 | } |
31 | | |
32 | | css::uno::Reference< css::frame::XFrame > SfxTabPage::GetFrame() const |
33 | 0 | { |
34 | 0 | return mxFrame; |
35 | 0 | } |
36 | | |
37 | | SfxTabPage::SfxTabPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet *rAttrSet) |
38 | 0 | : BuilderPage(pPage, pController, rUIXMLDescription, rID) |
39 | 0 | , mpSet(rAttrSet) |
40 | 0 | , mbHasExchangeSupport(false) |
41 | 0 | , mbCancel(false) |
42 | 0 | , mbStandard(false) |
43 | 0 | , mpSfxDialogController(dynamic_cast<SfxOkDialogController*>(m_pDialogController)) |
44 | 0 | { |
45 | 0 | } |
46 | | |
47 | | SfxTabPage::~SfxTabPage() |
48 | 0 | { |
49 | 0 | if (m_xContainer) |
50 | 0 | { |
51 | 0 | std::unique_ptr<weld::Container> xParent(m_xContainer->weld_parent()); |
52 | 0 | if (xParent) |
53 | 0 | xParent->move(m_xContainer.get(), nullptr); |
54 | 0 | } |
55 | 0 | m_xContainer.reset(); |
56 | 0 | m_xBuilder.reset(); |
57 | 0 | } |
58 | | |
59 | | bool SfxTabPage::FillItemSet( SfxItemSet* ) |
60 | 0 | { |
61 | 0 | return false; |
62 | 0 | } |
63 | | |
64 | | /* |
65 | | Returns the visible strings of a dialog. |
66 | | |
67 | | Supported items: |
68 | | - label |
69 | | - check button |
70 | | - radio button |
71 | | - toggle button |
72 | | - link button |
73 | | - button |
74 | | */ |
75 | 0 | OUString SfxTabPage::GetAllStrings() { return OUString(); } |
76 | | |
77 | | void SfxTabPage::Reset( const SfxItemSet* ) |
78 | 0 | { |
79 | 0 | } |
80 | | |
81 | 0 | bool SfxTabPage::DeferResetToFirstActivation() { return false; } |
82 | | |
83 | | void SfxTabPage::ActivatePage( const SfxItemSet& ) |
84 | | /* [Description] |
85 | | |
86 | | Default implementation of the virtual ActivatePage method. This method is |
87 | | called when a page of dialogue supports the exchange of data between pages. |
88 | | <SfxTabPage::DeactivatePage(SfxItemSet *)> |
89 | | */ |
90 | 0 | { |
91 | 0 | } |
92 | | |
93 | | DeactivateRC SfxTabPage::DeactivatePage( SfxItemSet* ) |
94 | | |
95 | | /* [Description] |
96 | | |
97 | | Default implementation of the virtual DeactivatePage method. This method is |
98 | | called by Sfx when leaving a page; the application can, through the return |
99 | | value, control whether to leave the page. If the page is displayed through |
100 | | bHasExchangeSupport which supports data exchange between pages, then a |
101 | | pointer to the exchange set is passed as parameter. This takes on data for |
102 | | the exchange, then the set is available as a parameter in |
103 | | <SfxTabPage::ActivatePage(const SfxItemSet &)>. |
104 | | |
105 | | [Return value] |
106 | | |
107 | | DeactivateRC::LeavePage; Allow leaving the page |
108 | | */ |
109 | 0 | { |
110 | 0 | return DeactivateRC::LeavePage; |
111 | 0 | } |
112 | | |
113 | | void SfxTabPage::FillUserData() |
114 | | |
115 | | /* [Description] |
116 | | |
117 | | Virtual method is called by the base class in the destructor to save |
118 | | specific information of the TabPage in the ini-file. When overriding a |
119 | | string must be compiled, which is then flushed with the <SetUserData()>. |
120 | | */ |
121 | 0 | { |
122 | 0 | } |
123 | | |
124 | | bool SfxTabPage::IsReadOnly() const |
125 | 0 | { |
126 | 0 | return false; |
127 | 0 | } |
128 | | |
129 | | const SfxPoolItem* SfxTabPage::GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep ) |
130 | | |
131 | | /* [Description] |
132 | | |
133 | | static Method: hereby are the implementations of the TabPage code |
134 | | being simplified. |
135 | | */ |
136 | 0 | { |
137 | 0 | const SfxItemPool* pPool = rSet.GetPool(); |
138 | 0 | sal_uInt16 nWh = pPool->GetWhichIDFromSlotID( nSlot, bDeep ); |
139 | 0 | const SfxPoolItem* pItem = nullptr; |
140 | 0 | rSet.GetItemState( nWh, true, &pItem ); |
141 | |
|
142 | 0 | if ( !pItem && nWh != nSlot ) |
143 | 0 | pItem = &pPool->GetUserOrPoolDefaultItem( nWh ); |
144 | 0 | return pItem; |
145 | 0 | } |
146 | | |
147 | | const SfxPoolItem* SfxTabPage::GetOldItem( const SfxItemSet& rSet, |
148 | | sal_uInt16 nSlot, bool bDeep ) |
149 | | |
150 | | /* [Description] |
151 | | |
152 | | This method returns an attribute for comparison of the old value. |
153 | | */ |
154 | 0 | { |
155 | 0 | const SfxItemSet& rOldSet = GetItemSet(); |
156 | 0 | sal_uInt16 nWh = GetWhich( nSlot, bDeep ); |
157 | 0 | const SfxPoolItem* pItem = nullptr; |
158 | |
|
159 | 0 | if (mbStandard && rOldSet.GetParent()) |
160 | 0 | pItem = GetItem( *rOldSet.GetParent(), nSlot ); |
161 | 0 | else if ( rSet.GetParent() && |
162 | 0 | SfxItemState::INVALID == rSet.GetItemState( nWh ) ) |
163 | 0 | pItem = GetItem( *rSet.GetParent(), nSlot ); |
164 | 0 | else |
165 | 0 | pItem = GetItem( rOldSet, nSlot ); |
166 | 0 | return pItem; |
167 | 0 | } |
168 | | |
169 | | void SfxTabPage::PageCreated( const SfxAllItemSet& /*aSet*/ ) |
170 | 0 | { |
171 | 0 | SAL_WARN( "sfx.dialog", "SfxTabPage::PageCreated should not be called"); |
172 | 0 | } |
173 | | |
174 | | void SfxTabPage::ChangesApplied() |
175 | 0 | { |
176 | 0 | } |
177 | | |
178 | | SfxOkDialogController* SfxTabPage::GetDialogController() const |
179 | 0 | { |
180 | 0 | return mpSfxDialogController; |
181 | 0 | } |
182 | | |
183 | | OUString SfxTabPage::GetHelpId() const |
184 | 0 | { |
185 | 0 | if (m_xContainer) |
186 | 0 | return m_xContainer->get_help_id(); |
187 | 0 | return {}; |
188 | 0 | } |
189 | | |
190 | | weld::Window* SfxTabPage::GetFrameWeld() const |
191 | 0 | { |
192 | 0 | if (m_pDialogController) |
193 | 0 | return m_pDialogController->getDialog(); |
194 | 0 | return nullptr; |
195 | 0 | } |
196 | | |
197 | | const SfxItemSet* SfxTabPage::GetDialogExampleSet() const |
198 | 0 | { |
199 | 0 | if (mpSfxDialogController) |
200 | 0 | return mpSfxDialogController->GetExampleSet(); |
201 | 0 | return nullptr; |
202 | 0 | } |
203 | | |
204 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |