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: pardlg.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"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
39 #include "hintids.hxx"
40 #include <svx/htmlmode.hxx>
41 #include <svtools/style.hxx>
43 #include <svx/htmlcfg.hxx>
45 #ifndef _SVSTDARR_STRINGSSORTDTOR
46 #define _SVSTDARR_STRINGSSORTDTOR
47 #include <svtools/svstdarr.hxx>
49 #include <svtools/cjkoptions.hxx>
54 #include "globals.hrc"
55 #include "swuipardlg.hxx"
56 #include "pagedesc.hxx"
60 #include "viewopt.hxx"
61 #include <numpara.hxx>
63 #include "poolfmt.hrc"
64 #include <svx/svxids.hrc>
65 #include <svtools/eitem.hxx>
66 #include <svtools/intitem.hxx>
67 #include <svx/svxdlg.hxx>
68 #include <svx/dialogs.hrc>
69 #include <svx/flagsdef.hxx>
70 // STATIC DATA -----------------------------------------------------------
73 SwParaDlg::SwParaDlg(Window
*pParent
,
75 const SfxItemSet
& rCoreSet
,
81 SfxTabDialog(pParent
, bDraw
? SW_RES(DLG_DRAWPARA
) : SW_RES(DLG_PARA
),
82 &rCoreSet
, 0 != pTitle
),
85 nDlgMode(nDialogMode
),
91 nHtmlMode
= ::GetHtmlMode(rVw
.GetDocShell());
92 BOOL bHtmlMode
= static_cast< BOOL
>(nHtmlMode
& HTMLMODE_ON
);
96 String
aTmp( GetText() );
97 aTmp
+= SW_RESSTR(STR_TEXTCOLL_HEADER
);
102 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
104 DBG_ASSERT(pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH
), "GetTabPageCreatorFunc fail!");
105 DBG_ASSERT(pFact
->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH
), "GetTabPageRangesFunc fail!");
106 AddTabPage( TP_PARA_STD
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH
) );
108 DBG_ASSERT(pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH
), "GetTabPageCreatorFunc fail!");
109 DBG_ASSERT(pFact
->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH
), "GetTabPageRangesFunc fail!");
110 AddTabPage( TP_PARA_ALIGN
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH
) );
112 SvxHtmlOptions
* pHtmlOpt
= SvxHtmlOptions::Get();
113 if (!bDrawParaDlg
&& (!bHtmlMode
|| pHtmlOpt
->IsPrintLayoutExtension()))
115 DBG_ASSERT(pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH
), "GetTabPageCreatorFunc fail!");
116 DBG_ASSERT(pFact
->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH
), "GetTabPageRangesFunc fail!");
117 AddTabPage( TP_PARA_EXT
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH
) );
121 RemoveTabPage(TP_PARA_EXT
);
123 SvtCJKOptions aCJKOptions
;
124 if(!bHtmlMode
&& aCJKOptions
.IsAsianTypographyEnabled())
126 DBG_ASSERT(pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN
), "GetTabPageCreatorFunc fail!");
127 DBG_ASSERT(pFact
->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN
), "GetTabPageRangesFunc fail!");
128 AddTabPage( TP_PARA_ASIAN
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN
) );
131 RemoveTabPage(TP_PARA_ASIAN
);
133 USHORT
nWhich(rCoreSet
.GetPool()->GetWhich(SID_ATTR_LRSPACE
));
134 BOOL bLRValid
= SFX_ITEM_AVAILABLE
<= rCoreSet
.GetItemState(nWhich
);
135 if(bHtmlMode
|| !bLRValid
)
136 RemoveTabPage(TP_TABULATOR
);
139 DBG_ASSERT(pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR
), "GetTabPageCreatorFunc fail!");
140 DBG_ASSERT(pFact
->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR
), "GetTabPageRangesFunc fail!");
141 AddTabPage( TP_TABULATOR
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR
) );
146 if(!(nDlgMode
& DLG_ENVELOP
))
147 AddTabPage(TP_NUMPARA
, SwParagraphNumTabPage::Create
,SwParagraphNumTabPage::GetRanges
);
149 RemoveTabPage(TP_NUMPARA
);
150 if(!bHtmlMode
|| (nHtmlMode
& HTMLMODE_FULL_STYLES
))
152 AddTabPage(TP_DROPCAPS
, SwDropCapsPage::Create
, SwDropCapsPage::GetRanges
);
156 RemoveTabPage(TP_DROPCAPS
);
158 if(!bHtmlMode
|| (nHtmlMode
& (HTMLMODE_SOME_STYLES
|HTMLMODE_FULL_STYLES
)))
160 DBG_ASSERT(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), "GetTabPageCreatorFunc fail!");
161 DBG_ASSERT(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND
), "GetTabPageRangesFunc fail!");
162 AddTabPage(TP_BACKGROUND
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND
) );
166 RemoveTabPage(TP_BACKGROUND
);
168 if(!bHtmlMode
|| (nHtmlMode
& HTMLMODE_PARA_BORDER
))
170 DBG_ASSERT(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), "GetTabPageCreatorFunc fail!");
171 DBG_ASSERT(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
), "GetTabPageRangesFunc fail!");
172 AddTabPage(TP_BORDER
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
) );
175 RemoveTabPage(TP_BORDER
);
179 SetCurPageId(nDefPage
);
183 __EXPORT
SwParaDlg::~SwParaDlg()
188 void __EXPORT
SwParaDlg::PageCreated(USHORT nId
, SfxTabPage
& rPage
)
190 SwWrtShell
& rSh
= rView
.GetWrtShell();
191 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
193 // Bei Tabellenumrandung kann im Writer kein Schatten eingestellt werden
194 if (nId
== TP_BORDER
)
196 aSet
.Put (SfxUInt16Item(SID_SWMODE_TYPE
,SW_BORDER_MODE_PARA
));
197 rPage
.PageCreated(aSet
);
199 else if( nId
== TP_PARA_STD
)
201 aSet
.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH
,
202 static_cast< UINT16
>(rSh
.GetAnyCurRect(RECT_PAGE_PRT
).Width()) ));
206 aSet
.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET
,0x000E));
207 aSet
.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST
, MM50
/10));
210 rPage
.PageCreated(aSet
);
212 else if( TP_PARA_ALIGN
== nId
)
216 aSet
.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT
,TRUE
));
217 rPage
.PageCreated(aSet
);
220 else if( TP_PARA_EXT
== nId
)
222 // Seitenumbruch nur, wenn der Cursor im Body-Bereich und nicht in
223 // einer Tabelle steht
224 const USHORT eType
= rSh
.GetFrmType(0,TRUE
);
225 if( !(FRMTYPE_BODY
& eType
) ||
226 rSh
.GetSelectionType() & nsSelectionType::SEL_TBL
)
228 aSet
.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK
,TRUE
));
229 rPage
.PageCreated(aSet
);
232 else if( TP_DROPCAPS
== nId
)
234 ((SwDropCapsPage
&)rPage
).SetFormat(FALSE
);
236 else if( TP_BACKGROUND
== nId
)
238 if(!( nHtmlMode
& HTMLMODE_ON
) ||
239 nHtmlMode
& HTMLMODE_SOME_STYLES
)
241 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
, SVX_SHOW_SELECTOR
));
242 rPage
.PageCreated(aSet
);
245 else if( TP_NUMPARA
== nId
)
247 //-->#outline level,added by zhaojianwei
248 SwTxtFmtColl
* pTmpColl
= rSh
.GetCurTxtFmtColl();
249 if( pTmpColl
&& pTmpColl
->IsAssignedToListLevelOfOutlineStyle() )
251 ((SwParagraphNumTabPage
&)rPage
).DisableOutline() ;
254 ((SwParagraphNumTabPage
&)rPage
).EnableNewStart();
255 ListBox
& rBox
= ((SwParagraphNumTabPage
&)rPage
).GetStyleBox();
256 SfxStyleSheetBasePool
* pPool
= rView
.GetDocShell()->GetStyleSheetPool();
257 pPool
->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO
, SFXSTYLEBIT_ALL
);
258 const SfxStyleSheetBase
* pBase
= pPool
->First();
259 SvStringsSortDtor aNames
;
262 aNames
.Insert(new String(pBase
->GetName()));
263 pBase
= pPool
->Next();
265 for(USHORT i
= 0; i
< aNames
.Count(); i
++)
266 rBox
.InsertEntry(*aNames
.GetObject(i
));