Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
WordProcessor.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include <cstdio> // for sprintf() call
5
6namespace Stroika::Frameworks::Led {
7
8 /*
9 ********************************************************************************
10 ************************************ ParagraphInfo *****************************
11 ********************************************************************************
12 */
13 /*
14 @METHOD: ParagraphInfo::GetJustification
15 @DESCRIPTION:
16 <p>Return the @'Justification' setting.</p>
17 */
18 inline Justification ParagraphInfo::GetJustification () const
19 {
20 return fJustification;
21 }
22 /*
23 @METHOD: ParagraphInfo::SetJustification
24 @DESCRIPTION:
25 <p>Set the @'Justification' setting.</p>
26 */
27 inline void ParagraphInfo::SetJustification (Justification justification)
28 {
29 fJustification = justification;
30 }
31 inline const StandardTabStopList& ParagraphInfo::GetTabStopList () const
32 {
33 return fTabStops;
34 }
35 inline void ParagraphInfo::SetTabStopList (const StandardTabStopList& tabStops)
36 {
37 fTabStops = tabStops;
38 }
39 inline TWIPS ParagraphInfo::GetLeftMargin () const
40 {
41 return fLeftMargin;
42 }
43 inline TWIPS ParagraphInfo::GetRightMargin () const
44 {
45 return fRightMargin;
46 }
47 inline void ParagraphInfo::SetMargins (TWIPS lhs, TWIPS rhs)
48 {
49 Require (lhs < rhs);
50 fLeftMargin = lhs;
51 fRightMargin = rhs;
52 }
53 inline TWIPS ParagraphInfo::GetFirstIndent () const
54 {
55 return fFirstIndent;
56 }
57 inline void ParagraphInfo::SetFirstIndent (TWIPS firstIndent)
58 {
59 fFirstIndent = firstIndent;
60 }
61 /*
62 @METHOD: ParagraphInfo::GetSpaceBefore
63 @DESCRIPTION:
64 <p>Get the 'space before' attribute of the given paragraph. This is the number of TWIPS of space inserted before
65 the paragraph - and defaults to zero. See the RTF \sb tag.</p>
66 <p>See also @'ParagraphInfo::SetSpaceBefore'.</p>
67 */
68 inline TWIPS ParagraphInfo::GetSpaceBefore () const
69 {
70 return fSpaceBefore;
71 }
72 /*
73 @METHOD: ParagraphInfo::SetSpaceBefore
74 @DESCRIPTION:
75 <p>See also @'ParagraphInfo::GetSpaceBefore'.</p>
76 */
77 inline void ParagraphInfo::SetSpaceBefore (TWIPS sb)
78 {
79 fSpaceBefore = sb;
80 }
81 /*
82 @METHOD: ParagraphInfo::GetSpaceAfter
83 @DESCRIPTION:
84 <p>Get the 'space after' attribute of the given paragraph. This is the number of TWIPS of space appended after
85 the paragraph - and defaults to zero. See the RTF \sa tag.</p>
86 <p>See also @'ParagraphInfo::SetSpaceAfter'.</p>
87 */
88 inline TWIPS ParagraphInfo::GetSpaceAfter () const
89 {
90 return fSpaceAfter;
91 }
92 /*
93 @METHOD: ParagraphInfo::SetSpaceAfter
94 @DESCRIPTION:
95 <p>See also @'ParagraphInfo::GetSpaceAfter'.</p>
96 */
97 inline void ParagraphInfo::SetSpaceAfter (TWIPS sa)
98 {
99 fSpaceAfter = sa;
100 }
101 /*
102 @METHOD: ParagraphInfo::GetLineSpacing
103 @DESCRIPTION:
104 <p>Get the spacing used between rows of a given paragraph. Can either be magic value of 1000 - meaning automatic.</p>
105 <p>From the RTF docs:
106 <blockquote>
107 If this control word is missing or if \sl1000 is used, the line spacing is automatically
108 determined by the tallest character in the line; if N is a positive value, this size is
109 used only if it is taller than the tallest character (otherwise, the tallest character is used);
110 if N is a negative value, the absolute value of N is used, even if it is shorter than the tallest character.
111 </blockquote>
112 </p>
113 <p>See the RTF docs for \slN and \slmultN</p>
114 <p>See also @'ParagraphInfo::SetLineSpacing'.</p>
115 */
116 inline LineSpacing ParagraphInfo::GetLineSpacing () const
117 {
118 return fLineSpacing;
119 }
120 /*
121 @METHOD: ParagraphInfo::SetLineSpacing
122 @DESCRIPTION:
123 <p>See also @'ParagraphInfo::GetLineSpacing'.</p>
124 */
125 inline void ParagraphInfo::SetLineSpacing (LineSpacing sl)
126 {
127 fLineSpacing = sl;
128 }
129 /*
130 @METHOD: ParagraphInfo::GetListStyle
131 @DESCRIPTION:
132 <p>Retrieve the @'ParagraphInfo::ListStyle' property associated with this paragraph
133 (e.g. eListStyle_Bullet or eListStyle_None).</p>
134 */
135 inline ListStyle ParagraphInfo::GetListStyle () const
136 {
137 return fListStyle;
138 }
139 /*
140 @METHOD: ParagraphInfo::SetListStyle
141 @DESCRIPTION:
142 <p>See also @'ParagraphInfo::GetListStyle'.</p>
143 */
144 inline void ParagraphInfo::SetListStyle (ListStyle listStyle)
145 {
146 fListStyle = listStyle;
147 }
148 /*
149 @METHOD: ParagraphInfo::GetListIndentLevel
150 @DESCRIPTION:
151 <p>Retrieve the indent level for the given list. Only valid value if @'ParagraphInfo::GetListStyle'
152 is not eListStyle_None.</p>
153 */
154 inline unsigned char ParagraphInfo::GetListIndentLevel () const
155 {
156 return fListIndentLevel;
157 }
158 /*
159 @METHOD: ParagraphInfo::SetListIndentLevel
160 @DESCRIPTION:
161 <p>See also @'ParagraphInfo::GetListIndentLevel'.</p>
162 */
163 inline void ParagraphInfo::SetListIndentLevel (unsigned char indentLevel)
164 {
165 fListIndentLevel = indentLevel;
166 }
167 inline void ParagraphInfo::MergeIn (const IncrementalParagraphInfo& incParaInfo)
168 {
169 if (incParaInfo.GetJustification_Valid ()) {
170 fJustification = incParaInfo.GetJustification ();
171 }
172 if (incParaInfo.GetTabStopList_Valid ()) {
173 fTabStops = incParaInfo.GetTabStopList ();
174 }
175 if (incParaInfo.GetMargins_Valid ()) {
176 fLeftMargin = incParaInfo.GetLeftMargin ();
177 fRightMargin = incParaInfo.GetRightMargin ();
178 }
179 if (incParaInfo.GetFirstIndent_Valid ()) {
180 fFirstIndent = incParaInfo.GetFirstIndent ();
181 }
182 if (incParaInfo.GetSpaceBefore_Valid ()) {
183 fSpaceBefore = incParaInfo.GetSpaceBefore ();
184 }
185 if (incParaInfo.GetSpaceAfter_Valid ()) {
186 fSpaceAfter = incParaInfo.GetSpaceAfter ();
187 }
188 if (incParaInfo.GetLineSpacing_Valid ()) {
189 fLineSpacing = incParaInfo.GetLineSpacing ();
190 }
191 if (incParaInfo.GetListStyle_Valid ()) {
192 fListStyle = incParaInfo.GetListStyle ();
193 }
194 if (incParaInfo.GetListIndentLevel_Valid ()) {
195 fListIndentLevel = incParaInfo.GetListIndentLevel ();
196 }
197 }
198
199 /*
200 ********************************************************************************
201 ****************************** IncrementalParagraphInfo ************************
202 ********************************************************************************
203 */
204 inline IncrementalParagraphInfo::IncrementalParagraphInfo ()
205 : fJustificationValid (false)
206 , fTabStopListValid (false)
207 , fMarginsValid (false)
208 , fFirstIndentValid (false)
209 , fSpaceBeforeValid (false)
210 , fSpaceAfterValid (false)
211 , fLineSpacingValid (false)
212 , fListStyleValid (false)
213 , fListIndentLevelValid (false)
214 {
215 }
216 inline IncrementalParagraphInfo::IncrementalParagraphInfo (const ParagraphInfo& pi)
217 : inherited (pi)
218 , fJustificationValid (true)
219 , fTabStopListValid (true)
220 , fMarginsValid (true)
221 , fFirstIndentValid (true)
222 , fSpaceBeforeValid (true)
223 , fSpaceAfterValid (true)
224 , fLineSpacingValid (true)
225 , fListStyleValid (true)
226 , fListIndentLevelValid (true)
227 {
228 }
229 inline Justification IncrementalParagraphInfo::GetJustification () const
230 {
231 Require (fJustificationValid);
232 return inherited::GetJustification ();
233 }
234 inline void IncrementalParagraphInfo::SetJustification (Justification justification)
235 {
236 fJustificationValid = true;
237 inherited::SetJustification (justification);
238 }
239 inline bool IncrementalParagraphInfo::GetJustification_Valid () const
240 {
241 return fJustificationValid;
242 }
243 inline void IncrementalParagraphInfo::InvalidateJustification ()
244 {
245 fJustificationValid = false;
246 }
247 inline const StandardTabStopList& IncrementalParagraphInfo::GetTabStopList () const
248 {
249 Require (fTabStopListValid);
250 return inherited::GetTabStopList ();
251 }
252 inline void IncrementalParagraphInfo::SetTabStopList (const StandardTabStopList& tabStops)
253 {
254 fTabStopListValid = true;
255 inherited::SetTabStopList (tabStops);
256 }
257 inline bool IncrementalParagraphInfo::GetTabStopList_Valid () const
258 {
259 return fTabStopListValid;
260 }
261 inline void IncrementalParagraphInfo::InvalidateTabStopList ()
262 {
263 fTabStopListValid = false;
264 }
265 inline TWIPS IncrementalParagraphInfo::GetLeftMargin () const
266 {
267 Require (fMarginsValid);
268 return inherited::GetLeftMargin ();
269 }
270 inline TWIPS IncrementalParagraphInfo::GetRightMargin () const
271 {
272 Require (fMarginsValid);
273 return inherited::GetRightMargin ();
274 }
275 inline void IncrementalParagraphInfo::SetMargins (TWIPS lhs, TWIPS rhs)
276 {
277 fMarginsValid = true;
278 inherited::SetMargins (lhs, rhs);
279 }
280 inline bool IncrementalParagraphInfo::GetMargins_Valid () const
281 {
282 return fMarginsValid;
283 }
284 inline void IncrementalParagraphInfo::InvalidateMargins ()
285 {
286 fMarginsValid = false;
287 }
288 inline TWIPS IncrementalParagraphInfo::GetFirstIndent () const
289 {
290 Require (fFirstIndentValid);
291 return inherited::GetFirstIndent ();
292 }
293 inline void IncrementalParagraphInfo::SetFirstIndent (TWIPS firstIndent)
294 {
295 fFirstIndentValid = true;
296 inherited::SetFirstIndent (firstIndent);
297 }
298 inline bool IncrementalParagraphInfo::GetFirstIndent_Valid () const
299 {
300 return fFirstIndentValid;
301 }
302 inline void IncrementalParagraphInfo::InvalidateFirstIndent ()
303 {
304 fFirstIndentValid = false;
305 }
306 inline TWIPS IncrementalParagraphInfo::GetSpaceBefore () const
307 {
308 Require (fSpaceBeforeValid);
309 return inherited::GetSpaceBefore ();
310 }
311 inline void IncrementalParagraphInfo::SetSpaceBefore (TWIPS sb)
312 {
313 fSpaceBeforeValid = true;
314 inherited::SetSpaceBefore (sb);
315 }
316 inline bool IncrementalParagraphInfo::GetSpaceBefore_Valid () const
317 {
318 return fSpaceBeforeValid;
319 }
320 inline void IncrementalParagraphInfo::InvalidateSpaceBefore ()
321 {
322 fSpaceBeforeValid = false;
323 }
324 inline TWIPS IncrementalParagraphInfo::GetSpaceAfter () const
325 {
326 Require (fSpaceAfterValid);
327 return inherited::GetSpaceAfter ();
328 }
329 inline void IncrementalParagraphInfo::SetSpaceAfter (TWIPS sa)
330 {
331 fSpaceAfterValid = true;
332 inherited::SetSpaceAfter (sa);
333 }
334 inline bool IncrementalParagraphInfo::GetSpaceAfter_Valid () const
335 {
336 return fSpaceAfterValid;
337 }
338 inline void IncrementalParagraphInfo::InvalidateSpaceAfter ()
339 {
340 fSpaceAfterValid = false;
341 }
342 inline LineSpacing IncrementalParagraphInfo::GetLineSpacing () const
343 {
344 Require (fLineSpacingValid);
345 return inherited::GetLineSpacing ();
346 }
347 inline void IncrementalParagraphInfo::SetLineSpacing (LineSpacing sl)
348 {
349 fLineSpacingValid = true;
350 inherited::SetLineSpacing (sl);
351 }
352 inline bool IncrementalParagraphInfo::GetLineSpacing_Valid () const
353 {
354 return fLineSpacingValid;
355 }
356 inline void IncrementalParagraphInfo::InvalidateLineSpacing ()
357 {
358 fLineSpacingValid = false;
359 }
360 inline ListStyle IncrementalParagraphInfo::GetListStyle () const
361 {
362 Require (fListStyleValid);
363 return inherited::GetListStyle ();
364 }
365 inline void IncrementalParagraphInfo::SetListStyle (ListStyle listStyle)
366 {
367 fListStyleValid = true;
368 inherited::SetListStyle (listStyle);
369 }
370 inline bool IncrementalParagraphInfo::GetListStyle_Valid () const
371 {
372 return fListStyleValid;
373 }
374 inline void IncrementalParagraphInfo::InvalidateListStyle ()
375 {
376 fListStyleValid = false;
377 }
378 inline unsigned char IncrementalParagraphInfo::GetListIndentLevel () const
379 {
380 Require (fListIndentLevelValid);
381 return inherited::GetListIndentLevel ();
382 }
383 inline void IncrementalParagraphInfo::SetListIndentLevel (unsigned char indentLevel)
384 {
385 fListIndentLevelValid = true;
386 inherited::SetListIndentLevel (indentLevel);
387 }
388 inline bool IncrementalParagraphInfo::GetListIndentLevel_Valid () const
389 {
390 return fListIndentLevelValid;
391 }
392 inline void IncrementalParagraphInfo::InvalidateListIndentLevel ()
393 {
394 fListIndentLevelValid = false;
395 }
396 inline bool IncrementalParagraphInfo::operator== (const IncrementalParagraphInfo& rhs) const
397 {
398 //Justification
399 if (GetJustification_Valid () != rhs.GetJustification_Valid ()) {
400 return false;
401 }
402 if (GetJustification_Valid () and (GetJustification () != rhs.GetJustification ())) {
403 return false;
404 }
405
406 //TabStopList
407 if (GetTabStopList_Valid () != rhs.GetTabStopList_Valid ()) {
408 return false;
409 }
410 if (GetTabStopList_Valid () and (GetTabStopList () != rhs.GetTabStopList ())) {
411 return false;
412 }
413
414 //Margins
415 if (GetMargins_Valid () != rhs.GetMargins_Valid ()) {
416 return false;
417 }
418 if (GetMargins_Valid () and (GetLeftMargin () != rhs.GetLeftMargin () or GetRightMargin () != rhs.GetRightMargin ())) {
419 return false;
420 }
421
422 //FirstIndent
423 if (GetFirstIndent_Valid () != rhs.GetFirstIndent_Valid ()) {
424 return false;
425 }
426 if (GetFirstIndent_Valid () and (GetFirstIndent () != rhs.GetFirstIndent ())) {
427 return false;
428 }
429
430 //SpaceBefore
431 if (GetSpaceBefore_Valid () != rhs.GetSpaceBefore_Valid ()) {
432 return false;
433 }
434 if (GetSpaceBefore_Valid () and (GetSpaceBefore () != rhs.GetSpaceBefore ())) {
435 return false;
436 }
437
438 //SpaceAfter
439 if (GetSpaceAfter_Valid () != rhs.GetSpaceAfter_Valid ()) {
440 return false;
441 }
442 if (GetSpaceAfter_Valid () and (GetSpaceAfter () != rhs.GetSpaceAfter ())) {
443 return false;
444 }
445
446 //LineSpacing
447 if (GetLineSpacing_Valid () != rhs.GetLineSpacing_Valid ()) {
448 return false;
449 }
450 if (GetLineSpacing_Valid () and (GetLineSpacing () != rhs.GetLineSpacing ())) {
451 return false;
452 }
453
454 //ListStyle/IndentLevel
455 if (GetListStyle_Valid () != rhs.GetListStyle_Valid ()) {
456 return false;
457 }
458 if (GetListStyle_Valid () and (GetListStyle () != rhs.GetListStyle ())) {
459 return false;
460 }
461 if (GetListIndentLevel_Valid () != rhs.GetListIndentLevel_Valid ()) {
462 return false;
463 }
464 if (GetListIndentLevel_Valid () and (GetListIndentLevel () != rhs.GetListIndentLevel ())) {
465 return false;
466 }
467
468 return true;
469 }
470
471 /*
472 ********************************************************************************
473 *************************** AbstractParagraphDatabaseRep ***********************
474 ********************************************************************************
475 */
476 inline AbstractParagraphDatabaseRep::AbstractParagraphDatabaseRep ()
477 : fSomeInvalidTables (false)
478 , fCachedFarthestRightMarginInDocument (kBadCachedFarthestRightMarginInDocument)
479 {
480 }
481
482 /*
483 ********************************************************************************
484 *************************** ParagraphInfoMarker ********************************
485 ********************************************************************************
486 */
487 inline ParagraphInfoMarker::ParagraphInfoMarker (ParagraphInfo paragraphInfo)
488 : fParagraphInfo (paragraphInfo)
489 {
490 }
491 inline const ParagraphInfo& ParagraphInfoMarker::GetInfo () const
492 {
493 return fParagraphInfo;
494 }
495 inline void ParagraphInfoMarker::SetInfo (ParagraphInfo paragraphInfo)
496 {
497 fParagraphInfo = paragraphInfo;
498 }
499
500 /*
501 ********************************************************************************
502 ******************************* ParagraphDatabaseRep ***************************
503 ********************************************************************************
504 */
505 inline shared_ptr<Partition> ParagraphDatabaseRep::GetPartition () const
506 {
507 return fPartition;
508 }
509
510 /*
511 ********************************************************************************
512 ******************* WordProcessor::WordProcessorTextIOSinkStream ***************
513 ********************************************************************************
514 */
515 inline bool WordProcessorTextIOSinkStream::GetOverwriteTableMode () const
516 {
517 return fOverwriteTableMode;
518 }
519 inline void WordProcessorTextIOSinkStream::SetOverwriteTableMode (bool overwriteTableMode)
520 {
521 fOverwriteTableMode = overwriteTableMode;
522 }
523#if !qStroika_Frameworks_Led_NestedTablesSupported
524 inline bool WordProcessorTextIOSinkStream::GetNoTablesAllowed () const
525 {
526 return fNoTablesAllowed;
527 }
528 inline void WordProcessorTextIOSinkStream::SetNoTablesAllowed (bool noTablesAllowed)
529 {
530 fNoTablesAllowed = noTablesAllowed;
531 }
532#endif
533
534 /*
535 ********************************************************************************
536 ******************* WordProcessor::WordProcessorTextIOSrcStream ****************
537 ********************************************************************************
538 */
539 inline bool WordProcessorTextIOSrcStream::GetUseTableSelection () const
540 {
541 return fUseTableSelection;
542 }
543 inline void WordProcessorTextIOSrcStream::SetUseTableSelection (bool useTableSelection)
544 {
545 fUseTableSelection = useTableSelection;
546 }
547
548 /*
549 ********************************************************************************
550 ********************************** WordProcessorTable **************************
551 ********************************************************************************
552 */
553 inline TWIPS WordProcessorTable::GetCellSpacing () const
554 {
555 return fCellSpacing;
556 }
557 inline void WordProcessorTable::SetCellSpacing (TWIPS cellSpacing)
558 {
559 if (fCellSpacing != cellSpacing) {
560 fCellSpacing = cellSpacing;
561#if qStroika_Frameworks_Led_SupportGDI
562 InvalidateLayout ();
563#endif
564 }
565 }
566 /*
567 @METHOD: WordProcessorTable::GetCellSelection
568 @DESCRIPTION: <p>Retrieve the cell selection range for the given table. Note that we always have a rectangular
569 table selection (could be in whole rows or columns or not). The special case of a single cell selection
570 may indicate that the ENTIRE cell is selected, or just a subset (which is decided by ITS GetCellSelection property).
571 </p>
572 <p>Like marker positions and STL iterators, we use the selEnd to be just PAST the end of the selected cell,
573 and so if rowSelStart==rowSelEnd then this implies NO SELECTION, and if rowSelStart + 1 == rowSelEnd and
574 colSelStart + 1 = colSelEnd then we have selected a single cell.
575 </p>
576 <p>See @'WordProcessorTable::SetCellSelection'.</p>
577 */
578 inline void WordProcessorTable::GetCellSelection (size_t* rowSelStart, size_t* rowSelEnd, size_t* colSelStart, size_t* colSelEnd) const
579 {
580 Ensure (fRowSelStart <= fRowSelEnd);
581 Ensure (fRowSelEnd <= GetRowCount ());
582 Ensure (fColSelStart <= fColSelEnd);
583 Ensure (fColSelEnd <= GetColumnCount ());
584 if (rowSelStart != nullptr) {
585 *rowSelStart = fRowSelStart;
586 }
587 if (rowSelEnd != nullptr) {
588 *rowSelEnd = fRowSelEnd;
589 }
590 if (colSelStart != nullptr) {
591 *colSelStart = fColSelStart;
592 }
593 if (colSelEnd != nullptr) {
594 *colSelEnd = fColSelEnd;
595 }
596 }
597 inline size_t WordProcessorTable::GetRowCount () const
598 {
599 size_t rows = 0;
600 GetDimensions (&rows, nullptr);
601 return rows;
602 }
603 inline size_t WordProcessorTable::GetColumnCount () const
604 {
605 size_t columns = 0;
606 GetDimensions (nullptr, &columns);
607 return columns;
608 }
609 inline void WordProcessorTable::GetDefaultCellMargins (TWIPS* top, TWIPS* left, TWIPS* bottom, TWIPS* right) const
610 {
611 if (top != nullptr) {
612 *top = fDefaultCellMargins.GetTop ();
613 }
614 if (left != nullptr) {
615 *left = fDefaultCellMargins.GetLeft ();
616 }
617 if (bottom != nullptr) {
618 *bottom = fDefaultCellMargins.GetBottom ();
619 }
620 if (right != nullptr) {
621 *right = fDefaultCellMargins.GetRight ();
622 }
623 }
624 inline void WordProcessorTable::SetDefaultCellMargins (TWIPS top, TWIPS left, TWIPS bottom, TWIPS right)
625 {
626 if (top != fDefaultCellMargins.GetTop () or left != fDefaultCellMargins.GetLeft () or bottom != fDefaultCellMargins.GetBottom () or
627 right != fDefaultCellMargins.GetRight ()) {
628 fDefaultCellMargins.top = top;
629 fDefaultCellMargins.left = left;
630 fDefaultCellMargins.bottom = bottom;
631 fDefaultCellMargins.right = right;
632 InvalidateLayout ();
633 }
634 }
635 inline void WordProcessorTable::InvalidateLayout ()
636 {
637 if (fNeedLayout != eNeedFullLayout) {
638 AbstractParagraphDatabaseRep* o = dynamic_cast<AbstractParagraphDatabaseRep*> (GetOwner ());
639 AssertNotNull (o);
640 o->fSomeInvalidTables = true;
641 fNeedLayout = eNeedFullLayout;
642 }
643 }
644 inline WordProcessorTable::Cell& WordProcessorTable::GetCell (size_t row, size_t column)
645 {
646 Require (row < GetRowCount ());
647 Require (column < GetColumnCount (row));
648 Assert (fRows.size () == GetRowCount ());
649 Assert (fRows[row].fCells.size () == GetColumnCount (row));
650 return fRows[row].fCells[column];
651 }
652 inline const WordProcessorTable::Cell& WordProcessorTable::GetCell (size_t row, size_t column) const
653 {
654 Require (row < GetRowCount ());
655 Require (column < GetColumnCount (row));
656 Assert (fRows.size () == GetRowCount ());
657 Assert (fRows[row].fCells.size () == GetColumnCount (row));
658 return fRows[row].fCells[column];
659 }
660 inline WordProcessorTable::CellMergeFlags WordProcessorTable::GetCellFlags (size_t row, size_t column) const
661 {
662 Require (row < GetRowCount ());
663 const RowInfo& rowInfo = fRows[row];
664 if (column < rowInfo.fCells.size ()) {
665 return rowInfo.fCells[column].GetCellMergeFlags ();
666 }
667 else {
668 return eInvalidCell;
669 }
670 }
671 /*
672 @METHOD: WordProcessorTable::GetIntraCellMode
673 @ACCESS: public
674 @DESCRIPTION: <p>Return true if the editor is in 'intraCell' editing mode. This edit mode means that the
675 current selection is a mini-editor inside of a cell. This is not the same as having selected
676 a single cell. It means characters typed go to the focused WP inside the currently selected
677 cell.</p>
678 */
679 inline bool WordProcessorTable::GetIntraCellMode (size_t* row, size_t* col) const
680 {
681 if (fIntraCellMode) {
682 Assert (fRowSelEnd == fRowSelStart + 1);
683 if (row != nullptr) {
684 *row = fRowSelStart;
685 }
686 Assert (fColSelEnd == fColSelStart + 1);
687 if (col != nullptr) {
688 *col = fColSelStart;
689 }
690 }
691 return fIntraCellMode;
692 }
693 inline void WordProcessorTable::GetIntraCellSelection (size_t* selStart, size_t* selEnd) const
694 {
695 RequireNotNull (selStart);
696 RequireNotNull (selEnd);
697 *selStart = fIntraSelStart;
698 *selEnd = fIntraSelEnd;
699 }
700 inline void WordProcessorTable::SaveIntraCellContextInfo (bool leftSideOfSelectionInteresting, const FontSpecification& intraCellSelectionEmptySelFontSpecification)
701 {
702 fSavedIntraCellInfoValid = true;
703 fSavedLeftSideOfSelectionInteresting = leftSideOfSelectionInteresting;
704 fSavedIntraCellSelectionEmptySelFontSpecification = intraCellSelectionEmptySelFontSpecification;
705 }
706 inline bool WordProcessorTable::RestoreIntraCellContextInfo (bool* leftSideOfSelectionInteresting, FontSpecification* intraCellSelectionEmptySelFontSpecification)
707 {
708 RequireNotNull (leftSideOfSelectionInteresting);
709 RequireNotNull (intraCellSelectionEmptySelFontSpecification);
710 if (fSavedIntraCellInfoValid) {
711 *leftSideOfSelectionInteresting = fSavedLeftSideOfSelectionInteresting;
712 *intraCellSelectionEmptySelFontSpecification = fSavedIntraCellSelectionEmptySelFontSpecification;
713 return true;
714 }
715 else {
716 return false;
717 }
718 }
719 inline void WordProcessorTable::InvalidateIntraCellContextInfo ()
720 {
721 fSavedIntraCellInfoValid = false;
722 }
723
724 /*
725 ********************************************************************************
726 ************************ WordProcessorTable::Cell ******************************
727 ********************************************************************************
728 */
729 inline WordProcessorTable::CellMergeFlags WordProcessorTable::Cell::GetCellMergeFlags () const
730 {
731 return fCellMergeFlags;
732 }
733 inline TWIPS WordProcessorTable::Cell::GetCellXWidth () const
734 {
735 return fCellRep->fCellXWidth;
736 }
737 inline void WordProcessorTable::Cell::SetCellXWidth (TWIPS width)
738 {
739 fCellRep->fCellXWidth = width;
740 }
741 inline Led_Rect WordProcessorTable::Cell::GetCachedBoundsRect () const
742 {
743 return fCellRep->fCachedBoundsRect;
744 }
745 inline void WordProcessorTable::Cell::SetCachedBoundsRect (Led_Rect r)
746 {
747 fCellRep->fCachedBoundsRect = r;
748 }
749
750#if qStroika_Frameworks_Led_SupportGDI
751
752#if qTemplateGeneratedMixinsSometimesCorrupted
753 inline void InteractorInteractorMixinHelper<StandardStyledTextInteractor, WordWrappedTextInteractor>::HookLosingTextStore ()
754 {
755 StandardStyledTextInteractor::HookLosingTextStore ();
756 WordWrappedTextInteractor::HookLosingTextStore ();
757 }
758 inline void InteractorInteractorMixinHelper<StandardStyledTextInteractor, WordWrappedTextInteractor>::HookGainedNewTextStore ()
759 {
760 StandardStyledTextInteractor::HookGainedNewTextStore ();
761 WordWrappedTextInteractor::HookGainedNewTextStore ();
762 }
763 inline void InteractorInteractorMixinHelper<StandardStyledTextInteractor, WordWrappedTextInteractor>::DidUpdateText (const UpdateInfo& updateInfo)
764 {
765 StandardStyledTextInteractor::DidUpdateText (updateInfo);
766 WordWrappedTextInteractor::DidUpdateText (updateInfo);
767 }
768#endif
769
770 /*
771 ********************************************************************************
772 ************************************ WordProcessor *****************************
773 ********************************************************************************
774 */
775 /*
776 @METHOD: WordProcessor::GetSmartQuoteMode
777 @DESCRIPTION: <p>If true, then when a user types a quote character (&quot;) - it will be replaced
778 with either an OPEN quote character or a CLOSE quote character (depending on text context).
779 <p>Note this defaults ON if in UNICODE mode (@'qWideCharacters') and is unavailable otherwise.</p>
780 <p>See also @'WordProcessor::SetSmartQuoteMode'</p>
781 */
782 inline bool WordProcessor::GetSmartQuoteMode () const
783 {
784 return fSmartQuoteMode;
785 }
786 /*
787 @METHOD: WordProcessor::SetSmartQuoteMode
788 @DESCRIPTION: @see @'WordProcessor::GetSmartQuoteMode'</p>
789 */
790 inline void WordProcessor::SetSmartQuoteMode (bool smartQuoteMode)
791 {
792 fSmartQuoteMode = smartQuoteMode;
793 }
794 inline shared_ptr<AbstractParagraphDatabaseRep> WordProcessor::GetParagraphDatabase () const
795 {
796 return fParagraphDatabase;
797 }
798 inline shared_ptr<HidableTextMarkerOwner> WordProcessor::GetHidableTextDatabase () const
799 {
800 return fHidableTextDatabase;
801 }
802 /*
803 @METHOD: WordProcessor::GetShowParagraphGlyphs
804 @DESCRIPTION: <p>See @'WordProcessor::SetShowParagraphGlyphs'.</p>
805 */
806 inline bool WordProcessor::GetShowParagraphGlyphs () const
807 {
808 return fShowParagraphGlyphs;
809 }
810 /*
811 @METHOD: WordProcessor::GetShowTabGlyphs
812 @DESCRIPTION: <p>See @'WordProcessor::SetShowTabGlyphs'.</p>
813 */
814 inline bool WordProcessor::GetShowTabGlyphs () const
815 {
816 return fShowTabGlyphs;
817 }
818 /*
819 @METHOD: WordProcessor::GetShowSpaceGlyphs
820 @DESCRIPTION: <p>See @'WordProcessor::SetShowSpaceGlyphs'.</p>
821 */
822 inline bool WordProcessor::GetShowSpaceGlyphs () const
823 {
824 return fShowSpaceGlyphs;
825 }
826 /*
827 @METHOD: WordProcessor::GetCommandNames
828 @DESCRIPTION: <p>Returns command name for each of the user-visible commands produced by this module.
829 This name is used used in the constructed Undo command name, as
830 in, "Undo Justification". You can replace this name with whatever you like.You change this value with
831 WordProcessor::SetCommandNames.</p>
832 <p> The point of this is to allow for different UI-language localizations,
833 without having to change Led itself.</p>
834 * @see @'WordProcessor::CommandNames'.
835 */
836 inline const WordProcessor::CommandNames& WordProcessor::GetCommandNames ()
837 {
838 return sCommandNames;
839 }
840 /*
841 @METHOD: WordProcessor::SetCommandNames
842 @DESCRIPTION: <p>See @'WordProcessor::GetCommandNames'.</p>
843 */
844 inline void WordProcessor::SetCommandNames (const WordProcessor::CommandNames& cmdNames)
845 {
846 sCommandNames = cmdNames;
847 }
848 /*
849 @METHOD: TextInteractor::GetDialogSupport
850 @DESCRIPTION: <p></p>
851 */
852 inline WordProcessor::DialogSupport& WordProcessor::GetDialogSupport ()
853 {
854 if (sDialogSupport == nullptr) {
855 static DialogSupport sDefSup;
856 sDialogSupport = &sDefSup;
857 }
858 return *sDialogSupport;
859 }
860 /*
861 @METHOD: WordProcessor::SetDialogSupport
862 @DESCRIPTION: <p></p>
863 */
864 inline void WordProcessor::SetDialogSupport (DialogSupport* ds)
865 {
866 sDialogSupport = ds;
867 }
868 inline IncrementalFontSpecification WordProcessor::GetCurSelFontSpec () const
869 {
870 if (not fCachedCurSelFontSpecValid) {
871 AssureCurSelFontCacheValid ();
872 }
873 return fCachedCurSelFontSpec;
874 }
875
876 /*
877 ********************************************************************************
878 ********** WordProcessor::WordProcessorFlavorPackageInternalizer ***************
879 ********************************************************************************
880 */
881 inline bool WordProcessor::WordProcessorFlavorPackageInternalizer::GetOverwriteTableMode () const
882 {
883 return fOverwriteTableMode;
884 }
885 inline void WordProcessor::WordProcessorFlavorPackageInternalizer::SetOverwriteTableMode (bool overwriteTableMode)
886 {
887 fOverwriteTableMode = overwriteTableMode;
888 }
889#if !qStroika_Frameworks_Led_NestedTablesSupported
890 inline bool WordProcessor::WordProcessorFlavorPackageInternalizer::GetNoTablesAllowed () const
891 {
892 return fNoTablesAllowed;
893 }
894 inline void WordProcessor::WordProcessorFlavorPackageInternalizer::SetNoTablesAllowed (bool noTablesAllowed)
895 {
896 fNoTablesAllowed = noTablesAllowed;
897 }
898#endif
899
900 /*
901 ********************************************************************************
902 ********** WordProcessor::WordProcessorFlavorPackageExternalizer ***************
903 ********************************************************************************
904 */
905 inline bool WordProcessor::WordProcessorFlavorPackageExternalizer::GetUseTableSelection () const
906 {
907 return fUseTableSelection;
908 }
909 inline void WordProcessor::WordProcessorFlavorPackageExternalizer::SetUseTableSelection (bool useTableSelection)
910 {
911 fUseTableSelection = useTableSelection;
912 }
913
914 /*
915 ********************************************************************************
916 ****** WordProcessorTable::SuppressCellUpdatePropagationContext **************
917 ********************************************************************************
918 */
919 inline WordProcessorTable::SuppressCellUpdatePropagationContext::SuppressCellUpdatePropagationContext (WordProcessorTable& t)
920 : fTable (t)
921 , fOldVal (t.fSuppressCellUpdatePropagationContext)
922 {
923 t.fSuppressCellUpdatePropagationContext = true;
924 }
925 inline WordProcessorTable::SuppressCellUpdatePropagationContext::~SuppressCellUpdatePropagationContext ()
926 {
927 fTable.fSuppressCellUpdatePropagationContext = fOldVal;
928 }
929
930 /*
931 ********************************************************************************
932 ********* WordProcessorTable::AllowUpdateInfoPropagationContext **************
933 ********************************************************************************
934 */
935 inline WordProcessorTable::AllowUpdateInfoPropagationContext::AllowUpdateInfoPropagationContext (WordProcessorTable& t)
936 : fTable (t)
937 , fOldVal (t.fAllowUpdateInfoPropagationContext)
938 {
939 t.fAllowUpdateInfoPropagationContext = true;
940 }
941 inline WordProcessorTable::AllowUpdateInfoPropagationContext::~AllowUpdateInfoPropagationContext ()
942 {
943 fTable.fAllowUpdateInfoPropagationContext = fOldVal;
944 }
945
946 /*
947 ********************************************************************************
948 *** WordProcessorTable::EmbeddedTableWordProcessor::TemporarilyUseTablet *****
949 ********************************************************************************
950 */
951 inline WordProcessorTable::EmbeddedTableWordProcessor::TemporarilyUseTablet::TemporarilyUseTablet (WordProcessorTable::EmbeddedTableWordProcessor& editor,
952 Tablet* t, DoTextMetricsChangedCall tmChanged)
953 : fEditor (editor)
954 , fOldTablet (editor.fUpdateTablet)
955 , fDoTextMetricsChangedCall (tmChanged)
956 {
957 editor.fUpdateTablet = t;
958 if (tmChanged == eDoTextMetricsChangedCall) {
959 editor.TabletChangedMetrics ();
960 }
961 }
962 inline WordProcessorTable::EmbeddedTableWordProcessor::TemporarilyUseTablet::~TemporarilyUseTablet ()
963 {
964 fEditor.fUpdateTablet = fOldTablet;
965 if (fDoTextMetricsChangedCall == eDoTextMetricsChangedCall) {
966 fEditor.TabletChangedMetrics ();
967 }
968 }
969
970 /*
971 ********************************************************************************
972 *** WordProcessorTable::EmbeddedTableWordProcessor::DisableRefreshContext ****
973 ********************************************************************************
974 */
975 inline WordProcessorTable::EmbeddedTableWordProcessor::DisableRefreshContext::DisableRefreshContext (WordProcessorTable::EmbeddedTableWordProcessor& wp)
976 : fWP (wp)
977 , fOldVal (wp.fSuppressRefreshCalls)
978 {
979 wp.fSuppressRefreshCalls = true;
980 }
981 inline WordProcessorTable::EmbeddedTableWordProcessor::DisableRefreshContext::~DisableRefreshContext ()
982 {
983 if (fWP.fSuppressRefreshCalls != fOldVal) {
984 fWP.fSuppressRefreshCalls = fOldVal;
985 if (not fWP.fSuppressRefreshCalls) {
986 fWP.NoteWindowPartiallyUpdated ();
987 }
988 }
989 }
990
991 /*
992 ********************************************************************************
993 ******************* WordProcessorTable::TemporarilySetOwningWP *****************
994 ********************************************************************************
995 */
996 inline WordProcessorTable::TemporarilySetOwningWP::TemporarilySetOwningWP (const WordProcessorTable& forTable, WordProcessor& forWordProcessor)
997 : fOwningTable (const_cast<WordProcessorTable&> (forTable))
998 , fSavedTableOwningWP (forTable.fCurrentOwningWP)
999 {
1000 fOwningTable.fCurrentOwningWP = &forWordProcessor;
1001 }
1002 inline WordProcessorTable::TemporarilySetOwningWP::~TemporarilySetOwningWP ()
1003 {
1004 fOwningTable.fCurrentOwningWP = fSavedTableOwningWP;
1005 }
1006
1007 /*
1008 ********************************************************************************
1009 ******************* WordProcessorTable::TemporarilyAllocateCellWP **************
1010 ********************************************************************************
1011 */
1012 inline WordProcessorTable::TemporarilyAllocateCellWP::TemporarilyAllocateCellWP (WordProcessorTable& forTable, WordProcessor& forWordProcessor,
1013 size_t forRow, size_t forColumn,
1014 const Led_Rect& cellWindowRect, bool captureChangesForUndo)
1015 : fOwningTable (forTable)
1016 , fCellEditor (forTable.ConstructEmbeddedTableWordProcessor (forWordProcessor, forRow, forColumn, cellWindowRect, captureChangesForUndo))
1017 {
1018 }
1019 inline WordProcessorTable::TemporarilyAllocateCellWP::~TemporarilyAllocateCellWP ()
1020 {
1021 AssertNotNull (fCellEditor);
1022 fOwningTable.ReleaseEmbeddedTableWordProcessor (fCellEditor);
1023 }
1024 inline WordProcessorTable::TemporarilyAllocateCellWP::operator WordProcessorTable::EmbeddedTableWordProcessor* ()
1025 {
1026 AssertNotNull (fCellEditor);
1027 return fCellEditor;
1028 }
1029 inline WordProcessorTable::EmbeddedTableWordProcessor& WordProcessorTable::TemporarilyAllocateCellWP::operator& ()
1030 {
1031 AssertNotNull (fCellEditor);
1032 return *fCellEditor;
1033 }
1034 inline WordProcessorTable::EmbeddedTableWordProcessor* WordProcessorTable::TemporarilyAllocateCellWP::operator->()
1035 {
1036 AssertNotNull (fCellEditor);
1037 return fCellEditor;
1038 }
1039
1040 /*
1041 ********************************************************************************
1042 *********** WordProcessorTable::TemporarilyAllocateCellWithTablet ************
1043 ********************************************************************************
1044 */
1045 inline WordProcessorTable::TemporarilyAllocateCellWithTablet::TemporarilyAllocateCellWithTablet (WordProcessorTable& forTable, size_t row,
1046 size_t column, bool captureChangesForUndo)
1047 : fWP (forTable, *forTable.fCurrentOwningWP, row, column,
1048 forTable.TableCoordinates2Window (forTable.GetCellEditorBounds (row, column)), captureChangesForUndo)
1049 , fTablet (forTable.fCurrentOwningWP)
1050 , fTmpUseTablet (*fWP, fTablet, TemporarilyUseTablet::eDontDoTextMetricsChangedCall)
1051 {
1052 }
1053 inline WordProcessorTable::TemporarilyAllocateCellWithTablet::operator WordProcessorTable::EmbeddedTableWordProcessor* ()
1054 {
1055 return fWP;
1056 }
1057 inline WordProcessorTable::EmbeddedTableWordProcessor& WordProcessorTable::TemporarilyAllocateCellWithTablet::operator& ()
1058 {
1059 return *fWP;
1060 }
1061 inline WordProcessorTable::EmbeddedTableWordProcessor* WordProcessorTable::TemporarilyAllocateCellWithTablet::operator->()
1062 {
1063 return fWP;
1064 }
1065
1066 /*
1067 ********************************************************************************
1068 *********** WordProcessor::DialogSupport::TableSelectionPropertiesInfo *********
1069 ********************************************************************************
1070 */
1071 inline WordProcessor::DialogSupport::TableSelectionPropertiesInfo::TableSelectionPropertiesInfo ()
1072 : fTableBorderWidth (TWIPS{0})
1073 , fTableBorderColor (Color::kWhite)
1074 , fDefaultCellMargins ()
1075 , fCellSpacing (TWIPS{0})
1076 , fCellWidth_Common (false)
1077 , fCellWidth (TWIPS{0})
1078 , fCellBackgroundColor_Common (false)
1079 , fCellBackgroundColor (Color::kWhite)
1080 {
1081 }
1082#endif
1083
1084}
#define AssertNotNull(p)
Definition Assertions.h:333
#define RequireNotNull(p)
Definition Assertions.h:347