Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "srchxtra.hxx"
21 : #include <tools/rcid.h>
22 : #include <vcl/msgbox.hxx>
23 : #include <svl/cjkoptions.hxx>
24 : #include <svl/whiter.hxx>
25 : #include <sfx2/objsh.hxx>
26 : #include <cuires.hrc>
27 : #include <svx/svxitems.hrc>
28 : #include <svx/dialmgr.hxx>
29 : #include <editeng/flstitem.hxx>
30 : #include "chardlg.hxx"
31 : #include "paragrph.hxx"
32 : #include <dialmgr.hxx>
33 : #include "backgrnd.hxx"
34 : #include <svx/dialogs.hrc>
35 : #include <tools/resary.hxx>
36 : #include <rtl/strbuf.hxx>
37 : #include "svtools/treelistentry.hxx"
38 :
39 0 : SvxSearchFormatDialog::SvxSearchFormatDialog(Window* pParent, const SfxItemSet& rSet)
40 : : SfxTabDialog(pParent, "SearchFormatDialog", "cui/ui/searchformatdialog.ui", &rSet)
41 : , m_pFontList(NULL)
42 : , m_nNamePageId(0)
43 : , m_nParaStdPageId(0)
44 : , m_nParaAlignPageId(0)
45 0 : , m_nBackPageId(0)
46 : {
47 0 : m_nNamePageId = AddTabPage("font", SvxCharNamePage::Create, 0);
48 0 : AddTabPage("fonteffects", SvxCharEffectsPage::Create, 0);
49 0 : AddTabPage("position", SvxCharPositionPage::Create, 0);
50 0 : AddTabPage("asianlayout", SvxCharTwoLinesPage::Create, 0);
51 0 : m_nParaStdPageId = AddTabPage("labelTP_PARA_STD", SvxStdParagraphTabPage::Create, 0);
52 0 : m_nParaAlignPageId = AddTabPage("labelTP_PARA_ALIGN", SvxParaAlignTabPage::Create, 0);
53 0 : AddTabPage("labelTP_PARA_EXT", SvxExtParagraphTabPage::Create, 0);
54 0 : AddTabPage("labelTP_PARA_ASIAN", SvxAsianTabPage::Create, 0 );
55 0 : m_nBackPageId = AddTabPage("background", SvxBackgroundTabPage::Create, 0);
56 :
57 : // remove asian tabpages if necessary
58 0 : SvtCJKOptions aCJKOptions;
59 0 : if ( !aCJKOptions.IsDoubleLinesEnabled() )
60 0 : RemoveTabPage("asianlayout");
61 0 : if ( !aCJKOptions.IsAsianTypographyEnabled() )
62 0 : RemoveTabPage("labelTP_PARA_ASIAN");
63 0 : }
64 :
65 0 : SvxSearchFormatDialog::~SvxSearchFormatDialog()
66 : {
67 0 : delete m_pFontList;
68 0 : }
69 :
70 0 : void SvxSearchFormatDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage )
71 : {
72 0 : if (nId == m_nNamePageId)
73 : {
74 0 : const FontList* pApm_pFontList = 0;
75 0 : SfxObjectShell* pSh = SfxObjectShell::Current();
76 :
77 0 : if ( pSh )
78 : {
79 : const SvxFontListItem* pFLItem = (const SvxFontListItem*)
80 0 : pSh->GetItem( SID_ATTR_CHAR_FONTLIST );
81 0 : if ( pFLItem )
82 0 : pApm_pFontList = pFLItem->GetFontList();
83 : }
84 :
85 0 : const FontList* pList = pApm_pFontList;
86 :
87 0 : if ( !pList )
88 : {
89 0 : if ( !m_pFontList )
90 0 : m_pFontList = new FontList( this );
91 0 : pList = m_pFontList;
92 : }
93 :
94 0 : if ( pList )
95 : ( (SvxCharNamePage&)rPage ).
96 0 : SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) );
97 0 : ( (SvxCharNamePage&)rPage ).EnableSearchMode();
98 : }
99 0 : else if (nId == m_nParaStdPageId)
100 : {
101 0 : ( (SvxStdParagraphTabPage&)rPage ).EnableAutoFirstLine();
102 : }
103 0 : else if (nId == m_nParaAlignPageId)
104 : {
105 0 : ( (SvxParaAlignTabPage&)rPage ).EnableJustifyExt();
106 : }
107 0 : else if (nId == m_nBackPageId)
108 : {
109 0 : ( (SvxBackgroundTabPage&)rPage ).ShowParaControl(sal_True);
110 : }
111 0 : }
112 :
113 0 : SvxSearchAttributeDialog::SvxSearchAttributeDialog(Window* pParent,
114 : SearchAttrItemList& rLst, const sal_uInt16* pWhRanges)
115 : : ModalDialog(pParent, "SearchAttrDialog", "cui/ui/searchattrdialog.ui")
116 0 : , rList(rLst)
117 : {
118 0 : get(m_pOKBtn, "ok");
119 0 : get(m_pAttrLB, "treeview");
120 0 : m_pAttrLB->set_height_request(m_pAttrLB->GetTextHeight() * 12);
121 0 : m_pAttrLB->set_width_request(m_pAttrLB->approximate_char_width() * 56);
122 :
123 0 : m_pAttrLB->SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
124 0 : m_pAttrLB->GetModel()->SetSortMode( SortAscending );
125 :
126 0 : m_pOKBtn->SetClickHdl( LINK( this, SvxSearchAttributeDialog, OKHdl ) );
127 :
128 0 : SfxObjectShell* pSh = SfxObjectShell::Current();
129 : DBG_ASSERT( pSh, "No DocShell" );
130 :
131 0 : ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
132 0 : SfxItemPool& rPool = pSh->GetPool();
133 0 : SfxItemSet aSet( rPool, pWhRanges );
134 0 : SfxWhichIter aIter( aSet );
135 0 : sal_uInt16 nWhich = aIter.FirstWhich();
136 :
137 0 : while ( nWhich )
138 : {
139 0 : sal_uInt16 nSlot = rPool.GetSlotId( nWhich );
140 0 : if ( nSlot >= SID_SVX_START )
141 : {
142 0 : sal_Bool bChecked = sal_False, bFound = sal_False;
143 0 : for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i )
144 : {
145 0 : if ( nSlot == rList[i].nSlot )
146 : {
147 0 : bFound = sal_True;
148 0 : if ( IsInvalidItem( rList[i].pItem ) )
149 0 : bChecked = sal_True;
150 : }
151 : }
152 :
153 : // item resources are in svx
154 0 : sal_uInt32 nId = aAttrNames.FindIndex( nSlot );
155 0 : SvTreeListEntry* pEntry = NULL;
156 0 : if ( RESARRAY_INDEX_NOTFOUND != nId )
157 0 : pEntry = m_pAttrLB->SvTreeListBox::InsertEntry( aAttrNames.GetString(nId) );
158 : else
159 : SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) );
160 :
161 0 : if ( pEntry )
162 : {
163 0 : m_pAttrLB->SetCheckButtonState( pEntry, bChecked ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
164 0 : pEntry->SetUserData( (void*)(sal_uLong)nSlot );
165 : }
166 : }
167 0 : nWhich = aIter.NextWhich();
168 : }
169 :
170 0 : m_pAttrLB->SetHighlightRange();
171 0 : m_pAttrLB->SelectEntryPos( 0 );
172 0 : }
173 :
174 :
175 :
176 0 : IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl)
177 : {
178 : SearchAttrItem aInvalidItem;
179 0 : aInvalidItem.pItem = (SfxPoolItem*)-1;
180 :
181 0 : for ( sal_uInt16 i = 0; i < m_pAttrLB->GetEntryCount(); ++i )
182 : {
183 0 : sal_uInt16 nSlot = (sal_uInt16)(sal_uLong)m_pAttrLB->GetEntryData(i);
184 0 : sal_Bool bChecked = m_pAttrLB->IsChecked(i);
185 :
186 : sal_uInt16 j;
187 0 : for ( j = rList.Count(); j; )
188 : {
189 0 : SearchAttrItem& rItem = rList[ --j ];
190 0 : if( rItem.nSlot == nSlot )
191 : {
192 0 : if( bChecked )
193 : {
194 0 : if( !IsInvalidItem( rItem.pItem ) )
195 0 : delete rItem.pItem;
196 0 : rItem.pItem = (SfxPoolItem*)-1;
197 : }
198 0 : else if( IsInvalidItem( rItem.pItem ) )
199 0 : rItem.pItem = 0;
200 0 : j = 1;
201 0 : break;
202 : }
203 : }
204 :
205 0 : if ( !j && bChecked )
206 : {
207 0 : aInvalidItem.nSlot = nSlot;
208 0 : rList.Insert( aInvalidItem );
209 : }
210 : }
211 :
212 : // remove invalid items (pItem == NULL)
213 0 : for ( sal_uInt16 n = rList.Count(); n; )
214 0 : if ( !rList[ --n ].pItem )
215 0 : rList.Remove( n );
216 :
217 0 : EndDialog( RET_OK );
218 0 : return 0;
219 : }
220 :
221 : // class SvxSearchSimilarityDialog ---------------------------------------
222 :
223 0 : SvxSearchSimilarityDialog::SvxSearchSimilarityDialog
224 : (
225 : Window* pParent,
226 : sal_Bool bRelax,
227 : sal_uInt16 nOther,
228 : sal_uInt16 nShorter,
229 : sal_uInt16 nLonger
230 : ) :
231 0 : ModalDialog( pParent, "SimilaritySearchDialog", "cui/ui/similaritysearchdialog.ui" )
232 : {
233 0 : get( m_pOtherFld, "otherfld");
234 0 : get( m_pLongerFld, "longerfld");
235 0 : get( m_pShorterFld, "shorterfld");
236 0 : get( m_pRelaxBox, "relaxbox");
237 :
238 0 : m_pOtherFld->SetValue( nOther );
239 0 : m_pShorterFld->SetValue( nShorter );
240 0 : m_pLongerFld->SetValue( nLonger );
241 0 : m_pRelaxBox->Check( bRelax );
242 0 : }
243 :
244 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|