Branch data 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 ResId& rResId, // ResId
37 : : SfxStyleSheetBase& rStyle, // stylesheet to be processed
38 : : sal_Bool bFreeRes, // Flag release resources
39 : : const String* pUserBtnTxt
40 : : ) :
41 : :
42 : : /* [Description]
43 : :
44 : : Constructor: Add Manage TabPage, set ExampleSet from style.
45 : : */
46 : :
47 : : SfxTabDialog( pParent, rResId,
48 : 0 : rStyle.GetItemSet().Clone(),
49 : : // return TRUE also without ParentSupport , but extended
50 : : // to suppress the standardButton
51 : 0 : rStyle.HasParentSupport() ? sal_True : 2,
52 : : pUserBtnTxt ),
53 : :
54 [ # # ]: 0 : pStyle( &rStyle )
55 : :
56 : : {
57 : : AddTabPage( ID_TABPAGE_MANAGESTYLES,
58 : : SfxResId( STR_TABPAGE_MANAGESTYLES ).toString(),
59 [ # # ][ # # ]: 0 : SfxManageStyleSheetPage::Create, 0, sal_False, 0 );
[ # # ][ # # ]
[ # # ]
60 : :
61 : : // With new template always set the management page as the current page
62 : :
63 [ # # ][ # # ]: 0 : if( !rStyle.GetName().Len() )
64 : 0 : SetCurPageId( ID_TABPAGE_MANAGESTYLES );
65 : : else
66 : : {
67 [ # # ]: 0 : String sTxt( GetText() );
68 [ # # ][ # # ]: 0 : sTxt += DEFINE_CONST_UNICODE(": ") ;
[ # # ]
69 [ # # ][ # # ]: 0 : sTxt += rStyle.GetName();
70 [ # # ][ # # ]: 0 : SetText( sTxt );
71 : : }
72 [ # # ][ # # ]: 0 : delete pExampleSet; // in SfxTabDialog::Ctor() already created
73 [ # # ]: 0 : pExampleSet = &pStyle->GetItemSet();
74 : :
75 [ # # ]: 0 : if ( bFreeRes )
76 [ # # ]: 0 : FreeResource();
77 [ # # ]: 0 : GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
78 : 0 : }
79 : :
80 : : // -----------------------------------------------------------------------
81 : :
82 : 0 : SfxStyleDialog::~SfxStyleDialog()
83 : :
84 : : /* [Description]
85 : :
86 : : Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
87 : : the Set from Style.
88 : : */
89 : :
90 : : {
91 : 0 : pExampleSet = 0;
92 : 0 : pStyle = 0;
93 [ # # ][ # # ]: 0 : delete GetInputSetImpl();
[ # # ]
94 [ # # ]: 0 : }
95 : :
96 : : // -----------------------------------------------------------------------
97 : :
98 : 0 : const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
99 : :
100 : : /* [Description]
101 : :
102 : : This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
103 : : returns <SfxTabPage::REFRESH_SET>.
104 : : */
105 : :
106 : : {
107 : 0 : return GetInputSetImpl();
108 : : }
109 : :
110 : : // -----------------------------------------------------------------------
111 : :
112 : 0 : short SfxStyleDialog::Ok()
113 : :
114 : : /* [Description]
115 : :
116 : : Overloaded, so that always RET_OK is returned.
117 : : */
118 : :
119 : : {
120 : 0 : SfxTabDialog::Ok();
121 : 0 : return RET_OK;
122 : : }
123 : :
124 : : // -----------------------------------------------------------------------
125 : :
126 : 0 : IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
127 : :
128 : : /* [Description]
129 : :
130 : : If the dialogue was canceled, then all selected attributes must be reset
131 : : again.
132 : : */
133 : :
134 : : {
135 : : (void)pButton; //unused
136 [ # # ]: 0 : SfxTabPage* pPage = GetTabPage( ID_TABPAGE_MANAGESTYLES );
137 : :
138 [ # # ]: 0 : const SfxItemSet* pInSet = GetInputSetImpl();
139 [ # # ]: 0 : SfxWhichIter aIter( *pInSet );
140 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
141 : :
142 [ # # ]: 0 : while ( nWhich )
143 : : {
144 [ # # ]: 0 : SfxItemState eState = pInSet->GetItemState( nWhich, sal_False );
145 : :
146 [ # # ]: 0 : if ( SFX_ITEM_DEFAULT == eState )
147 [ # # ]: 0 : pExampleSet->ClearItem( nWhich );
148 : : else
149 [ # # ][ # # ]: 0 : pExampleSet->Put( pInSet->Get( nWhich ) );
150 [ # # ]: 0 : nWhich = aIter.NextWhich();
151 : : }
152 : :
153 [ # # ]: 0 : if ( pPage )
154 [ # # ][ # # ]: 0 : pPage->Reset( *GetInputSetImpl() );
155 [ # # ]: 0 : EndDialog( RET_CANCEL );
156 [ # # ]: 0 : return 0;
157 : : }
158 : :
159 : :
160 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|