LibreOffice Module sw (master) 1
expfld.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <limits>
23
24#include <UndoTable.hxx>
25#include <hintids.hxx>
26#include <o3tl/any.hxx>
27#include <osl/diagnose.h>
30#include <editeng/langitem.hxx>
31#include <editeng/fontitem.hxx>
32#include <com/sun/star/text/SetVariableType.hpp>
33#include <unofield.hxx>
34#include <frmfmt.hxx>
35#include <fmtfld.hxx>
36#include <txtfld.hxx>
37#include <fmtanchr.hxx>
38#include <txtftn.hxx>
39#include <doc.hxx>
41#include <layfrm.hxx>
42#include <pagefrm.hxx>
43#include <cntfrm.hxx>
44#include <txtfrm.hxx>
45#include <rootfrm.hxx>
46#include <tabfrm.hxx>
47#include <flyfrm.hxx>
48#include <ftnfrm.hxx>
49#include <rowfrm.hxx>
50#include <expfld.hxx>
51#include <usrfld.hxx>
52#include <ndtxt.hxx>
53#include <calc.hxx>
54#include <pam.hxx>
55#include <docfld.hxx>
56#include <swtable.hxx>
57#include <breakit.hxx>
58#include <SwStyleNameMapper.hxx>
59#include <unofldmid.h>
60#include <numrule.hxx>
61
62using namespace ::com::sun::star;
63using namespace ::com::sun::star::text;
64
65static sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType)
66{
67 sal_Int16 nRet = 0;
68 switch(nSubType)
69 {
71 nRet = SetVariableType::VAR; // 0
72 break;
74 nRet = SetVariableType::SEQUENCE; // 1
75 break;
77 nRet = SetVariableType::FORMULA; // 2
78 break;
80 nRet = SetVariableType::STRING; // 3
81 break;
82 }
83 return nRet;
84}
85
86static sal_Int32 lcl_APIToSubType(const uno::Any& rAny)
87{
88 sal_Int16 nVal = 0;
89 rAny >>= nVal;
90 sal_Int32 nSet = 0;
91 switch(nVal)
92 {
93 case SetVariableType::VAR: nSet = nsSwGetSetExpType::GSE_EXPR; break;
94 case SetVariableType::SEQUENCE: nSet = nsSwGetSetExpType::GSE_SEQ; break;
95 case SetVariableType::FORMULA: nSet = nsSwGetSetExpType::GSE_FORMULA; break;
96 case SetVariableType::STRING: nSet = nsSwGetSetExpType::GSE_STRING; break;
97 default:
98 OSL_FAIL("wrong value");
99 nSet = -1;
100 }
101 return nSet;
102}
103
104OUString ReplacePoint( const OUString& rTmpName, bool bWithCommandType )
105{
106 // replace first and last (if bWithCommandType: last two) dot
107 // since table names may contain dots
108
109 sal_Int32 nIndex = rTmpName.lastIndexOf('.');
110 if (nIndex<0)
111 {
112 return rTmpName;
113 }
114
115 OUString sRes = rTmpName.replaceAt(nIndex, 1, rtl::OUStringChar(DB_DELIM));
116
117 if (bWithCommandType)
118 {
119 nIndex = sRes.lastIndexOf('.', nIndex);
120 if (nIndex<0)
121 {
122 return sRes;
123 }
124 sRes = sRes.replaceAt(nIndex, 1, rtl::OUStringChar(DB_DELIM));
125 }
126
127 nIndex = sRes.indexOf('.');
128 if (nIndex>=0)
129 {
130 sRes = sRes.replaceAt(nIndex, 1, rtl::OUStringChar(DB_DELIM));
131 }
132 return sRes;
133}
134
135static SwTextNode* GetFirstTextNode( const SwDoc& rDoc, SwPosition& rPos,
136 const SwContentFrame *pCFrame, Point &rPt )
137{
138 SwTextNode* pTextNode = nullptr;
139 if ( !pCFrame )
140 {
141 const SwNodes& rNodes = rDoc.GetNodes();
142 rPos.nNode = *rNodes.GetEndOfContent().StartOfSectionNode();
143 SwContentNode* pCNd;
144 while( nullptr != (pCNd = rNodes.GoNext( &rPos.nNode ) ) &&
145 nullptr == ( pTextNode = pCNd->GetTextNode() ) )
146 ;
147 OSL_ENSURE( pTextNode, "Where is the 1. TextNode?" );
148 rPos.nContent.Assign( pTextNode, 0 );
149 }
150 else if ( !pCFrame->isFrameAreaDefinitionValid() )
151 {
152 assert(pCFrame->IsTextFrame());
153 rPos = static_cast<SwTextFrame const*>(pCFrame)->MapViewToModelPos(TextFrameIndex(0));
154 }
155 else
156 {
157 pCFrame->GetModelPositionForViewPoint( &rPos, rPt );
158 pTextNode = rPos.nNode.GetNode().GetTextNode();
159 }
160 return pTextNode;
161}
162
163const SwTextNode* GetBodyTextNode( const SwDoc& rDoc, SwPosition& rPos,
164 const SwFrame& rFrame )
165{
166 const SwLayoutFrame* pLayout = rFrame.GetUpper();
167 const SwTextNode* pTextNode = nullptr;
168
169 while( pLayout )
170 {
171 if( pLayout->IsFlyFrame() )
172 {
173 // get the FlyFormat
174 const SwFrameFormat* pFlyFormat = static_cast<const SwFlyFrame*>(pLayout)->GetFormat();
175 OSL_ENSURE( pFlyFormat, "Could not find FlyFormat, where is the field?" );
176
177 const SwFormatAnchor &rAnchor = pFlyFormat->GetAnchor();
178
179 if( RndStdIds::FLY_AT_FLY == rAnchor.GetAnchorId() )
180 {
181 // the fly needs to be attached somewhere, so ask it
182 pLayout = static_cast<const SwLayoutFrame*>(static_cast<const SwFlyFrame*>(pLayout)->GetAnchorFrame());
183 continue;
184 }
185 else if ((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) ||
186 (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
187 (RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()))
188 {
189 OSL_ENSURE( rAnchor.GetContentAnchor(), "no valid position" );
190 rPos = *rAnchor.GetContentAnchor();
191 pTextNode = rPos.nNode.GetNode().GetTextNode();
192 if ( RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() )
193 {
194 const_cast<SwTextNode*>(pTextNode)->MakeStartIndex(
195 &rPos.nContent );
196 }
197
198 // do not break yet, might be as well in Header/Footer/Footnote/Fly
199 pLayout = static_cast<const SwFlyFrame*>(pLayout)->GetAnchorFrame()
200 ? static_cast<const SwFlyFrame*>(pLayout)->GetAnchorFrame()->GetUpper() : nullptr;
201 continue;
202 }
203 else
204 {
206 pLayout->getFrameArea().Pos(), rPos );
207 pTextNode = rPos.nNode.GetNode().GetTextNode();
208 }
209 }
210 else if( pLayout->IsFootnoteFrame() )
211 {
212 // get the anchor's node
213 const SwTextFootnote* pFootnote = static_cast<const SwFootnoteFrame*>(pLayout)->GetAttr();
214 pTextNode = &pFootnote->GetTextNode();
215 rPos.nNode = *pTextNode;
216 rPos.nContent = pFootnote->GetStart();
217 }
218 else if( pLayout->IsHeaderFrame() || pLayout->IsFooterFrame() )
219 {
220 const SwContentFrame* pContentFrame;
221 const SwPageFrame* pPgFrame = pLayout->FindPageFrame();
222 if( pLayout->IsHeaderFrame() )
223 {
224 const SwTabFrame *pTab;
225 if( nullptr != ( pContentFrame = pPgFrame->FindFirstBodyContent()) &&
226 nullptr != (pTab = pContentFrame->FindTabFrame()) && pTab->IsFollow() &&
227 pTab->GetTable()->GetRowsToRepeat() > 0 &&
228 pTab->IsInHeadline( *pContentFrame ) )
229 {
230 // take the next line
231 const SwLayoutFrame* pRow = pTab->GetFirstNonHeadlineRow();
232 pContentFrame = pRow->ContainsContent();
233 }
234 }
235 else
236 pContentFrame = pPgFrame->FindLastBodyContent();
237
238 if( pContentFrame )
239 {
240 assert(pContentFrame->IsTextFrame());
241 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(pContentFrame));
242 rPos = pFrame->MapViewToModelPos(TextFrameIndex(pFrame->GetText().getLength()));
243 pTextNode = rPos.nNode.GetNode().GetTextNode();
244 assert(pTextNode);
245 }
246 else
247 {
248 Point aPt( pLayout->getFrameArea().Pos() );
249 aPt.AdjustY( 1 ); // get out of the header
250 pContentFrame = pPgFrame->GetContentPos( aPt, false, true );
251 pTextNode = GetFirstTextNode( rDoc, rPos, pContentFrame, aPt );
252 }
253 }
254 else
255 {
256 pLayout = pLayout->GetUpper();
257 continue;
258 }
259 break; // found, so finish loop
260 }
261 return pTextNode;
262}
263
266{
267}
268
269std::unique_ptr<SwFieldType> SwGetExpFieldType::Copy() const
270{
271 return std::make_unique<SwGetExpFieldType>(GetDoc());
272}
273
275{
276 if (rHint.GetId() != SfxHintId::SwLegacyModify)
277 return;
278 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
279 // do not expand anything else
280 if(pLegacy->GetWhich() != RES_DOCPOS_UPDATE)
281 return;
282 CallSwClientNotify(rHint);
283}
284
285SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const OUString& rFormel,
286 sal_uInt16 nSub, sal_uLong nFormat)
287 : SwFormulaField( pTyp, nFormat, 0.0 )
288 , m_fValueRLHidden(0.0)
289 ,
290 m_bIsInBodyText( true ),
291 m_nSubType(nSub),
292 m_bLateInitialization( false )
293{
294 SetFormula( rFormel );
295}
296
297void SwGetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const pLayout)
298{
299 if (!pLayout || pLayout->IsHideRedlines())
300 {
301 m_sExpandRLHidden = rExpand;
302 }
303 if (!pLayout || !pLayout->IsHideRedlines())
304 {
305 m_sExpand = rExpand;
306 }
307}
308
309OUString SwGetExpField::ExpandImpl(SwRootFrame const*const pLayout) const
310{
312 return GetFormula();
313
314 return (pLayout && pLayout->IsHideRedlines()) ? m_sExpandRLHidden : m_sExpand;
315}
316
318{
319 const SwFieldTypesEnum nType =
323
324 return SwFieldType::GetTypeStr(nType) + " " + GetFormula();
325}
326
327std::unique_ptr<SwField> SwGetExpField::Copy() const
328{
329 std::unique_ptr<SwGetExpField> pTmp(new SwGetExpField(static_cast<SwGetExpFieldType*>(GetTyp()),
331 pTmp->SetLanguage(GetLanguage());
332 pTmp->m_fValueRLHidden = m_fValueRLHidden;
333 pTmp->SwValueField::SetValue(GetValue());
334 pTmp->m_sExpand = m_sExpand;
335 pTmp->m_sExpandRLHidden = m_sExpandRLHidden;
336 pTmp->m_bIsInBodyText = m_bIsInBodyText;
337 pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
339 pTmp->SetLateInitialization();
340
341 return std::unique_ptr<SwField>(pTmp.release());
342}
343
344void SwGetExpField::ChangeExpansion( const SwFrame& rFrame, const SwTextField& rField )
345{
346 if( m_bIsInBodyText ) // only fields in Footer, Header, FootNote, Flys
347 return;
348
349 OSL_ENSURE( !rFrame.IsInDocBody(), "Flag incorrect, frame is in DocBody" );
350
351 // determine document (or is there an easier way?)
352 const SwTextNode* pTextNode = &rField.GetTextNode();
353 SwDoc& rDoc = const_cast<SwDoc&>(pTextNode->GetDoc());
354
355 // create index for determination of the TextNode
356 SwPosition aPos( SwNodeIndex( rDoc.GetNodes() ) );
357 pTextNode = GetBodyTextNode( rDoc, aPos, rFrame );
358
359 // If no layout exists, ChangeExpansion is called for header and
360 // footer lines via layout formatting without existing TextNode.
361 if(!pTextNode)
362 return;
363 // #i82544#
365 {
367 if( pSetExpField )
368 {
369 m_bLateInitialization = false;
371 static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING )
373 }
374 }
375
376 SwRootFrame const& rLayout(*rFrame.getRootFrame());
377 OUString & rExpand(rLayout.IsHideRedlines() ? m_sExpandRLHidden : m_sExpand);
378 // here a page number is needed to sort correctly
379 SetGetExpField aEndField(aPos.nNode, &rField, &aPos.nContent, rFrame.GetPhyPageNum());
381 {
382 SwHashTable<HashStr> aHashTable(0);
383 rDoc.getIDocumentFieldsAccess().FieldsToExpand(aHashTable, aEndField, rLayout);
384 rExpand = LookString( aHashTable, GetFormula() );
385 }
386 else
387 {
388 // fill calculator with values
389 SwCalc aCalc( rDoc );
390 rDoc.getIDocumentFieldsAccess().FieldsToCalc(aCalc, aEndField, &rLayout);
391
392 // calculate value
393 SetValue(aCalc.Calculate(GetFormula()).GetDouble(), &rLayout);
394
395 // analyse based on format
396 rExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue(
397 GetValue(&rLayout), GetFormat(), GetLanguage());
398 }
399}
400
402{
403 return GetFormula();
404}
405
406void SwGetExpField::SetPar2(const OUString& rStr)
407{
408 SetFormula(rStr);
409}
410
412{
413 return m_nSubType;
414}
415
416void SwGetExpField::SetSubType(sal_uInt16 nType)
417{
419}
420
422{
425 else
427}
428
429bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
430{
431 switch( nWhichId )
432 {
434 rAny <<= GetValue();
435 break;
437 rAny <<= static_cast<sal_Int32>(GetFormat());
438 break;
440 rAny <<= static_cast<sal_Int16>(m_nSubType);
441 break;
442 case FIELD_PROP_PAR1:
443 rAny <<= GetFormula();
444 break;
446 {
447 sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
448 rAny <<= nRet;
449 }
450 break;
451 case FIELD_PROP_BOOL2:
453 break;
454 case FIELD_PROP_PAR4:
455 rAny <<= m_sExpand;
456 break;
457 default:
458 return SwField::QueryValue(rAny, nWhichId);
459 }
460 return true;
461}
462
463bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
464{
465 sal_Int32 nTmp = 0;
466 switch( nWhichId )
467 {
469 SwValueField::SetValue(*o3tl::doAccess<double>(rAny));
470 m_fValueRLHidden = *o3tl::doAccess<double>(rAny);
471 break;
473 rAny >>= nTmp;
474 SetFormat(nTmp);
475 break;
477 rAny >>= nTmp;
478 m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp);
479 break;
480 case FIELD_PROP_PAR1:
481 {
482 OUString sTmp;
483 rAny >>= sTmp;
484 SetFormula(sTmp);
485 break;
486 }
488 nTmp = lcl_APIToSubType(rAny);
489 if( nTmp >=0 )
490 SetSubType( o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
491 break;
492 case FIELD_PROP_BOOL2:
493 if(*o3tl::doAccess<bool>(rAny))
495 else
497 break;
498 case FIELD_PROP_PAR4:
499 {
500 OUString sTmp;
501 rAny >>= sTmp;
502 ChgExpStr(sTmp, nullptr);
503 break;
504 }
505 default:
506 return SwField::PutValue(rAny, nWhichId);
507 }
508 return true;
509}
510
511SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const OUString& rName, sal_uInt16 nTyp )
513 m_sName( rName ),
514 m_sDelim( "." ),
515 m_nType(nTyp), m_nLevel( UCHAR_MAX ),
516 m_bDeleted( false )
517{
519 EnableFormat(false); // do not use Numberformatter
520}
521
522std::unique_ptr<SwFieldType> SwSetExpFieldType::Copy() const
523{
524 std::unique_ptr<SwSetExpFieldType> pNew(new SwSetExpFieldType(GetDoc(), m_sName, m_nType));
525 pNew->m_bDeleted = m_bDeleted;
526 pNew->m_sDelim = m_sDelim;
527 pNew->m_nLevel = m_nLevel;
528
529 return pNew;
530}
531
533{
534 return m_sName;
535}
536
537const OUString& SwSetExpField::GetExpStr(SwRootFrame const*const pLayout) const
538{
539 return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand;
540}
541
542void SwSetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const pLayout)
543{
544 if (!pLayout || pLayout->IsHideRedlines())
545 {
546 msExpandRLHidden = rExpand;
547 }
548 if (!pLayout || !pLayout->IsHideRedlines())
549 {
550 msExpand = rExpand;
551 }
552}
553
555{
556 // do not expand further
557}
558
560{
561 std::vector<SwFormatField*> vFields;
562 GatherFields(vFields, false);
563 for(auto pFormatField: vFields)
564 pFormatField->GetField()->ChangeFormat(nFormat);
565}
566
568{
569 if( !HasWriterListeners() )
570 return SVX_NUM_ARABIC;
571
572 std::vector<SwFormatField*> vFields;
573 GatherFields(vFields, false);
574 return vFields.front()->GetField()->GetFormat();
575}
576
578{
580 return;
581
582 std::vector<sal_uInt16> aArr;
583
584 // check if number is already used and if a new one needs to be created
585 std::vector<SwFormatField*> vFields;
586 GatherFields(vFields);
587 for(SwFormatField* pF: vFields)
588 if(pF->GetField() != &rField)
589 InsertSort(aArr, static_cast<SwSetExpField*>(pF->GetField())->GetSeqNumber());
590
591 // check first if number already exists
592 sal_uInt16 nNum = rField.GetSeqNumber();
593 if( USHRT_MAX != nNum )
594 {
595 std::vector<sal_uInt16>::size_type n {0};
596
597 for( n = 0; n < aArr.size(); ++n )
598 if( aArr[ n ] >= nNum )
599 break;
600
601 if( n == aArr.size() || aArr[ n ] > nNum )
602 return; // no -> use it
603 }
604
605 // flagged all numbers, so determine the right number
606 std::vector<sal_uInt16>::size_type n = aArr.size();
607 OSL_ENSURE( n <= std::numeric_limits<sal_uInt16>::max(), "Array is too big for using a sal_uInt16 index" );
608
609 if ( n > 0 && aArr[ n-1 ] != n-1 )
610 {
611 for( n = 0; n < aArr.size(); ++n )
612 if( n != aArr[ n ] )
613 break;
614 }
615
616 rField.SetSeqNumber( n );
617}
618
620 SwRootFrame const*const pLayout)
621{
622 rList.Clear();
623
624 IDocumentRedlineAccess const& rIDRA(GetDoc()->getIDocumentRedlineAccess());
625
626 std::vector<SwFormatField*> vFields;
627 GatherFields(vFields);
628 for(SwFormatField* pF: vFields)
629 {
630 const SwTextNode* pNd;
631 if( nullptr != ( pNd = pF->GetTextField()->GetpTextNode() )
632 && (!pLayout || !pLayout->IsHideRedlines()
633 || !sw::IsFieldDeletedInModel(rIDRA, *pF->GetTextField())))
634 {
635 SeqFieldLstElem aNew(
636 pNd->GetExpandText(pLayout),
637 static_cast<SwSetExpField*>(pF->GetField())->GetSeqNumber() );
638 rList.InsertSort( aNew );
639 }
640 }
641 return rList.Count();
642}
643
645 SwRootFrame const*const pLayout)
646{
647 const SwTextNode* pTextNd = rNd.FindOutlineNodeOfLevel(m_nLevel, pLayout);
648 if( !pTextNd )
649 return;
650
651 SwNumRule * pRule = pTextNd->GetNumRule();
652
653 if (!pRule)
654 return;
655
656 // --> OD 2005-11-02 #i51089 - TUNING#
657 if (SwNodeNum const*const pNum = pTextNd->GetNum(pLayout))
658 {
659 // only get the number, without pre-/post-fixstrings
660 OUString const sNumber(pRule->MakeNumString(*pNum, false));
661
662 if( !sNumber.isEmpty() )
663 rField.ChgExpStr(sNumber + m_sDelim + rField.GetExpStr(pLayout), pLayout);
664 }
665 else
666 {
667 OSL_ENSURE(pTextNd->GetNum(nullptr), "<SwSetExpFieldType::SetChapter(..)> - text node with numbering rule, but without number. This is a serious defect");
668 }
669}
670
671void SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
672{
673 switch( nWhichId )
674 {
676 {
677 sal_Int16 nRet = lcl_SubTypeToAPI(GetType());
678 rAny <<= nRet;
679 }
680 break;
681 case FIELD_PROP_PAR2:
682 rAny <<= GetDelimiter();
683 break;
685 {
686 sal_Int8 nRet = m_nLevel < MAXLEVEL? m_nLevel : -1;
687 rAny <<= nRet;
688 }
689 break;
690 default:
691 assert(false);
692 }
693}
694
695void SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
696{
697 switch( nWhichId )
698 {
700 {
701 sal_Int32 nSet = lcl_APIToSubType(rAny);
702 if(nSet >=0)
703 SetType(o3tl::narrowing<sal_uInt16>(nSet));
704 }
705 break;
706 case FIELD_PROP_PAR2:
707 {
708 OUString sTmp;
709 rAny >>= sTmp;
710 if( !sTmp.isEmpty() )
711 SetDelimiter( sTmp );
712 else
713 SetDelimiter( " " );
714 }
715 break;
717 {
718 sal_Int8 nLvl = 0;
719 rAny >>= nLvl;
720 if(nLvl < 0 || nLvl >= MAXLEVEL)
721 SetOutlineLvl(UCHAR_MAX);
722 else
723 SetOutlineLvl(nLvl);
724 }
725 break;
726 default:
727 assert(false);
728 }
729}
730
732{
733 OUStringBuffer aBuf(aNew.sDlgEntry);
734 const sal_Int32 nLen = aBuf.getLength();
735 for (sal_Int32 i = 0; i < nLen; ++i)
736 {
737 if (aBuf[i]<' ')
738 {
739 aBuf[i]=' ';
740 }
741 }
742 aNew.sDlgEntry = aBuf.makeStringAndClear();
743
744 size_t nPos = 0;
745 bool bRet = SeekEntry( aNew, &nPos );
746 if( !bRet )
747 maData.insert( maData.begin() + nPos, aNew );
748 return bRet;
749}
750
751bool SwSeqFieldList::SeekEntry( const SeqFieldLstElem& rNew, size_t* pP ) const
752{
753 size_t nO = maData.size();
754 size_t nU = 0;
755 if( nO > 0 )
756 {
758 & rColl = ::GetAppCollator();
759 const CharClass& rCC = GetAppCharClass();
760
761 //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1")
762 const OUString rTmp2 = rNew.sDlgEntry;
763 sal_Int32 nFndPos2 = 0;
764 const OUString sNum2( rTmp2.getToken( 0, ' ', nFndPos2 ));
765 bool bIsNum2IsNumeric = CharClass::isAsciiNumeric( sNum2 );
766 sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.toInt32() : 0;
767
768 nO--;
769 while( nU <= nO )
770 {
771 const size_t nM = nU + ( nO - nU ) / 2;
772
773 //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1")
774 const OUString rTmp1 = maData[nM].sDlgEntry;
775 sal_Int32 nFndPos1 = 0;
776 const OUString sNum1( rTmp1.getToken( 0, ' ', nFndPos1 ));
777 sal_Int32 nCmp;
778
779 if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) )
780 {
781 sal_Int32 nNum1 = sNum1.toInt32();
782 nCmp = nNum2 - nNum1;
783 if( 0 == nCmp )
784 {
785 OUString aTmp1 = nFndPos1 != -1 ? rTmp1.copy(nFndPos1) : OUString();
786 OUString aTmp2 = nFndPos2 != -1 ? rTmp2.copy(nFndPos2) : OUString();
787 nCmp = rCaseColl.compareString(aTmp2, aTmp1);
788 }
789 }
790 else
791 nCmp = rColl.compareString( rTmp2, rTmp1 );
792
793 if( 0 == nCmp )
794 {
795 if( pP ) *pP = nM;
796 return true;
797 }
798 else if( 0 < nCmp )
799 nU = nM + 1;
800 else if( nM == 0 )
801 break;
802 else
803 nO = nM - 1;
804 }
805 }
806 if( pP ) *pP = nU;
807 return false;
808}
809
810SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const OUString& rFormel,
811 sal_uLong nFormat)
812 : SwFormulaField( pTyp, nFormat, 0.0 )
813 , m_fValueRLHidden(0.0)
814 , mnSeqNo( USHRT_MAX )
815 , mnSubType(0)
816 , mpFormatField(nullptr)
817{
818 SetFormula(rFormel);
819 // ignore SubType
820 mbInput = false;
821 if( IsSequenceField() )
822 {
824 m_fValueRLHidden = 1.0;
825 if( rFormel.isEmpty() )
826 {
827 SetFormula(pTyp->GetName() + "+1");
828 }
829 }
830}
831
833{
834 mpFormatField = &rFormatField;
835}
836
837OUString SwSetExpField::ExpandImpl(SwRootFrame const*const pLayout) const
838{
840 { // we need the CommandString
841 return GetTyp()->GetName() + " = " + GetFormula();
842 }
844 { // value is visible
845 return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand;
846 }
847 return OUString();
848}
849
852{
853 SwFieldTypesEnum const nStrType( (IsSequenceField())
855 : mbInput
858
859 OUString aStr(
860 SwFieldType::GetTypeStr( nStrType )
861 + " "
862 + GetTyp()->GetName() );
863
864 // Sequence: without formula
865 if (SwFieldTypesEnum::Sequence != nStrType)
866 {
867 aStr += " = " + GetFormula();
868 }
869 return aStr;
870}
871
872std::unique_ptr<SwField> SwSetExpField::Copy() const
873{
874 std::unique_ptr<SwSetExpField> pTmp(new SwSetExpField(static_cast<SwSetExpFieldType*>(GetTyp()),
875 GetFormula(), GetFormat()));
876 pTmp->SwValueField::SetValue(GetValue());
877 pTmp->m_fValueRLHidden = m_fValueRLHidden;
878 pTmp->msExpand = msExpand;
879 pTmp->msExpandRLHidden = msExpandRLHidden;
880 pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
881 pTmp->SetLanguage(GetLanguage());
882 pTmp->maPText = maPText;
883 pTmp->mbInput = mbInput;
884 pTmp->mnSeqNo = mnSeqNo;
885 pTmp->SetSubType(GetSubType());
886
887 return std::unique_ptr<SwField>(pTmp.release());
888}
889
890void SwSetExpField::SetSubType(sal_uInt16 nSub)
891{
892 static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & 0xff);
893 mnSubType = nSub & 0xff00;
894
895 OSL_ENSURE( (nSub & 0xff) != 3, "SubType is illegal!" );
896}
897
899{
900 return static_cast<SwSetExpFieldType*>(GetTyp())->GetType() | mnSubType;
901}
902
903void SwSetExpField::SetValue( const double& rAny )
904{
906
907 if( IsSequenceField() )
909 else
910 msExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue( rAny,
912}
913
914void SwSetExpField::SetValue(const double& rValue, SwRootFrame const*const pLayout)
915{
916 if (!pLayout || !pLayout->IsHideRedlines())
917 {
918 SetValue(rValue);
919 }
920 if (pLayout && !pLayout->IsHideRedlines())
921 return;
922
923 m_fValueRLHidden = rValue;
924 if (IsSequenceField())
925 {
926 msExpandRLHidden = FormatNumber(rValue, static_cast<SvxNumType>(GetFormat()), GetLanguage());
927 }
928 else
929 {
931 rValue, GetFormat(), GetLanguage());
932 }
933}
934
935double SwSetExpField::GetValue(SwRootFrame const* pLayout) const
936{
937 return (pLayout && pLayout->IsHideRedlines()) ? m_fValueRLHidden : GetValue();
938}
939
940void SwGetExpField::SetValue( const double& rAny )
941{
943 m_sExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue( rAny, GetFormat(),
944 GetLanguage());
945}
946
947void SwGetExpField::SetValue(const double& rValue, SwRootFrame const*const pLayout)
948{
949 if (!pLayout || !pLayout->IsHideRedlines())
950 {
951 SetValue(rValue);
952 }
953 if (!pLayout || pLayout->IsHideRedlines())
954 {
955 m_fValueRLHidden = rValue;
957 rValue, GetFormat(), GetLanguage());
958 }
959}
960
961double SwGetExpField::GetValue(SwRootFrame const* pLayout) const
962{
963 return (pLayout && pLayout->IsHideRedlines()) ? m_fValueRLHidden : GetValue();
964}
965
973sal_Int32 SwGetExpField::GetReferenceTextPos( const SwFormatField& rFormat, SwDoc& rDoc, sal_Int32 nHint)
974{
975
976 const SwTextField* pTextField = rFormat.GetTextField();
977 const SwTextNode& rTextNode = pTextField->GetTextNode();
978
979 sal_Int32 nRet = nHint ? nHint : pTextField->GetStart() + 1;
980 OUString sNodeText = rTextNode.GetText();
981
982 if(nRet<sNodeText.getLength())
983 {
984 sNodeText = sNodeText.copy(nRet);
985
986 // now check if sNodeText starts with a non-alphanumeric character plus blanks
987 sal_uInt16 nSrcpt = g_pBreakIt->GetRealScriptOfText( sNodeText, 0 );
988
989 static const WhichRangesContainer nIds(svl::Items<
996 >);
997 SwAttrSet aSet(rDoc.GetAttrPool(), nIds);
998 rTextNode.GetParaAttr(aSet, nRet, nRet+1);
999
1001 if( RTL_TEXTENCODING_SYMBOL != aSet.Get( nFontWhich ).GetCharSet() )
1002 {
1004 LanguageType eLang = aSet.Get(nLangWhich).GetLanguage();
1005 CharClass aCC(( LanguageTag(eLang) ));
1006 sal_Unicode c0 = sNodeText[0];
1007 bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 );
1008 if( !bIsAlphaNum ||
1009 (c0 == ' ' || c0 == '\t'))
1010 {
1011 // ignoring blanks
1012 nRet++;
1013 const sal_Int32 nLen = sNodeText.getLength();
1014 for (sal_Int32 i = 1;
1015 i<nLen && (sNodeText[i]==' ' || sNodeText[i]=='\t');
1016 ++i
1017 )
1018 ++nRet;
1019 }
1020 }
1021 }
1022 return nRet;
1023}
1024
1026{
1027 return static_cast<const SwSetExpFieldType*>(GetTyp())->GetName();
1028}
1029
1031{
1032 sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType();
1033
1035 return GetFormula();
1036 return GetExpandedFormula();
1037}
1038
1039void SwSetExpField::SetPar2(const OUString& rStr)
1040{
1041 sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType();
1042
1043 if( !(nType & nsSwGetSetExpType::GSE_SEQ) || !rStr.isEmpty() )
1044 {
1046 SetFormula(rStr);
1047 else
1048 SetExpandedFormula(rStr);
1049 }
1050}
1051
1052bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1053{
1054 sal_Int32 nTmp32 = 0;
1055 sal_Int16 nTmp16 = 0;
1056 switch( nWhichId )
1057 {
1058 case FIELD_PROP_BOOL2:
1059 if(*o3tl::doAccess<bool>(rAny))
1061 else
1063 break;
1064 case FIELD_PROP_FORMAT:
1065 rAny >>= nTmp32;
1066 SetFormat(nTmp32);
1067 break;
1068 case FIELD_PROP_USHORT2:
1069 {
1070 rAny >>= nTmp16;
1071 if(nTmp16 <= css::style::NumberingType::NUMBER_NONE )
1072 SetFormat(nTmp16);
1073 else {
1074 //exception(wrong_value)
1075 ;
1076 }
1077 }
1078 break;
1079 case FIELD_PROP_USHORT1:
1080 rAny >>= nTmp16;
1081 mnSeqNo = nTmp16;
1082 break;
1083 case FIELD_PROP_PAR1:
1084 {
1085 OUString sTmp;
1086 rAny >>= sTmp;
1088 }
1089 break;
1090 case FIELD_PROP_PAR2:
1091 {
1092 OUString uTmp;
1093 rAny >>= uTmp;
1094 //I18N - if the formula contains only "TypeName+1"
1095 //and it's one of the initially created sequence fields
1096 //then the localized names has to be replaced by a programmatic name
1097 OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, false);
1098 SetFormula( sMyFormula );
1099 }
1100 break;
1101 case FIELD_PROP_DOUBLE:
1102 {
1103 double fVal = 0.0;
1104 rAny >>= fVal;
1105 SetValue(fVal);
1106 m_fValueRLHidden = fVal;
1107 }
1108 break;
1109 case FIELD_PROP_SUBTYPE:
1110 nTmp32 = lcl_APIToSubType(rAny);
1111 if(nTmp32 >= 0)
1112 SetSubType(o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
1113 break;
1114 case FIELD_PROP_PAR3:
1115 rAny >>= maPText;
1116 break;
1117 case FIELD_PROP_BOOL3:
1118 if(*o3tl::doAccess<bool>(rAny))
1120 else
1122 break;
1123 case FIELD_PROP_BOOL1:
1124 {
1125 bool newInput(*o3tl::doAccess<bool>(rAny));
1126 if (newInput != GetInputFlag())
1127 {
1128 if (static_cast<SwSetExpFieldType*>(GetTyp())->GetType()
1130 {
1132 }
1133 else
1134 {
1135 SetInputFlag(newInput);
1136 }
1137 }
1138 }
1139 break;
1140 case FIELD_PROP_PAR4:
1141 {
1142 OUString sTmp;
1143 rAny >>= sTmp;
1144 ChgExpStr(sTmp, nullptr);
1145 }
1146 break;
1147 default:
1148 return SwField::PutValue(rAny, nWhichId);
1149 }
1150 return true;
1151}
1152
1153bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1154{
1155 switch( nWhichId )
1156 {
1157 case FIELD_PROP_BOOL2:
1159 break;
1160 case FIELD_PROP_FORMAT:
1161 rAny <<= static_cast<sal_Int32>(GetFormat());
1162 break;
1163 case FIELD_PROP_USHORT2:
1164 rAny <<= static_cast<sal_Int16>(GetFormat());
1165 break;
1166 case FIELD_PROP_USHORT1:
1167 rAny <<= static_cast<sal_Int16>(mnSeqNo);
1168 break;
1169 case FIELD_PROP_PAR1:
1171 break;
1172 case FIELD_PROP_PAR2:
1173 {
1174 //I18N - if the formula contains only "TypeName+1"
1175 //and it's one of the initially created sequence fields
1176 //then the localized names has to be replaced by a programmatic name
1177 OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), true);
1178 rAny <<= sMyFormula;
1179 }
1180 break;
1181 case FIELD_PROP_DOUBLE:
1182 rAny <<= GetValue();
1183 break;
1184 case FIELD_PROP_SUBTYPE:
1185 {
1186 sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
1187 rAny <<= nRet;
1188 }
1189 break;
1190 case FIELD_PROP_PAR3:
1191 rAny <<= maPText;
1192 break;
1193 case FIELD_PROP_BOOL3:
1194 rAny <<= 0 != (mnSubType & nsSwExtendedSubType::SUB_CMD);
1195 break;
1196 case FIELD_PROP_BOOL1:
1197 rAny <<= GetInputFlag();
1198 break;
1199 case FIELD_PROP_PAR4:
1200 rAny <<= GetExpStr(nullptr);
1201 break;
1202 default:
1203 return SwField::QueryValue(rAny, nWhichId);
1204 }
1205 return true;
1206}
1207
1210 , mpDoc( pD )
1211{
1212}
1213
1214std::unique_ptr<SwFieldType> SwInputFieldType::Copy() const
1215{
1216 return std::make_unique<SwInputFieldType>( mpDoc );
1217}
1218
1220 const OUString& rContent,
1221 const OUString& rPrompt,
1222 sal_uInt16 nSub,
1223 sal_uLong nFormat,
1224 bool bIsFormField )
1225 : SwField( pFieldType, nFormat, LANGUAGE_SYSTEM, false )
1226 , maContent(rContent)
1227 , maPText(rPrompt)
1228 , mnSubType(nSub)
1229 , mbIsFormField( bIsFormField )
1230 , mpFormatField( nullptr )
1231{
1232}
1233
1235{
1236}
1237
1239{
1240 mpFormatField = &rFormatField;
1241}
1242
1243
1244void SwInputField::applyFieldContent( const OUString& rNewFieldContent )
1245{
1246 if ( (mnSubType & 0x00ff) == INP_TXT )
1247 {
1248 maContent = rNewFieldContent;
1249 }
1250 else if( (mnSubType & 0x00ff) == INP_USR )
1251 {
1252 SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
1253 static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::User, getContent(), false ) );
1254 if( pUserTyp )
1255 {
1256 pUserTyp->SetContent( rNewFieldContent );
1257 if (!pUserTyp->IsModifyLocked())
1258 {
1259 // trigger update of the corresponding User Fields and other
1260 // related Input Fields
1261 bool bUnlock(false);
1262 if (GetFormatField() != nullptr)
1263 {
1264 SwTextInputField *const pTextInputField =
1265 dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
1266 if (pTextInputField != nullptr)
1267 {
1268 bUnlock = pTextInputField->LockNotifyContentChange();
1269 }
1270 }
1271 pUserTyp->UpdateFields();
1272 if (bUnlock)
1273 {
1274 SwTextInputField *const pTextInputField =
1275 dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
1276 if (pTextInputField != nullptr)
1277 {
1278 pTextInputField->UnlockNotifyContentChange();
1279 }
1280 }
1281 }
1282 }
1283 }
1284}
1285
1287{
1288 OUString aStr(SwField::GetFieldName());
1289 if ((mnSubType & 0x00ff) == INP_USR)
1290 {
1291 aStr += GetTyp()->GetName() + " " + getContent();
1292 }
1293 return aStr;
1294}
1295
1296std::unique_ptr<SwField> SwInputField::Copy() const
1297{
1298 std::unique_ptr<SwInputField> pField(
1299 new SwInputField(
1300 static_cast<SwInputFieldType*>(GetTyp()),
1301 getContent(),
1302 maPText,
1303 GetSubType(),
1304 GetFormat(),
1305 mbIsFormField ));
1306
1307 pField->SetHelp( maHelp );
1308 pField->SetToolTip( maToolTip );
1309 pField->maGrabBag = maGrabBag;
1310
1311 pField->SetAutomaticLanguage(IsAutomaticLanguage());
1312 return std::unique_ptr<SwField>(pField.release());
1313}
1314
1315OUString SwInputField::ExpandImpl(SwRootFrame const*const) const
1316{
1317 if((mnSubType & 0x00ff) == INP_TXT)
1318 {
1319 return getContent();
1320 }
1321
1322 if( (mnSubType & 0x00ff) == INP_USR )
1323 {
1324 SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
1325 static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::User, getContent(), false ) );
1326 if( pUserTyp )
1327 return pUserTyp->GetContent();
1328 }
1329
1330 return OUString();
1331}
1332
1334{
1335 return mbIsFormField
1336 || !maHelp.isEmpty()
1337 || !maToolTip.isEmpty();
1338}
1339
1340bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1341{
1342 switch( nWhichId )
1343 {
1344 case FIELD_PROP_PAR1:
1345 rAny <<= getContent();
1346 break;
1347 case FIELD_PROP_PAR2:
1348 rAny <<= maPText;
1349 break;
1350 case FIELD_PROP_PAR3:
1351 rAny <<= maHelp;
1352 break;
1353 case FIELD_PROP_PAR4:
1354 rAny <<= maToolTip;
1355 break;
1356 case FIELD_PROP_GRABBAG:
1357 rAny <<= maGrabBag;
1358 break;
1359 case FIELD_PROP_TITLE:
1360 break;
1361 default:
1362 assert(false);
1363 }
1364 return true;
1365}
1366
1367bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1368{
1369 switch( nWhichId )
1370 {
1371 case FIELD_PROP_PAR1:
1372 rAny >>= maContent;
1373 break;
1374 case FIELD_PROP_PAR2:
1375 rAny >>= maPText;
1376 break;
1377 case FIELD_PROP_PAR3:
1378 rAny >>= maHelp;
1379 break;
1380 case FIELD_PROP_PAR4:
1381 rAny >>= maToolTip;
1382 break;
1383 case FIELD_PROP_GRABBAG:
1384 rAny >>= maGrabBag;
1385 break;
1386 case FIELD_PROP_TITLE:
1387 break;
1388 default:
1389 assert(false);
1390 }
1391 return true;
1392}
1393
1395void SwInputField::SetPar1(const OUString& rStr)
1396{
1397 maContent = rStr;
1398}
1399
1401{
1402 return getContent();
1403}
1404
1405void SwInputField::SetPar2(const OUString& rStr)
1406{
1407 maPText = rStr;
1408}
1409
1411{
1412 return maPText;
1413}
1414
1415void SwInputField::SetHelp(const OUString & rStr)
1416{
1417 maHelp = rStr;
1418}
1419
1420const OUString& SwInputField::GetHelp() const
1421{
1422 return maHelp;
1423}
1424
1425void SwInputField::SetToolTip(const OUString & rStr)
1426{
1427 maToolTip = rStr;
1428}
1429
1430const OUString& SwInputField::GetToolTip() const
1431{
1432 return maToolTip;
1433}
1434
1436{
1437 return mnSubType;
1438}
1439
1440void SwInputField::SetSubType(sal_uInt16 nSub)
1441{
1442 mnSubType = nSub;
1443}
1444
1445/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nLevel
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
void InsertSort(std::vector< sal_uInt16 > &rArr, sal_uInt16 nIdx)
Definition: untbl.cxx:3086
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:33
bool isNumeric(const OUString &rStr) const
static bool isAsciiNumeric(std::u16string_view rStr)
bool isAlphaNumeric(const OUString &rStr, sal_Int32 nPos) const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
virtual void FieldsToExpand(SwHashTable< HashStr > &rTable, const SetGetExpField &rToThisField, SwRootFrame const &rLayout)=0
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
virtual void FieldsToCalc(SwCalc &rCalc, SwNodeOffset nLastNd, sal_Int32 nLastCnt)=0
SfxHintId GetId() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
Definition: breakit.cxx:83
Definition: calc.hxx:195
SwSbxValue Calculate(const OUString &rStr)
Definition: calc.cxx:356
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
Definition: doc.hxx:188
SwNodes & GetNodes()
Definition: doc.hxx:408
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1318
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
virtual void UpdateFields()
Definition: fldbas.cxx:213
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:137
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:122
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:203
Base class of all fields.
Definition: fldbas.hxx:292
virtual void SetLanguage(LanguageType nLng)
Definition: fldbas.cxx:442
virtual void SetPar1(const OUString &rStr)
Definition: fldbas.cxx:336
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:383
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:307
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:403
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
Definition: fldbas.cxx:351
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:305
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
Definition: fldbas.cxx:369
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:408
bool IsFollow() const
Definition: flowfrm.hxx:166
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
FlyAnchors.
Definition: fmtanchr.hxx:35
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:134
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
OUString GetExpandedFormula() const
Definition: fldbas.cxx:805
void SetExpandedFormula(const OUString &rStr)
Definition: fldbas.cxx:786
void SetFormula(const OUString &rStr)
Definition: fldbas.cxx:771
virtual OUString GetFormula() const override
Definition: fldbas.cxx:766
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:171
Style of a layout element.
Definition: frmfmt.hxx:61
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1234
bool IsInDocBody() const
Definition: frame.hxx:943
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1099
bool IsHeaderFrame() const
Definition: frame.hxx:1190
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
bool IsFooterFrame() const
Definition: frame.hxx:1194
bool IsFootnoteFrame() const
Definition: frame.hxx:1202
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
SwRootFrame * getRootFrame()
Definition: frame.hxx:679
bool IsFlyFrame() const
Definition: frame.hxx:1210
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1709
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Overlay, because get-field cannot be changed and therefore does not need to be updated.
Definition: expfld.cxx:274
SwGetExpFieldType(SwDoc *pDoc)
Definition: expfld.cxx:264
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:269
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:297
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:327
virtual OUString GetPar2() const override
Change formula.
Definition: expfld.cxx:401
sal_uInt16 m_nSubType
Definition: expfld.hxx:91
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: expfld.cxx:309
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:429
SwGetExpField(SwGetExpFieldType *, const OUString &rFormel, sal_uInt16 nSubType, sal_uLong nFormat)
Definition: expfld.cxx:285
virtual void SetSubType(sal_uInt16 nType) override
Definition: expfld.cxx:416
void ChangeExpansion(const SwFrame &, const SwTextField &)
For fields in header/footer/footnotes/flys: Only called by formatting!!
Definition: expfld.cxx:344
OUString m_sExpandRLHidden
hidden redlines
Definition: expfld.hxx:89
bool m_bIsInBodyText
Definition: expfld.hxx:90
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:411
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:463
bool m_bLateInitialization
Definition: expfld.hxx:93
virtual OUString GetFieldName() const override
get name or content
Definition: expfld.cxx:317
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: expfld.cxx:421
OUString m_sExpand
Definition: expfld.hxx:88
double m_fValueRLHidden
SwValueField; hidden redlines.
Definition: expfld.hxx:87
static sal_Int32 GetReferenceTextPos(const SwFormatField &rFormat, SwDoc &rDoc, sal_Int32 nHint=0)
Find the index of the reference text following the current field.
Definition: expfld.cxx:973
virtual void SetValue(const double &rVal) override
Definition: expfld.cxx:940
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:406
T should be a subclass of SwHash.
Definition: calc.hxx:154
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
SwInputFieldType(SwDoc *pDoc)
Definition: expfld.cxx:1208
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:1214
SwDoc * mpDoc
Definition: expfld.hxx:276
OUString maContent
Definition: expfld.hxx:287
sal_uInt16 mnSubType
Definition: expfld.hxx:291
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: expfld.cxx:1315
bool isFormField() const
Definition: expfld.cxx:1333
bool mbIsFormField
Definition: expfld.hxx:292
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:1367
SwFormatField * mpFormatField
Definition: expfld.hxx:295
const OUString & GetHelp() const
Definition: expfld.cxx:1420
css::uno::Sequence< css::beans::PropertyValue > maGrabBag
Definition: expfld.hxx:293
void SetToolTip(const OUString &rStr)
Definition: expfld.cxx:1425
virtual void SetSubType(sal_uInt16 nSub) override
Definition: expfld.cxx:1440
void SetHelp(const OUString &rStr)
Definition: expfld.cxx:1415
const OUString & GetToolTip() const
Definition: expfld.cxx:1430
virtual void SetPar1(const OUString &rStr) override
set condition
Definition: expfld.cxx:1395
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:1340
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:1296
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:1238
void applyFieldContent(const OUString &rNewFieldContent)
Definition: expfld.cxx:1244
const OUString & getContent() const
Definition: expfld.hxx:301
OUString maPText
Definition: expfld.hxx:288
virtual OUString GetFieldName() const override
get name or content
Definition: expfld.cxx:1286
OUString maHelp
Definition: expfld.hxx:289
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:1405
OUString maToolTip
Definition: expfld.hxx:290
SwFormatField * GetFormatField()
Definition: expfld.hxx:315
virtual ~SwInputField() override
Definition: expfld.cxx:1234
virtual OUString GetPar2() const override
aPromptText
Definition: expfld.cxx:1410
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:1435
SwInputField(SwInputFieldType *pFieldType, const OUString &rContent, const OUString &rPrompt, sal_uInt16 nSubType, sal_uLong nFormat=0, bool bIsFormField=true)
Direct input via dialog; delete old value.
Definition: expfld.cxx:1219
virtual OUString GetPar1() const override
Content.
Definition: expfld.cxx:1400
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:70
const SwContentFrame * GetContentPos(Point &rPoint, const bool bDontLeave, const bool bBodyOnly=false, SwCursorMoveState *pCMS=nullptr, const bool bDefaultExpand=true) const
Finds the closest Content for the SPoint Is used for Pages, Flys and Cells if GetModelPositionForView...
Definition: trvlfrm.cxx:1186
bool IsModifyLocked() const
Definition: calbck.hxx:210
bool HasWriterListeners() const
Definition: calbck.hxx:202
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:128
Base class of the Writer document model elements.
Definition: node.hxx:83
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:871
const SwTextNode * FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame const *pLayout=nullptr) const
Definition: node.cxx:773
SwDoc & GetDoc()
Definition: node.hxx:213
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:162
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1300
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:642
A page of the document layout.
Definition: pagefrm.hxx:58
SwContentFrame * FindLastBodyContent()
Searches the last ContentFrame in BodyText below the page.
Definition: findfrm.cxx:55
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:350
void GetContentPosition(const Point &rPt, SwPosition &rPos) const
Same as SwLayoutFrame::GetContentPos().
Definition: trvlfrm.cxx:1396
void Pos(const Point &rNew)
Definition: swrect.hxx:171
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
Definition: rootfrm.hxx:421
void Clear()
Definition: expfld.hxx:69
bool SeekEntry(const SeqFieldLstElem &rNew, size_t *pPos) const
Definition: expfld.cxx:751
bool InsertSort(SeqFieldLstElem aNew)
Definition: expfld.cxx:731
size_t Count()
Definition: expfld.hxx:66
std::vector< SeqFieldLstElem > maData
Definition: expfld.hxx:61
const OUString & GetDelimiter() const
Number sequence fields chapterwise if required.
Definition: expfld.hxx:180
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: expfld.cxx:554
sal_uInt16 GetType() const
Definition: expfld.hxx:197
virtual OUString GetName() const override
Only in derived classes.
Definition: expfld.cxx:532
void SetType(sal_uInt16 nTyp)
Definition: expfld.hxx:191
void SetOutlineLvl(sal_uInt8 n)
Definition: expfld.hxx:183
size_t GetSeqFieldList(SwSeqFieldList &rList, SwRootFrame const *pLayout)
Definition: expfld.cxx:619
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:671
OUString m_sDelim
Definition: expfld.hxx:150
void SetChapter(SwSetExpField &rField, const SwNode &rNd, SwRootFrame const *pLayout)
Definition: expfld.cxx:644
void SetSeqRefNo(SwSetExpField &rField)
Definition: expfld.cxx:577
sal_uInt8 m_nLevel
Definition: expfld.hxx:152
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:695
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:181
void SetSeqFormat(sal_uLong nFormat)
Definition: expfld.cxx:559
sal_uLong GetSeqFormat() const
Definition: expfld.cxx:567
sal_uInt16 m_nType
Definition: expfld.hxx:151
SwSetExpFieldType(SwDoc *pDoc, const OUString &rName, sal_uInt16 nType=nsSwGetSetExpType::GSE_EXPR)
Definition: expfld.cxx:511
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:522
OUString m_sName
Definition: expfld.hxx:149
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:832
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
pool item to which the SwSetExpField belongs
Definition: expfld.cxx:837
virtual void SetValue(const double &rVal) override
Definition: expfld.cxx:903
OUString msExpandRLHidden
hidden redlines
Definition: expfld.hxx:207
SwSetExpField(SwSetExpFieldType *, const OUString &rFormel, sal_uLong nFormat=0)
Definition: expfld.cxx:810
virtual OUString GetPar1() const override
Query name only.
Definition: expfld.cxx:1025
SwFormatField * mpFormatField
Definition: expfld.hxx:212
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:1052
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:898
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:542
virtual OUString GetPar2() const override
Query formula.
Definition: expfld.cxx:1030
void SetInputFlag(bool bInp)
Definition: expfld.hxx:265
sal_uInt16 mnSeqNo
Definition: expfld.hxx:210
sal_uInt16 GetSeqNumber() const
Definition: expfld.hxx:247
sal_uInt16 mnSubType
Definition: expfld.hxx:211
virtual void SetSubType(sal_uInt16 nType) override
Definition: expfld.cxx:890
virtual OUString GetFieldName() const override
Definition: expfld.cxx:851
OUString maPText
Definition: expfld.hxx:208
bool mbInput
Definition: expfld.hxx:209
bool IsSequenceField() const
Definition: expfld.hxx:271
double m_fValueRLHidden
SwValueField; hidden redlines.
Definition: expfld.hxx:205
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:1153
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:872
void SetSeqNumber(sal_uInt16 n)
Logical number, sequence fields.
Definition: expfld.hxx:246
OUString msExpand
Definition: expfld.hxx:206
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:1039
const OUString & GetExpStr(SwRootFrame const *pLayout) const
Definition: expfld.cxx:537
bool GetInputFlag() const
Definition: expfld.hxx:268
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:47
SwRowFrame * GetFirstNonHeadlineRow() const
Definition: tabfrm.cxx:5790
const SwTable * GetTable() const
Definition: tabfrm.hxx:158
bool IsInHeadline(const SwFrame &rFrame) const
Definition: tabfrm.cxx:5771
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:196
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:70
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:163
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1249
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1296
void UnlockNotifyContentChange()
Definition: atrfld.cxx:657
bool LockNotifyContentChange()
Definition: atrfld.cxx:647
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:84
bool GetParaAttr(SfxItemSet &rSet, sal_Int32 nStt, sal_Int32 nEnd, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true, const bool bMergeIndentValuesOfNumRule=false, SwRootFrame const *pLayout=nullptr) const
Query the attributes of textnode over the range.
Definition: thints.cxx:2110
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
Definition: ndtxt.cxx:3412
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Definition: ndtxt.cxx:3994
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2833
const OUString & GetText() const
Definition: ndtxt.hxx:220
The shared part of a user field.
Definition: usrfld.hxx:35
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:294
OUString GetContent(sal_uInt32 nFormat=0)
Definition: usrfld.cxx:278
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:415
SwDoc * GetDoc() const
Definition: fldbas.hxx:425
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:435
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: fldbas.cxx:703
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
Definition: fldbas.hxx:466
virtual double GetValue() const
Definition: fldbas.cxx:745
virtual void SetValue(const double &rVal)
Definition: fldbas.cxx:750
static OUString LocalizeFormula(const SwSetExpField &rField, const OUString &rFormula, bool bQuery)
Definition: unofield.cxx:1017
static void TransmuteLeadToInputField(SwSetExpField &rField)
Convert between SwSetExpField with InputFlag false and InputFlag true.
Definition: unofield.cxx:1260
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
virtual OUString GetName() const override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
OUString LookString(SwHashTable< HashStr > const &rTable, const OUString &rName)
Look up the Name, if it is present, return its String, otherwise return an empty String.
Definition: docfld.cxx:375
OUString m_sName
static SwTextNode * GetFirstTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwContentFrame *pCFrame, Point &rPt)
Definition: expfld.cxx:135
static sal_Int32 lcl_APIToSubType(const uno::Any &rAny)
Definition: expfld.cxx:86
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
Definition: expfld.cxx:163
static sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType)
Definition: expfld.cxx:65
OUString ReplacePoint(const OUString &rTmpName, bool bWithCommandType)
Definition: expfld.cxx:104
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
expand numbering
Definition: fldbas.cxx:516
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:94
@ INP_USR
Definition: fldbas.hxx:219
@ INP_TXT
Definition: fldbas.hxx:218
SwFieldIds
Definition: fldbas.hxx:45
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SwDocPosUpdate > RES_DOCPOS_UPDATE(169)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:193
CharClass & GetAppCharClass()
Definition: init.cxx:705
CollatorWrapper & GetAppCaseCollator()
Definition: init.cxx:749
CollatorWrapper & GetAppCollator()
Definition: init.cxx:737
sal_Int32 nIndex
sal_Int64 n
#define LANGUAGE_SYSTEM
sal_uInt16 nPos
aStr
aBuf
def Input(s)
int i
const SwExtendedSubType SUB_CMD
Show command.
Definition: fldbas.hxx:212
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:213
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:205
const SwGetSetExpType GSE_EXPR
Expression.
Definition: fldbas.hxx:204
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:206
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:203
static constexpr auto Items
const SvxPageUsage aArr[]
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
QPRO_FUNC_TYPE nType
sal_uIntPtr sal_uLong
OUString sDlgEntry
Definition: expfld.hxx:51
Marks a position in the document model.
Definition: pam.hxx:37
SwNodeIndex nNode
Definition: pam.hxx:38
SwIndex nContent
Definition: pam.hxx:39
SvxNumType
SVX_NUM_ARABIC
#define DB_DELIM
Definition: swtypes.hxx:130
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
sal_uInt16 sal_Unicode
signed char sal_Int8
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
#define FIELD_PROP_GRABBAG
Definition: unofldmid.h:44
#define FIELD_PROP_PAR3
Definition: unofldmid.h:25
#define FIELD_PROP_BOOL2
Definition: unofldmid.h:29
#define FIELD_PROP_SUBTYPE
Definition: unofldmid.h:27
#define FIELD_PROP_USHORT1
Definition: unofldmid.h:31
#define FIELD_PROP_USHORT2
Definition: unofldmid.h:32
#define FIELD_PROP_FORMAT
Definition: unofldmid.h:26
#define FIELD_PROP_DOUBLE
Definition: unofldmid.h:34
#define FIELD_PROP_TITLE
Definition: unofldmid.h:50
#define FIELD_PROP_BOOL3
Definition: unofldmid.h:35
#define FIELD_PROP_SHORT1
Definition: unofldmid.h:37
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
#define FIELD_PROP_PAR4
Definition: unofldmid.h:36
#define FIELD_PROP_PAR2
Definition: unofldmid.h:24