1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtnum.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
36 #ifndef _MSGBOX_HXX //autogen
37 #include <vcl/msgbox.hxx>
39 #include <sfx2/request.hxx>
40 #include <svtools/eitem.hxx>
41 #include <svtools/stritem.hxx>
42 #include <svx/numitem.hxx>
43 #include <svx/brshitem.hxx>
44 #include <numrule.hxx>
49 #include "viewopt.hxx"
52 #include "uiitems.hxx"
53 #include "swabstdlg.hxx"
54 #include <globals.hrc>
55 #include <sfx2/tabdlg.hxx>
57 void SwTextShell::ExecEnterNum(SfxRequest
&rReq
)
59 //wg. Aufzeichnung schon vor dem evtl. Shellwechsel
60 switch(rReq
.GetSlot())
62 case FN_NUM_NUMBERING_ON
:
64 SFX_REQUEST_ARG( rReq
, pItem
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
65 BOOL bMode
= !GetShell().HasNumber(); // #i29560#
67 bMode
= pItem
->GetValue();
69 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bMode
) );
71 if ( bMode
!= (GetShell().HasNumber()) ) // #i29560#
77 GetShell().NumOrBulletOff(); // #i29560#
81 case FN_NUM_BULLET_ON
:
83 SFX_REQUEST_ARG( rReq
, pItem
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
84 BOOL bMode
= !GetShell().HasBullet(); // #i29560#
86 bMode
= pItem
->GetValue();
88 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bMode
) );
90 if ( bMode
!= (GetShell().HasBullet()) ) // #i29560#
94 GetShell().BulletOn();
96 GetShell().NumOrBulletOff(); // #i29560#
100 case FN_NUMBER_BULLETS
:
102 // --> OD 2008-02-29 #refactorlists#
103 // // per default TRUE, damit die Schleife im Dialog richtig arbeitet!
104 // BOOL bHasChild = TRUE;
106 SfxItemSet
aSet(GetPool(),
107 SID_HTML_MODE
, SID_HTML_MODE
,
108 SID_ATTR_NUMBERING_RULE
, SID_PARAM_CUR_NUM_LEVEL
,
110 SwDocShell
* pDocSh
= GetView().GetDocShell();
111 BOOL bHtml
= 0 != PTR_CAST(SwWebDocShell
, pDocSh
);
112 const SwNumRule
* pCurRule
= GetShell().GetCurNumRule();
115 SvxNumRule aRule
= pCurRule
->MakeSvxNumRule();
117 //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN)
118 for(USHORT i
= 0; i
< aRule
.GetLevelCount(); i
++)
120 SvxNumberFormat
aFmt(aRule
.GetLevel(i
));
121 if(SVX_NUM_BITMAP
== aFmt
.GetNumberingType())
123 const SvxBrushItem
* pBrush
= aFmt
.GetBrush();
124 const String
* pLinkStr
;
126 0 != (pLinkStr
= pBrush
->GetGraphicLink()) &&
128 aFmt
.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP
|LINK_TOKEN
));
129 aRule
.SetLevel(i
, aFmt
, aRule
.Get(i
) != 0);
133 aRule
.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP
, FALSE
);
135 aSet
.Put(SvxNumBulletItem(aRule
));
136 // --> OD 2008-02-29 #refactorlists# - removed <bHasChild>
137 ASSERT( GetShell().GetNumLevel() < MAXLEVEL
,
138 "<SwTextShell::ExecEnterNum()> - numbered node without valid list level. Serious defect -> please inform OD." );
139 USHORT nLevel
= GetShell().GetNumLevel();
141 if( nLevel
< MAXLEVEL
)
144 aSet
.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL
, nLevel
));
149 // --> OD 2008-02-11 #newlistlevelattrs#
150 SwNumRule
aRule( GetShell().GetUniqueNumRuleName(),
151 // --> OD 2008-06-06 #i89178#
152 numfunc::GetDefaultPositionAndSpaceMode() );
155 SvxNumRule aSvxRule
= aRule
.MakeSvxNumRule();
156 const bool bRightToLeft
= GetShell().IsInRightToLeftText( 0 );
158 if( bHtml
|| bRightToLeft
)
160 for( BYTE n
= 0; n
< MAXLEVEL
; ++n
)
162 SvxNumberFormat
aFmt( aSvxRule
.GetLevel( n
) );
167 aFmt
.SetAbsLSpace(n
* 720);
169 // --> FME 2005-01-21 #i38904# Default alignment for
170 // numbering/bullet should be rtl in rtl paragraph:
173 aFmt
.SetNumAdjust( SVX_ADJUST_RIGHT
);
176 aSvxRule
.SetLevel( n
, aFmt
, FALSE
);
178 aSvxRule
.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP
, FALSE
);
180 aSet
.Put(SvxNumBulletItem(aSvxRule
));
183 aSet
.Put( SfxBoolItem( SID_PARAM_NUM_PRESET
,FALSE
));
185 // vor dem Dialog wird der HtmlMode an der DocShell versenkt
186 pDocSh
->PutItem(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(pDocSh
)));
188 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
189 DBG_ASSERT(pFact
, "Dialogdiet fail!");
190 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET
,
191 GetView().GetWindow(), &aSet
, GetShell());
192 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
193 USHORT nRet
= pDlg
->Execute();
194 const SfxPoolItem
* pItem
;
197 if( SFX_ITEM_SET
== pDlg
->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE
, FALSE
, &pItem
))
199 rReq
.AppendItem(*pItem
);
201 SvxNumRule
* pSetRule
= ((SvxNumBulletItem
*)pItem
)->GetNumRule();
202 pSetRule
->UnLinkGraphics();
203 // --> OD 2008-02-11 #newlistlevelattrs#
204 SwNumRule
aSetRule( pCurRule
205 ? pCurRule
->GetName()
206 : GetShell().GetUniqueNumRuleName(),
207 // --> OD 2008-06-06 #i89178#
208 numfunc::GetDefaultPositionAndSpaceMode() );
211 aSetRule
.SetSvxRule( *pSetRule
, GetShell().GetDoc());
212 aSetRule
.SetAutoRule( TRUE
);
213 // --> OD 2008-03-17 #refactorlists#
214 // No start of new list, if an existing list style is edited.
215 // Otherwise start a new list.
216 const bool bCreateList
= (pCurRule
== 0);
217 GetShell().SetCurNumRule( aSetRule
, bCreateList
);
220 // wenn der Dialog mit OK verlassen wurde, aber nichts ausgewaehlt
221 // wurde dann muss die Numerierung zumindest eingeschaltet werden,
222 // wenn sie das noch nicht ist
223 else if( !pCurRule
&& SFX_ITEM_SET
== aSet
.GetItemState( SID_ATTR_NUMBERING_RULE
, FALSE
, &pItem
))
225 rReq
.AppendItem( *pItem
);
227 SvxNumRule
* pSetRule
= ((SvxNumBulletItem
*)pItem
)->GetNumRule();
228 // --> OD 2008-02-11 #newlistlevelattrs#
229 SwNumRule
aSetRule( GetShell().GetUniqueNumRuleName(),
230 // --> OD 2008-06-06 #i89178#
231 numfunc::GetDefaultPositionAndSpaceMode() );
234 aSetRule
.SetSvxRule(*pSetRule
, GetShell().GetDoc());
235 aSetRule
.SetAutoRule( TRUE
);
236 // --> OD 2008-03-17 #refactorlists#
238 GetShell().SetCurNumRule( aSetRule
, true );
242 else if(RET_USER
== nRet
)
243 GetShell().DelNumRules();
249 ASSERT(FALSE
, falscher Dispatcher
);