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>
22 #include <vcl/msgbox.hxx>
24 #include <sfx2/styledlg.hxx>
25 #include <sfx2/mgetempl.hxx>
26 #include <sfx2/sfxresid.hxx>
27 #include <sfx2/sfxuno.hxx>
31 // class SfxStyleDialog --------------------------------------------------
33 SfxStyleDialog::SfxStyleDialog
35 vcl::Window
* pParent
, // Parent
36 const OUString
& rID
, const OUString
& rUIXMLDescription
,
37 SfxStyleSheetBase
& rStyle
// stylesheet to be processed
42 Constructor: Add Manage TabPage, set ExampleSet from style.
45 : SfxTabDialog(pParent
, rID
, rUIXMLDescription
,
46 rStyle
.GetItemSet().Clone(), true)
50 // without ParentSupport suppress the standardButton
51 if (!rStyle
.HasParentSupport())
52 RemoveStandardButton();
54 m_nOrganizerId
= AddTabPage("organizer", SfxManageStyleSheetPage::Create
, 0);
56 // With new template always set the management page as the current page
58 if( rStyle
.GetName().isEmpty() )
59 SetCurPageId(m_nOrganizerId
);
62 OUString sTxt
= OUString(GetText()) + ": " + rStyle
.GetName();
65 delete pExampleSet
; // in SfxTabDialog::Ctor() already created
66 pExampleSet
= &pStyle
->GetItemSet();
68 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog
, CancelHdl
) );
73 SfxStyleDialog::~SfxStyleDialog()
80 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
84 void SfxStyleDialog::dispose()
88 SfxTabDialog::dispose();
93 void SfxStyleDialog::RefreshInputSet()
97 This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
98 returns <SfxTabPage::REFRESH_SET>.
102 SfxTabDialog::RefreshInputSet();
107 short SfxStyleDialog::Ok()
111 Override so that always RET_OK is returned.
121 IMPL_LINK( SfxStyleDialog
, CancelHdl
, Button
*, pButton
)
125 If the dialogue was canceled, then all selected attributes must be reset
130 (void)pButton
; //unused
131 SfxTabPage
* pPage
= GetTabPage(m_nOrganizerId
);
133 const SfxItemSet
* pInSet
= GetInputSetImpl();
134 SfxWhichIter
aIter( *pInSet
);
135 sal_uInt16 nWhich
= aIter
.FirstWhich();
139 SfxItemState eState
= pInSet
->GetItemState( nWhich
, false );
141 if ( SfxItemState::DEFAULT
== eState
)
142 pExampleSet
->ClearItem( nWhich
);
144 pExampleSet
->Put( pInSet
->Get( nWhich
) );
145 nWhich
= aIter
.NextWhich();
149 pPage
->Reset( GetInputSetImpl() );
150 EndDialog( RET_CANCEL
);
154 OUString
SfxStyleDialog::GenerateUnusedName(SfxStyleSheetBasePool
&rPool
)
156 OUString
aNoName(SfxResId(STR_NONAME
).toString());
158 OUString
aNo(aNoName
);
159 aNoName
+= OUString::number(nNo
);
160 while (rPool
.Find(aNoName
))
164 aNoName
+= OUString::number(nNo
);
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */