xref: /aoo42x/main/sw/source/ui/chrdlg/pardlg.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #ifdef SW_DLLIMPLEMENTATION
28 #undef SW_DLLIMPLEMENTATION
29 #endif
30 
31 
32 #include "hintids.hxx"
33 #include <svx/htmlmode.hxx>
34 #include <svl/style.hxx>
35 
36 #include <svtools/htmlcfg.hxx>
37 
38 #ifndef _SVSTDARR_STRINGSSORTDTOR
39 #define _SVSTDARR_STRINGSSORTDTOR
40 #include <svl/svstdarr.hxx>
41 #endif
42 #include <svl/cjkoptions.hxx>
43 #include "docsh.hxx"
44 #include "wrtsh.hxx"
45 #include "frmatr.hxx"
46 #include "view.hxx"
47 #include "globals.hrc"
48 #include "swuipardlg.hxx"
49 #include "pagedesc.hxx"
50 #include "paratr.hxx"
51 #include "drpcps.hxx"
52 #include "uitool.hxx"
53 #include "viewopt.hxx"
54 #include <numpara.hxx>
55 #include "chrdlg.hrc"
56 #include "poolfmt.hrc"
57 #include <svx/svxids.hrc>
58 #include <svl/eitem.hxx>
59 #include <svl/intitem.hxx>
60 #include <svx/svxdlg.hxx>
61 #include <svx/dialogs.hrc>
62 #include <svx/flagsdef.hxx>
63 // STATIC DATA -----------------------------------------------------------
64 
65 
66 SwParaDlg::SwParaDlg(Window *pParent,
67 					SwView& rVw,
68 					const SfxItemSet& rCoreSet,
69 					sal_uInt8 nDialogMode,
70 					const String *pTitle,
71 					sal_Bool bDraw,
72 					sal_uInt16 nDefPage):
73 
74 	SfxTabDialog(pParent, bDraw ? SW_RES(DLG_DRAWPARA) : SW_RES(DLG_PARA),
75 					&rCoreSet,  0 != pTitle),
76 
77 	rView(rVw),
78 	nDlgMode(nDialogMode),
79 	bDrawParaDlg(bDraw)
80 
81 {
82 	FreeResource();
83 
84 	nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
85     sal_Bool bHtmlMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
86 	if(pTitle)
87 	{
88 			// Update des Titels
89 		String aTmp( GetText() );
90 		aTmp += SW_RESSTR(STR_TEXTCOLL_HEADER);
91 		aTmp += *pTitle;
92 		aTmp += ')';
93 		SetText(aTmp);
94 	}
95 	SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
96 
97     DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
98     DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
99 	AddTabPage( TP_PARA_STD,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
100 
101     DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
102     DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
103 	AddTabPage( TP_PARA_ALIGN,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH) );
104 
105     SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
106 	if (!bDrawParaDlg && (!bHtmlMode || pHtmlOpt->IsPrintLayoutExtension()))
107 	{
108         DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
109         DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
110 		AddTabPage( TP_PARA_EXT,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH) );
111 
112 	}
113 	else
114 		RemoveTabPage(TP_PARA_EXT);
115 
116     SvtCJKOptions aCJKOptions;
117     if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
118 	{
119         DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
120         DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
121 		AddTabPage( TP_PARA_ASIAN,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
122 	}
123 	else
124 		RemoveTabPage(TP_PARA_ASIAN);
125 
126 	sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
127 	sal_Bool bLRValid = SFX_ITEM_AVAILABLE <= rCoreSet.GetItemState(nWhich);
128 	if(bHtmlMode || !bLRValid)
129 		RemoveTabPage(TP_TABULATOR);
130 	else
131 	{
132         DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
133         DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
134 		AddTabPage( TP_TABULATOR,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
135 
136 	}
137 	if (!bDrawParaDlg)
138 	{
139 		if(!(nDlgMode & DLG_ENVELOP))
140 			AddTabPage(TP_NUMPARA,   SwParagraphNumTabPage::Create,SwParagraphNumTabPage::GetRanges);
141 		else
142 			RemoveTabPage(TP_NUMPARA);
143 		if(!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES))
144 		{
145 			AddTabPage(TP_DROPCAPS,  SwDropCapsPage::Create, 		SwDropCapsPage::GetRanges);
146 		}
147 		else
148 		{
149 			RemoveTabPage(TP_DROPCAPS);
150 		}
151 		if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
152 		{
153             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
154             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
155             AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
156 		}
157 		else
158 		{
159 			RemoveTabPage(TP_BACKGROUND);
160 		}
161 		if(!bHtmlMode || (nHtmlMode & HTMLMODE_PARA_BORDER))
162 		{
163             DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
164             DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
165             AddTabPage(TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
166 		}
167 		else
168 			RemoveTabPage(TP_BORDER);
169 	}
170 
171 	if (nDefPage)
172 		SetCurPageId(nDefPage);
173 }
174 
175 
176 __EXPORT SwParaDlg::~SwParaDlg()
177 {
178 }
179 
180 
181 void __EXPORT SwParaDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage)
182 {
183 	SwWrtShell& rSh = rView.GetWrtShell();
184     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
185 
186 	// Bei Tabellenumrandung kann im Writer kein Schatten eingestellt werden
187 	if (nId == TP_BORDER)
188 	{
189 		aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA));
190 		rPage.PageCreated(aSet);
191 	}
192 	else if( nId == TP_PARA_STD )
193 	{
194         aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
195                             static_cast< sal_uInt16 >(rSh.GetAnyCurRect(RECT_PAGE_PRT).Width()) ));
196 
197 		if (!bDrawParaDlg)
198         {
199             aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x000E));
200             aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
201 
202 		}
203         rPage.PageCreated(aSet);
204 	}
205 	else if( TP_PARA_ALIGN == nId)
206 	{
207 		if (!bDrawParaDlg)
208 		{
209 			aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,sal_True));
210             rPage.PageCreated(aSet);
211 		}
212 	}
213 	else if( TP_PARA_EXT == nId )
214 	{
215 		// Seitenumbruch nur, wenn der Cursor im Body-Bereich und nicht in
216 		// einer Tabelle steht
217 		const sal_uInt16 eType = rSh.GetFrmType(0,sal_True);
218 		if( !(FRMTYPE_BODY & eType) ||
219 			rSh.GetSelectionType() & nsSelectionType::SEL_TBL )
220 		{
221 			aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,sal_True));
222             rPage.PageCreated(aSet);
223 		}
224 	}
225 	else if( TP_DROPCAPS == nId )
226 	{
227 		((SwDropCapsPage&)rPage).SetFormat(sal_False);
228 	}
229 	else if( TP_BACKGROUND == nId )
230 	{
231 	  if(!( nHtmlMode & HTMLMODE_ON ) ||
232 		nHtmlMode & HTMLMODE_SOME_STYLES)
233         {
234 			aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
235 			rPage.PageCreated(aSet);
236 		}
237 	}
238 	else if( TP_NUMPARA == nId)
239 	{
240 		//-->#outline level,added by zhaojianwei
241 		SwTxtFmtColl* pTmpColl = rSh.GetCurTxtFmtColl();
242 		if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
243 		{
244 			((SwParagraphNumTabPage&)rPage).DisableOutline() ;
245 		}//<-end
246 
247 		((SwParagraphNumTabPage&)rPage).EnableNewStart();
248 		ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox();
249 		SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool();
250 		pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL);
251 		const SfxStyleSheetBase* pBase = pPool->First();
252         SvStringsSortDtor aNames;
253 		while(pBase)
254 		{
255 			aNames.Insert(new String(pBase->GetName()));
256 			pBase = pPool->Next();
257 		}
258 		for(sal_uInt16 i = 0; i < aNames.Count(); i++)
259 			rBox.InsertEntry(*aNames.GetObject(i));
260 	}
261 
262 }
263 
264 
265 
266