1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5d119d52dSAndrew Rist * distributed with this work for additional information
6d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at
10d119d52dSAndrew Rist *
11d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12d119d52dSAndrew Rist *
13d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist * software distributed under the License is distributed on an
15d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist * KIND, either express or implied. See the License for the
17d119d52dSAndrew Rist * specific language governing permissions and limitations
18d119d52dSAndrew Rist * under the License.
19d119d52dSAndrew Rist *
20d119d52dSAndrew Rist *************************************************************/
21d119d52dSAndrew Rist
22d119d52dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir
29cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <vcl/field.hxx>
33cdf0e10cSrcweir #include <svl/eitem.hxx>
34cdf0e10cSrcweir #include <svl/intitem.hxx>
35cdf0e10cSrcweir #include <svl/style.hxx>
36cdf0e10cSrcweir #ifndef GCC
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include <sfx2/styfitem.hxx>
40cdf0e10cSrcweir #include <sfx2/styledlg.hxx>
41cdf0e10cSrcweir #include <sfx2/app.hxx>
42cdf0e10cSrcweir #include <sfx2/mgetempl.hxx>
43cdf0e10cSrcweir #include <sfx2/objsh.hxx>
44cdf0e10cSrcweir #include "sfxtypes.hxx"
45cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
46cdf0e10cSrcweir #include <sfx2/module.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir #include <sfx2/sfx.hrc>
49cdf0e10cSrcweir #include "dialog.hrc"
50cdf0e10cSrcweir #include "mgetempl.hrc"
51cdf0e10cSrcweir
52cdf0e10cSrcweir #ifndef _SFX_STYLE_HRC
53cdf0e10cSrcweir #include <svl/style.hrc>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir
56cdf0e10cSrcweir // SfxManageStyleSheetPage -----------------------------------------------
57cdf0e10cSrcweir
SfxManageStyleSheetPage(Window * pParent,const SfxItemSet & rAttrSet)58cdf0e10cSrcweir SfxManageStyleSheetPage::SfxManageStyleSheetPage( Window* pParent, const SfxItemSet& rAttrSet ) :
59cdf0e10cSrcweir
60cdf0e10cSrcweir SfxTabPage( pParent, SfxResId( TP_MANAGE_STYLES ), rAttrSet ),
61cdf0e10cSrcweir
62cdf0e10cSrcweir aNameFt ( this, SfxResId( FT_NAME ) ),
63cdf0e10cSrcweir aNameEd ( this, SfxResId( ED_NAME ) ),
64cdf0e10cSrcweir aNameMLE ( this, SfxResId( MLE_NAME ) ),
65cdf0e10cSrcweir aAutoCB ( this, SfxResId( CB_AUTO ) ),
66cdf0e10cSrcweir
67cdf0e10cSrcweir aFollowFt ( this, SfxResId( FT_NEXT ) ),
68cdf0e10cSrcweir aFollowLb ( this, SfxResId( LB_NEXT ) ),
69cdf0e10cSrcweir
70cdf0e10cSrcweir aBaseFt ( this, SfxResId( FT_BASE ) ),
71cdf0e10cSrcweir aBaseLb ( this, SfxResId( LB_BASE ) ),
72cdf0e10cSrcweir
73cdf0e10cSrcweir aFilterFt ( this, SfxResId( FT_REGION ) ),
74cdf0e10cSrcweir aFilterLb ( this, SfxResId( LB_REGION ) ),
75cdf0e10cSrcweir
76cdf0e10cSrcweir aDescGb ( this, SfxResId( GB_DESC ) ),
77cdf0e10cSrcweir aDescFt ( this, SfxResId( FT_DESC ) ),
78cdf0e10cSrcweir aDescED ( this, SfxResId( ED_DESC ) ),
79cdf0e10cSrcweir
80cdf0e10cSrcweir pStyle( &( (SfxStyleDialog*)pParent->GetParent() )->GetStyleSheet() ),
81cdf0e10cSrcweir
82cdf0e10cSrcweir pItem ( 0 ),
83cdf0e10cSrcweir bModified ( sal_False ),
84cdf0e10cSrcweir aName ( pStyle->GetName() ),
85cdf0e10cSrcweir aFollow ( pStyle->GetFollow() ),
86cdf0e10cSrcweir aParent ( pStyle->GetParent() ),
87cdf0e10cSrcweir nFlags ( pStyle->GetMask() )
88cdf0e10cSrcweir
89cdf0e10cSrcweir /* [Beschreibung]
90cdf0e10cSrcweir
91cdf0e10cSrcweir Konstruktor; initialisiert die ListBoxen mit den Vorlagen
92cdf0e10cSrcweir
93cdf0e10cSrcweir */
94cdf0e10cSrcweir
95cdf0e10cSrcweir {
96cdf0e10cSrcweir FreeResource();
97cdf0e10cSrcweir
98cdf0e10cSrcweir if ( IsBackground() )
99cdf0e10cSrcweir aDescED.SetBackground( GetBackground() );
100cdf0e10cSrcweir FixedInfo* pInfo = new FixedInfo( this );
101cdf0e10cSrcweir aDescED.SetFont( pInfo->GetFont() );
102cdf0e10cSrcweir delete pInfo;
103cdf0e10cSrcweir
104cdf0e10cSrcweir aDescED.Hide();
105cdf0e10cSrcweir aDescFt.Show();
106cdf0e10cSrcweir
107cdf0e10cSrcweir // diese Page braucht ExchangeSupport
108cdf0e10cSrcweir SetExchangeSupport();
109cdf0e10cSrcweir
110cdf0e10cSrcweir ResMgr* pResMgr = SFX_APP()->GetModule_Impl()->GetResMgr();
111cdf0e10cSrcweir DBG_ASSERT( pResMgr, "kein ResMgr am Modul" );
112cdf0e10cSrcweir pFamilies = new SfxStyleFamilies( ResId( DLG_STYLE_DESIGNER, *pResMgr ) );
113cdf0e10cSrcweir
114cdf0e10cSrcweir SfxStyleSheetBasePool* pPool = 0;
115cdf0e10cSrcweir SfxObjectShell* pDocShell = SfxObjectShell::Current();
116cdf0e10cSrcweir
117cdf0e10cSrcweir if ( pDocShell )
118cdf0e10cSrcweir pPool = pDocShell->GetStyleSheetPool();
119cdf0e10cSrcweir DBG_ASSERT( pPool, "kein Pool oder keine DocShell" );
120cdf0e10cSrcweir
121cdf0e10cSrcweir if ( pPool )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir pPool->SetSearchMask( pStyle->GetFamily() );
124cdf0e10cSrcweir pPool->First(); // fuer SW - interne Liste updaten
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir if ( !pStyle->GetName().Len() && pPool )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir // NullString als Name -> Name generieren
130cdf0e10cSrcweir String aNoName( SfxResId( STR_NONAME ) );
131cdf0e10cSrcweir sal_uInt16 nNo = 1;
132cdf0e10cSrcweir String aNo( aNoName );
133cdf0e10cSrcweir aNoName += String::CreateFromInt32( nNo );
134cdf0e10cSrcweir while ( pPool->Find( aNoName ) )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir ++nNo;
137cdf0e10cSrcweir aNoName = aNo;
138cdf0e10cSrcweir aNoName += String::CreateFromInt32( nNo );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir pStyle->SetName( aNoName );
141cdf0e10cSrcweir aName = aNoName;
142cdf0e10cSrcweir aFollow = pStyle->GetFollow();
143cdf0e10cSrcweir aParent = pStyle->GetParent();
144cdf0e10cSrcweir }
145cdf0e10cSrcweir aNameEd.SetText(pStyle->GetName());
146cdf0e10cSrcweir
147cdf0e10cSrcweir // Set the field read-only if it is NOT an user-defined style
148cdf0e10cSrcweir // but allow selecting and copying
149cdf0e10cSrcweir if ( !pStyle->IsUserDefined() ) {
150cdf0e10cSrcweir aNameEd.SetReadOnly();
151cdf0e10cSrcweir aNameEd.Hide();
152cdf0e10cSrcweir
153cdf0e10cSrcweir aNameMLE.SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
154cdf0e10cSrcweir aNameMLE.SetText( pStyle->GetName() );
155cdf0e10cSrcweir aNameMLE.EnableCursor( sal_False );
156cdf0e10cSrcweir aNameMLE.Show();
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir if ( pStyle->HasFollowSupport() && pPool )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir SfxStyleSheetBase* pPoolStyle = pPool->First();
162cdf0e10cSrcweir
163cdf0e10cSrcweir while ( pPoolStyle )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir aFollowLb.InsertEntry( pPoolStyle->GetName() );
166cdf0e10cSrcweir pPoolStyle = pPool->Next();
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir // eine neue Vorlage ist noch nicht im Pool
170cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND == aFollowLb.GetEntryPos( pStyle->GetName() ) )
171cdf0e10cSrcweir aFollowLb.InsertEntry( pStyle->GetName() );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir else
174cdf0e10cSrcweir {
175cdf0e10cSrcweir aFollowFt.Hide();
176cdf0e10cSrcweir aFollowLb.Hide();
177cdf0e10cSrcweir
178cdf0e10cSrcweir aFilterFt.SetPosPixel( aBaseFt.GetPosPixel() );
179cdf0e10cSrcweir aFilterLb.SetPosPixel( aBaseLb.GetPosPixel() );
180cdf0e10cSrcweir
181cdf0e10cSrcweir aBaseFt.SetPosPixel( aFollowFt.GetPosPixel() );
182cdf0e10cSrcweir aBaseLb.SetPosPixel( aFollowLb.GetPosPixel() );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir if ( pStyle->HasParentSupport() && pPool )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if ( pStyle->HasClearParentSupport() )
188cdf0e10cSrcweir // die Basisvorlage darf auf NULL gesetzt werden
189cdf0e10cSrcweir aBaseLb.InsertEntry( String( SfxResId( STR_NONE ) ) );
190cdf0e10cSrcweir
191cdf0e10cSrcweir SfxStyleSheetBase* pPoolStyle = pPool->First();
192cdf0e10cSrcweir
193cdf0e10cSrcweir while ( pPoolStyle )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir const String aStr( pPoolStyle->GetName() );
196cdf0e10cSrcweir // eigener Namen nicht als Basisvorlage
197cdf0e10cSrcweir if ( aStr != aName )
198cdf0e10cSrcweir aBaseLb.InsertEntry( aStr );
199cdf0e10cSrcweir pPoolStyle = pPool->Next();
200cdf0e10cSrcweir }
201cdf0e10cSrcweir }
202cdf0e10cSrcweir else
203cdf0e10cSrcweir {
204cdf0e10cSrcweir aBaseFt.Disable();
205cdf0e10cSrcweir aBaseLb.Disable();
206cdf0e10cSrcweir }
207cdf0e10cSrcweir sal_uInt16 nCount = pFamilies->Count();
208cdf0e10cSrcweir
209cdf0e10cSrcweir sal_uInt16 i;
210cdf0e10cSrcweir for ( i = 0; i < nCount; ++i )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir pItem = pFamilies->GetObject(i);
213cdf0e10cSrcweir
214cdf0e10cSrcweir if ( pItem->GetFamily() == pStyle->GetFamily() )
215cdf0e10cSrcweir break;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir sal_uInt16 nStyleFilterIdx = 0xffff;
219cdf0e10cSrcweir
220cdf0e10cSrcweir if ( i < nCount )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir // Filterflags
223cdf0e10cSrcweir const SfxStyleFilter& rList = pItem->GetFilterList();
224cdf0e10cSrcweir nCount = (sal_uInt16)rList.Count();
225cdf0e10cSrcweir sal_uInt16 nIdx = 0;
226cdf0e10cSrcweir sal_uInt16 nMask = pStyle->GetMask() & ~SFXSTYLEBIT_USERDEF;
227cdf0e10cSrcweir
228cdf0e10cSrcweir if ( !nMask ) // Benutzervorlage?
229cdf0e10cSrcweir nMask = pStyle->GetMask();
230cdf0e10cSrcweir
231cdf0e10cSrcweir for ( i = 0; i < nCount; ++i )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir SfxFilterTupel* pTupel = rList.GetObject(i);
234cdf0e10cSrcweir
235cdf0e10cSrcweir if ( pTupel->nFlags != SFXSTYLEBIT_AUTO &&
236cdf0e10cSrcweir pTupel->nFlags != SFXSTYLEBIT_USED &&
237cdf0e10cSrcweir // pTupel->nFlags != SFXSTYLEBIT_USERDEF &&
238cdf0e10cSrcweir pTupel->nFlags != SFXSTYLEBIT_ALL )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir aFilterLb.InsertEntry( pTupel->aName, nIdx );
241cdf0e10cSrcweir aFilterLb.SetEntryData(nIdx, (void*)(long)i);
242cdf0e10cSrcweir
243cdf0e10cSrcweir if ( ( pTupel->nFlags & nMask ) == nMask )
244cdf0e10cSrcweir nStyleFilterIdx = nIdx;
245cdf0e10cSrcweir ++nIdx;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir if ( nStyleFilterIdx != 0xFFFF )
250cdf0e10cSrcweir aFilterLb.SelectEntryPos( nStyleFilterIdx );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir if ( !aFilterLb.GetEntryCount() || !pStyle->IsUserDefined() )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir pItem = 0;
256cdf0e10cSrcweir aFilterFt.Disable();
257cdf0e10cSrcweir aFilterLb.Disable();
258cdf0e10cSrcweir }
259cdf0e10cSrcweir else
260cdf0e10cSrcweir aFilterLb.SaveValue();
261cdf0e10cSrcweir SetDescriptionText_Impl();
262cdf0e10cSrcweir
263cdf0e10cSrcweir if ( aFollowLb.IsEnabled() || aBaseLb.IsEnabled() )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir aNameEd.SetGetFocusHdl(
266cdf0e10cSrcweir LINK( this, SfxManageStyleSheetPage, GetFocusHdl ) );
267cdf0e10cSrcweir aNameEd.SetLoseFocusHdl(
268cdf0e10cSrcweir LINK( this, SfxManageStyleSheetPage, LoseFocusHdl ) );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir // ist es ein Style mit automatischem Update? (nur SW)
271cdf0e10cSrcweir if(SFX_ITEM_SET == rAttrSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE))
272cdf0e10cSrcweir {
273cdf0e10cSrcweir Size aSize = aNameEd.GetSizePixel();
274cdf0e10cSrcweir aSize.Width() /= 2;
275cdf0e10cSrcweir aNameEd.SetSizePixel(aSize);
276cdf0e10cSrcweir aAutoCB.Show();
277cdf0e10cSrcweir }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir //-------------------------------------------------------------------------
281cdf0e10cSrcweir
~SfxManageStyleSheetPage()282cdf0e10cSrcweir SfxManageStyleSheetPage::~SfxManageStyleSheetPage()
283cdf0e10cSrcweir
284cdf0e10cSrcweir /* [Beschreibung]
285cdf0e10cSrcweir
286cdf0e10cSrcweir Destruktor; Freigabe der Daten
287cdf0e10cSrcweir
288cdf0e10cSrcweir */
289cdf0e10cSrcweir
290cdf0e10cSrcweir {
291cdf0e10cSrcweir aNameEd.SetGetFocusHdl( Link() );
292cdf0e10cSrcweir aNameEd.SetLoseFocusHdl( Link() );
293cdf0e10cSrcweir delete pFamilies;
294cdf0e10cSrcweir pItem = 0;
295cdf0e10cSrcweir pStyle = 0;
296cdf0e10cSrcweir
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir //-------------------------------------------------------------------------
300cdf0e10cSrcweir
UpdateName_Impl(ListBox * pBox,const String & rNew)301cdf0e10cSrcweir void SfxManageStyleSheetPage::UpdateName_Impl( ListBox* pBox,
302cdf0e10cSrcweir const String& rNew )
303cdf0e10cSrcweir
304cdf0e10cSrcweir /* [Beschreibung]
305cdf0e10cSrcweir
306cdf0e10cSrcweir Nach der "Anderung eines Vorlagennamens die ListBox pBox
307cdf0e10cSrcweir aktualisieren
308cdf0e10cSrcweir
309cdf0e10cSrcweir [Parameter]
310cdf0e10cSrcweir
311cdf0e10cSrcweir ListBox* pBox ListBox, deren Eintr"age aktualisiert
312cdf0e10cSrcweir werden sollen
313cdf0e10cSrcweir const String& rNew der neue Name
314cdf0e10cSrcweir
315cdf0e10cSrcweir */
316cdf0e10cSrcweir
317cdf0e10cSrcweir {
318cdf0e10cSrcweir if ( pBox->IsEnabled() )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir // ist der aktuelle Eintrag, dessen Namen modifizieren wurde
321cdf0e10cSrcweir const sal_Bool bSelect = pBox->GetSelectEntry() == aBuf;
322cdf0e10cSrcweir pBox->RemoveEntry( aBuf );
323cdf0e10cSrcweir pBox->InsertEntry( rNew );
324cdf0e10cSrcweir
325cdf0e10cSrcweir if ( bSelect )
326cdf0e10cSrcweir pBox->SelectEntry( rNew );
327cdf0e10cSrcweir }
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir //-------------------------------------------------------------------------
331cdf0e10cSrcweir
SetDescriptionText_Impl()332cdf0e10cSrcweir void SfxManageStyleSheetPage::SetDescriptionText_Impl()
333cdf0e10cSrcweir
334cdf0e10cSrcweir /* [Beschreibung]
335cdf0e10cSrcweir
336cdf0e10cSrcweir Attributbeschreibung setzen. daf"ur die eingestellte Metrik besorgen.
337cdf0e10cSrcweir */
338cdf0e10cSrcweir
339cdf0e10cSrcweir {
340cdf0e10cSrcweir SfxMapUnit eUnit = SFX_MAPUNIT_CM;
341cdf0e10cSrcweir // FieldUnit eFieldUnit = pSfxApp->GetOptions().GetMetric();
342cdf0e10cSrcweir FieldUnit eFieldUnit( FUNIT_CM );
343cdf0e10cSrcweir SfxModule* pModule = SfxModule::GetActiveModule();
344cdf0e10cSrcweir if ( pModule )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir const SfxPoolItem* pPoolItem = pModule->GetItem( SID_ATTR_METRIC );
347cdf0e10cSrcweir if ( pPoolItem )
348cdf0e10cSrcweir eFieldUnit = (FieldUnit)( (SfxUInt16Item*)pPoolItem )->GetValue();
349cdf0e10cSrcweir }
350cdf0e10cSrcweir
351cdf0e10cSrcweir switch ( eFieldUnit )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir case FUNIT_MM: eUnit = SFX_MAPUNIT_MM; break;
354cdf0e10cSrcweir
355cdf0e10cSrcweir case FUNIT_CM:
356cdf0e10cSrcweir case FUNIT_M:
357cdf0e10cSrcweir case FUNIT_KM: eUnit = SFX_MAPUNIT_CM; break;
358cdf0e10cSrcweir
359cdf0e10cSrcweir case FUNIT_POINT:
360cdf0e10cSrcweir case FUNIT_PICA: eUnit = SFX_MAPUNIT_POINT; break;
361cdf0e10cSrcweir
362cdf0e10cSrcweir case FUNIT_INCH:
363cdf0e10cSrcweir case FUNIT_FOOT:
364cdf0e10cSrcweir case FUNIT_MILE: eUnit = SFX_MAPUNIT_INCH; break;
365cdf0e10cSrcweir
366cdf0e10cSrcweir default:
367cdf0e10cSrcweir DBG_ERRORFILE( "not supported fieldunit" );
368cdf0e10cSrcweir }
369cdf0e10cSrcweir aDescFt.SetText( pStyle->GetDescription( eUnit ) );
370cdf0e10cSrcweir }
371cdf0e10cSrcweir
372cdf0e10cSrcweir //-------------------------------------------------------------------------
373cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SfxManageStyleSheetPage,GetFocusHdl,Edit *,pEdit)374cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxManageStyleSheetPage, GetFocusHdl, Edit *, pEdit )
375cdf0e10cSrcweir
376cdf0e10cSrcweir /* [Beschreibung]
377cdf0e10cSrcweir
378cdf0e10cSrcweir StarView Handler; GetFocus-Handler des Edits mit dem Vorlagennamen.
379cdf0e10cSrcweir
380cdf0e10cSrcweir */
381cdf0e10cSrcweir
382cdf0e10cSrcweir {
383cdf0e10cSrcweir aBuf = pEdit->GetText().EraseLeadingChars();
384cdf0e10cSrcweir return 0;
385cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SfxManageStyleSheetPage,GetFocusHdl,Edit *,pEdit)386cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxManageStyleSheetPage, GetFocusHdl, Edit *, pEdit )
387cdf0e10cSrcweir
388cdf0e10cSrcweir //-------------------------------------------------------------------------
389cdf0e10cSrcweir
390cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxManageStyleSheetPage, LoseFocusHdl, Edit *, pEdit )
391cdf0e10cSrcweir
392cdf0e10cSrcweir /* [Beschreibung]
393cdf0e10cSrcweir
394cdf0e10cSrcweir StarView Handler; LoseFocus-Handler des Edits mit dem Vorlagennamen.
395cdf0e10cSrcweir Dieser aktualisiert ggf. die Listbox mit den Folgevorlagen.
396cdf0e10cSrcweir In der Listbox mit den Basisvorlagen ist die aktuelle Vorlage
397cdf0e10cSrcweir selbst nicht enthalten.
398cdf0e10cSrcweir
399cdf0e10cSrcweir */
400cdf0e10cSrcweir
401cdf0e10cSrcweir {
402cdf0e10cSrcweir const String aStr( pEdit->GetText().EraseLeadingChars() );
403cdf0e10cSrcweir pEdit->SetText( aStr );
404cdf0e10cSrcweir // ggf. Listbox der Basisvorlagen aktualisieren
405cdf0e10cSrcweir if ( aStr != aBuf )
406cdf0e10cSrcweir UpdateName_Impl( &aFollowLb, aStr );
407cdf0e10cSrcweir return 0;
408cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SfxManageStyleSheetPage,LoseFocusHdl,Edit *,pEdit)409cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxManageStyleSheetPage, LoseFocusHdl, Edit *, pEdit )
410cdf0e10cSrcweir
411cdf0e10cSrcweir //-------------------------------------------------------------------------
412cdf0e10cSrcweir
413cdf0e10cSrcweir sal_Bool SfxManageStyleSheetPage::FillItemSet( SfxItemSet& rSet )
414cdf0e10cSrcweir
415cdf0e10cSrcweir /* [Beschreibung]
416cdf0e10cSrcweir
417cdf0e10cSrcweir
418cdf0e10cSrcweir Handler f"ur das Setzen der (modifizierten) Daten. Wird aus
419cdf0e10cSrcweir dem Ok des SfxTabDialog gerufen.
420cdf0e10cSrcweir
421cdf0e10cSrcweir [Parameter]
422cdf0e10cSrcweir
423cdf0e10cSrcweir SfxItemSet &rAttrSet das Set, das die Daten entgegennimmt.
424cdf0e10cSrcweir
425cdf0e10cSrcweir
426cdf0e10cSrcweir [R"uckgabewert]
427cdf0e10cSrcweir
428cdf0e10cSrcweir sal_Bool sal_True: es hat eine "Anderung der Daten
429cdf0e10cSrcweir stattgefunden
430cdf0e10cSrcweir sal_False: es hat keine "Anderung der Daten
431cdf0e10cSrcweir stattgefunden
432cdf0e10cSrcweir
433cdf0e10cSrcweir [Querverweise]
434cdf0e10cSrcweir
435cdf0e10cSrcweir <class SfxTabDialog>
436cdf0e10cSrcweir
437cdf0e10cSrcweir */
438cdf0e10cSrcweir
439cdf0e10cSrcweir {
440cdf0e10cSrcweir const sal_uInt16 nFilterIdx = aFilterLb.GetSelectEntryPos();
441cdf0e10cSrcweir
442cdf0e10cSrcweir // Filter setzen
443cdf0e10cSrcweir
444cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND != nFilterIdx &&
445cdf0e10cSrcweir nFilterIdx != aFilterLb.GetSavedValue() &&
446cdf0e10cSrcweir aFilterLb.IsEnabled() )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir bModified = sal_True;
449cdf0e10cSrcweir DBG_ASSERT( pItem, "kein Item" );
450cdf0e10cSrcweir // geht nur bei Benutzervorlagen
451cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
452cdf0e10cSrcweir sal_uInt16 nIdx = (sal_uInt16)(long)aFilterLb.GetEntryData( nFilterIdx );
453cdf0e10cSrcweir SfxFilterTupel* p;
454cdf0e10cSrcweir p = pItem->GetFilterList().GetObject( nIdx );
455cdf0e10cSrcweir #endif
456cdf0e10cSrcweir sal_uInt16 nMask = pItem->GetFilterList().GetObject(
457cdf0e10cSrcweir (sal_uInt16)(long)aFilterLb.GetEntryData( nFilterIdx ) )->nFlags |
458cdf0e10cSrcweir SFXSTYLEBIT_USERDEF;
459cdf0e10cSrcweir pStyle->SetMask( nMask );
460cdf0e10cSrcweir }
461cdf0e10cSrcweir if(aAutoCB.IsVisible() &&
462cdf0e10cSrcweir aAutoCB.IsChecked() != aAutoCB.GetSavedValue())
463cdf0e10cSrcweir {
464cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, aAutoCB.IsChecked()));
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir return bModified;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir //-------------------------------------------------------------------------
471cdf0e10cSrcweir
Reset(const SfxItemSet &)472cdf0e10cSrcweir void SfxManageStyleSheetPage::Reset( const SfxItemSet& /*rAttrSet*/ )
473cdf0e10cSrcweir
474cdf0e10cSrcweir /* [Beschreibung]
475cdf0e10cSrcweir
476cdf0e10cSrcweir
477cdf0e10cSrcweir Handler f"ur das Initialisieren der Seite mit den initialen Daten.
478cdf0e10cSrcweir
479cdf0e10cSrcweir [Parameter]
480cdf0e10cSrcweir
481cdf0e10cSrcweir const SfxItemSet &rAttrSet das Set mit den Daten
482cdf0e10cSrcweir
483cdf0e10cSrcweir
484cdf0e10cSrcweir [Querverweise]
485cdf0e10cSrcweir
486cdf0e10cSrcweir <class SfxTabDialog>
487cdf0e10cSrcweir
488cdf0e10cSrcweir */
489cdf0e10cSrcweir
490cdf0e10cSrcweir {
491cdf0e10cSrcweir bModified = sal_False;
492cdf0e10cSrcweir String sCmp( pStyle->GetName() );
493cdf0e10cSrcweir
494cdf0e10cSrcweir if ( sCmp != aName )
495cdf0e10cSrcweir pStyle->SetName( aName );
496cdf0e10cSrcweir aNameEd.SetText( aName );
497*cf1bb939STsutomu Uchino aNameEd.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
498cdf0e10cSrcweir
499cdf0e10cSrcweir if ( aFollowLb.IsEnabled() )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir sCmp = pStyle->GetFollow();
502cdf0e10cSrcweir
503cdf0e10cSrcweir if ( sCmp != aFollow )
504cdf0e10cSrcweir pStyle->SetFollow( aFollow );
505cdf0e10cSrcweir
506cdf0e10cSrcweir if ( !aFollow.Len() )
507cdf0e10cSrcweir aFollowLb.SelectEntry( aName );
508cdf0e10cSrcweir else
509cdf0e10cSrcweir aFollowLb.SelectEntry( aFollow );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir if ( aBaseLb.IsEnabled() )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir sCmp = pStyle->GetParent();
515cdf0e10cSrcweir
516cdf0e10cSrcweir if ( sCmp != aParent )
517cdf0e10cSrcweir pStyle->SetParent( aParent );
518cdf0e10cSrcweir
519cdf0e10cSrcweir if ( !aParent.Len() )
520cdf0e10cSrcweir aBaseLb.SelectEntry( String( SfxResId( STR_NONE ) ) );
521cdf0e10cSrcweir else
522cdf0e10cSrcweir aBaseLb.SelectEntry( aParent );
523cdf0e10cSrcweir
524cdf0e10cSrcweir if ( String( SfxResId( STR_STANDARD ) ) == aName )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir // die Standardvorlage kann nicht verkn"upft werden
527cdf0e10cSrcweir aBaseFt.Disable();
528cdf0e10cSrcweir aBaseLb.Disable();
529cdf0e10cSrcweir }
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir if ( aFilterLb.IsEnabled() )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir sal_uInt16 nCmp = pStyle->GetMask();
535cdf0e10cSrcweir
536cdf0e10cSrcweir if ( nCmp != nFlags )
537cdf0e10cSrcweir pStyle->SetMask( nFlags );
538cdf0e10cSrcweir aFilterLb.SelectEntryPos( aFilterLb.GetSavedValue() );
539cdf0e10cSrcweir }
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542cdf0e10cSrcweir //-------------------------------------------------------------------------
543cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rAttrSet)544cdf0e10cSrcweir SfxTabPage* SfxManageStyleSheetPage::Create( Window* pParent,
545cdf0e10cSrcweir const SfxItemSet &rAttrSet )
546cdf0e10cSrcweir
547cdf0e10cSrcweir /* [Beschreibung]
548cdf0e10cSrcweir
549cdf0e10cSrcweir
550cdf0e10cSrcweir Factory f"ur das Erzeugen der Seite
551cdf0e10cSrcweir
552cdf0e10cSrcweir [Querverweise]
553cdf0e10cSrcweir
554cdf0e10cSrcweir <class SfxTabDialog>
555cdf0e10cSrcweir
556cdf0e10cSrcweir */
557cdf0e10cSrcweir
558cdf0e10cSrcweir {
559cdf0e10cSrcweir return new SfxManageStyleSheetPage( pParent, rAttrSet );
560cdf0e10cSrcweir }
561cdf0e10cSrcweir
562cdf0e10cSrcweir //-------------------------------------------------------------------------
563cdf0e10cSrcweir
ActivatePage(const SfxItemSet & rSet)564cdf0e10cSrcweir void SfxManageStyleSheetPage::ActivatePage( const SfxItemSet& rSet)
565cdf0e10cSrcweir
566cdf0e10cSrcweir /* [Beschreibung]
567cdf0e10cSrcweir
568cdf0e10cSrcweir ActivatePage- Handler des SfxTabDialog; wird f"ur die Aktualisierung
569cdf0e10cSrcweir des beschreibenden Textes verwendet, da sich dieser durch "Anderungen
570cdf0e10cSrcweir der Daten anderer Seiten ge"andert haben kann.
571cdf0e10cSrcweir
572cdf0e10cSrcweir [Parameter]
573cdf0e10cSrcweir
574cdf0e10cSrcweir const SfxItemSet& das Set f"ur den Datenaustausch; wird
575cdf0e10cSrcweir hier nicht verwendet.
576cdf0e10cSrcweir
577cdf0e10cSrcweir [Querverweise]
578cdf0e10cSrcweir
579cdf0e10cSrcweir <SfxTabDialog::ActivatePage(const SfxItemSet &)>
580cdf0e10cSrcweir
581cdf0e10cSrcweir */
582cdf0e10cSrcweir
583cdf0e10cSrcweir {
584cdf0e10cSrcweir SetDescriptionText_Impl();
585cdf0e10cSrcweir
586cdf0e10cSrcweir // ist es ein Style mit automatischem Update? (nur SW)
587cdf0e10cSrcweir const SfxPoolItem* pPoolItem;
588cdf0e10cSrcweir
589cdf0e10cSrcweir if ( SFX_ITEM_SET ==
590cdf0e10cSrcweir rSet.GetItemState( SID_ATTR_AUTO_STYLE_UPDATE, sal_False, &pPoolItem ) )
591cdf0e10cSrcweir aAutoCB.Check( ( (const SfxBoolItem*)pPoolItem )->GetValue() );
592cdf0e10cSrcweir aAutoCB.SaveValue();
593cdf0e10cSrcweir }
594cdf0e10cSrcweir
595cdf0e10cSrcweir //-------------------------------------------------------------------------
596cdf0e10cSrcweir
DeactivatePage(SfxItemSet * pItemSet)597cdf0e10cSrcweir int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet )
598cdf0e10cSrcweir
599cdf0e10cSrcweir /* [Beschreibung]
600cdf0e10cSrcweir
601cdf0e10cSrcweir DeactivatePage- Handler des SfxTabDialog; die Daten werden
602cdf0e10cSrcweir an der Vorlage eingestellt, damit die richtige Vererbung
603cdf0e10cSrcweir f"ur die anderen Seiten des Dialoges vorliegt.
604cdf0e10cSrcweir Im Fehlerfall wird das Verlassen der Seite unterbunden.
605cdf0e10cSrcweir
606cdf0e10cSrcweir [Parameter]
607cdf0e10cSrcweir
608cdf0e10cSrcweir SfxItemSet* das Set f"ur den Datenaustausch; wird hier nicht verwendet.
609cdf0e10cSrcweir
610cdf0e10cSrcweir [Querverweise]
611cdf0e10cSrcweir
612cdf0e10cSrcweir <SfxTabDialog::DeactivatePage(SfxItemSet*)>
613cdf0e10cSrcweir
614cdf0e10cSrcweir */
615cdf0e10cSrcweir
616cdf0e10cSrcweir {
617cdf0e10cSrcweir int nRet = SfxTabPage::LEAVE_PAGE;
618cdf0e10cSrcweir
619cdf0e10cSrcweir if ( aNameEd.IsModified() )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir // bei <Enter> wird kein LoseFocus() durch StarView ausgel"ost
622cdf0e10cSrcweir if ( aNameEd.HasFocus() )
623cdf0e10cSrcweir LoseFocusHdl( &aNameEd );
624cdf0e10cSrcweir
625cdf0e10cSrcweir if ( !pStyle->SetName( aNameEd.GetText().EraseLeadingChars() ) )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDNAME ) );
628cdf0e10cSrcweir aBox.Execute();
629cdf0e10cSrcweir aNameEd.GrabFocus();
630cdf0e10cSrcweir aNameEd.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
631cdf0e10cSrcweir return SfxTabPage::KEEP_PAGE;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir bModified = sal_True;
634cdf0e10cSrcweir }
635cdf0e10cSrcweir
636cdf0e10cSrcweir if ( pStyle->HasFollowSupport() && aFollowLb.IsEnabled() )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir const String aFollowEntry( aFollowLb.GetSelectEntry() );
639cdf0e10cSrcweir
640cdf0e10cSrcweir if ( pStyle->GetFollow() != aFollowEntry )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir if ( !pStyle->SetFollow( aFollowEntry ) )
643cdf0e10cSrcweir {
644cdf0e10cSrcweir InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDSTYLE ) );
645cdf0e10cSrcweir aBox.Execute();
646cdf0e10cSrcweir aFollowLb.GrabFocus();
647cdf0e10cSrcweir return SfxTabPage::KEEP_PAGE;
648cdf0e10cSrcweir }
649cdf0e10cSrcweir bModified = sal_True;
650cdf0e10cSrcweir }
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
653cdf0e10cSrcweir if ( aBaseLb.IsEnabled() )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir String aParentEntry( aBaseLb.GetSelectEntry() );
656cdf0e10cSrcweir
657cdf0e10cSrcweir if ( String( SfxResId( STR_NONE ) ) == aParentEntry || aParentEntry == pStyle->GetName() )
658cdf0e10cSrcweir aParentEntry.Erase();
659cdf0e10cSrcweir
660cdf0e10cSrcweir if ( pStyle->GetParent() != aParentEntry )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir if ( !pStyle->SetParent( aParentEntry ) )
663cdf0e10cSrcweir {
664cdf0e10cSrcweir InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDPARENT ) );
665cdf0e10cSrcweir aBox.Execute();
666cdf0e10cSrcweir aBaseLb.GrabFocus();
667cdf0e10cSrcweir return SfxTabPage::KEEP_PAGE;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir bModified = sal_True;
670cdf0e10cSrcweir nRet |= (int)SfxTabPage::REFRESH_SET;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir }
673cdf0e10cSrcweir
674cdf0e10cSrcweir if ( pItemSet )
675cdf0e10cSrcweir FillItemSet( *pItemSet );
676cdf0e10cSrcweir
677cdf0e10cSrcweir return nRet;
678cdf0e10cSrcweir }
679cdf0e10cSrcweir
680