Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "srchxtra.hxx"
30 : : #include <tools/rcid.h>
31 : : #include <vcl/msgbox.hxx>
32 : : #include <svl/cjkoptions.hxx>
33 : : #include <svl/whiter.hxx>
34 : : #include <sfx2/objsh.hxx>
35 : : #include <cuires.hrc>
36 : : #include "srchxtra.hrc"
37 : : #include <svx/svxitems.hrc> // RID_ATTR_BEGIN
38 : : #include <svx/dialmgr.hxx> // item resources
39 : : #include <editeng/flstitem.hxx>
40 : : #include "chardlg.hxx"
41 : : #include "paragrph.hxx"
42 : : #include <dialmgr.hxx>
43 : : #include "backgrnd.hxx"
44 : : #include <svx/dialogs.hrc> // RID_SVXPAGE_...
45 : : #include <tools/resary.hxx>
46 : : #include <rtl/strbuf.hxx>
47 : :
48 : : // class SvxSearchFormatDialog -------------------------------------------
49 : :
50 : 0 : SvxSearchFormatDialog::SvxSearchFormatDialog( Window* pParent, const SfxItemSet& rSet ) :
51 : :
52 : 0 : SfxTabDialog( pParent, CUI_RES( RID_SVXDLG_SEARCHFORMAT ), &rSet ),
53 : :
54 [ # # ]: 0 : pFontList( NULL )
55 : :
56 : : {
57 [ # # ]: 0 : FreeResource();
58 : :
59 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_CHAR_NAME, SvxCharNamePage::Create, 0 );
60 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_CHAR_EFFECTS, SvxCharEffectsPage::Create, 0 );
61 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_CHAR_POSITION, SvxCharPositionPage::Create, 0 );
62 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_CHAR_TWOLINES, SvxCharTwoLinesPage::Create, 0 );
63 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_STD_PARAGRAPH, SvxStdParagraphTabPage::Create, 0 );
64 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH, SvxParaAlignTabPage::Create, 0 );
65 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_EXT_PARAGRAPH, SvxExtParagraphTabPage::Create, 0 );
66 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_PARA_ASIAN, SvxAsianTabPage::Create, 0 );
67 [ # # ]: 0 : AddTabPage( RID_SVXPAGE_BACKGROUND, SvxBackgroundTabPage::Create, 0 );
68 : :
69 : : // remove asian tabpages if necessary
70 [ # # ]: 0 : SvtCJKOptions aCJKOptions;
71 [ # # ][ # # ]: 0 : if ( !aCJKOptions.IsDoubleLinesEnabled() )
72 [ # # ]: 0 : RemoveTabPage( RID_SVXPAGE_CHAR_TWOLINES );
73 [ # # ][ # # ]: 0 : if ( !aCJKOptions.IsAsianTypographyEnabled() )
74 [ # # ][ # # ]: 0 : RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
75 : 0 : }
76 : :
77 : : // -----------------------------------------------------------------------
78 : :
79 : 0 : SvxSearchFormatDialog::~SvxSearchFormatDialog()
80 : : {
81 [ # # ][ # # ]: 0 : delete pFontList;
82 [ # # ]: 0 : }
83 : :
84 : : // -----------------------------------------------------------------------
85 : :
86 : 0 : void SvxSearchFormatDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage )
87 : : {
88 [ # # # # : 0 : switch ( nId )
# ]
89 : : {
90 : : case RID_SVXPAGE_CHAR_NAME:
91 : : {
92 : 0 : const FontList* pAppFontList = 0;
93 : 0 : SfxObjectShell* pSh = SfxObjectShell::Current();
94 : :
95 [ # # ]: 0 : if ( pSh )
96 : : {
97 : : const SvxFontListItem* pFLItem = (const SvxFontListItem*)
98 : 0 : pSh->GetItem( SID_ATTR_CHAR_FONTLIST );
99 [ # # ]: 0 : if ( pFLItem )
100 : 0 : pAppFontList = pFLItem->GetFontList();
101 : : }
102 : :
103 : 0 : const FontList* pList = pAppFontList;
104 : :
105 [ # # ]: 0 : if ( !pList )
106 : : {
107 [ # # ]: 0 : if ( !pFontList )
108 [ # # ]: 0 : pFontList = new FontList( this );
109 : 0 : pList = pFontList;
110 : : }
111 : :
112 [ # # ]: 0 : if ( pList )
113 : : ( (SvxCharNamePage&)rPage ).
114 [ # # ]: 0 : SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) );
115 : 0 : ( (SvxCharNamePage&)rPage ).EnableSearchMode();
116 : 0 : break;
117 : : }
118 : :
119 : : case RID_SVXPAGE_STD_PARAGRAPH:
120 : 0 : ( (SvxStdParagraphTabPage&)rPage ).EnableAutoFirstLine();
121 : 0 : break;
122 : :
123 : : case RID_SVXPAGE_ALIGN_PARAGRAPH:
124 : 0 : ( (SvxParaAlignTabPage&)rPage ).EnableJustifyExt();
125 : 0 : break;
126 : : case RID_SVXPAGE_BACKGROUND :
127 : 0 : ( (SvxBackgroundTabPage&)rPage ).ShowParaControl(sal_True);
128 : 0 : break;
129 : : }
130 : 0 : }
131 : :
132 : : // class SvxSearchFormatDialog -------------------------------------------
133 : :
134 : 0 : SvxSearchAttributeDialog::SvxSearchAttributeDialog( Window* pParent,
135 : : SearchAttrItemList& rLst,
136 : : const sal_uInt16* pWhRanges ) :
137 : :
138 : 0 : ModalDialog( pParent, CUI_RES( RID_SVXDLG_SEARCHATTR ) ),
139 : :
140 [ # # ]: 0 : aAttrFL ( this, CUI_RES( FL_ATTR ) ),
141 [ # # ]: 0 : aAttrLB ( this, CUI_RES( LB_ATTR ) ),
142 [ # # ]: 0 : aOKBtn ( this, CUI_RES( BTN_ATTR_OK ) ),
143 [ # # ]: 0 : aEscBtn ( this, CUI_RES( BTN_ATTR_CANCEL ) ),
144 [ # # ]: 0 : aHelpBtn( this, CUI_RES( BTN_ATTR_HELP ) ),
145 : :
146 [ # # ][ # # ]: 0 : rList( rLst )
[ # # ][ # # ]
[ # # ][ # # ]
147 : :
148 : : {
149 [ # # ]: 0 : FreeResource();
150 : :
151 [ # # ][ # # ]: 0 : aAttrLB.SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
152 : 0 : aAttrLB.GetModel()->SetSortMode( SortAscending );
153 : :
154 [ # # ]: 0 : aOKBtn.SetClickHdl( LINK( this, SvxSearchAttributeDialog, OKHdl ) );
155 : :
156 [ # # ]: 0 : SfxObjectShell* pSh = SfxObjectShell::Current();
157 : : DBG_ASSERT( pSh, "No DocShell" );
158 : :
159 [ # # ][ # # ]: 0 : ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
160 : 0 : SfxItemPool& rPool = pSh->GetPool();
161 [ # # ]: 0 : SfxItemSet aSet( rPool, pWhRanges );
162 [ # # ]: 0 : SfxWhichIter aIter( aSet );
163 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
164 : :
165 [ # # ]: 0 : while ( nWhich )
166 : : {
167 [ # # ]: 0 : sal_uInt16 nSlot = rPool.GetSlotId( nWhich );
168 [ # # ]: 0 : if ( nSlot >= SID_SVX_START )
169 : : {
170 : 0 : sal_Bool bChecked = sal_False, bFound = sal_False;
171 [ # # ][ # # ]: 0 : for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i )
[ # # ]
172 : : {
173 [ # # ][ # # ]: 0 : if ( nSlot == rList[i].nSlot )
174 : : {
175 : 0 : bFound = sal_True;
176 [ # # ][ # # ]: 0 : if ( IsInvalidItem( rList[i].pItem ) )
177 : 0 : bChecked = sal_True;
178 : : }
179 : : }
180 : :
181 : : // item resources are in svx
182 [ # # ]: 0 : sal_uInt32 nId = aAttrNames.FindIndex( nSlot );
183 : 0 : SvLBoxEntry* pEntry = NULL;
184 [ # # ]: 0 : if ( RESARRAY_INDEX_NOTFOUND != nId )
185 [ # # ][ # # ]: 0 : pEntry = aAttrLB.SvTreeListBox::InsertEntry( aAttrNames.GetString(nId) );
[ # # ][ # # ]
186 : : else
187 : : SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) );
188 : :
189 [ # # ]: 0 : if ( pEntry )
190 : : {
191 [ # # ][ # # ]: 0 : aAttrLB.SetCheckButtonState( pEntry, bChecked ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
192 : 0 : pEntry->SetUserData( (void*)(sal_uLong)nSlot );
193 : : }
194 : : }
195 [ # # ]: 0 : nWhich = aIter.NextWhich();
196 : : }
197 : :
198 [ # # ]: 0 : aAttrLB.SetHighlightRange();
199 [ # # ][ # # ]: 0 : aAttrLB.SelectEntryPos( 0 );
[ # # ][ # # ]
200 : 0 : }
201 : :
202 : : // -----------------------------------------------------------------------
203 : :
204 : 0 : IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl)
205 : : {
206 : : SearchAttrItem aInvalidItem;
207 : 0 : aInvalidItem.pItem = (SfxPoolItem*)-1;
208 : :
209 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < aAttrLB.GetEntryCount(); ++i )
210 : : {
211 [ # # ]: 0 : sal_uInt16 nSlot = (sal_uInt16)(sal_uLong)aAttrLB.GetEntryData(i);
212 [ # # ]: 0 : sal_Bool bChecked = aAttrLB.IsChecked(i);
213 : :
214 : : sal_uInt16 j;
215 [ # # ]: 0 : for ( j = rList.Count(); j; )
216 : : {
217 [ # # ]: 0 : SearchAttrItem& rItem = rList[ --j ];
218 [ # # ]: 0 : if( rItem.nSlot == nSlot )
219 : : {
220 [ # # ]: 0 : if( bChecked )
221 : : {
222 [ # # ]: 0 : if( !IsInvalidItem( rItem.pItem ) )
223 [ # # ][ # # ]: 0 : delete rItem.pItem;
224 : 0 : rItem.pItem = (SfxPoolItem*)-1;
225 : : }
226 [ # # ]: 0 : else if( IsInvalidItem( rItem.pItem ) )
227 : 0 : rItem.pItem = 0;
228 : 0 : j = 1;
229 : 0 : break;
230 : : }
231 : : }
232 : :
233 [ # # ][ # # ]: 0 : if ( !j && bChecked )
234 : : {
235 : 0 : aInvalidItem.nSlot = nSlot;
236 [ # # ]: 0 : rList.Insert( aInvalidItem );
237 : : }
238 : : }
239 : :
240 : : // remove invalid items (pItem == NULL)
241 [ # # ]: 0 : for ( sal_uInt16 n = rList.Count(); n; )
242 [ # # ][ # # ]: 0 : if ( !rList[ --n ].pItem )
243 [ # # ]: 0 : rList.Remove( n );
244 : :
245 [ # # ]: 0 : EndDialog( RET_OK );
246 : 0 : return 0;
247 : : }
248 : :
249 : : // class SvxSearchSimilarityDialog ---------------------------------------
250 : :
251 : 0 : SvxSearchSimilarityDialog::SvxSearchSimilarityDialog
252 : : (
253 : : Window* pParent,
254 : : sal_Bool bRelax,
255 : : sal_uInt16 nOther,
256 : : sal_uInt16 nShorter,
257 : : sal_uInt16 nLonger
258 : : ) :
259 : 0 : ModalDialog( pParent, CUI_RES( RID_SVXDLG_SEARCHSIMILARITY ) ),
260 : :
261 [ # # ]: 0 : aFixedLine ( this, CUI_RES( FL_SIMILARITY ) ),
262 [ # # ]: 0 : aOtherTxt ( this, CUI_RES( FT_OTHER ) ),
263 [ # # ]: 0 : aOtherFld ( this, CUI_RES( NF_OTHER ) ),
264 [ # # ]: 0 : aLongerTxt ( this, CUI_RES( FT_LONGER ) ),
265 [ # # ]: 0 : aLongerFld ( this, CUI_RES( NF_LONGER ) ),
266 [ # # ]: 0 : aShorterTxt ( this, CUI_RES( FT_SHORTER ) ),
267 [ # # ]: 0 : aShorterFld ( this, CUI_RES( NF_SHORTER ) ),
268 [ # # ]: 0 : aRelaxBox ( this, CUI_RES( CB_RELAX ) ),
269 : :
270 [ # # ]: 0 : aOKBtn ( this, CUI_RES( BTN_ATTR_OK ) ),
271 [ # # ]: 0 : aEscBtn ( this, CUI_RES( BTN_ATTR_CANCEL ) ),
272 [ # # ][ # # ]: 0 : aHelpBtn ( this, CUI_RES( BTN_ATTR_HELP ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
273 : :
274 : : {
275 [ # # ]: 0 : FreeResource();
276 : :
277 [ # # ]: 0 : aOtherFld.SetValue( nOther );
278 [ # # ]: 0 : aShorterFld.SetValue( nShorter );
279 [ # # ]: 0 : aLongerFld.SetValue( nLonger );
280 [ # # ]: 0 : aRelaxBox.Check( bRelax );
281 : 0 : }
282 : :
283 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|