a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
wfind.cpp
gehe zur Dokumentation dieser Datei
1 // wfind.cpp : Find menu (Fernglas Formular)
2 // 1998/2012 Find-Dialogfenster f. boolesche Suche
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 #include "program.h"
6 #include "stdafx.h"
7 #include "ca99.h"
8 #include "a99.h"
9 #include "abase.hpp"
10 #include "wfind.h"
11 
12 #ifdef _DEBUG
13 #define new DEBUG_NEW
14 #undef THIS_FILE
15 static char THIS_FILE[] = __FILE__;
16 #endif
17 
18 
19 extern int accu; // Berechtigung
20 
21 // Fuer den Inhalt des Suchformulars
22 extern struct Command // find command elements
23  {
24  int type; // 1:online 0=full text
25  char term1[200], term2[200], term3[200]; // the 3 terms
26 // if type==0: term1 = term for fulltext srch
27  int ind1, ind2, ind3; // the index numbers
28  bool ex1, ex2, ex3, tr1, tr2, tr3; // expansion and truncation flags
29  int bool1, bool2; // boolean operators
30  int qua, op; // qualifyer, option
31  char term4[50]; // qual. term
32  int rad1; // 0/1 : in Erg.Menge / in Offline-Datei
33  } Com;
34 
35 /////////////////////////////////////////////////////////////////////////////
36 // Wfind dialog
37 
38 
39 Wfind::Wfind(CWnd* pParent /*=NULL*/)
40  : CDialog(Wfind::IDD, pParent)
41 {
42  //{{AFX_DATA_INIT(Wfind)
43  m_trunc2 = FALSE;
44  m_trunc3 = FALSE;
45  m_expand2 = FALSE;
46  m_expand3 = FALSE;
47  //}}AFX_DATA_INIT
48 }
49 
50 // Die Dialogelemente mit den Daten fuellen
51 void Wfind::DoDataExchange(CDataExchange* pDX)
52 {
54  //{{AFX_DATA_MAP(Wfind)
55  DDX_Control(pDX, IDC_exterm, m_exterm);
56  DDX_Control(pDX, IDC_BUTTON1, m_repeat);
57  DDX_Control(pDX, IDC_BUTTON2, m_clear);
58  DDX_Control(pDX, IDC_FTS, m_fts);
59  DDX_Control(pDX, IDC_RADIO1, m_rad1);
60  DDX_Control(pDX, IDC_RADIO2, m_rad2);
61  DDX_Control(pDX, IDC_qualif, m_qualif);
62  DDX_Control(pDX, IDC_qua, m_qua);
63  DDX_Control(pDX, IDC_OP, m_op);
64  DDX_Control(pDX, IDC_qtxt, m_qtxt);
65  DDX_Control(pDX, IDC_EXP1, m_expa1);
66  DDX_Control(pDX, IDC_EXP3, m_expa3);
67  DDX_Control(pDX, IDC_EXP2, m_expa2);
68  DDX_Control(pDX, IDC_CHECK1, m_trunk1);
69  DDX_Control(pDX, IDC_CHECK2, m_trunk2);
70  DDX_Control(pDX, IDC_CHECK3, m_trunk3);
71  DDX_Control(pDX, IDC_BOOL1, m_bool1);
72  DDX_Control(pDX, IDC_BOOL2, m_bool2);
73  DDX_Control(pDX, IDC_COMBO1, m_index1);
74  DDX_Control(pDX, IDC_COMBO2, m_index2);
75  DDX_Control(pDX, IDC_COMBO3, m_index3);
76  DDX_Control(pDX, IDC_Term1, m_term1);
77  DDX_Control(pDX, IDC_Term2, m_term2);
78  DDX_Control(pDX, IDC_RESULT, m_result);
79  DDX_Control(pDX, IDC_FTSRCH, m_plusterm);
80  DDX_Check(pDX, IDC_CHECK2, m_trunc2);
81  DDX_Check(pDX, IDC_CHECK3, m_trunc3);
82  DDX_Check(pDX, IDC_CHECK1, m_trunc1);
83  DDX_Check(pDX, IDC_EXP1, m_expand1);
84  DDX_Check(pDX, IDC_EXP2, m_expand2);
85  DDX_Check(pDX, IDC_EXP3, m_expand3);
86  //}}AFX_DATA_MAP
87 }
88 
89 
90 BEGIN_MESSAGE_MAP(Wfind, CDialog)
91  //{{AFX_MSG_MAP(Wfind)
92  ON_BN_CLICKED(IDCOK, OnCok)
93  ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
94  ON_BN_CLICKED(IDC_CH, OnCh) // Help Button
95  ON_BN_CLICKED(IDC_BUTTON1, OnRepeat) // vorher. Suche
96  ON_BN_CLICKED(IDC_BUTTON2, OnClear)
97  ON_WM_HELPINFO()
98  //}}AFX_MSG_MAP
99 END_MESSAGE_MAP()
100 
101 /////////////////////////////////////////////////////////////////////////////
102 // Wfind message handlers
103 
104 // Bank = Database (may be 0)
105 // Res = Result set name (may be 0)
106 // cmd = Address for command
107 
108 int Wfind::DoModal(ABASE *Bank, char *Res, char *cmd)
109 {
110  int rc;
111  *cmd=0;
112  Base = Bank;
113  result = Res;
114  command = cmd;
115  rc=CDialog::DoModal();
116 
117  return rc;
118 
119 }
120 
122 {
123  return CDialog::DoModal();
124 }
125 
127 {
129  if(*result) m_result.SetWindowText(result);
130  else m_result.SetWindowText(uif[324]);
131 
132  extern int Xmod; // expand flag
133  extern CFont *bFont; // von wegen Hebraeisch und so
134  if(bFont)
135  {
136  m_term1.SetFont(bFont,TRUE);
137  m_term2.SetFont(bFont,TRUE);
138  m_term3.SetFont(bFont,TRUE);
139  m_plusterm.SetFont(bFont,TRUE);
140  }
141 
142 // Beschriftungen setzen
143  SetWindowText(uif[352]); // a99 : Suchbefehle
144  m_expa1.SetWindowText(uif[346]); // "mit Expand"
145  m_expa2.SetWindowText(uif[346]); // "mit Expand"
146  m_expa3.SetWindowText(uif[346]); // "mit Expand"
147  m_trunk1.SetWindowText(uif[345]); // "mit Trunk"
148  m_trunk2.SetWindowText(uif[345]); // "mit Trunk"
149  m_trunk3.SetWindowText(uif[345]); // "mit Trunk"
150  m_qtxt.SetWindowText(uif[347]); // Einschr.
151  m_rad1.SetWindowText(uif[348]); // in Erg.Menge
152  m_fts.SetWindowText(uif[325]); // Volltextsuche in :
153  m_exterm.SetWindowText(uif[326]); // Hier exakten Suchbegriff eingeben:
154  m_repeat.SetWindowText(uif[327]); // vorh.Suche
155  m_clear.SetWindowText(uif[328]); // Loeschen
156  if(Base)
157  {
158  int i=-1; int y=0;
159  while(++i<Base->tnix) // index names
160  {
161 #ifndef ALCARTA // in ALCARTA Reg. 10 und 11 nicht erlauben
162  if(accu<4) // sonst 10 nur bei accu>2, 11 bei accu>3
163 #endif
164  if(Base->InamE[i][4]==';') continue;
165 #ifndef ALCARTA
166  if(accu<3)
167 #endif
168  if(Base->InamE[i][4]==':') continue;
169  m_index1.InsertString(y,Base->InamX[i]);
170  m_index2.InsertString(y,Base->InamX[i]);
171  m_index3.InsertString(y,Base->InamX[i]);
172  ++y;
173  }
174 
175  i=-1; int j;
176  while(++i<Base->ress) // restri
177  {
178  j=UtPfind(4000+i);
179  m_qualif.InsertString(i,(char *)pa[j]+5);
180  }
181 // if(!i) m_qualif.Enable(FALSE);
182  m_bool1.SelectString(-1,"A");
183  m_bool2.SelectString(-1,"A");
184  m_op.SelectString(-1,"=");
185  m_qualif.SelectString(-1," ");
186  if(Base->i7)
187  { m_expa1.EnableWindow(TRUE);
188  m_expa2.EnableWindow(TRUE);
189  m_expa3.EnableWindow(TRUE);
190  if(Xmod)
191  {
192  m_expa1.SetCheck(TRUE);
193  m_expa2.SetCheck(TRUE);
194  m_expa3.SetCheck(TRUE);
195  }
196  }
197  m_index1.SetCurSel(0); // set defaults
198  m_index2.SetCurSel(1);
199  m_index3.SetCurSel(2);
200  m_trunk1.SetCheck(TRUE);
201  m_trunk2.SetCheck(TRUE);
202  m_trunk3.SetCheck(TRUE);
203  }
204  m_rad1.SetCheck(1);
205  m_rad2.SetCheck(0);
206  return TRUE; // return TRUE unless you set the focus to a control
207  // EXCEPTION: OCX Property Pages should return FALSE
208 }
209 
210 extern CHAR restri[];
211 
213 {
214  char ind[80];
215  char term1[80];
216  char term2[80];
217  char term3[80];
218  char term[40];
219  char *bools[4] = { "and", "or", "not", "" };
220  char *oper[6] = { "=", "<", "<=", ">=", ">", "!" };
221 
222  int i;
223  int j;
224 
225 // Inhalt des Formulars sichern in Struktur Com
226 if(ok==IDOK)
227 {
228  m_term1.GetWindowText(term1,80);
229  m_term2.GetWindowText(term2,80);
230  m_term3.GetWindowText(term3,80);
231  m_qua.GetWindowText(term,80);
232  if(*term1 || *term2 || *term3 || *term) //irgendeine Eingabe?
233  {
234  if(Base)
235  {
236  *command=0;
237 
238  if(*term) // restric? then set as prefix
239  {
240  strcpy(Com.term4,term);
241  Com.qua=i=m_qualif.GetCurSel();
242  Com.op=j=m_op.GetCurSel();
243  }
244  if(!m_expand1 && !m_expand2 && !m_expand3) // Keine Exp, dann Restric zuerst
245  if(*term) // restric? then set as prefix
246  {
247  sprintf(command,"%s %.3s%s",(char *)Base->restrics+i*6+2,oper[j],term);
248  if(*term1 || *term2 || *term3) strcat(command," and ");
249  }
250 
251  if(!*term1 && *term2)
252  {
253  strcpy(term1,term2); *term2=0;
255  m_index1.SetCurSel(m_index2.GetCurSel());
256  if(*term3)
257  {
258  strcpy(term2,term3); *term3=0;
260  m_index2.SetCurSel(m_index3.GetCurSel());
261  }
262  }
263  if(!*term1 && *term3)
264  {
265  strcpy(term1,term3); *term3=0;
267  m_index1.SetCurSel(m_index3.GetCurSel());
268  }
269 
270  if(*term1 && !*term2 && *term3)
271  {
272  strcpy(term2,term3); *term3=0;
274  m_index2.SetCurSel(m_index3.GetCurSel());
275  }
276 
277 // 1. Suchbegr.
278  if(*term1)
279  {
280  if(*term2 || *term3) strcat(command,"(");
281  Com.type=1;
282  strcpy(Com.term1,term1);
283  Com.ind1=i=m_index1.GetCurSel();
284 
285  strcpy(ind,Base->InamE[i]); ind[3]=0; // z.B. ind="PER"
286 
287  Com.ex1=m_expand1;
288  Com.ex2=m_expand2;
289  Com.ex3=m_expand3;
290  Com.tr1=m_trunc1;
291  Com.tr2=m_trunc2;
292  Com.tr3=m_trunc3;
293 
294  if(m_expand1==FALSE) sprintf(command+strlen(command),"%s \042%s",ind,term1);
295  else sprintf(command+strlen(command),"%s \042&%s",ind,term1); // &suchbegriff : expand
296  if(m_trunc1==TRUE)
297  {
298  if(command[strlen(command)-1]!='?') strcat(command,"?"); // trunc only for index srch!
299  }
300  strcat(command,"\042"); // " anhaengen
301  }
302  else { *Com.term1=Com.ind1=Com.ex1=Com.tr1=0; strcat(command,"\042"); }
303 
304 // 2. Suchbegr.
305  if(*term2)
306  {
307  strcpy(Com.term2,term2);
308  Com.ind2=i=m_index2.GetCurSel();
309  Com.bool1=j=m_bool1.GetCurSel();
310  strcpy(ind,Base->InamE[i]); ind[3]=0;
311  if(!*term1) j=3;
312  if(m_expand2==FALSE) sprintf(command+strlen(command)," %s %s \042%s",bools[j],ind,term2);
313  else sprintf(command+strlen(command)," %s %s \042&%s",bools[j],ind,term2);
314  if(m_trunc2==TRUE)
315  {
316  if(command[strlen(command)-1]!='?') strcat(command,"?"); // trunc only for index srch!
317  }
318 // if(*term1 && *term2 && !*term3) strcat(command,"\042)");
319 // else
320  if(!*term3) strcat(command,"\042)"); else strcat(command,"\042");
321  }
322 
323  else { *Com.term2=Com.bool1=Com.ex2=Com.tr2=0; Com.ind2=1; }
324 
325 // 3. Suchbegr.
326  if(*term3)
327  {
328  strcpy(Com.term3,term3);
329  Com.ind3=i=m_index3.GetCurSel();
330  Com.bool2=j=m_bool2.GetCurSel();
331  strcpy(ind,Base->InamE[i]); ind[3]=0;
332  if(!*term1 && !*term2) j=3;
333 
334  if(m_expand3==FALSE) sprintf(command+strlen(command)," %s %s \042%s",bools[j],ind,term3);
335  else sprintf(command+strlen(command)," %s %s \042&%s",bools[j],ind,term3);
336  if(m_trunc3==TRUE)
337  {
338  if(command[strlen(command)-1]!='?') strcat(command,"?"); // trunc only for index srch!
339  }
340  strcat(command,"\042)");
341 
342  }
343  else { *Com.term3=Com.bool2=Com.ex3=Com.tr3=0; Com.ind3=2; }
344 
345  if(!*term)
346  *Com.term4=Com.qua=Com.op=0;
347  else if(m_expand1 || m_expand2 || m_expand3) // Expans? dann Restric zuletzt
348  // restric? then set as suffix
349  { int k=strlen(command)-1;
350  if(strstr(command,"(") && command[k]!=')') strcat(command,"\042)");
351  else if(command[k]!=34 && command[k]!=')') strcat(command,"\042");
352  sprintf(command+strlen(command)," and %s %.3s%s",(char *)Base->restrics+Com.qua*6+2,oper[Com.op],term);
353  }
354  }
355  else sprintf(command,"?%s",term); // Keine DB, also nur VtSuche in externer Datei
356  }
357  else Com.type=0; // keine Eingabe
358 
359  m_plusterm.GetWindowText(term,80); // +-Suche?
360  if(*term)
361  {
362  strcpy(Com.term1,term1);
363 
364  if(*command)
365  MessageBox(uif[349]); // not online and offline at the same time
366  else
367  {
368  if(m_rad1.GetCheck()==1)
369  { sprintf(command,"+%s",term); Com.rad1=1; }
370  else
371  { sprintf(command,"?%s",term); Com.rad1=0; }
372  }
373  }
374 }
375 // in command steht jetzt der fertige Suchbefehl
376  return CDialog::DestroyWindow();
377 }
378 
379 void Wfind::OnCok() // OK-Button oder Enter
380 {
381  ok=IDOK;
382  CDialog::OnOK();
383 }
384 
386 {
387  ok=IDNO;
388  *command=0;
390 }
391 
392 void Wfind::OnOK()
393 {
394  // wirkungslos
395 }
396 
398 {
399  // Keine Aktion
400 }
401 
402 void Wfind::OnRepeat() // Button "vorh. Suche"
403 {
404 
405 // Elemente der vorh. Suche aus Struktur Com entnehmen
406  if(!Com.type) // full txt, dann nur diese 3:
407  {
408  m_plusterm.SetWindowText(Com.term1);
409  m_rad1.SetCheck(Com.rad1);
410  m_rad2.SetCheck(1-Com.rad1);
411  return;
412  }
413 // echter find-Befehl
414  m_term1.SetWindowText(Com.term1);
415  m_index1.SetCurSel(Com.ind1);
416  m_expa1.SetCheck(Com.ex1);
417  m_trunk1.SetCheck(Com.tr1);
418  m_bool1.SetCurSel(Com.bool1);
419 
420  m_term2.SetWindowText(Com.term2);
421  m_index2.SetCurSel(Com.ind2);
422  m_trunk2.SetCheck(Com.tr2);
423  m_expa2.SetCheck(Com.ex2);
424  m_bool2.SetCurSel(Com.bool2);
425 
426  m_term3.SetWindowText(Com.term3);
427  m_index3.SetCurSel(Com.ind3);
428  m_expa3.SetCheck(Com.ex3);
429  m_trunk3.SetCheck(Com.tr3);
430 
431  m_qua.SetWindowText(Com.term4);
432  m_qualif.SetCurSel(Com.qua);
433  m_op.SetCurSel(Com.op);
434 
435 }
436 
437 void Wfind::OnClear() // Formular leeren
438 {
439  m_term1.SetWindowText("");
440  m_term2.SetWindowText("");
441  m_term3.SetWindowText("");
442  m_qua.SetWindowText("");
443  m_plusterm.SetWindowText("");
444  m_index1.SetCurSel(0);
445  m_index2.SetCurSel(1);
446  m_index3.SetCurSel(2);
447  m_bool1.SetCurSel(0);
448  m_bool2.SetCurSel(0);
449  m_expa1.SetCheck(0);
450  m_expa2.SetCheck(0);
451  m_expa3.SetCheck(0);
452  m_trunk1.SetCheck(1);
453  m_trunk2.SetCheck(1);
454  m_trunk3.SetCheck(1);
455  m_qualif.SetCurSel(0);
456  m_op.SetCurSel(0);
457  m_rad1.SetCheck(1);
458  m_rad2.SetCheck(0);
459 
460 }
461 
462 
463 BOOL Wfind::OnHelpInfo(HELPINFO* pHelpInfo)
464 {
465 
466  OnCh(); return 1;
467 
468 }
469 
470 void Wfind::OnCh() // Help Button
471 {
472  extern a99 *dlg; // main dialog
473  dlg->helpinfo("_CH",uif[352]);
474  SetFocus();
475 }
476 
477 
478 /*
479  Copyright 2011 Universitätsbibliothek Braunschweig
480 
481  Licensed under the Apache License, Version 2.0 (the "License");
482  you may not use this file except in compliance with the License.
483  You may obtain a copy of the License at
484 
485  http://www.apache.org/licenses/LICENSE-2.0
486 
487  Unless required by applicable law or agreed to in writing, software
488  distributed under the License is distributed on an "AS IS" BASIS,
489  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
490  See the License for the specific language governing permissions and
491  limitations under the License.
492 */
493