1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*2ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*2ee96f1cSAndrew Rist * distributed with this work for additional information
6*2ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*2ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*2ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*2ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
17*2ee96f1cSAndrew Rist * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*2ee96f1cSAndrew Rist *************************************************************/
21*2ee96f1cSAndrew Rist
22*2ee96f1cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "srchxtra.hxx"
30cdf0e10cSrcweir #include <tools/rcid.h>
31cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32cdf0e10cSrcweir #include <svl/cjkoptions.hxx>
33cdf0e10cSrcweir #include <svl/whiter.hxx>
34cdf0e10cSrcweir #include <sfx2/objsh.hxx>
35cdf0e10cSrcweir #include <cuires.hrc>
36cdf0e10cSrcweir #include "srchxtra.hrc"
37cdf0e10cSrcweir #include <svx/svxitems.hrc> // RID_ATTR_BEGIN
38cdf0e10cSrcweir #include <svx/dialmgr.hxx> // item resources
39cdf0e10cSrcweir #include <editeng/flstitem.hxx>
40cdf0e10cSrcweir #include "chardlg.hxx"
41cdf0e10cSrcweir #include "paragrph.hxx"
42cdf0e10cSrcweir #include <dialmgr.hxx>
43cdf0e10cSrcweir #include "backgrnd.hxx"
44cdf0e10cSrcweir #include <svx/dialogs.hrc> // RID_SVXPAGE_...
45cdf0e10cSrcweir #include <tools/resary.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir // class SvxSearchFormatDialog -------------------------------------------
48cdf0e10cSrcweir
SvxSearchFormatDialog(Window * pParent,const SfxItemSet & rSet)49cdf0e10cSrcweir SvxSearchFormatDialog::SvxSearchFormatDialog( Window* pParent, const SfxItemSet& rSet ) :
50cdf0e10cSrcweir
51cdf0e10cSrcweir SfxTabDialog( pParent, CUI_RES( RID_SVXDLG_SEARCHFORMAT ), &rSet ),
52cdf0e10cSrcweir
53cdf0e10cSrcweir pFontList( NULL )
54cdf0e10cSrcweir
55cdf0e10cSrcweir {
56cdf0e10cSrcweir FreeResource();
57cdf0e10cSrcweir
58cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_CHAR_NAME, SvxCharNamePage::Create, 0 );
59cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_CHAR_EFFECTS, SvxCharEffectsPage::Create, 0 );
60cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_CHAR_POSITION, SvxCharPositionPage::Create, 0 );
61cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_CHAR_TWOLINES, SvxCharTwoLinesPage::Create, 0 );
62cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_STD_PARAGRAPH, SvxStdParagraphTabPage::Create, 0 );
63cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH, SvxParaAlignTabPage::Create, 0 );
64cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_EXT_PARAGRAPH, SvxExtParagraphTabPage::Create, 0 );
65cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_PARA_ASIAN, SvxAsianTabPage::Create, 0 );
66cdf0e10cSrcweir AddTabPage( RID_SVXPAGE_BACKGROUND, SvxBackgroundTabPage::Create, 0 );
67cdf0e10cSrcweir
68cdf0e10cSrcweir // remove asian tabpages if necessary
69cdf0e10cSrcweir SvtCJKOptions aCJKOptions;
70cdf0e10cSrcweir if ( !aCJKOptions.IsDoubleLinesEnabled() )
71cdf0e10cSrcweir RemoveTabPage( RID_SVXPAGE_CHAR_TWOLINES );
72cdf0e10cSrcweir if ( !aCJKOptions.IsAsianTypographyEnabled() )
73cdf0e10cSrcweir RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir // -----------------------------------------------------------------------
77cdf0e10cSrcweir
~SvxSearchFormatDialog()78cdf0e10cSrcweir SvxSearchFormatDialog::~SvxSearchFormatDialog()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir delete pFontList;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir // -----------------------------------------------------------------------
84cdf0e10cSrcweir
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)85cdf0e10cSrcweir void SvxSearchFormatDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir switch ( nId )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir case RID_SVXPAGE_CHAR_NAME:
90cdf0e10cSrcweir {
91cdf0e10cSrcweir const FontList* pAppFontList = 0;
92cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::Current();
93cdf0e10cSrcweir
94cdf0e10cSrcweir if ( pSh )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir const SvxFontListItem* pFLItem = (const SvxFontListItem*)
97cdf0e10cSrcweir pSh->GetItem( SID_ATTR_CHAR_FONTLIST );
98cdf0e10cSrcweir if ( pFLItem )
99cdf0e10cSrcweir pAppFontList = pFLItem->GetFontList();
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir const FontList* pList = pAppFontList;
103cdf0e10cSrcweir
104cdf0e10cSrcweir if ( !pList )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if ( !pFontList )
107cdf0e10cSrcweir pFontList = new FontList( this );
108cdf0e10cSrcweir pList = pFontList;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir if ( pList )
112cdf0e10cSrcweir ( (SvxCharNamePage&)rPage ).
113cdf0e10cSrcweir SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) );
114cdf0e10cSrcweir ( (SvxCharNamePage&)rPage ).EnableSearchMode();
115cdf0e10cSrcweir break;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir case RID_SVXPAGE_STD_PARAGRAPH:
119cdf0e10cSrcweir ( (SvxStdParagraphTabPage&)rPage ).EnableAutoFirstLine();
120cdf0e10cSrcweir break;
121cdf0e10cSrcweir
122cdf0e10cSrcweir case RID_SVXPAGE_ALIGN_PARAGRAPH:
123cdf0e10cSrcweir ( (SvxParaAlignTabPage&)rPage ).EnableJustifyExt();
124cdf0e10cSrcweir break;
125cdf0e10cSrcweir case RID_SVXPAGE_BACKGROUND :
126cdf0e10cSrcweir ( (SvxBackgroundTabPage&)rPage ).ShowParaControl(sal_True);
127cdf0e10cSrcweir break;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir // class SvxSearchFormatDialog -------------------------------------------
132cdf0e10cSrcweir
SvxSearchAttributeDialog(Window * pParent,SearchAttrItemList & rLst,const sal_uInt16 * pWhRanges)133cdf0e10cSrcweir SvxSearchAttributeDialog::SvxSearchAttributeDialog( Window* pParent,
134cdf0e10cSrcweir SearchAttrItemList& rLst,
135cdf0e10cSrcweir const sal_uInt16* pWhRanges ) :
136cdf0e10cSrcweir
137cdf0e10cSrcweir ModalDialog( pParent, CUI_RES( RID_SVXDLG_SEARCHATTR ) ),
138cdf0e10cSrcweir
139cdf0e10cSrcweir aAttrFL ( this, CUI_RES( FL_ATTR ) ),
140cdf0e10cSrcweir aAttrLB ( this, CUI_RES( LB_ATTR ) ),
141cdf0e10cSrcweir aOKBtn ( this, CUI_RES( BTN_ATTR_OK ) ),
142cdf0e10cSrcweir aEscBtn ( this, CUI_RES( BTN_ATTR_CANCEL ) ),
143cdf0e10cSrcweir aHelpBtn( this, CUI_RES( BTN_ATTR_HELP ) ),
144cdf0e10cSrcweir
145cdf0e10cSrcweir rList( rLst )
146cdf0e10cSrcweir
147cdf0e10cSrcweir {
148cdf0e10cSrcweir FreeResource();
149cdf0e10cSrcweir
150cdf0e10cSrcweir aAttrLB.SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
151cdf0e10cSrcweir aAttrLB.GetModel()->SetSortMode( SortAscending );
152cdf0e10cSrcweir
153cdf0e10cSrcweir aOKBtn.SetClickHdl( LINK( this, SvxSearchAttributeDialog, OKHdl ) );
154cdf0e10cSrcweir
155cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::Current();
156cdf0e10cSrcweir DBG_ASSERT( pSh, "No DocShell" );
157cdf0e10cSrcweir
158cdf0e10cSrcweir ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
159cdf0e10cSrcweir SfxItemPool& rPool = pSh->GetPool();
160cdf0e10cSrcweir SfxItemSet aSet( rPool, pWhRanges );
161cdf0e10cSrcweir SfxWhichIter aIter( aSet );
162cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
163cdf0e10cSrcweir
164cdf0e10cSrcweir while ( nWhich )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir sal_uInt16 nSlot = rPool.GetSlotId( nWhich );
167cdf0e10cSrcweir if ( nSlot >= SID_SVX_START )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir sal_Bool bChecked = sal_False, bFound = sal_False;
170cdf0e10cSrcweir for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir if ( nSlot == rList[i].nSlot )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir bFound = sal_True;
175cdf0e10cSrcweir if ( IsInvalidItem( rList[i].pItem ) )
176cdf0e10cSrcweir bChecked = sal_True;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir // item resources are in svx
181cdf0e10cSrcweir sal_uInt32 nId = aAttrNames.FindIndex( nSlot );
182cdf0e10cSrcweir SvLBoxEntry* pEntry = NULL;
183cdf0e10cSrcweir if ( RESARRAY_INDEX_NOTFOUND != nId )
184cdf0e10cSrcweir pEntry = aAttrLB.SvTreeListBox::InsertEntry( aAttrNames.GetString(nId) );
185cdf0e10cSrcweir else
186cdf0e10cSrcweir {
187cdf0e10cSrcweir ByteString sError( "no resource for slot id\nslot = " );
188cdf0e10cSrcweir sError += ByteString::CreateFromInt32( nSlot );
189cdf0e10cSrcweir DBG_ERRORFILE( sError.GetBuffer() );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir if ( pEntry )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir aAttrLB.SetCheckButtonState( pEntry, bChecked ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
195cdf0e10cSrcweir pEntry->SetUserData( (void*)(sal_uLong)nSlot );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir }
198cdf0e10cSrcweir nWhich = aIter.NextWhich();
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir aAttrLB.SetHighlightRange();
202cdf0e10cSrcweir aAttrLB.SelectEntryPos( 0 );
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir // -----------------------------------------------------------------------
206cdf0e10cSrcweir
IMPL_LINK(SvxSearchAttributeDialog,OKHdl,Button *,EMPTYARG)207cdf0e10cSrcweir IMPL_LINK( SvxSearchAttributeDialog, OKHdl, Button *, EMPTYARG )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir SearchAttrItem aInvalidItem;
210cdf0e10cSrcweir aInvalidItem.pItem = (SfxPoolItem*)-1;
211cdf0e10cSrcweir
212cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < aAttrLB.GetEntryCount(); ++i )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir sal_uInt16 nSlot = (sal_uInt16)(sal_uLong)aAttrLB.GetEntryData(i);
215cdf0e10cSrcweir sal_Bool bChecked = aAttrLB.IsChecked(i);
216cdf0e10cSrcweir
217cdf0e10cSrcweir sal_uInt16 j;
218cdf0e10cSrcweir for ( j = rList.Count(); j; )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir SearchAttrItem& rItem = rList[ --j ];
221cdf0e10cSrcweir if( rItem.nSlot == nSlot )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir if( bChecked )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir if( !IsInvalidItem( rItem.pItem ) )
226cdf0e10cSrcweir delete rItem.pItem;
227cdf0e10cSrcweir rItem.pItem = (SfxPoolItem*)-1;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir else if( IsInvalidItem( rItem.pItem ) )
230cdf0e10cSrcweir rItem.pItem = 0;
231cdf0e10cSrcweir j = 1;
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir if ( !j && bChecked )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir aInvalidItem.nSlot = nSlot;
239cdf0e10cSrcweir rList.Insert( aInvalidItem );
240cdf0e10cSrcweir }
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
243cdf0e10cSrcweir // remove invalid items (pItem == NULL)
244cdf0e10cSrcweir for ( sal_uInt16 n = rList.Count(); n; )
245cdf0e10cSrcweir if ( !rList[ --n ].pItem )
246cdf0e10cSrcweir rList.Remove( n );
247cdf0e10cSrcweir
248cdf0e10cSrcweir EndDialog( RET_OK );
249cdf0e10cSrcweir return 0;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir // class SvxSearchSimilarityDialog ---------------------------------------
253cdf0e10cSrcweir
SvxSearchSimilarityDialog(Window * pParent,sal_Bool bRelax,sal_uInt16 nOther,sal_uInt16 nShorter,sal_uInt16 nLonger)254cdf0e10cSrcweir SvxSearchSimilarityDialog::SvxSearchSimilarityDialog
255cdf0e10cSrcweir (
256cdf0e10cSrcweir Window* pParent,
257cdf0e10cSrcweir sal_Bool bRelax,
258cdf0e10cSrcweir sal_uInt16 nOther,
259cdf0e10cSrcweir sal_uInt16 nShorter,
260cdf0e10cSrcweir sal_uInt16 nLonger
261cdf0e10cSrcweir ) :
262cdf0e10cSrcweir ModalDialog( pParent, CUI_RES( RID_SVXDLG_SEARCHSIMILARITY ) ),
263cdf0e10cSrcweir
264cdf0e10cSrcweir aFixedLine ( this, CUI_RES( FL_SIMILARITY ) ),
265cdf0e10cSrcweir aOtherTxt ( this, CUI_RES( FT_OTHER ) ),
266cdf0e10cSrcweir aOtherFld ( this, CUI_RES( NF_OTHER ) ),
267cdf0e10cSrcweir aLongerTxt ( this, CUI_RES( FT_LONGER ) ),
268cdf0e10cSrcweir aLongerFld ( this, CUI_RES( NF_LONGER ) ),
269cdf0e10cSrcweir aShorterTxt ( this, CUI_RES( FT_SHORTER ) ),
270cdf0e10cSrcweir aShorterFld ( this, CUI_RES( NF_SHORTER ) ),
271cdf0e10cSrcweir aRelaxBox ( this, CUI_RES( CB_RELAX ) ),
272cdf0e10cSrcweir
273cdf0e10cSrcweir aOKBtn ( this, CUI_RES( BTN_ATTR_OK ) ),
274cdf0e10cSrcweir aEscBtn ( this, CUI_RES( BTN_ATTR_CANCEL ) ),
275cdf0e10cSrcweir aHelpBtn ( this, CUI_RES( BTN_ATTR_HELP ) )
276cdf0e10cSrcweir
277cdf0e10cSrcweir {
278cdf0e10cSrcweir FreeResource();
279cdf0e10cSrcweir
280cdf0e10cSrcweir aOtherFld.SetValue( nOther );
281cdf0e10cSrcweir aShorterFld.SetValue( nShorter );
282cdf0e10cSrcweir aLongerFld.SetValue( nLonger );
283cdf0e10cSrcweir aRelaxBox.Check( bRelax );
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286