Line data Source code
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 : #include <vcl/msgbox.hxx>
23 :
24 : #include <sfx2/styledlg.hxx>
25 : #include <sfx2/mgetempl.hxx>
26 : #include <sfx2/sfxresid.hxx>
27 : #include <sfx2/sfxuno.hxx>
28 :
29 : #include "dialog.hrc"
30 :
31 : // class SfxStyleDialog --------------------------------------------------
32 :
33 0 : SfxStyleDialog::SfxStyleDialog
34 : (
35 : Window* pParent, // Parent
36 : const OString& rID, const OUString& rUIXMLDescription,
37 : SfxStyleSheetBase& rStyle // stylesheet to be processed
38 : )
39 :
40 : /* [Description]
41 :
42 : Constructor: Add Manage TabPage, set ExampleSet from style.
43 : */
44 :
45 : : SfxTabDialog(pParent, rID, rUIXMLDescription,
46 0 : rStyle.GetItemSet().Clone(), true)
47 0 : , pStyle( &rStyle )
48 :
49 : {
50 : // without ParentSupport suppress the standardButton
51 0 : if (!rStyle.HasParentSupport())
52 0 : RemoveStandardButton();
53 :
54 0 : m_nOrganizerId = AddTabPage("organizer", SfxManageStyleSheetPage::Create, 0);
55 :
56 : // With new template always set the management page as the current page
57 :
58 0 : if( rStyle.GetName().isEmpty() )
59 0 : SetCurPageId(m_nOrganizerId);
60 : else
61 : {
62 0 : OUString sTxt = OUString(GetText()) + ": " + rStyle.GetName();
63 0 : SetText( sTxt );
64 : }
65 0 : delete pExampleSet; // in SfxTabDialog::Ctor() already created
66 0 : pExampleSet = &pStyle->GetItemSet();
67 :
68 0 : GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
69 0 : }
70 :
71 :
72 :
73 0 : SfxStyleDialog::~SfxStyleDialog()
74 :
75 : /* [Description]
76 :
77 : Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
78 : the Set from Style.
79 : */
80 :
81 : {
82 0 : pExampleSet = 0;
83 0 : pStyle = 0;
84 0 : delete GetInputSetImpl();
85 0 : }
86 :
87 :
88 :
89 0 : const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
90 :
91 : /* [Description]
92 :
93 : This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
94 : returns <SfxTabPage::REFRESH_SET>.
95 : */
96 :
97 : {
98 0 : return GetInputSetImpl();
99 : }
100 :
101 :
102 :
103 0 : short SfxStyleDialog::Ok()
104 :
105 : /* [Description]
106 :
107 : Overloaded, so that always RET_OK is returned.
108 : */
109 :
110 : {
111 0 : SfxTabDialog::Ok();
112 0 : return RET_OK;
113 : }
114 :
115 :
116 :
117 0 : IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
118 :
119 : /* [Description]
120 :
121 : If the dialogue was canceled, then all selected attributes must be reset
122 : again.
123 : */
124 :
125 : {
126 : (void)pButton; //unused
127 0 : SfxTabPage* pPage = GetTabPage(m_nOrganizerId);
128 :
129 0 : const SfxItemSet* pInSet = GetInputSetImpl();
130 0 : SfxWhichIter aIter( *pInSet );
131 0 : sal_uInt16 nWhich = aIter.FirstWhich();
132 :
133 0 : while ( nWhich )
134 : {
135 0 : SfxItemState eState = pInSet->GetItemState( nWhich, false );
136 :
137 0 : if ( SFX_ITEM_DEFAULT == eState )
138 0 : pExampleSet->ClearItem( nWhich );
139 : else
140 0 : pExampleSet->Put( pInSet->Get( nWhich ) );
141 0 : nWhich = aIter.NextWhich();
142 : }
143 :
144 0 : if ( pPage )
145 0 : pPage->Reset( *GetInputSetImpl() );
146 0 : EndDialog( RET_CANCEL );
147 0 : return 0;
148 3 : }
149 :
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|