1efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5efeef26fSAndrew Rist * distributed with this work for additional information 6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14efeef26fSAndrew Rist * software distributed under the License is distributed on an 15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17efeef26fSAndrew Rist * specific language governing permissions and limitations 18efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20efeef26fSAndrew Rist *************************************************************/ 21efeef26fSAndrew Rist 22efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir 32cdf0e10cSrcweir #ifndef _VIEW_HXX 33cdf0e10cSrcweir #include <view.hxx> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #include <wrtsh.hxx> 36cdf0e10cSrcweir #include <cption.hxx> 37cdf0e10cSrcweir #include <fldmgr.hxx> 38cdf0e10cSrcweir #include <expfld.hxx> 39cdf0e10cSrcweir #include <numrule.hxx> 40cdf0e10cSrcweir #include <poolfmt.hxx> 41cdf0e10cSrcweir #include <docsh.hxx> 42cdf0e10cSrcweir #include <frmfmt.hxx> 43cdf0e10cSrcweir #include <calc.hxx> 44cdf0e10cSrcweir #include <uitool.hxx> 45cdf0e10cSrcweir #include <doc.hxx> 46cdf0e10cSrcweir #include <modcfg.hxx> 47cdf0e10cSrcweir #include <swmodule.hxx> 48cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp> 49cdf0e10cSrcweir #include <com/sun/star/text/GraphicCrop.hpp> 50cdf0e10cSrcweir #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> 51cdf0e10cSrcweir #include <com/sun/star/text/XTextTableCursor.hpp> 52cdf0e10cSrcweir #include <com/sun/star/text/XTextTablesSupplier.hpp> 53cdf0e10cSrcweir #include <com/sun/star/text/TableColumnSeparator.hpp> 54cdf0e10cSrcweir #include <com/sun/star/text/XTextTable.hpp> 55cdf0e10cSrcweir #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> 56cdf0e10cSrcweir #include <com/sun/star/text/XTextEmbeddedObject.hpp> 57cdf0e10cSrcweir #include <com/sun/star/text/XTextFramesSupplier.hpp> 58cdf0e10cSrcweir #include <com/sun/star/text/XTextFrame.hpp> 59cdf0e10cSrcweir 60cdf0e10cSrcweir #ifndef _FRMUI_HRC 61cdf0e10cSrcweir #include <frmui.hrc> 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir #ifndef _CPTION_HRC 64cdf0e10cSrcweir #include <cption.hrc> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #include <SwStyleNameMapper.hxx> 67cdf0e10cSrcweir using namespace ::com::sun::star; 68cdf0e10cSrcweir 69cdf0e10cSrcweir extern String* GetOldGrfCat(); 70cdf0e10cSrcweir extern String* GetOldTabCat(); 71cdf0e10cSrcweir extern String* GetOldFrmCat(); 72cdf0e10cSrcweir extern String* GetOldDrwCat(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir class SwSequenceOptionDialog : public SvxStandardDialog 75cdf0e10cSrcweir { 76cdf0e10cSrcweir FixedLine aFlHeader; 77cdf0e10cSrcweir FixedText aFtLevel; 78cdf0e10cSrcweir ListBox aLbLevel; 79cdf0e10cSrcweir FixedText aFtDelim; 80cdf0e10cSrcweir Edit aEdDelim; 81cdf0e10cSrcweir 82cdf0e10cSrcweir FixedLine aFlCatAndFrame; 83cdf0e10cSrcweir FixedText aFtCharStyle; 84cdf0e10cSrcweir ListBox aLbCharStyle; 85cdf0e10cSrcweir CheckBox aApplyBorderAndShadowCB; 86cdf0e10cSrcweir 87cdf0e10cSrcweir //#i61007# order of captions 88cdf0e10cSrcweir FixedLine aFlCaptionOrder; 89cdf0e10cSrcweir FixedText aFtCaptionOrder; 90cdf0e10cSrcweir ListBox aLbCaptionOrder; 91cdf0e10cSrcweir 92cdf0e10cSrcweir OKButton aOKButton; 93cdf0e10cSrcweir CancelButton aCancelButton; 94cdf0e10cSrcweir HelpButton aHelpButton; 95cdf0e10cSrcweir 96cdf0e10cSrcweir SwView& rView; 97cdf0e10cSrcweir String aFldTypeName; 98cdf0e10cSrcweir 99cdf0e10cSrcweir public: 100cdf0e10cSrcweir SwSequenceOptionDialog( Window *pParent, SwView &rV, 101cdf0e10cSrcweir const String& rSeqFldType ); 102cdf0e10cSrcweir virtual ~SwSequenceOptionDialog(); 103cdf0e10cSrcweir virtual void Apply(); 104cdf0e10cSrcweir 105cdf0e10cSrcweir bool IsApplyBorderAndShadow( void ) { return aApplyBorderAndShadowCB.IsChecked(); } 106cdf0e10cSrcweir void SetApplyBorderAndShadow( bool bSet ) { aApplyBorderAndShadowCB.Check(bSet); } 107cdf0e10cSrcweir 108cdf0e10cSrcweir //#i61007# order of captions 109cdf0e10cSrcweir bool IsOrderNumberingFirst() const {return aLbCaptionOrder.GetSelectEntryPos() == 1;} 110cdf0e10cSrcweir void SetOrderNumberingFirst(bool bSet) { aLbCaptionOrder.SelectEntryPos( bSet ? 1 : 0 ); } 111cdf0e10cSrcweir 112cdf0e10cSrcweir void SetCharacterStyle(const String& rStyle); 113cdf0e10cSrcweir String GetCharacterStyle() const; 114cdf0e10cSrcweir }; 115cdf0e10cSrcweir 116cdf0e10cSrcweir SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : 117cdf0e10cSrcweir 118cdf0e10cSrcweir SvxStandardDialog( pParent, SW_RES(DLG_CAPTION) ), 119cdf0e10cSrcweir 120cdf0e10cSrcweir aTextText (this, SW_RES(TXT_TEXT )), 121cdf0e10cSrcweir aTextEdit (this, SW_RES(EDT_TEXT )), 122cdf0e10cSrcweir aSettingsFL (this, SW_RES(FL_SETTINGS)), 123cdf0e10cSrcweir aCategoryText (this, SW_RES(TXT_CATEGORY)), 124cdf0e10cSrcweir aCategoryBox (this, SW_RES(BOX_CATEGORY)), 125cdf0e10cSrcweir aFormatText (this, SW_RES(TXT_FORMAT )), 126cdf0e10cSrcweir aFormatBox (this, SW_RES(BOX_FORMAT )), 127cdf0e10cSrcweir aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP )), 128cdf0e10cSrcweir aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP )), 129cdf0e10cSrcweir aSepText (this, SW_RES(TXT_SEP )), 130cdf0e10cSrcweir aSepEdit (this, SW_RES(EDT_SEP )), 131cdf0e10cSrcweir aPosText (this, SW_RES(TXT_POS )), 132cdf0e10cSrcweir aPosBox (this, SW_RES(BOX_POS )), 133cdf0e10cSrcweir aOKButton (this, SW_RES(BTN_OK )), 134cdf0e10cSrcweir aCancelButton (this, SW_RES(BTN_CANCEL )), 135cdf0e10cSrcweir aHelpButton (this, SW_RES(BTN_HELP )), 136cdf0e10cSrcweir aAutoCaptionButton(this, SW_RES(BTN_AUTOCAPTION)), 137cdf0e10cSrcweir aOptionButton (this, SW_RES(BTN_OPTION )), 138cdf0e10cSrcweir sNone( SW_RES( STR_CATEGORY_NONE )), 139cdf0e10cSrcweir aPrevWin (this, SW_RES(WIN_SAMPLE )), 140cdf0e10cSrcweir rView( rV ), 141cdf0e10cSrcweir pMgr( new SwFldMgr(rView.GetWrtShellPtr()) ), 142cdf0e10cSrcweir bCopyAttributes( sal_False ), 143cdf0e10cSrcweir bOrderNumberingFirst( SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir //#i61007# order of captions 146cdf0e10cSrcweir if( bOrderNumberingFirst ) 147cdf0e10cSrcweir ApplyCaptionOrder(); 148cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 149cdf0e10cSrcweir uno::Reference< frame::XModel > xModel = rView.GetDocShell()->GetBaseModel(); 150cdf0e10cSrcweir 151cdf0e10cSrcweir eType = rSh.GetSelectionType(); 152cdf0e10cSrcweir if ( eType & nsSelectionType::SEL_OLE ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir eType = nsSelectionType::SEL_GRF; 155cdf0e10cSrcweir uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY); 156cdf0e10cSrcweir xNameAccess = xObjs->getEmbeddedObjects(); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir Link aLk = LINK( this, SwCaptionDialog, ModifyHdl ); 160cdf0e10cSrcweir aCategoryBox.SetModifyHdl( aLk ); 161cdf0e10cSrcweir aTextEdit .SetModifyHdl( aLk ); 162cdf0e10cSrcweir aNumberingSeparatorED.SetModifyHdl ( aLk ); 163cdf0e10cSrcweir aSepEdit .SetModifyHdl( aLk ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir aLk = LINK(this, SwCaptionDialog, SelectHdl); 166cdf0e10cSrcweir aCategoryBox.SetSelectHdl( aLk ); 167cdf0e10cSrcweir aFormatBox .SetSelectHdl( aLk ); 168cdf0e10cSrcweir aOptionButton.SetClickHdl( LINK( this, SwCaptionDialog, OptionHdl ) ); 169cdf0e10cSrcweir aAutoCaptionButton.SetClickHdl(LINK(this, SwCaptionDialog, CaptionHdl)); 170cdf0e10cSrcweir 171cdf0e10cSrcweir aCategoryBox.InsertEntry( sNone ); 172cdf0e10cSrcweir sal_uInt16 i, nCount = pMgr->GetFldTypeCount(); 173cdf0e10cSrcweir for (i = 0; i < nCount; i++) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i ); 176cdf0e10cSrcweir if( pType->Which() == RES_SETEXPFLD && 177cdf0e10cSrcweir ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ ) 178cdf0e10cSrcweir aCategoryBox.InsertEntry(pType->GetName()); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir String* pString = 0; 182cdf0e10cSrcweir sal_uInt16 nPoolId = 0; 183cdf0e10cSrcweir if (eType & nsSelectionType::SEL_GRF) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir nPoolId = RES_POOLCOLL_LABEL_ABB; 186cdf0e10cSrcweir pString = ::GetOldGrfCat(); 187cdf0e10cSrcweir bCopyAttributes = sal_True; 188cdf0e10cSrcweir sObjectName = rSh.GetFlyName(); 189cdf0e10cSrcweir //if not OLE 190cdf0e10cSrcweir if(!xNameAccess.is()) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY); 193cdf0e10cSrcweir xNameAccess = xGraphics->getGraphicObjects(); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir } 197cdf0e10cSrcweir else if( eType & nsSelectionType::SEL_TBL ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir nPoolId = RES_POOLCOLL_LABEL_TABLE; 200cdf0e10cSrcweir pString = ::GetOldTabCat(); 201cdf0e10cSrcweir uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY); 202cdf0e10cSrcweir xNameAccess = xTables->getTextTables(); 203cdf0e10cSrcweir sObjectName = rSh.GetTableFmt()->GetName(); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir else if( eType & nsSelectionType::SEL_FRM ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir nPoolId = RES_POOLCOLL_LABEL_FRAME; 208cdf0e10cSrcweir pString = ::GetOldFrmCat(); 209cdf0e10cSrcweir uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); 210cdf0e10cSrcweir xNameAccess = xFrms->getTextFrames(); 211cdf0e10cSrcweir sObjectName = rSh.GetFlyName(); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir else if( eType == nsSelectionType::SEL_TXT ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir nPoolId = RES_POOLCOLL_LABEL_FRAME; 216cdf0e10cSrcweir pString = ::GetOldFrmCat(); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir else if( eType & nsSelectionType::SEL_DRW ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir nPoolId = RES_POOLCOLL_LABEL_DRAWING; 221cdf0e10cSrcweir pString = ::GetOldDrwCat(); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir if( nPoolId ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir if( pString && pString->Len()) 226cdf0e10cSrcweir aCategoryBox.SetText( *pString ); 227cdf0e10cSrcweir else 228cdf0e10cSrcweir aCategoryBox.SetText( 229cdf0e10cSrcweir SwStyleNameMapper::GetUIName( nPoolId, aEmptyStr )); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir // aFormatBox 233cdf0e10cSrcweir sal_uInt16 nSelFmt = SVX_NUM_ARABIC; 234cdf0e10cSrcweir nCount = pMgr->GetFldTypeCount(); 235cdf0e10cSrcweir SwFieldType* pFldType; 236cdf0e10cSrcweir for ( i = nCount; i; ) 237cdf0e10cSrcweir if( ( pFldType = pMgr->GetFldType(USHRT_MAX, --i))->GetName() == 238cdf0e10cSrcweir aCategoryBox.GetText() ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat(); 241cdf0e10cSrcweir break; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir 245cdf0e10cSrcweir nCount = pMgr->GetFormatCount(TYP_SEQFLD, sal_False); 246cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) ); 249cdf0e10cSrcweir sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i); 250cdf0e10cSrcweir aFormatBox.SetEntryData( i, reinterpret_cast<void*>( nFmtId ) ); 251cdf0e10cSrcweir if( nFmtId == nSelFmt ) 252cdf0e10cSrcweir aFormatBox.SelectEntryPos( i ); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir // aPosBox 256cdf0e10cSrcweir switch (eType) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir case nsSelectionType::SEL_GRF: 259cdf0e10cSrcweir case nsSelectionType::SEL_TBL: 260cdf0e10cSrcweir case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM: 261cdf0e10cSrcweir case nsSelectionType::SEL_TBL | nsSelectionType::SEL_TXT: 262cdf0e10cSrcweir case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM | nsSelectionType::SEL_TXT: 263cdf0e10cSrcweir case nsSelectionType::SEL_DRW: 264cdf0e10cSrcweir case nsSelectionType::SEL_DRW | nsSelectionType::SEL_BEZ: 265cdf0e10cSrcweir aPosBox.InsertEntry(SW_RESSTR(STR_ABOVE)); 266cdf0e10cSrcweir aPosBox.InsertEntry(SW_RESSTR(STR_CP_BELOW)); 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir case nsSelectionType::SEL_FRM: 269cdf0e10cSrcweir case nsSelectionType::SEL_TXT: 270cdf0e10cSrcweir aPosBox.InsertEntry(SW_RESSTR(STR_BEGINNING)); 271cdf0e10cSrcweir aPosBox.InsertEntry(SW_RESSTR(STR_END )); 272cdf0e10cSrcweir break; 273cdf0e10cSrcweir } 274cdf0e10cSrcweir aPosBox.SelectEntryPos(1); 275cdf0e10cSrcweir if (eType & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_DRW)) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir aPosText.Enable( sal_False ); 278cdf0e10cSrcweir aPosBox.Enable( sal_False ); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir aCategoryBox.GetModifyHdl().Call(&aCategoryBox); 282cdf0e10cSrcweir 283cdf0e10cSrcweir FreeResource(); 284cdf0e10cSrcweir 285cdf0e10cSrcweir CheckButtonWidth(); 286cdf0e10cSrcweir aTextEdit.GrabFocus(); 287cdf0e10cSrcweir DrawSample(); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir void SwCaptionDialog::Apply() 291cdf0e10cSrcweir { 292cdf0e10cSrcweir InsCaptionOpt aOpt; 293cdf0e10cSrcweir aOpt.UseCaption() = sal_True; 294cdf0e10cSrcweir String aName( aCategoryBox.GetText() ); 295cdf0e10cSrcweir if ( aName == sNone ) 296cdf0e10cSrcweir aOpt.SetCategory( aEmptyStr ); 297cdf0e10cSrcweir else 298cdf0e10cSrcweir { 299cdf0e10cSrcweir aName.EraseLeadingChars( ' ' ); 300cdf0e10cSrcweir aName.EraseTrailingChars( ' ' ); 301cdf0e10cSrcweir aOpt.SetCategory( aName ); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir aOpt.SetNumType( (sal_uInt16)(sal_uIntPtr)aFormatBox.GetEntryData( aFormatBox.GetSelectEntryPos() ) ); 304cdf0e10cSrcweir aOpt.SetSeparator( aSepEdit.IsEnabled() ? aSepEdit.GetText() : String() ); 305cdf0e10cSrcweir aOpt.SetNumSeparator( aNumberingSeparatorED.GetText() ); 306cdf0e10cSrcweir aOpt.SetCaption( aTextEdit.GetText() ); 307cdf0e10cSrcweir aOpt.SetPos( aPosBox.GetSelectEntryPos() ); 308cdf0e10cSrcweir aOpt.IgnoreSeqOpts() = sal_True; 309cdf0e10cSrcweir aOpt.CopyAttributes() = bCopyAttributes; 310cdf0e10cSrcweir aOpt.SetCharacterStyle( sCharacterStyle ); 311cdf0e10cSrcweir rView.InsertCaption( &aOpt ); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwCaptionDialog, OptionHdl, Button*, pButton ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir String sFldTypeName = aCategoryBox.GetText(); 317cdf0e10cSrcweir if(sFldTypeName == sNone) 318cdf0e10cSrcweir sFldTypeName = aEmptyStr; 319cdf0e10cSrcweir SwSequenceOptionDialog aDlg( pButton, rView, sFldTypeName ); 320cdf0e10cSrcweir aDlg.SetApplyBorderAndShadow(bCopyAttributes); 321cdf0e10cSrcweir aDlg.SetCharacterStyle( sCharacterStyle ); 322cdf0e10cSrcweir aDlg.SetOrderNumberingFirst( bOrderNumberingFirst ); 323cdf0e10cSrcweir aDlg.Execute(); 324cdf0e10cSrcweir bCopyAttributes = aDlg.IsApplyBorderAndShadow(); 325cdf0e10cSrcweir sCharacterStyle = aDlg.GetCharacterStyle(); 326cdf0e10cSrcweir //#i61007# order of captions 327cdf0e10cSrcweir if( bOrderNumberingFirst != aDlg.IsOrderNumberingFirst() ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir bOrderNumberingFirst = aDlg.IsOrderNumberingFirst(); 330cdf0e10cSrcweir SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(bOrderNumberingFirst); 331cdf0e10cSrcweir ApplyCaptionOrder(); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir DrawSample(); 334cdf0e10cSrcweir return 0; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwCaptionDialog, OptionHdl, Button*, EMPTYARG ) 337cdf0e10cSrcweir 338cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwCaptionDialog, SelectHdl, ListBox *, EMPTYARG ) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir DrawSample(); 341cdf0e10cSrcweir return 0; 342cdf0e10cSrcweir } 343cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwCaptionDialog, SelectHdl, ListBox *, EMPTYARG ) 344cdf0e10cSrcweir 345cdf0e10cSrcweir 346cdf0e10cSrcweir 347cdf0e10cSrcweir IMPL_LINK( SwCaptionDialog, ModifyHdl, Edit *, EMPTYARG ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 350cdf0e10cSrcweir String sFldTypeName = aCategoryBox.GetText(); 351cdf0e10cSrcweir sal_Bool bCorrectFldName = sFldTypeName.Len() > 0; 352cdf0e10cSrcweir sal_Bool bNone = sFldTypeName == sNone; 353cdf0e10cSrcweir SwFieldType* pType = (bCorrectFldName && !bNone) 354cdf0e10cSrcweir ? rSh.GetFldType( RES_SETEXPFLD, sFldTypeName ) 355cdf0e10cSrcweir : 0; 356cdf0e10cSrcweir aOKButton.Enable( bCorrectFldName && 357cdf0e10cSrcweir (!pType || 358cdf0e10cSrcweir ((SwSetExpFieldType*)pType)->GetType() == nsSwGetSetExpType::GSE_SEQ) 359cdf0e10cSrcweir && 0 != sFldTypeName.Len() ); 360cdf0e10cSrcweir aOptionButton.Enable( aOKButton.IsEnabled() && !bNone ); 361cdf0e10cSrcweir aFormatText.Enable( !bNone ); 362cdf0e10cSrcweir aFormatBox.Enable( !bNone ); 363cdf0e10cSrcweir aSepText.Enable( !bNone ); 364cdf0e10cSrcweir aSepEdit.Enable( !bNone ); 365cdf0e10cSrcweir DrawSample(); 366cdf0e10cSrcweir return 0; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir IMPL_LINK(SwCaptionDialog, CaptionHdl, PushButton*, EMPTYARG) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir SfxItemSet aSet( rView.GetDocShell()->GetDoc()->GetAttrPool() ); 372cdf0e10cSrcweir SwCaptionOptDlg aDlg( this, aSet ); 373cdf0e10cSrcweir aDlg.Execute(); 374cdf0e10cSrcweir 375cdf0e10cSrcweir return 0; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir void SwCaptionDialog::DrawSample() 379cdf0e10cSrcweir { 380cdf0e10cSrcweir String aStr; 381cdf0e10cSrcweir String sCaption = aTextEdit.GetText(); 382cdf0e10cSrcweir 383cdf0e10cSrcweir // Nummer 384cdf0e10cSrcweir String sFldTypeName = aCategoryBox.GetText(); 385cdf0e10cSrcweir sal_Bool bNone = sFldTypeName == sNone; 386cdf0e10cSrcweir if( !bNone ) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir sal_uInt16 nNumFmt = (sal_uInt16)(sal_uIntPtr)aFormatBox.GetEntryData( 389cdf0e10cSrcweir aFormatBox.GetSelectEntryPos() ); 390cdf0e10cSrcweir if( SVX_NUM_NUMBER_NONE != nNumFmt ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir // Kategorie 393cdf0e10cSrcweir //#i61007# order of captions 394cdf0e10cSrcweir if( !bOrderNumberingFirst ) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir aStr += sFldTypeName; 397cdf0e10cSrcweir if ( aStr.Len() > 0 ) 398cdf0e10cSrcweir aStr += ' '; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 402cdf0e10cSrcweir SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType( 403cdf0e10cSrcweir RES_SETEXPFLD, sFldTypeName ); 404cdf0e10cSrcweir if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir sal_Int8 nLvl = pFldType->GetOutlineLvl(); 407cdf0e10cSrcweir SwNumberTree::tNumberVector aNumVector; 408cdf0e10cSrcweir for( sal_Int8 i = 0; i <= nLvl; ++i ) 409cdf0e10cSrcweir aNumVector.push_back(1); 410cdf0e10cSrcweir 411cdf0e10cSrcweir String sNumber( rSh.GetOutlineNumRule()-> 412cdf0e10cSrcweir MakeNumString(aNumVector, sal_False )); 413cdf0e10cSrcweir if( sNumber.Len() ) 414cdf0e10cSrcweir (aStr += sNumber) += pFldType->GetDelimiter(); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir switch( nNumFmt ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir case SVX_NUM_CHARS_UPPER_LETTER: aStr += 'A'; break; 420cdf0e10cSrcweir case SVX_NUM_CHARS_UPPER_LETTER_N: aStr += 'A'; break; 421cdf0e10cSrcweir case SVX_NUM_CHARS_LOWER_LETTER: aStr += 'a'; break; 422cdf0e10cSrcweir case SVX_NUM_CHARS_LOWER_LETTER_N: aStr += 'a'; break; 423cdf0e10cSrcweir case SVX_NUM_ROMAN_UPPER: aStr += 'I'; break; 424cdf0e10cSrcweir case SVX_NUM_ROMAN_LOWER: aStr += 'i'; break; 425cdf0e10cSrcweir //case ARABIC: 426cdf0e10cSrcweir default: aStr += '1'; break; 427cdf0e10cSrcweir } 428cdf0e10cSrcweir //#i61007# order of captions 429cdf0e10cSrcweir if( bOrderNumberingFirst ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir aStr += aNumberingSeparatorED.GetText(); 432cdf0e10cSrcweir aStr += sFldTypeName; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir } 436cdf0e10cSrcweir if( sCaption.Len() > 0 ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir aStr += aSepEdit.GetText(); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir } 441cdf0e10cSrcweir aStr += sCaption; 442cdf0e10cSrcweir // do preview! 443cdf0e10cSrcweir aPrevWin.SetPreviewText( aStr ); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir void SwCaptionDialog::CheckButtonWidth() 447cdf0e10cSrcweir { 448cdf0e10cSrcweir // check if the text of the AutoCaption button is to wide 449cdf0e10cSrcweir const long nOffset = 10; 450cdf0e10cSrcweir String sText = aAutoCaptionButton.GetText(); 451cdf0e10cSrcweir long nTxtW = aAutoCaptionButton.GetTextWidth( sText ); 452cdf0e10cSrcweir if ( sText.Search( '~' ) == STRING_NOTFOUND ) 453cdf0e10cSrcweir nTxtW += nOffset; 454cdf0e10cSrcweir long nBtnW = aAutoCaptionButton.GetSizePixel().Width(); 455cdf0e10cSrcweir if ( nTxtW > nBtnW ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir // then broaden all buttons 458cdf0e10cSrcweir Size aNewSize; 459cdf0e10cSrcweir long nDelta = Max( ( nTxtW - nBtnW ), nOffset ); 460cdf0e10cSrcweir Button* pBtns[] = 461cdf0e10cSrcweir { 462cdf0e10cSrcweir &aOKButton, &aCancelButton, &aHelpButton, &aAutoCaptionButton, &aOptionButton 463cdf0e10cSrcweir }; 464cdf0e10cSrcweir Button** pCurrent = pBtns; 465cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < sizeof( pBtns ) / sizeof( pBtns[ 0 ] ); ++i, ++pCurrent ) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir aNewSize = (*pCurrent)->GetSizePixel(); 468cdf0e10cSrcweir aNewSize.Width() += nDelta; 469cdf0e10cSrcweir (*pCurrent)->SetSizePixel( aNewSize ); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir // and the dialog 472cdf0e10cSrcweir aNewSize = GetOutputSizePixel(); 473cdf0e10cSrcweir aNewSize.Width() += nDelta; 474cdf0e10cSrcweir SetOutputSizePixel( aNewSize ); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir } 477cdf0e10cSrcweir 478cdf0e10cSrcweir SwCaptionDialog::~SwCaptionDialog() 479cdf0e10cSrcweir { 480cdf0e10cSrcweir delete pMgr; 481cdf0e10cSrcweir } 482*1dda6fa0Smseidel /* */ 483cdf0e10cSrcweir 484cdf0e10cSrcweir 485cdf0e10cSrcweir SwSequenceOptionDialog::SwSequenceOptionDialog( Window *pParent, SwView &rV, 486cdf0e10cSrcweir const String& rSeqFldType ) 487cdf0e10cSrcweir : SvxStandardDialog( pParent, SW_RES(DLG_SEQUENCE_OPTION) ), 488cdf0e10cSrcweir aFlHeader (this, SW_RES(FL_HEADER )), 489cdf0e10cSrcweir aFtLevel (this, SW_RES(FT_LEVEL )), 490cdf0e10cSrcweir aLbLevel (this, SW_RES(LB_LEVEL )), 491cdf0e10cSrcweir aFtDelim (this, SW_RES(FT_SEPARATOR )), 492cdf0e10cSrcweir aEdDelim (this, SW_RES(ED_SEPARATOR )), 493cdf0e10cSrcweir aFlCatAndFrame (this, SW_RES(FL_CATANDFRAME)), 494cdf0e10cSrcweir aFtCharStyle (this, SW_RES(FT_CHARSTYLE )), 495cdf0e10cSrcweir aLbCharStyle (this, SW_RES(LB_CHARSTYLE )), 496cdf0e10cSrcweir aApplyBorderAndShadowCB(this, SW_RES(CB_APPLYBAS)), 497cdf0e10cSrcweir aFlCaptionOrder(this, SW_RES( FL_ORDER )), //#i61007# order of captions 498cdf0e10cSrcweir aFtCaptionOrder(this, SW_RES( FT_ORDER )), 499cdf0e10cSrcweir aLbCaptionOrder(this, SW_RES( LB_ORDER )), 500cdf0e10cSrcweir aOKButton (this, SW_RES(BTN_OK )), 501cdf0e10cSrcweir aCancelButton (this, SW_RES(BTN_CANCEL )), 502cdf0e10cSrcweir aHelpButton (this, SW_RES(BTN_HELP )), 503cdf0e10cSrcweir 504cdf0e10cSrcweir rView( rV ), 505cdf0e10cSrcweir aFldTypeName( rSeqFldType ) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir FreeResource(); 508cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 509cdf0e10cSrcweir 510cdf0e10cSrcweir for( sal_uInt16 n = 0; n < MAXLEVEL; ++n ) 511cdf0e10cSrcweir aLbLevel.InsertEntry( String::CreateFromInt32(n+1) ); 512cdf0e10cSrcweir 513cdf0e10cSrcweir SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType( 514cdf0e10cSrcweir RES_SETEXPFLD, aFldTypeName ); 515cdf0e10cSrcweir 516cdf0e10cSrcweir sal_Unicode nLvl = MAXLEVEL; 517cdf0e10cSrcweir String sDelim( String::CreateFromAscii( ": " ) ); 518cdf0e10cSrcweir if( pFldType ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir sDelim = pFldType->GetDelimiter(); 521cdf0e10cSrcweir nLvl = pFldType->GetOutlineLvl(); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 ); 525cdf0e10cSrcweir aEdDelim.SetText( sDelim ); 526cdf0e10cSrcweir 527cdf0e10cSrcweir ::FillCharStyleListBox( aLbCharStyle, rView.GetDocShell(), sal_True, sal_True ); 528cdf0e10cSrcweir aLbCharStyle.SelectEntryPos( 0 ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir SwSequenceOptionDialog::~SwSequenceOptionDialog() 532cdf0e10cSrcweir { 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir void SwSequenceOptionDialog::Apply() 536cdf0e10cSrcweir { 537cdf0e10cSrcweir SwWrtShell &rSh = rView.GetWrtShell(); 538cdf0e10cSrcweir SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType( 539cdf0e10cSrcweir RES_SETEXPFLD, aFldTypeName ); 540cdf0e10cSrcweir 541cdf0e10cSrcweir sal_Int8 nLvl = (sal_Int8)( aLbLevel.GetSelectEntryPos() - 1); 542cdf0e10cSrcweir sal_Unicode cDelim = aEdDelim.GetText().GetChar(0); 543cdf0e10cSrcweir 544cdf0e10cSrcweir sal_Bool bUpdate = sal_True; 545cdf0e10cSrcweir if( pFldType ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir pFldType->SetDelimiter( cDelim ); 548cdf0e10cSrcweir pFldType->SetOutlineLvl( nLvl ); 549cdf0e10cSrcweir } 550cdf0e10cSrcweir else if( aFldTypeName.Len() && nLvl < MAXLEVEL ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir // dann muessen wir das mal einfuegen 553cdf0e10cSrcweir SwSetExpFieldType aFldType( rSh.GetDoc(), aFldTypeName, nsSwGetSetExpType::GSE_SEQ ); 554cdf0e10cSrcweir aFldType.SetDelimiter( cDelim ); 555cdf0e10cSrcweir aFldType.SetOutlineLvl( nLvl ); 556cdf0e10cSrcweir rSh.InsertFldType( aFldType ); 557cdf0e10cSrcweir } 558cdf0e10cSrcweir else 559cdf0e10cSrcweir bUpdate = sal_False; 560cdf0e10cSrcweir 561cdf0e10cSrcweir if( bUpdate ) 562cdf0e10cSrcweir rSh.UpdateExpFlds(); 563cdf0e10cSrcweir } 564cdf0e10cSrcweir 565cdf0e10cSrcweir /*-- 24.08.2004 16:13:53--------------------------------------------------- 566cdf0e10cSrcweir 567cdf0e10cSrcweir -----------------------------------------------------------------------*/ 568cdf0e10cSrcweir String SwSequenceOptionDialog::GetCharacterStyle() const 569cdf0e10cSrcweir { 570cdf0e10cSrcweir String sRet; 571cdf0e10cSrcweir if(aLbCharStyle.GetSelectEntryPos()) 572cdf0e10cSrcweir sRet = aLbCharStyle.GetSelectEntry(); 573cdf0e10cSrcweir return sRet; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir 576cdf0e10cSrcweir /*-- 24.08.2004 16:14:00--------------------------------------------------- 577cdf0e10cSrcweir 578cdf0e10cSrcweir -----------------------------------------------------------------------*/ 579cdf0e10cSrcweir void SwSequenceOptionDialog::SetCharacterStyle(const String& rStyle) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir aLbCharStyle.SelectEntryPos(0); 582cdf0e10cSrcweir aLbCharStyle.SelectEntry(rStyle); 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir long SwCaptionDialog::CategoryBox::PreNotify( NotifyEvent& rNEvt ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir long nHandled = 0; 588cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_KEYINPUT && 589cdf0e10cSrcweir rNEvt.GetKeyEvent()->GetCharCode() ) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir const KeyEvent* pEvent = rNEvt.GetKeyEvent(); 592cdf0e10cSrcweir const KeyCode& rKeyCode = pEvent->GetKeyCode(); 593cdf0e10cSrcweir sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE; 594cdf0e10cSrcweir 595cdf0e10cSrcweir if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN 596cdf0e10cSrcweir && nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir String sKey( pEvent->GetCharCode() ), sName( GetText() ); 599cdf0e10cSrcweir Selection aSel( GetSelection() ); 600cdf0e10cSrcweir aSel.Justify(); 601cdf0e10cSrcweir if( aSel.Len() ) 602cdf0e10cSrcweir sName.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() ); 603cdf0e10cSrcweir sName.Insert( sKey, (xub_StrLen)aSel.Min() ); 604cdf0e10cSrcweir if( !SwCalc::IsValidVarName( sName )) 605cdf0e10cSrcweir nHandled = 1; 606cdf0e10cSrcweir } 607cdf0e10cSrcweir } 608cdf0e10cSrcweir if(!nHandled) 609cdf0e10cSrcweir nHandled = ComboBox::PreNotify( rNEvt ); 610cdf0e10cSrcweir return nHandled; 611cdf0e10cSrcweir } 612cdf0e10cSrcweir /*-- 01.11.2007 10:45:51--------------------------------------------------- 613cdf0e10cSrcweir //#i61007# order of captions 614cdf0e10cSrcweir -----------------------------------------------------------------------*/ 615cdf0e10cSrcweir void lcl_MoveH( Window& rWin, sal_Int32 nMove ) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir Point aPos( rWin.GetPosPixel() ); 618cdf0e10cSrcweir aPos.Y() += nMove; 619cdf0e10cSrcweir rWin.SetPosPixel(aPos); 620cdf0e10cSrcweir } 621cdf0e10cSrcweir void SwCaptionDialog::ApplyCaptionOrder() 622cdf0e10cSrcweir { 623cdf0e10cSrcweir //have the settings changed? 624cdf0e10cSrcweir bool bVisible = aNumberingSeparatorED.IsVisible() != 0; 625cdf0e10cSrcweir if( bOrderNumberingFirst != bVisible ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir sal_Int32 nDiff = aPosBox.GetPosPixel().Y() - aSepEdit.GetPosPixel().Y(); 628cdf0e10cSrcweir 629cdf0e10cSrcweir aNumberingSeparatorFT.Show( bOrderNumberingFirst ); 630cdf0e10cSrcweir aNumberingSeparatorED.Show( bOrderNumberingFirst ); 631cdf0e10cSrcweir if( !bOrderNumberingFirst ) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir nDiff = -nDiff; 634cdf0e10cSrcweir } 635cdf0e10cSrcweir lcl_MoveH( aCategoryText, 2 * nDiff); 636cdf0e10cSrcweir lcl_MoveH( aFormatText, -nDiff ); 637cdf0e10cSrcweir lcl_MoveH( aFormatBox, -nDiff ); 638cdf0e10cSrcweir lcl_MoveH( aCategoryBox, 2 * nDiff); 639cdf0e10cSrcweir lcl_MoveH( aSepText, nDiff ); 640cdf0e10cSrcweir lcl_MoveH( aSepEdit, nDiff ); 641cdf0e10cSrcweir lcl_MoveH( aPosText, nDiff ); 642cdf0e10cSrcweir lcl_MoveH( aPosBox, nDiff ); 643cdf0e10cSrcweir lcl_MoveH( aPrevWin, nDiff ); 644cdf0e10cSrcweir Size aDlgSize( GetSizePixel() ); 645cdf0e10cSrcweir aDlgSize.Height() += nDiff; 646cdf0e10cSrcweir SetSizePixel( aDlgSize ); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir } 649