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