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