1*d119d52dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d119d52dSAndrew Rist * distributed with this work for additional information 6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance 9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d119d52dSAndrew Rist * software distributed under the License is distributed on an 15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the 17*d119d52dSAndrew Rist * specific language governing permissions and limitations 18*d119d52dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*d119d52dSAndrew Rist *************************************************************/ 21*d119d52dSAndrew Rist 22*d119d52dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 28cdf0e10cSrcweir #include <svl/style.hxx> 29cdf0e10cSrcweir #ifndef GCC 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <sfx2/newstyle.hxx> 33cdf0e10cSrcweir #include "dialog.hrc" 34cdf0e10cSrcweir #include "newstyle.hrc" 35cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir // PRIVATE METHODES ------------------------------------------------------ 38cdf0e10cSrcweir 39cdf0e10cSrcweir IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl ) 40cdf0e10cSrcweir { 41cdf0e10cSrcweir (void)pControl; //unused 42cdf0e10cSrcweir const String aName( aColBox.GetText() ); 43cdf0e10cSrcweir SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL ); 44cdf0e10cSrcweir if ( pStyle ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir if ( !pStyle->IsUserDefined() ) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir InfoBox( this, SfxResId( MSG_POOL_STYLE_NAME ) ).Execute(); 49cdf0e10cSrcweir return 0; 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir if ( RET_YES == aQueryOverwriteBox.Execute() ) 53cdf0e10cSrcweir EndDialog( RET_OK ); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir else 56cdf0e10cSrcweir EndDialog( RET_OK ); 57cdf0e10cSrcweir 58cdf0e10cSrcweir return 0; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir // ----------------------------------------------------------------------- 62cdf0e10cSrcweir 63cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir aOKBtn.Enable( pBox->GetText().EraseAllChars().Len() > 0 ); 66cdf0e10cSrcweir return 0; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox ) 69cdf0e10cSrcweir 70cdf0e10cSrcweir // CTOR / DTOR ----------------------------------------------------------- 71cdf0e10cSrcweir 72cdf0e10cSrcweir SfxNewStyleDlg::SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& rInPool ) : 73cdf0e10cSrcweir 74cdf0e10cSrcweir ModalDialog( pParent, SfxResId( DLG_NEW_STYLE_BY_EXAMPLE ) ), 75cdf0e10cSrcweir 76cdf0e10cSrcweir aColFL ( this, SfxResId( FL_COL ) ), 77cdf0e10cSrcweir aColBox ( this, SfxResId( LB_COL ) ), 78cdf0e10cSrcweir aOKBtn ( this, SfxResId( BT_OK ) ), 79cdf0e10cSrcweir aCancelBtn ( this, SfxResId( BT_CANCEL ) ), 80cdf0e10cSrcweir aQueryOverwriteBox ( this, SfxResId( MSG_OVERWRITE ) ), 81cdf0e10cSrcweir 82cdf0e10cSrcweir rPool( rInPool ) 83cdf0e10cSrcweir 84cdf0e10cSrcweir { 85cdf0e10cSrcweir FreeResource(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir aOKBtn.SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl)); 88cdf0e10cSrcweir aColBox.SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl)); 89cdf0e10cSrcweir aColBox.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl)); 9000d11a91SMathias Bauer // aColBox.SetAccessibleName(SfxResId(FL_COL)); 91cdf0e10cSrcweir 92cdf0e10cSrcweir SfxStyleSheetBase *pStyle = rPool.First(); 93cdf0e10cSrcweir while ( pStyle ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir aColBox.InsertEntry(pStyle->GetName()); 96cdf0e10cSrcweir pStyle = rPool.Next(); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir // ----------------------------------------------------------------------- 101cdf0e10cSrcweir 102cdf0e10cSrcweir __EXPORT SfxNewStyleDlg::~SfxNewStyleDlg() 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106