xref: /trunk/main/sw/source/ui/chrdlg/pardlg.cxx (revision 56b35d86)
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 
SwParaDlg(Window * pParent,SwView & rVw,const SfxItemSet & rCoreSet,sal_uInt8 nDialogMode,const String * pTitle,sal_Bool bDraw,sal_uInt16 nDefPage)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             //UUUU remove?
154             //DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
155             //DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
156             //AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
157 
158             //UUUU add Area and Transparence TabPages
159             AddTabPage(RID_SVXPAGE_AREA);
160             AddTabPage(RID_SVXPAGE_TRANSPARENCE);
161         }
162 		else
163 		{
164 			//UUUU RemoveTabPage(TP_BACKGROUND);
165             RemoveTabPage(RID_SVXPAGE_AREA);
166             RemoveTabPage(RID_SVXPAGE_TRANSPARENCE);
167 		}
168 		if(!bHtmlMode || (nHtmlMode & HTMLMODE_PARA_BORDER))
169 		{
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 ) );
173 		}
174 		else
175 			RemoveTabPage(TP_BORDER);
176 	}
177 
178 	if (nDefPage)
179 		SetCurPageId(nDefPage);
180 }
181 
182 
~SwParaDlg()183 __EXPORT SwParaDlg::~SwParaDlg()
184 {
185 }
186 
187 
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)188 void __EXPORT SwParaDlg::PageCreated(sal_uInt16 nId,SfxTabPage& rPage)
189 {
190     SwWrtShell& rSh = rView.GetWrtShell();
191     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
192 
193     switch(nId)
194     {
195         case TP_BORDER:
196         {
197             // Bei Tabellenumrandung kann im Writer kein Schatten eingestellt werden
198             aSet.Put(SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA));
199             rPage.PageCreated(aSet);
200             break;
201         }
202         case TP_PARA_STD:
203         {
204             aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
205                 static_cast<sal_uInt16>(rSh.GetAnyCurRect(RECT_PAGE_PRT).Width())));
206 
207             if(!bDrawParaDlg)
208             {
209                 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x000E));
210                 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST,MM50 / 10));
211 
212             }
213             rPage.PageCreated(aSet);
214             break;
215         }
216         case TP_PARA_ALIGN:
217         {
218             if(!bDrawParaDlg)
219             {
220                 aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,sal_True));
221                 rPage.PageCreated(aSet);
222             }
223             break;
224         }
225         case TP_PARA_EXT:
226         {
227             // Seitenumbruch nur, wenn der Cursor im Body-Bereich und nicht in
228             // einer Tabelle steht
229             const sal_uInt16 eType = rSh.GetFrmType(0,sal_True);
230             if(!(FRMTYPE_BODY & eType) ||
231                 rSh.GetSelectionType() & nsSelectionType::SEL_TBL)
232             {
233                 aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,sal_True));
234                 rPage.PageCreated(aSet);
235             }
236             break;
237         }
238         case TP_DROPCAPS:
239         {
240             ((SwDropCapsPage&)rPage).SetFormat(sal_False);
241             break;
242         }
243         case TP_BACKGROUND:
244         {
245             if(!(nHtmlMode & HTMLMODE_ON) ||
246                 nHtmlMode & HTMLMODE_SOME_STYLES)
247             {
248                 aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,SVX_SHOW_SELECTOR));
249                 rPage.PageCreated(aSet);
250             }
251             break;
252         }
253         case TP_NUMPARA:
254         {
255             //-->#outline level,added by zhaojianwei
256             SwTxtFmtColl* pTmpColl = rSh.GetCurTxtFmtColl();
257             if(pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle())
258             {
259                 ((SwParagraphNumTabPage&)rPage).DisableOutline();
260             }//<-end
261 
262             ((SwParagraphNumTabPage&)rPage).EnableNewStart();
263             ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox();
264             SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool();
265             pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO,SFXSTYLEBIT_ALL);
266             const SfxStyleSheetBase* pBase = pPool->First();
267             SvStringsSortDtor aNames;
268             while(pBase)
269             {
270                 aNames.Insert(new String(pBase->GetName()));
271                 pBase = pPool->Next();
272             }
273             for(sal_uInt16 i = 0; i < aNames.Count(); i++)
274                 rBox.InsertEntry(*aNames.GetObject(i));
275             break;
276         }
277 
278         //UUUU inits for Area and Transparency TabPages
279         // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
280         // the color table) need to be added as items (e.g. SvxColorTableItem) to make
281         // these pages find the needed attributes for fill style suggestions.
282         // These are added in SwDocStyleSheet::GetItemSet() for the SFX_STYLE_FAMILY_PARA on
283         // demand, but could also be directly added from the DrawModel.
284         case RID_SVXPAGE_AREA:
285         {
286             SfxItemSet aNew(*aSet.GetPool(),
287                 SID_COLOR_TABLE, SID_BITMAP_LIST,
288                 SID_OFFER_IMPORT, SID_OFFER_IMPORT, 0, 0);
289 
290             aNew.Put(*GetInputSetImpl());
291 
292             // add flag for direct graphic content selection
293             aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
294 
295             rPage.PageCreated(aNew);
296             break;
297         }
298 
299         case RID_SVXPAGE_TRANSPARENCE:
300         {
301             rPage.PageCreated(*GetInputSetImpl());
302             break;
303         }
304     }
305 }
306 
307 // eof
308