1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #include "annot.h"
8
9 #include <QCheckBox>
10 #include <QComboBox>
11 #include <QDateTime>
12 #include <QFrame>
13 #include <QGroupBox>
14 #include <QHBoxLayout>
15 #include <QGridLayout>
16 #include <QVBoxLayout>
17 #include <QLabel>
18 #include <QLineEdit>
19 #include <QList>
20 #include <QPixmap>
21 #include <QPushButton>
22 #include <QSpinBox>
23 #include <QTabWidget>
24 #include <QTextEdit>
25 #include <QToolTip>
26 #include <QRadioButton>
27 #include <QSpacerItem>
28 #include <QStackedWidget>
29 #include <QStringList>
30 #include <QWidget>
31
32 #include "annotation.h"
33 #include "buttonicon.h"
34 #include "cmsettings.h"
35 #include "colorcombo.h"
36 #include "colorlistbox.h"
37 #include "commonstrings.h"
38 #include "editor.h"
39 #include "iconmanager.h"
40 #include "navigator.h"
41 #include "pageitem.h"
42 #include "prefscontext.h"
43 #include "prefsfile.h"
44 #include "prefsmanager.h"
45 #include "scfonts.h"
46 #include "scimage.h"
47 #include "scribusstructs.h"
48 #include "scribusdoc.h"
49 #include "scribusview.h"
50 #include "selfield.h"
51 #include "ui/customfdialog.h"
52 #include "ui/propertiespalette_utils.h"
53 #include "util.h"
54 #include "util_formats.h"
55
ScAnnot(QWidget * parent,PageItem * it,ScribusDoc * doc,ScribusView * view)56 ScAnnot::ScAnnot(QWidget* parent, PageItem *it, ScribusDoc* doc, ScribusView* view) : QDialog(parent),
57 m_item(it),
58 m_doc(doc),
59 m_view(view)
60 {
61 m_prefsCtxt = PrefsManager::instance().prefsFile->getContext("dirs");
62 m_annotation = it->annotation();
63
64 setupUi(this);
65 setModal(true);
66 setWindowTitle( tr( "Field Properties" ) );
67 setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
68
69 Width = static_cast<int>(m_doc->pageWidth());
70 Height = static_cast<int>(m_doc->pageHeight());
71 OriWidth = static_cast<int>(m_doc->pageWidth());
72 OriHeight = static_cast<int>(m_doc->pageHeight());
73 MaxPages = m_doc->DocPages.count();
74
75 QStringList tl;
76 if ((m_annotation.ActionType() == Annotation::Action_GoTo) || (m_annotation.ActionType() == Annotation::Action_GoToR_FileRel) || (m_annotation.ActionType() == Annotation::Action_GoToR_FileAbs))
77 {
78 QString tm = m_annotation.Action();
79 tl = tm.split(" ", Qt::SkipEmptyParts);
80 }
81 else
82 {
83 tl.append("0");
84 tl.append("0");
85 }
86
87 if (m_annotation.Type() != Annotation::RadioButton)
88 ComboBox1->setCurrentIndex(m_annotation.Type() - 2);
89 else
90 ComboBox1->setCurrentIndex(5);
91
92 PropertiesGroup->layout()->setAlignment(Qt::AlignTop);
93
94 Tip->setText(m_annotation.ToolTip());
95 Name->setText(m_item->itemName());
96 OldName = m_item->itemName();
97
98 TextGroup->layout()->setAlignment(Qt::AlignTop);
99 Schrift->setCurrentIndex(m_annotation.Font());
100
101 BorderGroup->layout()->setAlignment(Qt::AlignTop);
102
103 ColorList::Iterator cit;
104 BorderC->setPixmapType(ColorCombo::fancyPixmaps);
105 BorderC->setColors(m_doc->PageColors, true);
106 if (m_annotation.borderColor() == CommonStrings::None)
107 BorderC->setCurrentIndex(0);
108 else
109 BorderC->setCurrentText(m_annotation.borderColor());
110
111 // PFJ - 28/02/04 - Altered to the QString/size_t/for style
112 QString borders[] = { CommonStrings::tr_NoneColor, tr("Thin"), tr("Normal"), tr("Wide") };
113 size_t bordersArray = sizeof(borders) / sizeof(*borders);
114 BorderW->clear();
115 for (uint propagate = 0; propagate < bordersArray; ++propagate)
116 BorderW->addItem(borders[propagate]);
117 BorderW->setCurrentIndex(m_annotation.borderWidth());
118
119 BorderS->setCurrentIndex(m_annotation.borderStyle());
120
121 OtherGroup->layout()->setAlignment(Qt::AlignTop);
122
123 ReadOnly->setEnabled(m_annotation.Type() != Annotation::Button);
124 ReadOnly->setChecked(m_annotation.Flag() & Annotation::Flag_ReadOnly);
125 Required->setEnabled(m_annotation.Type() != Annotation::Button);
126 Required->setChecked(m_annotation.Flag() & Annotation::Flag_Required);
127 NoExport->setEnabled(m_annotation.Type() != Annotation::Button);
128 NoExport->setChecked(m_annotation.Flag() & Annotation::Flag_NoExport);
129 Visib->setCurrentIndex(m_annotation.Vis());
130
131 TextOptionGroup->layout()->setAlignment(Qt::AlignTop);
132 DownT->setText(m_annotation.Down());
133 TextO->setText(m_annotation.RollOver());
134
135 IconOptionGroup->layout()->setAlignment(Qt::AlignTop);
136 UseIcons->setChecked(m_annotation.UseIcons());
137 IconNR->setEnabled(false);
138 IconPR->setEnabled(false);
139 IconRR->setEnabled(false);
140 if (!UseIcons->isChecked())
141 {
142 IconN->setEnabled(false);
143 IconP->setEnabled(false);
144 IconR->setEnabled(false);
145 NiconPrev->setEnabled(false);
146 PiconPrev->setEnabled(false);
147 RiconPrev->setEnabled(false);
148 PlaceIcon->setEnabled(false);
149 }
150 else
151 {
152 QPixmap pmI1;
153 ScImage im;
154 CMSettings cms(m_view->m_doc, "", Intent_Perceptual);
155 cms.allowColorManagement(false);
156 if (!m_item->Pfile.isEmpty())
157 {
158 im.loadPicture(m_item->Pfile, 1, cms, ScImage::RGBData, 72);
159 pmI1=QPixmap::fromImage(im.qImage());
160 NiconPrev->setPixmap(pmI1);
161 IconNR->setEnabled(true);
162 }
163 if (!m_item->Pfile2.isEmpty())
164 {
165 im.loadPicture(m_item->Pfile2, 1, cms, ScImage::RGBData, 72);
166 pmI1=QPixmap::fromImage(im.qImage());
167 PiconPrev->setPixmap(pmI1);
168 IconPR->setEnabled(true);
169 }
170 if (!m_item->Pfile3.isEmpty())
171 {
172 im.loadPicture(m_item->Pfile3, 1, cms, ScImage::RGBData, 72);
173 pmI1=QPixmap::fromImage(im.qImage());
174 RiconPrev->setPixmap(pmI1);
175 IconRR->setEnabled(true);
176 }
177 }
178
179 HighlightOptionGroup->layout()->setAlignment(Qt::AlignTop);
180 ComboBox7_2->setCurrentIndex(m_annotation.Feed());
181
182 MultiL->setChecked(m_annotation.Flag() & Annotation::Flag_Multiline);
183 Passwd->setChecked(m_annotation.Flag() & Annotation::Flag_Password);
184 MaxChars->setMinimum(0);
185 MaxChars->setMaximum(32768);
186 bool setter = m_annotation.MaxChar() != -1;
187 MaxChars->setValue(setter ? m_annotation.MaxChar() : 0);
188 Limit->setChecked(setter);
189 MaxChars->setEnabled(setter);
190 NoScroll->setChecked(m_annotation.Flag() & Annotation::Flag_DoNotScroll);
191 NoSpell->setChecked(m_annotation.Flag() & Annotation::Flag_DoNotSpellCheck);
192
193 ChkStil->setCurrentIndex(m_annotation.ChkStil());
194 isChkd->setChecked(m_annotation.IsChk());
195
196 CanEdit->setChecked(m_annotation.Flag() & Annotation::Flag_Edit);
197
198 int tmpac = m_annotation.ActionType();
199 if (m_annotation.ActionType() < 0)
200 tmpac = 1;
201 if ((tmpac == 7) || (tmpac == 9))
202 tmpac = 2;
203 else if (tmpac == 10)
204 tmpac = 6;
205 ActionCombo->setCurrentIndex(tmpac);
206
207 QPalette palTxt = EditJava->palette();
208 palTxt.setColor(QPalette::Base, palette().color(QPalette::Window));
209 if ((m_annotation.ActionType() == Annotation::Action_JavaScript) || (m_annotation.AAact()))
210 EditJava->setPlainText(m_annotation.Action());
211 ScrEdited = Annotation::Java_ReleaseButton;
212 SelAction->setCurrentIndex(0);
213 EditJava->setReadOnly(true);
214 EditJava->setAutoFillBackground(true);
215 EditJava->setPalette(palTxt);
216 EditJava->setMinimumSize( QSize( 0, 50 ) );
217 EditJava->setFocusPolicy(Qt::NoFocus);
218
219 GroupBoxDestination->layout()->setAlignment(Qt::AlignTop);
220 Destfile->setText(m_annotation.Extern());
221 Destfile->setReadOnly(true);
222 if (m_annotation.ActionType() == Annotation::Action_GoToR_FileRel)
223 useAbsolute->setChecked(false);
224 else if (m_annotation.ActionType() == Annotation::Action_GoToR_FileAbs)
225 useAbsolute->setChecked(true);
226 SpinBox11->setMinimum(1);
227 SpinBox11->setMaximum(((m_annotation.ActionType() == Annotation::Action_GoToR_FileRel) || (m_annotation.ActionType() == Annotation::Action_GoToR_FileAbs)) ? 1000 : MaxPages);
228 SpinBox11->setValue(qMin(m_annotation.Ziel() + 1, MaxPages));
229
230 if ((m_annotation.ActionType() == Annotation::Action_GoToR_FileRel) || (m_annotation.ActionType() == Annotation::Action_GoToR_FileAbs))
231 m_navig = new Navigator( GroupBoxDestination, 100, m_annotation.Ziel()+1, m_view, m_annotation.Extern());
232 else
233 m_navig = new Navigator( GroupBoxDestination, 100, qMin(m_annotation.Ziel(), MaxPages - 1), m_view);
234 m_navig->setMinimumSize(QSize(m_navig->pmx.width(), m_navig->pmx.height()));
235 GroupBoxDestinationLayout->addWidget(m_navig, 2, 2, 3, 1);
236
237 SpinBox21->setSuffix( tr( " pt" ) );
238 SpinBox21->setMaximum(Width);
239 SpinBox21->setValue(tl[0].toInt());
240 SpinBox31->setMaximum(Height);
241 SpinBox31->setSuffix( tr( " pt" ) );
242 SpinBox31->setValue(Height - tl[1].toInt());
243
244 if (m_annotation.ActionType() == Annotation::Action_SubmitForm)
245 SubURL->setText(m_annotation.Action());
246 SelAsHtml->setCurrentIndex(m_annotation.HTML());
247
248 if (m_annotation.ActionType() == Annotation::Action_ImportData)
249 SubURLa->setText(m_annotation.Action());
250
251 nameActionCombo->addItem( tr("First Page"), QString("FirstPage"));
252 nameActionCombo->addItem( tr("Previous Page"), QString("PrevPage"));
253 nameActionCombo->addItem( tr("Next Page"), QString("NextPage"));
254 nameActionCombo->addItem( tr("Last Page"), QString("LastPage"));
255 nameActionCombo->addItem( tr("Go Back"), QString("GoBack"));
256 nameActionCombo->addItem( tr("Go Forward"), QString("GoForward"));
257 nameActionCombo->addItem( tr("Go Back Doc"), QString("GoBackDoc"));
258 nameActionCombo->addItem( tr("Go Forward Doc"), QString("GoForwardDoc"));
259 nameActionCombo->addItem( tr("Go To Page"), QString("GoToPage"));
260 nameActionCombo->addItem( tr("Actual Size"), QString("ActualSize"));
261 nameActionCombo->addItem( tr("Fit Page"), QString("FitPage"));
262 nameActionCombo->addItem( tr("Fit Width"), QString("FitWidth"));
263 nameActionCombo->addItem( tr("Fit Height"), QString("FitHeight"));
264 nameActionCombo->addItem( tr("Fit Visible"), QString("FitVisible"));
265 nameActionCombo->addItem( tr("Single Page"), QString("SinglePage"));
266 nameActionCombo->addItem( tr("Two Pages"), QString("TwoPages"));
267 nameActionCombo->addItem( tr("One Column"), QString("OneColumn"));
268 nameActionCombo->addItem( tr("Two Columns"), QString("TwoColumns"));
269 nameActionCombo->addItem( tr("Zoom View In"), QString("ZoomViewIn"));
270 nameActionCombo->addItem( tr("Zoom View Out"), QString("ZoomViewOut"));
271 nameActionCombo->addItem( tr("Zoom To"), QString("ZoomTo"));
272 nameActionCombo->addItem( tr("Print"), QString("Print"));
273 nameActionCombo->addItem( tr("Close"), QString("Close"));
274 nameActionCombo->addItem( tr("Quit"), QString("Quit"));
275 nameActionCombo->addItem( tr("General Prefs"), QString("GeneralPrefs"));
276 nameActionCombo->addItem( tr("General Info"), QString("GeneralInfo"));
277 nameActionCombo->addItem( tr("Page Setup"), QString("PageSetup"));
278 nameActionCombo->addItem( tr("Full Screen"), QString("FullScreen"));
279 nameActionCombo->addItem( tr("Show/Hide Bookmarks"), QString("ShowHideBookmarks"));
280 nameActionCombo->addItem( tr("Show/Hide Thumbnails"), QString("ShowHideThumbnails"));
281 nameActionCombo->addItem( tr("Show/Hide Toolbar Editing"), QString("ShowHideToolbarEditing"));
282 nameActionCombo->addItem( tr("Show/Hide Toolbar Commenting"), QString("ShowHideToolbarCommenting"));
283 nameActionCombo->addItem( tr("Show/Hide Toolbar Edit"), QString("ShowHideToolbarEdit"));
284 nameActionCombo->addItem( tr("Show/Hide Toolbar File"), QString("ShowHideToolbarFile"));
285 nameActionCombo->addItem( tr("Show/Hide Toolbar Find"), QString("ShowHideToolbarFind"));
286 nameActionCombo->addItem( tr("Show/Hide Toolbar Forms"), QString("ShowHideToolbarForms"));
287 nameActionCombo->addItem( tr("Show/Hide Toolbar Measuring"), QString("ShowHideToolbarMeasuring"));
288 nameActionCombo->addItem( tr("Show/Hide Toolbar Data"), QString("ShowHideToolbarData"));
289 nameActionCombo->addItem( tr("Show/Hide Toolbar Page Display"), QString("ShowHideToolbarPageDisplay"));
290 nameActionCombo->addItem( tr("Show/Hide Toolbar Navigation"), QString("ShowHideToolbarNavigation"));
291 nameActionCombo->addItem( tr("Show/Hide Toolbar Print Production"), QString("ShowHideToolbarPrintProduction"));
292 nameActionCombo->addItem( tr("Show/Hide Toolbar Redaction"), QString("ShowHideToolbarRedaction"));
293 nameActionCombo->addItem( tr("Show/Hide Toolbar Basic Tools"), QString("ShowHideToolbarBasicTools"));
294 nameActionCombo->addItem( tr("Show/Hide Toolbar Tasks"), QString("ShowHideToolbarTasks"));
295 nameActionCombo->addItem( tr("Show/Hide Toolbar Typewriter"), QString("ShowHideToolbarTypewriter"));
296 nameActionCombo->addItem( tr("Show/Hide Articles"), QString("ShowHideArticles"));
297 nameActionCombo->addItem( tr("Show/Hide File Attachment"), QString("ShowHideFileAttachment"));
298 nameActionCombo->addItem( tr("Show/Hide Annot Manager"), QString("ShowHideAnnotManager"));
299 nameActionCombo->addItem( tr("Show/Hide Fields"), QString("ShowHideFields"));
300 nameActionCombo->addItem( tr("Show/Hide Optional Content"), QString("ShowHideOptCont"));
301 nameActionCombo->addItem( tr("Show/Hide Model Tree"), QString("ShowHideModelTree"));
302 nameActionCombo->addItem( tr("Show/Hide Signatures"), QString("ShowHideSignatures"));
303
304 if ((m_annotation.ActionType() == Annotation::Action_GoToR_FileRel) || (m_annotation.ActionType() == Annotation::Action_GoToR_FileAbs))
305 {
306 LExtern->setChecked(true);
307 if (!Destfile->text().isEmpty())
308 {
309 Width = m_navig->Width;
310 Height = m_navig->Height;
311 }
312 else
313 {
314 Destfile->setEnabled(false);
315 ChFile->setEnabled(false);
316 LExtern->setChecked(false);
317 }
318 }
319 else
320 {
321 Destfile->setEnabled(false);
322 ChFile->setEnabled(false);
323 LExtern->setChecked(false);
324 }
325
326 // Format tab settings
327 TxFormat->setCurrentIndex(m_annotation.Format());
328
329 NumbGroup->layout()->setAlignment( Qt::AlignTop );
330 Decim->setMinimum(0);
331 Decim->setMaximum(12);
332 Decim->setValue(0);
333 CurSym->setEnabled(false);
334 PreCurr->setEnabled(false);
335
336 FormNum = 0;
337
338 Decim2->setMinimum(0);
339 Decim2->setMaximum(12);
340 Decim2->setValue(0);
341
342 NumGroup2a->layout()->setAlignment(Qt::AlignTop);
343
344 GroupCust->layout()->setAlignment(Qt::AlignTop);
345 EditFormat->setAutoDefault(false);
346 if (m_annotation.Format() != 5)
347 EditFormat->setEnabled( false );
348 if (m_annotation.Format() == 5)
349 FormatScript->setPlainText( m_annotation.F_act() );
350 FormatScript->setReadOnly(true);
351 FormatScript->setAutoFillBackground(true);
352 FormatScript->setPalette(palTxt);
353 FormatScript->setMaximumSize(QSize(32000,50));
354 FormatScript->setFocusPolicy(Qt::NoFocus);
355 EditKeystr->setAutoDefault( false );
356 if (m_annotation.Format() != 5)
357 EditKeystr->setEnabled( false );
358 if (m_annotation.Format() == 5)
359 KeyScript->setPlainText( m_annotation.K_act() );
360 KeyScript->setReadOnly(true);
361 KeyScript->setAutoFillBackground(true);
362 KeyScript->setPalette(palTxt);
363 KeyScript->setMaximumSize(QSize(32000, 50));
364 KeyScript->setFocusPolicy(Qt::NoFocus);
365
366 DecodeNum();
367
368 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabFormat), false);
369
370
371 // Value validation settings
372 /*ValidateGroup->layout()->setAlignment(Qt::AlignTop);*/
373 ValidScript->setMinimumSize( QSize( 0, 50 ) );
374 ValidScript->setFocusPolicy(Qt::NoFocus);
375 ValidScript->setReadOnly( true );
376 ValidScript->setAutoFillBackground(true);
377 ValidScript->setPalette(palTxt);
378 EditValScript->setAutoDefault( false );
379
380 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabValidate), false);
381 SetVali();
382
383 // Value calculation settings
384 /*CalcGroup->layout()->setAlignment(Qt::AlignTop);*/
385 CalcScript->setMinimumSize( QSize( 0, 50 ) );
386 CalcScript->setFocusPolicy(Qt::NoFocus);
387 CalcScript->setReadOnly( true );
388 CalcScript->setAutoFillBackground(true);
389 CalcScript->setPalette(palTxt);
390
391 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabCalculate), false);
392 SetCalc();
393
394 if (m_annotation.Type() == Annotation::RadioButton)
395 SetAnnotationType(5);
396 else
397 SetAnnotationType(m_annotation.Type()-2);
398
399 PushButton1->setDefault( true );
400
401 connect(PushButton1, SIGNAL(clicked()), this, SLOT(SetValues()));
402 connect(PushButton2, SIGNAL(clicked()), this, SLOT(reject()));
403 connect(EditFormat, SIGNAL(clicked()), this, SLOT(editFormatSc()));
404 connect(EditKeystr, SIGNAL(clicked()), this, SLOT(editKeySc()));
405 connect(EditValScript, SIGNAL(clicked()), this, SLOT(editValidSc()));
406 connect(EditCalc, SIGNAL(clicked()), this, SLOT(editCalcSc()));
407 connect(EditJ, SIGNAL(clicked()), this, SLOT(editJavaSc()));
408 connect(SeField, SIGNAL(clicked()), this, SLOT(SelectFelder()));
409 connect(Format0c, SIGNAL(activated(const QString&)), this, SLOT(setDateSample(const QString&)));
410 connect(TxFormat, SIGNAL(activated(int)), this, SLOT(SetFoScript(int)));
411 connect(ComboBox1, SIGNAL(activated(int)), this, SLOT(SetAnnotationType(int)));
412 connect(ActionCombo, SIGNAL(activated(int)), this, SLOT(SetActionType(int)));
413 connect(SelAction, SIGNAL(activated(int)), this, SLOT(SetActionScript(int)));
414 connect(m_navig, SIGNAL(Coords(double, double)), this, SLOT(SetCoords(double, double)));
415 connect(SpinBox11, SIGNAL(valueChanged(int)), this, SLOT(SetPage(int)));
416 connect(SpinBox21, SIGNAL(valueChanged(int)), this, SLOT(SetCross()));
417 connect(SpinBox31, SIGNAL(valueChanged(int)), this, SLOT(SetCross()));
418 connect(Limit, SIGNAL(clicked()), this, SLOT(SetLimit()));
419 connect(UseCurr, SIGNAL(clicked()), this, SLOT(SetCurr()));
420 connect(Format0, SIGNAL(clicked()), this, SLOT(SetFormNum()));
421 connect(Format1, SIGNAL(clicked()), this, SLOT(SetFormNum()));
422 connect(Format2, SIGNAL(clicked()), this, SLOT(SetFormNum()));
423 connect(Format3, SIGNAL(clicked()), this, SLOT(SetFormNum()));
424 connect(Format0a, SIGNAL(clicked()), this, SLOT(SetFormNum()));
425 connect(Format1a, SIGNAL(clicked()), this, SLOT(SetFormNum()));
426 connect(Format2a, SIGNAL(clicked()), this, SLOT(SetFormNum()));
427 connect(Format3a, SIGNAL(clicked()), this, SLOT(SetFormNum()));
428 connect(Format0b, SIGNAL(clicked()), this, SLOT(SetFormNum()));
429 connect(Format1b, SIGNAL(clicked()), this, SLOT(SetFormNum()));
430 connect(Format2b, SIGNAL(clicked()), this, SLOT(SetFormNum()));
431 connect(Format3b, SIGNAL(clicked()), this, SLOT(SetFormNum()));
432 connect(NoValid, SIGNAL(clicked()), this, SLOT(HandleVali()));
433 connect(SimpleValid, SIGNAL(clicked()), this, SLOT(HandleVali()));
434 connect(CustomValid, SIGNAL(clicked()), this, SLOT(HandleVali()));
435 connect(NoCalc, SIGNAL(clicked()), this, SLOT(HandleCalc()));
436 connect(SimpleCalc, SIGNAL(clicked()), this, SLOT(HandleCalc()));
437 connect(CustomCalc, SIGNAL(clicked()), this, SLOT(HandleCalc()));
438 connect(IconN, SIGNAL(clicked()), this, SLOT(GetNIcon()));
439 connect(IconNR, SIGNAL(clicked()), this, SLOT(RemoveNIcon()));
440 connect(IconP, SIGNAL(clicked()), this, SLOT(GetPIcon()));
441 connect(IconPR, SIGNAL(clicked()), this, SLOT(RemovePIcon()));
442 connect(IconR, SIGNAL(clicked()), this, SLOT(GetRIcon()));
443 connect(IconRR, SIGNAL(clicked()), this, SLOT(RemoveRIcon()));
444 connect(UseIcons, SIGNAL(clicked()), this, SLOT(IconsEin()));
445 connect(PlaceIcon, SIGNAL(clicked()), this, SLOT(IPlace()));
446 connect(ChFile, SIGNAL(clicked()), this, SLOT(GetFile()));
447 connect(LExtern, SIGNAL(clicked()), this, SLOT(SetExternLink()));
448 connect(Name, SIGNAL(Leaved()), this, SLOT(NewName()));
449
450 NoSpell->setToolTip( tr( "Flag is ignored for PDF 1.3" ) );
451 NoScroll->setToolTip( tr( "Flag is ignored for PDF 1.3" ) );
452 CalcFields->setToolTip( tr( "Enter a comma separated list of fields here" ) );
453 IconNR->setToolTip( tr("You need at least the Icon for Normal to use Icons for Buttons"));
454
455 SetPage(qMin(SpinBox11->value(), MaxPages));
456 SetCross();
457 //resize( minimumSizeHint() );
458 }
459
~ScAnnot()460 ScAnnot::~ScAnnot()
461 {}
462
NewName()463 void ScAnnot::NewName()
464 {
465 QString NameNew = Name->text();
466 if (NameNew.isEmpty())
467 {
468 Name->setText(OldName);
469 return;
470 }
471 bool found = false;
472 QList<PageItem*> allItems;
473 for (int i = 0; i < m_view->m_doc->Items->count(); ++i)
474 {
475 PageItem *currItem = m_view->m_doc->Items->at(i);
476 if (currItem->isGroup())
477 allItems = currItem->getAllChildren();
478 else
479 allItems.append(currItem);
480 for (int j = 0; j < allItems.count(); j++)
481 {
482 PageItem* ite = allItems.at(j);
483 if ((NameNew == ite->itemName()) && (ite != m_item))
484 {
485 found = true;
486 break;
487 }
488 }
489 allItems.clear();
490 }
491 if (found)
492 {
493 Name->setText(OldName);
494 Name->setFocus();
495 }
496 }
497
IPlace()498 void ScAnnot::IPlace()
499 {
500 ButtonIcon* dia = new ButtonIcon(this, m_item);
501 if (dia->exec())
502 {
503 int w = m_item->pixm.width();
504 int h = m_item->pixm.height();
505 double sw = m_item->width() / w;
506 double sh = m_item->height() / h;
507 double sc = qMin(sw, sh);
508 if (dia->IcScaleH == 3)
509 {
510 m_item->setImageXYScale(1.0, 1.0);
511 m_item->setImageXYOffset((m_item->width() - w) * dia->IcPlaceX, (m_item->height() - h) * dia->IcPlaceY);
512 }
513 else if (dia->ScaleH->currentIndex() == 0)
514 {
515 m_item->setImageXYScale(sc, sc);
516 m_item->setImageXYOffset(((m_item->width() - w * sc) / sc) / 2.0 / sc, ((m_item->height() - h * sc) / sc) / 2.0 / sc);
517 }
518 else
519 {
520 m_item->setImageXYScale(sw, sh);
521 m_item->setImageXYOffset(0.0, 0.0);
522 }
523 m_annotation.setIPlace(dia->Place->currentIndex());
524 m_annotation.setScaleW(dia->ScaleW->currentIndex());
525 }
526 delete dia;
527 }
528
RemoveNIcon()529 void ScAnnot::RemoveNIcon()
530 {
531 NiconPrev->clear();
532 m_item->Pfile.clear();
533 m_item->imageIsAvailable = false;
534 IconNR->setEnabled(false);
535 }
536
RemovePIcon()537 void ScAnnot::RemovePIcon()
538 {
539 PiconPrev->clear();
540 m_item->Pfile2.clear();
541 IconPR->setEnabled(false);
542 }
543
RemoveRIcon()544 void ScAnnot::RemoveRIcon()
545 {
546 RiconPrev->clear();
547 m_item->Pfile3.clear();
548 IconRR->setEnabled(false);
549 }
550
IconsEin()551 void ScAnnot::IconsEin()
552 {
553 bool setter = UseIcons->isChecked();
554 IconN->setEnabled(setter);
555 IconP->setEnabled(setter);
556 IconR->setEnabled(setter);
557
558 NiconPrev->setEnabled(setter);
559 PiconPrev->setEnabled(setter);
560 RiconPrev->setEnabled(setter);
561 PlaceIcon->setEnabled(setter);
562 IconNR->setEnabled(!m_item->Pfile.isEmpty());
563 IconPR->setEnabled(!m_item->Pfile2.isEmpty());
564 IconRR->setEnabled(!m_item->Pfile3.isEmpty());
565 m_annotation.setUseIcons(UseIcons->isChecked());
566 }
567
GetNIcon()568 void ScAnnot::GetNIcon()
569 {
570 QString fileName;
571 QString wdir = m_prefsCtxt->get("icon", ".");
572 CustomFDialog dia(this, wdir, tr("Open"),
573 tr("Images (*.tif *.png *.jpg *.xpm);;%1;;All Files (*)").arg(FormatsManager::instance()->extensionsForFormat(FormatsManager::EPS)), fdShowPreview | fdExistingFiles);
574 if (dia.exec() == QDialog::Accepted)
575 fileName = dia.selectedFile();
576 else
577 return;
578 if (!fileName.isEmpty())
579 {
580 m_prefsCtxt->set("icon", fileName.left(fileName.lastIndexOf("/")));
581 QPixmap pmI1;
582 CMSettings cms(m_view->m_doc, "", Intent_Perceptual);
583 cms.allowColorManagement(false);
584 m_item->pixm.loadPicture(fileName, 1, cms, ScImage::RGBData, 72);
585 pmI1=QPixmap::fromImage(m_item->pixm.qImage());
586 NiconPrev->setPixmap(pmI1);
587 m_item->Pfile = fileName;
588 m_item->imageIsAvailable = true;
589 int w = m_item->pixm.width();
590 int h = m_item->pixm.height();
591 double sw = m_item->width() / w;
592 double sh = m_item->height() / h;
593 double sc = qMin(sw,sh);
594 m_item->setImageXYScale(sc, sc);
595 m_item->setImageXYOffset(((m_item->width() - (w * sc)) / 2) / sc, ((m_item->height() - (h * sc)) / 2) / sc);
596 IconNR->setEnabled(true);
597 }
598 }
599
GetPIcon()600 void ScAnnot::GetPIcon()
601 {
602 QString fileName;
603 QString wdir = m_prefsCtxt->get("icon", ".");
604 CustomFDialog dia(this, wdir, tr("Open"),
605 tr("Images (*.tif *.png *.jpg *.xpm);;PostScript (*.eps *.epsi);;All Files (*)"), fdShowPreview | fdExistingFiles);
606 if (dia.exec() == QDialog::Accepted)
607 fileName = dia.selectedFile();
608 else
609 return;
610 if (!fileName.isEmpty())
611 {
612 m_prefsCtxt->set("icon", fileName.left(fileName.lastIndexOf("/")));
613 QPixmap pmI1;
614 ScImage im;
615 CMSettings cms(m_view->m_doc, "", Intent_Perceptual);
616 cms.allowColorManagement(false);
617 im.loadPicture(fileName, 1, cms, ScImage::RGBData, 72);
618 pmI1 = QPixmap::fromImage(im.qImage());
619 PiconPrev->setPixmap(pmI1);
620 m_item->Pfile2 = fileName;
621 IconPR->setEnabled(true);
622 }
623 }
624
GetRIcon()625 void ScAnnot::GetRIcon()
626 {
627 QString fileName;
628 QString wdir = m_prefsCtxt->get("icon", ".");
629 CustomFDialog dia(this, wdir, tr("Open"),
630 tr("Images (*.tif *.png *.jpg *.xpm);;PostScript (*.eps *.epsi);;All Files (*)"), fdShowPreview | fdExistingFiles);
631 if (dia.exec() == QDialog::Accepted)
632 fileName = dia.selectedFile();
633 else
634 return;
635 if (!fileName.isEmpty())
636 {
637 m_prefsCtxt->set("icon", fileName.left(fileName.lastIndexOf("/")));
638 QPixmap pmI1;
639 ScImage im;
640 CMSettings cms(m_view->m_doc, "", Intent_Perceptual);
641 cms.allowColorManagement(false);
642 im.loadPicture(fileName, 1, cms, ScImage::RGBData, 72);
643 pmI1 = QPixmap::fromImage(im.qImage());
644 RiconPrev->setPixmap(pmI1);
645 m_item->Pfile3 = fileName;
646 IconRR->setEnabled(true);
647 }
648 }
649
SelectFelder()650 void ScAnnot::SelectFelder()
651 {
652 SelectFields* dia = new SelectFields(this, CalcFields->text(), m_item->itemName(), m_view->m_doc, 3);
653 if (dia->exec())
654 CalcFields->setText(dia->S_Fields);
655 delete dia;
656 }
657
editKeySc()658 void ScAnnot::editKeySc()
659 {
660 Editor* dia = new Editor(this, m_annotation.K_act(), m_view);
661 if (dia->exec())
662 {
663 m_annotation.setK_act(dia->EditTex->toPlainText());
664 KeyScript->setPlainText( m_annotation.K_act() );
665 }
666 delete dia;
667 }
668
editFormatSc()669 void ScAnnot::editFormatSc()
670 {
671 Editor* dia = new Editor(this, m_annotation.F_act(), m_view);
672 if (dia->exec())
673 {
674 m_annotation.setF_act(dia->EditTex->toPlainText());
675 FormatScript->setPlainText( m_annotation.F_act() );
676 }
677 delete dia;
678 }
679
editValidSc()680 void ScAnnot::editValidSc()
681 {
682 Editor* dia = new Editor(this, m_annotation.V_act(), m_view);
683 if (dia->exec())
684 {
685 m_annotation.setV_act(dia->EditTex->toPlainText());
686 ValidScript->setPlainText( m_annotation.V_act() );
687 }
688 delete dia;
689 }
690
editCalcSc()691 void ScAnnot::editCalcSc()
692 {
693 Editor* dia = new Editor(this, m_annotation.C_act(), m_view);
694 if (dia->exec())
695 {
696 m_annotation.setC_act(dia->EditTex->toPlainText());
697 CalcScript->setPlainText( m_annotation.C_act() );
698 }
699 delete dia;
700 }
701
editJavaSc()702 void ScAnnot::editJavaSc()
703 {
704 Editor* dia = new Editor(this, EditJava->toPlainText(), m_view);
705 if (dia->exec())
706 EditJava->setPlainText(dia->EditTex->toPlainText());
707 delete dia;
708 }
709
setDateSample(const QString & ds)710 void ScAnnot::setDateSample(const QString& ds)
711 {
712 QDateTime dt = QDateTime::currentDateTime();
713 QString tmp = "";
714 if (ds == "m/d")
715 tmp = "M/d";
716 if (ds == "m/d/yy")
717 tmp = "M/d/yy";
718 if (ds == "mm/dd/yy")
719 tmp = "MM/dd/yy";
720 if (ds == "mm/yy")
721 tmp = "MM/yy";
722 if (ds == "d-mmm")
723 tmp = "d-MMM";
724 if (ds == "d-mmm-yy")
725 tmp = "d-MMM-yy";
726 if (ds == "dd-mmm-yy")
727 tmp = "dd-MMM-yy";
728 if (ds == "dd/mm/yy")
729 tmp = "dd/MM/yy";
730 if (ds == "dd.mm.yyyy")
731 tmp = "dd.MM.yyyy";
732 if (ds == "dd/mm/yyyy")
733 tmp = "dd/MM/yyyy";
734 if (ds == "yy-mm-dd")
735 tmp = "yy-MM-dd";
736 if (ds == "mmm-yy")
737 tmp = "MMM-yy";
738 if (ds == "mmmm-yy")
739 tmp = "MMMM-yy";
740 if (ds == "mmm d, yyyy")
741 tmp = "MMM d, yyyy";
742 if (ds == "mmmm d, yyyy")
743 tmp = "MMMM d, yyyy";
744 if (ds == "m/d/yy h:MM tt")
745 tmp = "M/d/yy h:mm ap";
746 if (ds == "m/d/yy HH:MM")
747 tmp = "M/d/yy hh:mm";
748 if (ds == "yyyy-mm-dd")
749 tmp = "yyyy-MM-dd";
750 TextDa1->setText( tr("Example:")+" "+dt.toString(tmp));
751 }
752
DecodeVali()753 void ScAnnot::DecodeVali()
754 {
755 QString pfor = m_annotation.V_act();
756 int ss = pfor.indexOf("(");
757 QString pfo = pfor.mid(ss+1, pfor.length()-ss-2);
758 QStringList pfol;
759 pfol = pfo.split(",", Qt::SkipEmptyParts);
760 MinValid->setText(pfol[1].simplified());
761 MaxValid->setText(pfol[3].simplified());
762 }
763
DecodeCalc()764 void ScAnnot::DecodeCalc()
765 {
766 QString tm = "";
767 QString tm2;
768 QString pfor = m_annotation.C_act();
769 int ss = pfor.lastIndexOf("(");
770 QString pfo = pfor.mid(ss+1, pfor.length()-ss-3);
771 QStringList pfol;
772 pfol = pfo.split(",", Qt::SkipEmptyParts);
773 if (pfol.count() > 1)
774 {
775 tm2 = pfol[0].simplified();
776 tm += tm2.midRef(1, tm2.length()-2);
777 for (int cfx = 1; cfx < pfol.count(); ++cfx)
778 {
779 tm2 = pfol[cfx].simplified();
780 tm += ", "+tm2.mid(1, tm2.length()-2);
781 }
782 }
783 CalcFields->setText(tm);
784 ss = pfor.indexOf("(");
785 pfo = pfor.mid(ss+1, pfor.length()-ss-3);
786 pfol = pfo.split(",", Qt::SkipEmptyParts);
787 /* PFJ - 28/02/04 - Let's get rid of lots of ifs.... */
788 QString pf[] = {"\"SUM\"", "\"PRD\"", "\"AVG\"", "\"MIN\"", "\"MAX\""};
789 size_t pfTest = sizeof(pf) / sizeof(*pf);
790 for (uint test = 0; test < pfTest; ++test)
791 {
792 if (pfol[0] == pf[test])
793 CalcArt->setCurrentIndex(test);
794 }
795 }
796
DecodeNum()797 void ScAnnot::DecodeNum()
798 {
799 QString pfor = m_annotation.F_act();
800 int ss = pfor.indexOf("(");
801 QString pfo = pfor.mid(ss+1, pfor.length()-ss-2);
802 QStringList pfol;
803 pfol = pfo.split(",", Qt::SkipEmptyParts);
804 if (m_annotation.Format() == 1)
805 {
806 Decim->setValue(pfol[0].toInt());
807 switch (pfol[1].toInt())
808 {
809 case 0:
810 Format0->setChecked(true);
811 FormNum = 0;
812 break;
813 case 1:
814 Format1->setChecked(true);
815 FormNum = 1;
816 break;
817 case 2:
818 Format2->setChecked(true);
819 FormNum = 2;
820 break;
821 case 3:
822 Format3->setChecked(true);
823 FormNum = 3;
824 break;
825 }
826 if (pfol[5] == " true")
827 PreCurr->setChecked(true);
828 else
829 PreCurr->setChecked(false);
830 if (pfol[4].length() > 2)
831 {
832 if (PreCurr->isChecked())
833 CurSym->setText(pfol[4].mid(2,pfol[4].length()-4));
834 else
835 CurSym->setText(pfol[4].mid(3,pfol[4].length()-4));
836 }
837 else
838 CurSym->setText("");
839 if (!CurSym->text().isEmpty())
840 {
841 CurSym->setEnabled(true);
842 UseCurr->setEnabled(true);
843 UseCurr->setChecked(true);
844 PreCurr->setEnabled(true);
845 }
846 }
847 if (m_annotation.Format() == 2)
848 {
849 Decim2->setValue(pfol[0].toInt());
850 switch (pfol[1].toInt())
851 {
852 case 0:
853 Format0a->setChecked(true);
854 FormNum = 0;
855 break;
856 case 1:
857 Format1a->setChecked(true);
858 FormNum = 1;
859 break;
860 case 2:
861 Format2a->setChecked(true);
862 FormNum = 2;
863 break;
864 case 3:
865 Format3a->setChecked(true);
866 FormNum = 3;
867 break;
868 }
869 }
870 if (m_annotation.Format() == 3)
871 {
872 setCurrentComboItem(Format0c, pfol[0].remove("\""));
873 setDateSample(pfol[0]);
874 }
875 if (m_annotation.Format() == 4)
876 {
877 switch (pfol[0].toInt())
878 {
879 case 0:
880 Format0b->setChecked(true);
881 FormNum = 0;
882 break;
883 case 1:
884 Format1b->setChecked(true);
885 FormNum = 1;
886 break;
887 case 2:
888 Format2b->setChecked(true);
889 FormNum = 2;
890 break;
891 case 3:
892 Format3b->setChecked(true);
893 FormNum = 3;
894 break;
895 }
896 }
897 }
898
SetFormNum()899 void ScAnnot::SetFormNum()
900 {
901 switch (m_annotation.Format())
902 {
903 case 1:
904 if (Format0->isChecked())
905 FormNum = 0;
906 if (Format1->isChecked())
907 FormNum = 1;
908 if (Format2->isChecked())
909 FormNum = 2;
910 if (Format3->isChecked())
911 FormNum = 3;
912 break;
913 case 2:
914 if (Format0a->isChecked())
915 FormNum = 0;
916 if (Format1a->isChecked())
917 FormNum = 1;
918 if (Format2a->isChecked())
919 FormNum = 2;
920 if (Format3a->isChecked())
921 FormNum = 3;
922 break;
923 case 4:
924 if (Format0b->isChecked())
925 FormNum = 0;
926 if (Format1b->isChecked())
927 FormNum = 1;
928 if (Format2b->isChecked())
929 FormNum = 2;
930 if (Format3b->isChecked())
931 FormNum = 3;
932 break;
933 }
934 }
935
HandleVali()936 void ScAnnot::HandleVali()
937 {
938 bool setter = SimpleValid->isChecked();
939 MaxValid->setEnabled(setter);
940 MinValid->setEnabled(setter);
941 EditValScript->setEnabled(false);
942 if (CustomValid->isChecked())
943 EditValScript->setEnabled(true);
944 }
945
SetVali()946 void ScAnnot::SetVali()
947 {
948 MaxValid->setEnabled(false);
949 MinValid->setEnabled(false);
950 EditValScript->setEnabled(false);
951 ValidScript->setEnabled(false);
952 if (m_annotation.V_act().isEmpty())
953 NoValid->setChecked(true);
954 else
955 {
956 if (m_annotation.V_act().startsWith("AFRange_Validate"))
957 {
958 MaxValid->setEnabled(true);
959 MinValid->setEnabled(true);
960 SimpleValid->setChecked(true);
961 DecodeVali();
962 }
963 else
964 {
965 EditValScript->setEnabled(true);
966 CustomValid->setChecked(true);
967 ValidScript->setPlainText(m_annotation.V_act());
968 }
969 }
970 }
971
HandleCalc()972 void ScAnnot::HandleCalc()
973 {
974 bool setter = SimpleCalc->isChecked();
975 CalcFields->setEnabled(setter);
976 CalcArt->setEnabled(setter);
977 EditCalc->setEnabled(false);
978 SeField->setEnabled(setter);
979 if (CustomCalc->isChecked())
980 EditCalc->setEnabled(true);
981 }
982
SetCalc()983 void ScAnnot::SetCalc()
984 {
985 CalcFields->setEnabled(false);
986 CalcArt->setEnabled(false);
987 EditCalc->setEnabled(false);
988 SeField->setEnabled(false);
989 if (m_annotation.C_act().isEmpty())
990 NoCalc->setChecked(true);
991 else
992 {
993 if (m_annotation.C_act().startsWith("AFSimple_Calculate"))
994 {
995 CalcFields->setEnabled(true);
996 CalcArt->setEnabled(true);
997 SimpleCalc->setChecked(true);
998 SeField->setEnabled(true);
999 DecodeCalc();
1000 }
1001 else
1002 {
1003 EditCalc->setEnabled(true);
1004 CustomCalc->setChecked(true);
1005 CalcScript->setPlainText(m_annotation.C_act());
1006 }
1007 }
1008 }
1009
SetCurr()1010 void ScAnnot::SetCurr()
1011 {
1012 bool setter = UseCurr->isChecked();
1013 CurSym->setEnabled(setter);
1014 PreCurr->setEnabled(setter);
1015 }
1016
SetFoScript(int it)1017 void ScAnnot::SetFoScript(int it)
1018 {
1019 if (it >= 0 && it <=5)
1020 FoFram->setCurrentIndex(it);
1021 if (it == 1)
1022 SetCurr();
1023 if (it == 5)
1024 {
1025 EditFormat->setEnabled( true );
1026 EditKeystr->setEnabled( true );
1027 // KeyScript->setPlainText("");
1028 // FormatScript->setPlainText("");
1029 KeyScript->setText(m_annotation.K_act());
1030 FormatScript->setText(m_annotation.F_act());
1031 }
1032 m_annotation.setFormat(it);
1033 }
1034
SetCoords(double x,double y)1035 void ScAnnot::SetCoords(double x, double y)
1036 {
1037 SpinBox21->setValue(static_cast<int>(x*Width));
1038 SpinBox31->setValue(static_cast<int>(y*Height));
1039 }
1040
SetPage(int v)1041 void ScAnnot::SetPage(int v)
1042 {
1043 disconnect(SpinBox11, SIGNAL(valueChanged(int)), this, SLOT(SetPage(int)));
1044 if ((m_annotation.ActionType() == Annotation::Action_GoToR_FileRel) || (m_annotation.ActionType() == 9))
1045 {
1046 if (!m_navig->setPage(v, 100, Destfile->text()))
1047 {
1048 SpinBox11->setValue(1);
1049 m_navig->setPage(1, 100, Destfile->text());
1050 }
1051 Width = m_navig->Width;
1052 Height = m_navig->Height;
1053 // SetCoords(0,0);
1054 }
1055 else
1056 {
1057 m_navig->setPage(qMin(v-1, MaxPages - 1), 100);
1058 SpinBox11->setValue(qMin(v, MaxPages));
1059 Width = OriWidth;
1060 Height = OriHeight;
1061 // SetCoords(0,0);
1062 }
1063 SpinBox21->setMaximum(Width);
1064 SpinBox31->setMaximum(Height);
1065 connect(SpinBox11, SIGNAL(valueChanged(int)), this, SLOT(SetPage(int)));
1066 }
1067
SetCross()1068 void ScAnnot::SetCross()
1069 {
1070 int x, y;
1071 disconnect(m_navig, SIGNAL(Coords(double, double)), this, SLOT(SetCoords(double, double)));
1072 x = static_cast<int>(static_cast<double>(SpinBox21->value()) / static_cast<double>(Width) * m_navig->pmx.width());
1073 y = static_cast<int>(static_cast<double>(SpinBox31->value()) / static_cast<double>(Height) * m_navig->pmx.height());
1074 m_navig->drawMark(x, y);
1075 connect(m_navig, SIGNAL(Coords(double, double)), this, SLOT(SetCoords(double, double)));
1076 }
1077
SetValues()1078 void ScAnnot::SetValues()
1079 {
1080 bool AAct = false;
1081 QString tmp, tmp2;
1082 QString Nfo("");
1083
1084 Annotation& annotation = m_item->annotation();
1085 annotation = m_annotation;
1086
1087 if (ComboBox1->currentIndex() == 5)
1088 annotation.setType(Annotation::RadioButton);
1089 else
1090 annotation.setType(ComboBox1->currentIndex() + 2);
1091 if (Name->text() != OldName)
1092 m_item->setItemName(Name->text());
1093 annotation.setToolTip(Tip->text());
1094 annotation.setRollOver(TextO->text());
1095 annotation.setDown(DownT->text());
1096 annotation.setBorderWidth(BorderW->currentIndex());
1097 annotation.setBorderStyle(BorderS->currentIndex());
1098 annotation.setFeed(ComboBox7_2->currentIndex());
1099 annotation.setVis(Visib->currentIndex());
1100 annotation.setFont(Schrift->currentIndex());
1101 annotation.setFlag(0);
1102 annotation.setIsChk(isChkd->isChecked());
1103 annotation.setCheckState(isChkd->isChecked());
1104 annotation.setChkStil(ChkStil->currentIndex());
1105 annotation.setBorderColor(BorderC->currentText());
1106 if (annotation.borderColor() == CommonStrings::tr_NoneColor)
1107 annotation.setBorderColor(CommonStrings::None);
1108 Limit->isChecked() ? annotation.setMaxChar(MaxChars->value()) : annotation.setMaxChar(-1);
1109 if (annotation.Type() == Annotation::Button)
1110 {
1111 annotation.addToFlag(Annotation::Flag_PushButton);
1112 if (m_item->Pfile.isEmpty())
1113 annotation.setUseIcons(false);
1114 annotation.setFormat(0);
1115 annotation.setF_act(QString());
1116 }
1117 else
1118 {
1119 annotation.setUseIcons(false);
1120 if (ReadOnly->isChecked())
1121 annotation.addToFlag(Annotation::Flag_ReadOnly);
1122 if (Required->isChecked())
1123 annotation.addToFlag(Annotation::Flag_Required);
1124 if (NoExport->isChecked())
1125 annotation.addToFlag(Annotation::Flag_NoExport);
1126 }
1127 if (annotation.Type() == Annotation::RadioButton)
1128 {
1129 annotation.addToFlag(Annotation::Flag_Radio | Annotation::Flag_NoToggleToOff);
1130 annotation.setFormat(0);
1131 annotation.setF_act(QString());
1132 }
1133 if (annotation.Type() == Annotation::Checkbox)
1134 {
1135 annotation.setFormat(0);
1136 annotation.setF_act(QString());
1137 }
1138 if (annotation.Type() == Annotation::Combobox)
1139 {
1140 annotation.addToFlag(Annotation::Flag_Combo);
1141 if (CanEdit->isChecked())
1142 annotation.addToFlag(Annotation::Flag_Edit);
1143 }
1144 if (annotation.Type() == Annotation::Listbox)
1145 {
1146 annotation.setFormat(0);
1147 annotation.setF_act(QString());
1148 }
1149 if (annotation.Type() == Annotation::Textfield)
1150 {
1151 if (MultiL->isChecked())
1152 annotation.addToFlag(Annotation::Flag_Multiline);
1153 if (Passwd->isChecked())
1154 annotation.addToFlag(Annotation::Flag_Password);
1155 if (NoSpell->isChecked())
1156 annotation.addToFlag(Annotation::Flag_DoNotSpellCheck);
1157 if (NoScroll->isChecked())
1158 annotation.addToFlag(Annotation::Flag_DoNotScroll);
1159 }
1160 if ((annotation.Type() == Annotation::Textfield) || (annotation.Type() == Annotation::Combobox))
1161 {
1162 if (NoValid->isChecked())
1163 annotation.setV_act("");
1164 if (SimpleValid->isChecked())
1165 annotation.setV_act("AFRange_Validate(true, "+MinValid->text()+", true, "+MaxValid->text()+")");
1166 if (CustomValid->isChecked())
1167 annotation.setV_act(ValidScript->toPlainText());
1168 if (NoCalc->isChecked())
1169 annotation.setC_act("");
1170 if (SimpleCalc->isChecked())
1171 {
1172 QString tmpCact = "AFSimple_Calculate(";
1173 switch (CalcArt->currentIndex())
1174 {
1175 case 0:
1176 tmpCact += "\"SUM\", ";
1177 break;
1178 case 1:
1179 tmpCact += "\"PRD\", ";
1180 break;
1181 case 2:
1182 tmpCact += "\"AVG\", ";
1183 break;
1184 case 3:
1185 tmpCact += "\"MIN\", ";
1186 break;
1187 case 4:
1188 tmpCact += "\"MAX\", ";
1189 break;
1190 }
1191 tmpCact += "new Array (";
1192 QStringList pfol;
1193 pfol = CalcFields->text().split(",", Qt::SkipEmptyParts);
1194 if (pfol.count() > 1)
1195 {
1196 tmpCact += "\""+pfol[0].simplified()+"\"";
1197 for (int cfx = 1; cfx < pfol.count(); cfx++)
1198 {
1199 tmpCact += ", \""+pfol[cfx].simplified()+"\"";
1200 }
1201 }
1202 tmpCact += "))";
1203 annotation.setC_act(tmpCact);
1204 }
1205 if (CustomCalc->isChecked())
1206 annotation.setC_act(CalcScript->toPlainText());
1207 switch (TxFormat->currentIndex())
1208 {
1209 case 0:
1210 annotation.setF_act("");
1211 annotation.setK_act("");
1212 break;
1213 case 1:
1214 Nfo = tmp.setNum(Decim->value())+", "+tmp2.setNum(FormNum)+", 0, 0, \"";
1215 if (UseCurr->isChecked())
1216 {
1217 if (!PreCurr->isChecked())
1218 Nfo += " ";
1219 Nfo += CurSym->text().simplified();
1220 if (PreCurr->isChecked())
1221 Nfo += " ";
1222 }
1223 if (PreCurr->isChecked())
1224 Nfo += "\", true)";
1225 else
1226 Nfo += "\", false)";
1227 annotation.setF_act("AFNumber_Format("+Nfo);
1228 annotation.setK_act("AFNumber_Keystroke("+Nfo);
1229 break;
1230 case 2:
1231 Nfo = tmp.setNum(Decim2->value())+", "+tmp.setNum(FormNum)+")";
1232 annotation.setF_act("AFPercent_Format("+Nfo);
1233 annotation.setK_act("AFPercent_Keystroke("+Nfo);
1234 break;
1235 case 3:
1236 Nfo = Format0c->currentText()+"\")";
1237 annotation.setF_act("AFDate_FormatEx(\""+Nfo);
1238 annotation.setK_act("AFDate_KeystrokeEx(\""+Nfo);
1239 break;
1240 case 4:
1241 Nfo = tmp.setNum(FormNum)+")";
1242 annotation.setF_act("AFTime_Format("+Nfo);
1243 annotation.setK_act("AFTime_Keystroke("+Nfo);
1244 break;
1245 case 5:
1246 annotation.setF_act(FormatScript->toPlainText());
1247 annotation.setK_act(KeyScript->toPlainText());
1248 break;
1249 }
1250 }
1251 switch (ActionCombo->currentIndex())
1252 {
1253 case 0:
1254 annotation.setActionType(Annotation::Action_None);
1255 annotation.setAction(QString());
1256 break;
1257 case 1:
1258 annotation.setActionType(Annotation::Action_JavaScript);
1259 switch (ScrEdited)
1260 {
1261 case Annotation::Java_ReleaseButton:
1262 annotation.setAction(EditJava->toPlainText());
1263 break;
1264 case Annotation::Java_PressButton:
1265 annotation.setD_act(EditJava->toPlainText());
1266 break;
1267 case Annotation::Java_EnterWidget:
1268 annotation.setE_act(EditJava->toPlainText());
1269 break;
1270 case Annotation::Java_LeaveWidget:
1271 annotation.setX_act(EditJava->toPlainText());
1272 break;
1273 case Annotation::Java_FocusIn:
1274 annotation.setFo_act(EditJava->toPlainText());
1275 break;
1276 case Annotation::Java_FocusOut:
1277 annotation.setBl_act(EditJava->toPlainText());
1278 break;
1279 case Annotation::Java_SelectionChg:
1280 annotation.setK_act(EditJava->toPlainText());
1281 break;
1282 }
1283 break;
1284 case 2:
1285 if ((LExtern->isChecked()) && (!Destfile->text().isEmpty()))
1286 {
1287 annotation.setExtern(Destfile->text());
1288 if (useAbsolute->isChecked())
1289 annotation.setActionType(Annotation::Action_GoToR_FileAbs);
1290 else
1291 annotation.setActionType(Annotation::Action_GoToR_FileRel);
1292 }
1293 else
1294 {
1295 annotation.setExtern("");
1296 annotation.setActionType(Annotation::Action_GoTo);
1297 }
1298 annotation.setZiel(SpinBox11->value()-1);
1299 annotation.setAction(tmp.setNum(SpinBox21->value())+" "+tmp2.setNum(Height-SpinBox31->value())+" 0");
1300 break;
1301 case 3:
1302 annotation.setActionType(Annotation::Action_SubmitForm);
1303 annotation.setAction(SubURL->text().simplified());
1304 annotation.setHTML(SelAsHtml->currentIndex());
1305 break;
1306 case 4:
1307 annotation.setActionType(Annotation::Action_ResetForm);
1308 annotation.setAction(QString());
1309 break;
1310 case 5:
1311 annotation.setActionType(Annotation::Action_ImportData);
1312 annotation.setAction(SubURLa->text().simplified());
1313 break;
1314 case 6:
1315 annotation.setActionType(Annotation::Action_Named);
1316 annotation.setAction(nameActionCombo->itemData(nameActionCombo->currentIndex()).toString());
1317 break;
1318 default:
1319 annotation.setActionType(Annotation::Action_None);
1320 annotation.setAction(QString());
1321 break;
1322 }
1323 if (!annotation.E_act().isEmpty())
1324 AAct = true;
1325 if (!annotation.X_act().isEmpty())
1326 AAct = true;
1327 if (!annotation.D_act().isEmpty())
1328 AAct = true;
1329 if (!annotation.Fo_act().isEmpty())
1330 AAct = true;
1331 if (!annotation.Bl_act().isEmpty())
1332 AAct = true;
1333 if (!annotation.K_act().isEmpty())
1334 AAct = true;
1335 if (!annotation.F_act().isEmpty())
1336 AAct = true;
1337 if (!annotation.V_act().isEmpty())
1338 AAct = true;
1339 if (!annotation.C_act().isEmpty())
1340 AAct = true;
1341 annotation.setAAact(AAct);
1342 accept();
1343 }
1344
SetAnnotationType(int it)1345 void ScAnnot::SetAnnotationType(int it)
1346 {
1347 disconnect(ActionCombo, SIGNAL(activated(int)), this, SLOT(SetActionType(int)));
1348 disconnect(TxFormat, SIGNAL(activated(int)), this, SLOT(SetFoScript(int)));
1349
1350 Annotation& annotation = m_annotation;
1351 int tmpac = annotation.ActionType();
1352 if ((tmpac == 7) || (tmpac == 9))
1353 tmpac = 2;
1354 else if (tmpac == 10)
1355 tmpac = 6;
1356 int sela = it + 2;
1357 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabFormat), false);
1358 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabValidate), false);
1359 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabCalculate), false);
1360 EditFormat->setEnabled( false );
1361 EditKeystr->setEnabled( false );
1362 CText1->show();
1363 ChkStil->show();
1364 SelAction->clear();
1365 QString tmp_selact[]={tr("Mouse Up"), tr("Mouse Down"), tr("Mouse Enter"),
1366 tr("Mouse Exit"), tr("On Focus"), tr("On Blur")};
1367 size_t array_sel = sizeof(tmp_selact) / sizeof(*tmp_selact);
1368 /* PFJ - 28/02/04 - Altered from uint to int and varname */
1369 for (uint prop = 0; prop < array_sel; ++prop)
1370 SelAction->addItem(tmp_selact[prop]);
1371 bool setter;
1372 switch (sela)
1373 {
1374 case 2:
1375 {
1376 Fram->setCurrentIndex(3);
1377 FramOp->setCurrentIndex(sela-2);
1378 ReadOnly->setEnabled(false);
1379 ReadOnly->setChecked(false);
1380 Required->setEnabled(false);
1381 Required->setChecked(false);
1382 NoExport->setEnabled(false);
1383 NoExport->setChecked(false);
1384 ActionCombo->clear();
1385 QString tmp_actcom[] = {tr("None", "action"), tr("JavaScript"), tr("Go To"),
1386 tr("Submit Form"), tr("Reset Form"), tr("Import Data"), tr("Named")};
1387 size_t array_act = sizeof(tmp_actcom) / sizeof(*tmp_actcom);
1388 /* PFJ - 28/02/04 - Altered from uint to int and varname */
1389 for (uint prop = 0; prop < array_act; ++prop)
1390 ActionCombo->addItem(tmp_actcom[prop]);
1391 ActionCombo->setCurrentIndex(qMin(tmpac,6));
1392 setter = (annotation.ActionType() != Annotation::Action_GoToR_FileRel) && (annotation.ActionType() != Annotation::Action_GoToR_FileAbs);
1393 Destfile->setEnabled(setter);
1394 ChFile->setEnabled(setter);
1395 SetActionType(tmpac);
1396 break;
1397 }
1398 case 3:
1399 case 6:
1400 case 4:
1401 case 5:
1402 case 7:
1403 if ((sela == 3) || (sela == 5))
1404 {
1405 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabFormat), true);
1406 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabValidate), true);
1407 TabWidget2->setTabEnabled(TabWidget2->indexOf(tabCalculate), true);
1408 TxFormat->setCurrentIndex(annotation.Format());
1409 SetFoScript(annotation.Format());
1410 SetVali();
1411 SetCalc();
1412 }
1413 if (sela == 6)
1414 SelAction->addItem( tr( "Selection Change" ) );
1415 ReadOnly->setEnabled(true);
1416 ReadOnly->setChecked(annotation.Flag() & Annotation::Flag_ReadOnly);
1417 Required->setChecked(annotation.Flag() & Annotation::Flag_Required);
1418 NoExport->setChecked(annotation.Flag() & Annotation::Flag_NoExport);
1419 Fram->setCurrentIndex(3);
1420 if (sela < 6)
1421 FramOp->setCurrentIndex(sela-2);
1422 else if (sela == 6)
1423 FramOp->setCurrentIndex(3);
1424 else
1425 {
1426 CText1->hide();
1427 ChkStil->hide();
1428 FramOp->setCurrentIndex(2);
1429 }
1430 ActionCombo->clear();
1431 ActionCombo->addItem( tr( "None" ) );
1432 ActionCombo->addItem( tr( "JavaScript" ) );
1433 ActionCombo->setCurrentIndex(qMin(tmpac, 1));
1434 SetActionType(tmpac);
1435 break;
1436 default:
1437 Fram->setCurrentIndex(2);
1438 break;
1439 }
1440 MultiL->setChecked(annotation.Flag() & Annotation::Flag_Multiline);
1441 Passwd->setChecked(annotation.Flag() & Annotation::Flag_Password);
1442 CanEdit->setChecked(annotation.Flag() & Annotation::Flag_Edit);
1443 NoSpell->setChecked(annotation.Flag() & Annotation::Flag_DoNotSpellCheck);
1444 NoScroll->setChecked(annotation.Flag() & Annotation::Flag_DoNotScroll);
1445 ChkStil->setCurrentIndex(annotation.ChkStil());
1446 isChkd->setChecked(annotation.IsChk());
1447 setter = annotation.MaxChar() != -1;
1448 MaxChars->setValue(setter ? annotation.MaxChar() : 0);
1449 Limit->setChecked(setter);
1450 MaxChars->setEnabled(setter);
1451 connect(ActionCombo, SIGNAL(activated(int)), this, SLOT(SetActionType(int)));
1452 connect(TxFormat, SIGNAL(activated(int)), this, SLOT(SetFoScript(int)));
1453 }
1454
SetLimit()1455 void ScAnnot::SetLimit()
1456 {
1457 Limit->isChecked() ? MaxChars->setEnabled(true) :MaxChars->setEnabled(false);
1458 }
1459
SetExternLink()1460 void ScAnnot::SetExternLink()
1461 {
1462 disconnect(LExtern, SIGNAL(clicked()), this, SLOT(SetExternLink()));
1463 bool enable;
1464 if (!LExtern->isChecked())
1465 {
1466 m_annotation.setActionType(Annotation::Action_GoTo);
1467 enable = false;
1468 // Destfile->setEnabled(false);
1469 // ChFile->setEnabled(false);
1470 SetPage(qMin(SpinBox11->value(), MaxPages));
1471 }
1472 else
1473 {
1474 if (useAbsolute->isChecked())
1475 m_annotation.setActionType(Annotation::Action_GoToR_FileAbs);
1476 else
1477 m_annotation.setActionType(Annotation::Action_GoToR_FileRel);
1478 enable = true;
1479 // Destfile->setEnabled(true);
1480 // ChFile->setEnabled(true);
1481 if (Destfile->text().isEmpty())
1482 {
1483 GetFile();
1484 if (Destfile->text().isEmpty())
1485 {
1486 m_annotation.setActionType(Annotation::Action_GoTo);
1487 enable = false;
1488 // Destfile->setEnabled(false);
1489 // ChFile->setEnabled(false);
1490 LExtern->setChecked(false);
1491 }
1492 }
1493 SetPage(qMin(SpinBox11->value(), MaxPages));
1494 }
1495 Destfile->setEnabled(enable);
1496 ChFile->setEnabled(enable);
1497 connect(LExtern, SIGNAL(clicked()), this, SLOT(SetExternLink()));
1498 }
1499
SetActionType(int it)1500 void ScAnnot::SetActionType(int it)
1501 {
1502 bool setter;
1503 switch (it)
1504 {
1505 case 6:
1506 {
1507 Fram2->setCurrentIndex(5);
1508 int nac = nameActionCombo->findData(m_annotation.Action());
1509 if (nac >= 0)
1510 nameActionCombo->setCurrentIndex(nac);
1511 break;
1512 }
1513 case 5:
1514 Fram2->setCurrentIndex(4);
1515 SubURLa->setText(m_annotation.Action());
1516 break;
1517 case 3:
1518 Fram2->setCurrentIndex(3);
1519 SubURL->setText(m_annotation.Action());
1520 SelAsHtml->setCurrentIndex(m_annotation.HTML());
1521 break;
1522 case 2:
1523 Fram2->setCurrentIndex(2);
1524 setter = (m_annotation.ActionType() != Annotation::Action_GoToR_FileRel);
1525 Destfile->setEnabled(setter);
1526 ChFile->setEnabled(setter);
1527 SetPage(qMin(SpinBox11->value(), MaxPages));
1528 break;
1529 case 1:
1530 Fram2->setCurrentIndex(1);
1531 SelAction->setCurrentIndex(ScrEdited);
1532 break;
1533 default:
1534 Fram2->setCurrentIndex(0);
1535 break;
1536 }
1537 }
1538
SetActionScript(int it)1539 void ScAnnot::SetActionScript(int it)
1540 {
1541 Annotation& annotation = m_annotation;
1542 switch (ScrEdited)
1543 {
1544 case Annotation::Java_ReleaseButton:
1545 annotation.setAction(EditJava->toPlainText());
1546 break;
1547 case Annotation::Java_PressButton:
1548 annotation.setD_act(EditJava->toPlainText());
1549 break;
1550 case Annotation::Java_EnterWidget:
1551 annotation.setE_act(EditJava->toPlainText());
1552 break;
1553 case Annotation::Java_LeaveWidget:
1554 annotation.setX_act(EditJava->toPlainText());
1555 break;
1556 case Annotation::Java_FocusIn:
1557 annotation.setFo_act(EditJava->toPlainText());
1558 break;
1559 case Annotation::Java_FocusOut:
1560 annotation.setBl_act(EditJava->toPlainText());
1561 break;
1562 case Annotation::Java_SelectionChg:
1563 annotation.setK_act(EditJava->toPlainText());
1564 break;
1565 }
1566 switch (it)
1567 {
1568 case Annotation::Java_ReleaseButton:
1569 EditJava->setPlainText(annotation.Action());
1570 break;
1571 case Annotation::Java_PressButton:
1572 EditJava->setPlainText(annotation.D_act());
1573 break;
1574 case Annotation::Java_EnterWidget:
1575 EditJava->setPlainText(annotation.E_act());
1576 break;
1577 case Annotation::Java_LeaveWidget:
1578 EditJava->setPlainText(annotation.X_act());
1579 break;
1580 case Annotation::Java_FocusIn:
1581 EditJava->setPlainText(annotation.Fo_act());
1582 break;
1583 case Annotation::Java_FocusOut:
1584 EditJava->setPlainText(annotation.Bl_act());
1585 break;
1586 case Annotation::Java_SelectionChg:
1587 EditJava->setPlainText(annotation.K_act());
1588 break;
1589 }
1590 ScrEdited = it;
1591 }
1592
GetFile()1593 void ScAnnot::GetFile()
1594 {
1595 QString wdir = m_prefsCtxt->get("annot_getfile", ".");
1596 CustomFDialog dia(this, wdir, tr("Open"), tr("PDF Files (*.pdf);;All Files (*)"));
1597 if (!Destfile->text().isEmpty())
1598 dia.setSelection(Destfile->text());
1599 if (dia.exec() != QDialog::Accepted)
1600 return;
1601
1602 QString fn = dia.selectedFile();
1603 if (fn.isEmpty())
1604 return;
1605 m_prefsCtxt->set("annot_getfile", fn.left(fn.lastIndexOf("/")));
1606 Destfile->setText(fn);
1607 SpinBox11->setValue(1);
1608 SpinBox11->setMaximum(1000);
1609 SetPage(1);
1610 }
1611