update dev300-m58
[ooovba.git] / sw / source / ui / chrdlg / pardlg.cxx
blobd23a4821879a900ed27a5fbacafa6523050ba8c4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pardlg.cxx,v $
10 * $Revision: 1.15 $
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
36 #endif
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>
48 #endif
49 #include <svtools/cjkoptions.hxx>
50 #include "docsh.hxx"
51 #include "wrtsh.hxx"
52 #include "frmatr.hxx"
53 #include "view.hxx"
54 #include "globals.hrc"
55 #include "swuipardlg.hxx"
56 #include "pagedesc.hxx"
57 #include "paratr.hxx"
58 #include "drpcps.hxx"
59 #include "uitool.hxx"
60 #include "viewopt.hxx"
61 #include <numpara.hxx>
62 #include "chrdlg.hrc"
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,
74 SwView& rVw,
75 const SfxItemSet& rCoreSet,
76 BYTE nDialogMode,
77 const String *pTitle,
78 BOOL bDraw,
79 UINT16 nDefPage):
81 SfxTabDialog(pParent, bDraw ? SW_RES(DLG_DRAWPARA) : SW_RES(DLG_PARA),
82 &rCoreSet, 0 != pTitle),
84 rView(rVw),
85 nDlgMode(nDialogMode),
86 bDrawParaDlg(bDraw)
89 FreeResource();
91 nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
92 BOOL bHtmlMode = static_cast< BOOL >(nHtmlMode & HTMLMODE_ON);
93 if(pTitle)
95 // Update des Titels
96 String aTmp( GetText() );
97 aTmp += SW_RESSTR(STR_TEXTCOLL_HEADER);
98 aTmp += *pTitle;
99 aTmp += ')';
100 SetText(aTmp);
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) );
120 else
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) );
130 else
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);
137 else
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) );
144 if (!bDrawParaDlg)
146 if(!(nDlgMode & DLG_ENVELOP))
147 AddTabPage(TP_NUMPARA, SwParagraphNumTabPage::Create,SwParagraphNumTabPage::GetRanges);
148 else
149 RemoveTabPage(TP_NUMPARA);
150 if(!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES))
152 AddTabPage(TP_DROPCAPS, SwDropCapsPage::Create, SwDropCapsPage::GetRanges);
154 else
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 ) );
164 else
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 ) );
174 else
175 RemoveTabPage(TP_BORDER);
178 if (nDefPage)
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()) ));
204 if (!bDrawParaDlg)
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)
214 if (!bDrawParaDlg)
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() ;
252 }//<-end
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;
260 while(pBase)
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));