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#include <utility>
62
63using namespace ::com::sun::star;
64using namespace ::com::sun::star::text;
65
66static sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType)
67{
68 sal_Int16 nRet = 0;
69 switch(nSubType)
70 {
72 nRet = SetVariableType::VAR; // 0
73 break;
75 nRet = SetVariableType::SEQUENCE; // 1
76 break;
78 nRet = SetVariableType::FORMULA; // 2
79 break;
81 nRet = SetVariableType::STRING; // 3
82 break;
83 }
84 return nRet;
85}
86
87static sal_Int32 lcl_APIToSubType(const uno::Any& rAny)
88{
89 sal_Int16 nVal = 0;
90 rAny >>= nVal;
91 sal_Int32 nSet = 0;
92 switch(nVal)
93 {
94 case SetVariableType::VAR: nSet = nsSwGetSetExpType::GSE_EXPR; break;
95 case SetVariableType::SEQUENCE: nSet = nsSwGetSetExpType::GSE_SEQ; break;
96 case SetVariableType::FORMULA: nSet = nsSwGetSetExpType::GSE_FORMULA; break;
97 case SetVariableType::STRING: nSet = nsSwGetSetExpType::GSE_STRING; break;
98 default:
99 OSL_FAIL("wrong value");
100 nSet = -1;
101 }
102 return nSet;
103}
104
105OUString ReplacePoint( const OUString& rTmpName, bool bWithCommandType )
106{
107 // replace first and last (if bWithCommandType: last two) dot
108 // since table names may contain dots
109
110 sal_Int32 nIndex = rTmpName.lastIndexOf('.');
111 if (nIndex<0)
112 {
113 return rTmpName;
114 }
115
116 OUString sRes = rTmpName.replaceAt(nIndex, 1, rtl::OUStringChar(DB_DELIM));
117
118 if (bWithCommandType)
119 {
120 nIndex = sRes.lastIndexOf('.', nIndex);
121 if (nIndex<0)
122 {
123 return sRes;
124 }
125 sRes = sRes.replaceAt(nIndex, 1, rtl::OUStringChar(DB_DELIM));
126 }
127
128 nIndex = sRes.indexOf('.');
129 if (nIndex>=0)
130 {
131 sRes = sRes.replaceAt(nIndex, 1, rtl::OUStringChar(DB_DELIM));
132 }
133 return sRes;
134}
135
136static SwTextNode* GetFirstTextNode( const SwDoc& rDoc, SwPosition& rPos,
137 const SwContentFrame *pCFrame, Point &rPt )
138{
139 SwTextNode* pTextNode = nullptr;
140 if ( !pCFrame )
141 {
142 const SwNodes& rNodes = rDoc.GetNodes();
143 rPos.Assign( *rNodes.GetEndOfContent().StartOfSectionNode() );
144 SwContentNode* pCNd;
145 while( nullptr != (pCNd = rNodes.GoNext( &rPos ) ) &&
146 nullptr == ( pTextNode = pCNd->GetTextNode() ) )
147 ;
148 OSL_ENSURE( pTextNode, "Where is the 1. TextNode?" );
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.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.GetNode().GetTextNode();
192 if ( RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() )
193 {
194 rPos.AssignStartIndex(*pTextNode);
195 }
196
197 // do not break yet, might be as well in Header/Footer/Footnote/Fly
198 pLayout = static_cast<const SwFlyFrame*>(pLayout)->GetAnchorFrame()
199 ? static_cast<const SwFlyFrame*>(pLayout)->GetAnchorFrame()->GetUpper() : nullptr;
200 continue;
201 }
202 else
203 {
205 pLayout->getFrameArea().Pos(), rPos );
206 pTextNode = rPos.GetNode().GetTextNode();
207 }
208 }
209 else if( pLayout->IsFootnoteFrame() )
210 {
211 // get the anchor's node
212 const SwTextFootnote* pFootnote = static_cast<const SwFootnoteFrame*>(pLayout)->GetAttr();
213 pTextNode = &pFootnote->GetTextNode();
214 rPos.Assign( *pTextNode, pFootnote->GetStart() );
215 }
216 else if( pLayout->IsHeaderFrame() || pLayout->IsFooterFrame() )
217 {
218 const SwContentFrame* pContentFrame;
219 const SwPageFrame* pPgFrame = pLayout->FindPageFrame();
220 if( pLayout->IsHeaderFrame() )
221 {
222 const SwTabFrame *pTab;
223 if( nullptr != ( pContentFrame = pPgFrame->FindFirstBodyContent()) &&
224 nullptr != (pTab = pContentFrame->FindTabFrame()) && pTab->IsFollow() &&
225 pTab->GetTable()->GetRowsToRepeat() > 0 &&
226 pTab->IsInHeadline( *pContentFrame ) )
227 {
228 // take the next line
229 const SwLayoutFrame* pRow = pTab->GetFirstNonHeadlineRow();
230 pContentFrame = pRow->ContainsContent();
231 }
232 }
233 else
234 pContentFrame = pPgFrame->FindLastBodyContent();
235
236 if( pContentFrame )
237 {
238 assert(pContentFrame->IsTextFrame());
239 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(pContentFrame));
240 rPos = pFrame->MapViewToModelPos(TextFrameIndex(pFrame->GetText().getLength()));
241 pTextNode = rPos.GetNode().GetTextNode();
242 assert(pTextNode);
243 }
244 else
245 {
246 Point aPt( pLayout->getFrameArea().Pos() );
247 aPt.AdjustY( 1 ); // get out of the header
248 pContentFrame = pPgFrame->GetContentPos( aPt, false, true );
249 pTextNode = GetFirstTextNode( rDoc, rPos, pContentFrame, aPt );
250 }
251 }
252 else
253 {
254 pLayout = pLayout->GetUpper();
255 continue;
256 }
257 break; // found, so finish loop
258 }
259 return pTextNode;
260}
261
264{
265}
266
267std::unique_ptr<SwFieldType> SwGetExpFieldType::Copy() const
268{
269 return std::make_unique<SwGetExpFieldType>(GetDoc());
270}
271
273{
274 if (rHint.GetId() != SfxHintId::SwLegacyModify)
275 return;
276 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
277 // do not expand anything else
278 if(pLegacy->GetWhich() != RES_DOCPOS_UPDATE)
279 return;
280 CallSwClientNotify(rHint);
281}
282
283SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const OUString& rFormel,
284 sal_uInt16 nSub, sal_uLong nFormat)
285 : SwFormulaField( pTyp, nFormat, 0.0 )
286 , m_fValueRLHidden(0.0)
287 ,
288 m_bIsInBodyText( true ),
289 m_nSubType(nSub),
290 m_bLateInitialization( false )
291{
292 SetFormula( rFormel );
293}
294
295void SwGetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const pLayout)
296{
297 if (!pLayout || pLayout->IsHideRedlines())
298 {
299 m_sExpandRLHidden = rExpand;
300 }
301 if (!pLayout || !pLayout->IsHideRedlines())
302 {
303 m_sExpand = rExpand;
304 }
305}
306
307OUString SwGetExpField::ExpandImpl(SwRootFrame const*const pLayout) const
308{
310 return GetFormula();
311
312 return (pLayout && pLayout->IsHideRedlines()) ? m_sExpandRLHidden : m_sExpand;
313}
314
316{
317 const SwFieldTypesEnum nType =
321
322 return SwFieldType::GetTypeStr(nType) + " " + GetFormula();
323}
324
325std::unique_ptr<SwField> SwGetExpField::Copy() const
326{
327 std::unique_ptr<SwGetExpField> pTmp(new SwGetExpField(static_cast<SwGetExpFieldType*>(GetTyp()),
329 pTmp->SetLanguage(GetLanguage());
330 pTmp->m_fValueRLHidden = m_fValueRLHidden;
331 pTmp->SwValueField::SetValue(GetValue());
332 pTmp->m_sExpand = m_sExpand;
333 pTmp->m_sExpandRLHidden = m_sExpandRLHidden;
334 pTmp->m_bIsInBodyText = m_bIsInBodyText;
335 pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
337 pTmp->SetLateInitialization();
338
339 return std::unique_ptr<SwField>(pTmp.release());
340}
341
342void SwGetExpField::ChangeExpansion( const SwFrame& rFrame, const SwTextField& rField )
343{
344 if( m_bIsInBodyText ) // only fields in Footer, Header, FootNote, Flys
345 return;
346
347 OSL_ENSURE( !rFrame.IsInDocBody(), "Flag incorrect, frame is in DocBody" );
348
349 // determine document (or is there an easier way?)
350 const SwTextNode* pTextNode = &rField.GetTextNode();
351 SwDoc& rDoc = const_cast<SwDoc&>(pTextNode->GetDoc());
352
353 // create index for determination of the TextNode
354 SwPosition aPos( rDoc.GetNodes() );
355 pTextNode = GetBodyTextNode( rDoc, aPos, rFrame );
356
357 // If no layout exists, ChangeExpansion is called for header and
358 // footer lines via layout formatting without existing TextNode.
359 if(!pTextNode)
360 return;
361 // #i82544#
363 {
365 if( pSetExpField )
366 {
367 m_bLateInitialization = false;
369 static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING )
371 }
372 }
373
374 SwRootFrame const& rLayout(*rFrame.getRootFrame());
375 OUString & rExpand(rLayout.IsHideRedlines() ? m_sExpandRLHidden : m_sExpand);
376 // here a page number is needed to sort correctly
377 SetGetExpField aEndField(aPos.GetNode(), &rField, aPos.GetContentIndex(), rFrame.GetPhyPageNum());
379 {
380 SwHashTable<HashStr> aHashTable(0);
381 rDoc.getIDocumentFieldsAccess().FieldsToExpand(aHashTable, aEndField, rLayout);
382 rExpand = LookString( aHashTable, GetFormula() );
383 }
384 else
385 {
386 // fill calculator with values
387 SwCalc aCalc( rDoc );
388 rDoc.getIDocumentFieldsAccess().FieldsToCalc(aCalc, aEndField, &rLayout);
389
390 // calculate value
391 SetValue(aCalc.Calculate(GetFormula()).GetDouble(), &rLayout);
392
393 // analyse based on format
394 rExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue(
395 GetValue(&rLayout), GetFormat(), GetLanguage());
396 }
397}
398
400{
401 return GetFormula();
402}
403
404void SwGetExpField::SetPar2(const OUString& rStr)
405{
406 SetFormula(rStr);
407}
408
410{
411 return m_nSubType;
412}
413
414void SwGetExpField::SetSubType(sal_uInt16 nType)
415{
417}
418
420{
423 else
425}
426
427bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
428{
429 switch( nWhichId )
430 {
432 rAny <<= GetValue();
433 break;
435 rAny <<= static_cast<sal_Int32>(GetFormat());
436 break;
438 rAny <<= static_cast<sal_Int16>(m_nSubType);
439 break;
440 case FIELD_PROP_PAR1:
441 rAny <<= GetFormula();
442 break;
444 {
445 sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
446 rAny <<= nRet;
447 }
448 break;
449 case FIELD_PROP_BOOL2:
451 break;
452 case FIELD_PROP_PAR4:
453 rAny <<= m_sExpand;
454 break;
455 default:
456 return SwField::QueryValue(rAny, nWhichId);
457 }
458 return true;
459}
460
461bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
462{
463 sal_Int32 nTmp = 0;
464 switch( nWhichId )
465 {
467 SwValueField::SetValue(*o3tl::doAccess<double>(rAny));
468 m_fValueRLHidden = *o3tl::doAccess<double>(rAny);
469 break;
471 rAny >>= nTmp;
472 SetFormat(nTmp);
473 break;
475 rAny >>= nTmp;
476 m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp);
477 break;
478 case FIELD_PROP_PAR1:
479 {
480 OUString sTmp;
481 rAny >>= sTmp;
482 SetFormula(sTmp);
483 break;
484 }
486 nTmp = lcl_APIToSubType(rAny);
487 if( nTmp >=0 )
488 SetSubType( o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
489 break;
490 case FIELD_PROP_BOOL2:
491 if(*o3tl::doAccess<bool>(rAny))
493 else
495 break;
496 case FIELD_PROP_PAR4:
497 {
498 OUString sTmp;
499 rAny >>= sTmp;
500 ChgExpStr(sTmp, nullptr);
501 break;
502 }
503 default:
504 return SwField::PutValue(rAny, nWhichId);
505 }
506 return true;
507}
508
509SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, OUString aName, sal_uInt16 nTyp )
511 m_sName( std::move(aName) ),
512 m_sDelim( "." ),
513 m_nType(nTyp), m_nLevel( UCHAR_MAX ),
514 m_bDeleted( false )
515{
517 EnableFormat(false); // do not use Numberformatter
518}
519
520std::unique_ptr<SwFieldType> SwSetExpFieldType::Copy() const
521{
522 std::unique_ptr<SwSetExpFieldType> pNew(new SwSetExpFieldType(GetDoc(), m_sName, m_nType));
523 pNew->m_bDeleted = m_bDeleted;
524 pNew->m_sDelim = m_sDelim;
525 pNew->m_nLevel = m_nLevel;
526
527 return pNew;
528}
529
531{
532 return m_sName;
533}
534
535const OUString& SwSetExpField::GetExpStr(SwRootFrame const*const pLayout) const
536{
537 return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand;
538}
539
540void SwSetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const pLayout)
541{
542 if (!pLayout || pLayout->IsHideRedlines())
543 {
544 msExpandRLHidden = rExpand;
545 }
546 if (!pLayout || !pLayout->IsHideRedlines())
547 {
548 msExpand = rExpand;
549 }
550}
551
553{
554 // do not expand further
555}
556
558{
559 std::vector<SwFormatField*> vFields;
560 GatherFields(vFields, false);
561 for(auto pFormatField: vFields)
562 pFormatField->GetField()->ChangeFormat(nFormat);
563}
564
566{
567 if( !HasWriterListeners() )
568 return SVX_NUM_ARABIC;
569
570 std::vector<SwFormatField*> vFields;
571 GatherFields(vFields, false);
572 return vFields.front()->GetField()->GetFormat();
573}
574
576{
577 if( !HasWriterListeners() || !(nsSwGetSetExpType::GSE_SEQ & m_nType) )
578 return;
579
580 std::vector<sal_uInt16> aArr;
581
582 // check if number is already used and if a new one needs to be created
583 std::vector<SwFormatField*> vFields;
584 GatherFields(vFields);
585 for(SwFormatField* pF: vFields)
586 if(pF->GetField() != &rField)
587 InsertSort(aArr, static_cast<SwSetExpField*>(pF->GetField())->GetSeqNumber());
588
589 // check first if number already exists
590 sal_uInt16 nNum = rField.GetSeqNumber();
591 if( USHRT_MAX != nNum )
592 {
593 std::vector<sal_uInt16>::size_type n {0};
594
595 for( n = 0; n < aArr.size(); ++n )
596 if( aArr[ n ] >= nNum )
597 break;
598
599 if( n == aArr.size() || aArr[ n ] > nNum )
600 return; // no -> use it
601 }
602
603 // flagged all numbers, so determine the right number
604 std::vector<sal_uInt16>::size_type n = aArr.size();
605 OSL_ENSURE( n <= std::numeric_limits<sal_uInt16>::max(), "Array is too big for using a sal_uInt16 index" );
606
607 if ( n > 0 && aArr[ n-1 ] != n-1 )
608 {
609 for( n = 0; n < aArr.size(); ++n )
610 if( n != aArr[ n ] )
611 break;
612 }
613
614 rField.SetSeqNumber( n );
615}
616
618 SwRootFrame const*const pLayout)
619{
620 rList.Clear();
621
622 IDocumentRedlineAccess const& rIDRA(GetDoc()->getIDocumentRedlineAccess());
623
624 std::vector<SwFormatField*> vFields;
625 GatherFields(vFields);
626 for(SwFormatField* pF: vFields)
627 {
628 const SwTextNode* pNd;
629 if( nullptr != ( pNd = pF->GetTextField()->GetpTextNode() )
630 && (!pLayout || !pLayout->IsHideRedlines()
631 || !sw::IsFieldDeletedInModel(rIDRA, *pF->GetTextField())))
632 {
633 SeqFieldLstElem aNew(
634 pNd->GetExpandText(pLayout),
635 static_cast<SwSetExpField*>(pF->GetField())->GetSeqNumber() );
636 rList.InsertSort( std::move(aNew) );
637 }
638 }
639 return rList.Count();
640}
641
643 SwRootFrame const*const pLayout)
644{
645 const SwTextNode* pTextNd = rNd.FindOutlineNodeOfLevel(m_nLevel, pLayout);
646 if( !pTextNd )
647 return;
648
649 SwNumRule * pRule = pTextNd->GetNumRule();
650
651 if (!pRule)
652 return;
653
654 // --> OD 2005-11-02 #i51089 - TUNING#
655 if (SwNodeNum const*const pNum = pTextNd->GetNum(pLayout))
656 {
657 // only get the number, without pre-/post-fixstrings
658 OUString const sNumber(pRule->MakeNumString(*pNum, false));
659
660 if( !sNumber.isEmpty() )
661 rField.ChgExpStr(sNumber + m_sDelim + rField.GetExpStr(pLayout), pLayout);
662 }
663 else
664 {
665 OSL_ENSURE(pTextNd->GetNum(nullptr), "<SwSetExpFieldType::SetChapter(..)> - text node with numbering rule, but without number. This is a serious defect");
666 }
667}
668
669void SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
670{
671 switch( nWhichId )
672 {
674 {
675 sal_Int16 nRet = lcl_SubTypeToAPI(GetType());
676 rAny <<= nRet;
677 }
678 break;
679 case FIELD_PROP_PAR2:
680 rAny <<= GetDelimiter();
681 break;
683 {
684 sal_Int8 nRet = m_nLevel < MAXLEVEL? m_nLevel : -1;
685 rAny <<= nRet;
686 }
687 break;
688 default:
689 assert(false);
690 }
691}
692
693void SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
694{
695 switch( nWhichId )
696 {
698 {
699 sal_Int32 nSet = lcl_APIToSubType(rAny);
700 if(nSet >=0)
701 SetType(o3tl::narrowing<sal_uInt16>(nSet));
702 }
703 break;
704 case FIELD_PROP_PAR2:
705 {
706 OUString sTmp;
707 rAny >>= sTmp;
708 if( !sTmp.isEmpty() )
709 SetDelimiter( sTmp );
710 else
711 SetDelimiter( " " );
712 }
713 break;
715 {
716 sal_Int8 nLvl = 0;
717 rAny >>= nLvl;
718 if(nLvl < 0 || nLvl >= MAXLEVEL)
719 SetOutlineLvl(UCHAR_MAX);
720 else
721 SetOutlineLvl(nLvl);
722 }
723 break;
724 default:
725 assert(false);
726 }
727}
728
730{
731 OUStringBuffer aBuf(aNew.sDlgEntry);
732 const sal_Int32 nLen = aBuf.getLength();
733 for (sal_Int32 i = 0; i < nLen; ++i)
734 {
735 if (aBuf[i]<' ')
736 {
737 aBuf[i]=' ';
738 }
739 }
740 aNew.sDlgEntry = aBuf.makeStringAndClear();
741
742 size_t nPos = 0;
743 bool bRet = SeekEntry( aNew, &nPos );
744 if( !bRet )
745 maData.insert( maData.begin() + nPos, aNew );
746 return bRet;
747}
748
749bool SwSeqFieldList::SeekEntry( const SeqFieldLstElem& rNew, size_t* pP ) const
750{
751 size_t nO = maData.size();
752 size_t nU = 0;
753 if( nO > 0 )
754 {
756 & rColl = ::GetAppCollator();
757 const CharClass& rCC = GetAppCharClass();
758
759 //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1")
760 const OUString rTmp2 = rNew.sDlgEntry;
761 sal_Int32 nFndPos2 = 0;
762 const OUString sNum2( rTmp2.getToken( 0, ' ', nFndPos2 ));
763 bool bIsNum2IsNumeric = CharClass::isAsciiNumeric( sNum2 );
764 sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.toInt32() : 0;
765
766 nO--;
767 while( nU <= nO )
768 {
769 const size_t nM = nU + ( nO - nU ) / 2;
770
771 //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1")
772 const OUString rTmp1 = maData[nM].sDlgEntry;
773 sal_Int32 nFndPos1 = 0;
774 const OUString sNum1( rTmp1.getToken( 0, ' ', nFndPos1 ));
775 sal_Int32 nCmp;
776
777 if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) )
778 {
779 sal_Int32 nNum1 = sNum1.toInt32();
780 nCmp = nNum2 - nNum1;
781 if( 0 == nCmp )
782 {
783 OUString aTmp1 = nFndPos1 != -1 ? rTmp1.copy(nFndPos1) : OUString();
784 OUString aTmp2 = nFndPos2 != -1 ? rTmp2.copy(nFndPos2) : OUString();
785 nCmp = rCaseColl.compareString(aTmp2, aTmp1);
786 }
787 }
788 else
789 nCmp = rColl.compareString( rTmp2, rTmp1 );
790
791 if( 0 == nCmp )
792 {
793 if( pP ) *pP = nM;
794 return true;
795 }
796 else if( 0 < nCmp )
797 nU = nM + 1;
798 else if( nM == 0 )
799 break;
800 else
801 nO = nM - 1;
802 }
803 }
804 if( pP ) *pP = nU;
805 return false;
806}
807
808SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const OUString& rFormel,
809 sal_uLong nFormat)
810 : SwFormulaField( pTyp, nFormat, 0.0 )
811 , m_fValueRLHidden(0.0)
812 , mnSeqNo( USHRT_MAX )
813 , mnSubType(0)
814 , mpFormatField(nullptr)
815{
816 SetFormula(rFormel);
817 // ignore SubType
818 mbInput = false;
819 if( IsSequenceField() )
820 {
822 m_fValueRLHidden = 1.0;
823 if( rFormel.isEmpty() )
824 {
825 SetFormula(pTyp->GetName() + "+1");
826 }
827 }
828}
829
831{
832 mpFormatField = &rFormatField;
833}
834
835OUString SwSetExpField::ExpandImpl(SwRootFrame const*const pLayout) const
836{
838 { // we need the CommandString
839 return GetTyp()->GetName() + " = " + GetFormula();
840 }
842 { // value is visible
843 return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand;
844 }
845 return OUString();
846}
847
850{
851 SwFieldTypesEnum const nStrType( (IsSequenceField())
853 : mbInput
856
857 OUString aStr(
858 SwFieldType::GetTypeStr( nStrType )
859 + " "
860 + GetTyp()->GetName() );
861
862 // Sequence: without formula
863 if (SwFieldTypesEnum::Sequence != nStrType)
864 {
865 aStr += " = " + GetFormula();
866 }
867 return aStr;
868}
869
870std::unique_ptr<SwField> SwSetExpField::Copy() const
871{
872 std::unique_ptr<SwSetExpField> pTmp(new SwSetExpField(static_cast<SwSetExpFieldType*>(GetTyp()),
873 GetFormula(), GetFormat()));
874 pTmp->SwValueField::SetValue(GetValue());
875 pTmp->m_fValueRLHidden = m_fValueRLHidden;
876 pTmp->msExpand = msExpand;
877 pTmp->msExpandRLHidden = msExpandRLHidden;
878 pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
879 pTmp->SetLanguage(GetLanguage());
880 pTmp->maPText = maPText;
881 pTmp->mbInput = mbInput;
882 pTmp->mnSeqNo = mnSeqNo;
883 pTmp->SetSubType(GetSubType());
884
885 return std::unique_ptr<SwField>(pTmp.release());
886}
887
888void SwSetExpField::SetSubType(sal_uInt16 nSub)
889{
890 static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & 0xff);
891 mnSubType = nSub & 0xff00;
892
893 OSL_ENSURE( (nSub & 0xff) != 3, "SubType is illegal!" );
894}
895
897{
898 return static_cast<SwSetExpFieldType*>(GetTyp())->GetType() | mnSubType;
899}
900
901void SwSetExpField::SetValue( const double& rAny )
902{
904
905 if( IsSequenceField() )
907 else
908 msExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue( rAny,
910}
911
912void SwSetExpField::SetValue(const double& rValue, SwRootFrame const*const pLayout)
913{
914 if (!pLayout || !pLayout->IsHideRedlines())
915 {
916 SetValue(rValue);
917 }
918 if (pLayout && !pLayout->IsHideRedlines())
919 return;
920
921 m_fValueRLHidden = rValue;
922 if (IsSequenceField())
923 {
924 msExpandRLHidden = FormatNumber(rValue, static_cast<SvxNumType>(GetFormat()), GetLanguage());
925 }
926 else
927 {
929 rValue, GetFormat(), GetLanguage());
930 }
931}
932
933double SwSetExpField::GetValue(SwRootFrame const* pLayout) const
934{
935 return (pLayout && pLayout->IsHideRedlines()) ? m_fValueRLHidden : GetValue();
936}
937
938void SwGetExpField::SetValue( const double& rAny )
939{
941 m_sExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue( rAny, GetFormat(),
942 GetLanguage());
943}
944
945void SwGetExpField::SetValue(const double& rValue, SwRootFrame const*const pLayout)
946{
947 if (!pLayout || !pLayout->IsHideRedlines())
948 {
949 SetValue(rValue);
950 }
951 if (!pLayout || pLayout->IsHideRedlines())
952 {
953 m_fValueRLHidden = rValue;
955 rValue, GetFormat(), GetLanguage());
956 }
957}
958
959double SwGetExpField::GetValue(SwRootFrame const* pLayout) const
960{
961 return (pLayout && pLayout->IsHideRedlines()) ? m_fValueRLHidden : GetValue();
962}
963
971sal_Int32 SwGetExpField::GetReferenceTextPos( const SwFormatField& rFormat, SwDoc& rDoc, sal_Int32 nHint)
972{
973
974 const SwTextField* pTextField = rFormat.GetTextField();
975 const SwTextNode& rTextNode = pTextField->GetTextNode();
976
977 sal_Int32 nRet = nHint ? nHint : pTextField->GetStart() + 1;
978 OUString sNodeText = rTextNode.GetText();
979
980 if(nRet<sNodeText.getLength())
981 {
982 sNodeText = sNodeText.copy(nRet);
983
984 // now check if sNodeText starts with a non-alphanumeric character plus blanks
985 sal_uInt16 nSrcpt = g_pBreakIt->GetRealScriptOfText( sNodeText, 0 );
986
987 static const WhichRangesContainer nIds(svl::Items<
994 >);
995 SwAttrSet aSet(rDoc.GetAttrPool(), nIds);
996 rTextNode.GetParaAttr(aSet, nRet, nRet+1);
997
999 if( RTL_TEXTENCODING_SYMBOL != aSet.Get( nFontWhich ).GetCharSet() )
1000 {
1002 LanguageType eLang = aSet.Get(nLangWhich).GetLanguage();
1003 CharClass aCC(( LanguageTag(eLang) ));
1004 sal_Unicode c0 = sNodeText[0];
1005 bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 );
1006 if( !bIsAlphaNum ||
1007 (c0 == ' ' || c0 == '\t'))
1008 {
1009 // ignoring blanks
1010 nRet++;
1011 const sal_Int32 nLen = sNodeText.getLength();
1012 for (sal_Int32 i = 1;
1013 i<nLen && (sNodeText[i]==' ' || sNodeText[i]=='\t');
1014 ++i
1015 )
1016 ++nRet;
1017 }
1018 }
1019 }
1020 return nRet;
1021}
1022
1024{
1025 return static_cast<const SwSetExpFieldType*>(GetTyp())->GetName();
1026}
1027
1029{
1030 sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType();
1031
1033 return GetFormula();
1034 return GetExpandedFormula();
1035}
1036
1037void SwSetExpField::SetPar2(const OUString& rStr)
1038{
1039 sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType();
1040
1041 if( !(nType & nsSwGetSetExpType::GSE_SEQ) || !rStr.isEmpty() )
1042 {
1044 SetFormula(rStr);
1045 else
1046 SetExpandedFormula(rStr);
1047 }
1048}
1049
1050bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1051{
1052 sal_Int32 nTmp32 = 0;
1053 sal_Int16 nTmp16 = 0;
1054 switch( nWhichId )
1055 {
1056 case FIELD_PROP_BOOL2:
1057 if(*o3tl::doAccess<bool>(rAny))
1059 else
1061 break;
1062 case FIELD_PROP_FORMAT:
1063 rAny >>= nTmp32;
1064 SetFormat(nTmp32);
1065 break;
1066 case FIELD_PROP_USHORT2:
1067 {
1068 rAny >>= nTmp16;
1069 if(nTmp16 <= css::style::NumberingType::NUMBER_NONE )
1070 SetFormat(nTmp16);
1071 else {
1072 //exception(wrong_value)
1073 ;
1074 }
1075 }
1076 break;
1077 case FIELD_PROP_USHORT1:
1078 rAny >>= nTmp16;
1079 mnSeqNo = nTmp16;
1080 break;
1081 case FIELD_PROP_PAR1:
1082 {
1083 OUString sTmp;
1084 rAny >>= sTmp;
1086 }
1087 break;
1088 case FIELD_PROP_PAR2:
1089 {
1090 OUString uTmp;
1091 rAny >>= uTmp;
1092 //I18N - if the formula contains only "TypeName+1"
1093 //and it's one of the initially created sequence fields
1094 //then the localized names has to be replaced by a programmatic name
1095 OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, false);
1096 SetFormula( sMyFormula );
1097 }
1098 break;
1099 case FIELD_PROP_DOUBLE:
1100 {
1101 double fVal = 0.0;
1102 rAny >>= fVal;
1103 SetValue(fVal);
1104 m_fValueRLHidden = fVal;
1105 }
1106 break;
1107 case FIELD_PROP_SUBTYPE:
1108 nTmp32 = lcl_APIToSubType(rAny);
1109 if(nTmp32 >= 0)
1110 SetSubType(o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
1111 break;
1112 case FIELD_PROP_PAR3:
1113 rAny >>= maPText;
1114 break;
1115 case FIELD_PROP_BOOL3:
1116 if(*o3tl::doAccess<bool>(rAny))
1118 else
1120 break;
1121 case FIELD_PROP_BOOL1:
1122 {
1123 bool newInput(*o3tl::doAccess<bool>(rAny));
1124 if (newInput != GetInputFlag())
1125 {
1126 if (static_cast<SwSetExpFieldType*>(GetTyp())->GetType()
1128 {
1130 }
1131 else
1132 {
1133 SetInputFlag(newInput);
1134 }
1135 }
1136 }
1137 break;
1138 case FIELD_PROP_PAR4:
1139 {
1140 OUString sTmp;
1141 rAny >>= sTmp;
1142 ChgExpStr(sTmp, nullptr);
1143 }
1144 break;
1145 default:
1146 return SwField::PutValue(rAny, nWhichId);
1147 }
1148 return true;
1149}
1150
1151bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1152{
1153 switch( nWhichId )
1154 {
1155 case FIELD_PROP_BOOL2:
1157 break;
1158 case FIELD_PROP_FORMAT:
1159 rAny <<= static_cast<sal_Int32>(GetFormat());
1160 break;
1161 case FIELD_PROP_USHORT2:
1162 rAny <<= static_cast<sal_Int16>(GetFormat());
1163 break;
1164 case FIELD_PROP_USHORT1:
1165 rAny <<= static_cast<sal_Int16>(mnSeqNo);
1166 break;
1167 case FIELD_PROP_PAR1:
1169 break;
1170 case FIELD_PROP_PAR2:
1171 {
1172 //I18N - if the formula contains only "TypeName+1"
1173 //and it's one of the initially created sequence fields
1174 //then the localized names has to be replaced by a programmatic name
1175 OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), true);
1176 rAny <<= sMyFormula;
1177 }
1178 break;
1179 case FIELD_PROP_DOUBLE:
1180 rAny <<= GetValue();
1181 break;
1182 case FIELD_PROP_SUBTYPE:
1183 {
1184 sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
1185 rAny <<= nRet;
1186 }
1187 break;
1188 case FIELD_PROP_PAR3:
1189 rAny <<= maPText;
1190 break;
1191 case FIELD_PROP_BOOL3:
1192 rAny <<= 0 != (mnSubType & nsSwExtendedSubType::SUB_CMD);
1193 break;
1194 case FIELD_PROP_BOOL1:
1195 rAny <<= GetInputFlag();
1196 break;
1197 case FIELD_PROP_PAR4:
1198 rAny <<= GetExpStr(nullptr);
1199 break;
1200 default:
1201 return SwField::QueryValue(rAny, nWhichId);
1202 }
1203 return true;
1204}
1205
1208 , mpDoc( pD )
1209{
1210}
1211
1212std::unique_ptr<SwFieldType> SwInputFieldType::Copy() const
1213{
1214 return std::make_unique<SwInputFieldType>( mpDoc );
1215}
1216
1218 OUString aContent,
1219 OUString aPrompt,
1220 sal_uInt16 nSub,
1221 sal_uLong nFormat,
1222 bool bIsFormField )
1223 : SwField( pFieldType, nFormat, LANGUAGE_SYSTEM, false )
1224 , maContent(std::move(aContent))
1225 , maPText(std::move(aPrompt))
1226 , mnSubType(nSub)
1227 , mbIsFormField( bIsFormField )
1228 , mpFormatField( nullptr )
1229{
1230}
1231
1233{
1234}
1235
1237{
1238 mpFormatField = &rFormatField;
1239}
1240
1241
1242void SwInputField::applyFieldContent( const OUString& rNewFieldContent )
1243{
1244 if ( (mnSubType & 0x00ff) == INP_TXT )
1245 {
1246 maContent = rNewFieldContent;
1247 }
1248 else if( (mnSubType & 0x00ff) == INP_USR )
1249 {
1250 SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
1251 static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::User, getContent(), false ) );
1252 if( pUserTyp )
1253 {
1254 pUserTyp->SetContent( rNewFieldContent );
1255 if (!pUserTyp->IsModifyLocked())
1256 {
1257 // trigger update of the corresponding User Fields and other
1258 // related Input Fields
1259 bool bUnlock(false);
1260 if (GetFormatField() != nullptr)
1261 {
1262 SwTextInputField *const pTextInputField =
1263 dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
1264 if (pTextInputField != nullptr)
1265 {
1266 bUnlock = pTextInputField->LockNotifyContentChange();
1267 }
1268 }
1269 pUserTyp->UpdateFields();
1270 if (bUnlock)
1271 {
1272 SwTextInputField *const pTextInputField =
1273 dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
1274 if (pTextInputField != nullptr)
1275 {
1276 pTextInputField->UnlockNotifyContentChange();
1277 }
1278 }
1279 }
1280 }
1281 }
1282}
1283
1285{
1286 OUString aStr(SwField::GetFieldName());
1287 if ((mnSubType & 0x00ff) == INP_USR)
1288 {
1289 aStr += GetTyp()->GetName() + " " + getContent();
1290 }
1291 return aStr;
1292}
1293
1294std::unique_ptr<SwField> SwInputField::Copy() const
1295{
1296 std::unique_ptr<SwInputField> pField(
1297 new SwInputField(
1298 static_cast<SwInputFieldType*>(GetTyp()),
1299 getContent(),
1300 maPText,
1301 GetSubType(),
1302 GetFormat(),
1303 mbIsFormField ));
1304
1305 pField->SetHelp( maHelp );
1306 pField->SetToolTip( maToolTip );
1307 pField->maGrabBag = maGrabBag;
1308
1309 pField->SetAutomaticLanguage(IsAutomaticLanguage());
1310 return std::unique_ptr<SwField>(pField.release());
1311}
1312
1313OUString SwInputField::ExpandImpl(SwRootFrame const*const) const
1314{
1315 if((mnSubType & 0x00ff) == INP_TXT)
1316 {
1317 return getContent();
1318 }
1319
1320 if( (mnSubType & 0x00ff) == INP_USR )
1321 {
1322 SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
1323 static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::User, getContent(), false ) );
1324 if( pUserTyp )
1325 return pUserTyp->GetContent();
1326 }
1327
1328 return OUString();
1329}
1330
1332{
1333 return mbIsFormField
1334 || !maHelp.isEmpty()
1335 || !maToolTip.isEmpty();
1336}
1337
1338bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1339{
1340 switch( nWhichId )
1341 {
1342 case FIELD_PROP_PAR1:
1343 rAny <<= getContent();
1344 break;
1345 case FIELD_PROP_PAR2:
1346 rAny <<= maPText;
1347 break;
1348 case FIELD_PROP_PAR3:
1349 rAny <<= maHelp;
1350 break;
1351 case FIELD_PROP_PAR4:
1352 rAny <<= maToolTip;
1353 break;
1354 case FIELD_PROP_GRABBAG:
1355 rAny <<= maGrabBag;
1356 break;
1357 case FIELD_PROP_TITLE:
1358 break;
1359 default:
1360 assert(false);
1361 }
1362 return true;
1363}
1364
1365bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1366{
1367 switch( nWhichId )
1368 {
1369 case FIELD_PROP_PAR1:
1370 rAny >>= maContent;
1371 break;
1372 case FIELD_PROP_PAR2:
1373 rAny >>= maPText;
1374 break;
1375 case FIELD_PROP_PAR3:
1376 rAny >>= maHelp;
1377 break;
1378 case FIELD_PROP_PAR4:
1379 rAny >>= maToolTip;
1380 break;
1381 case FIELD_PROP_GRABBAG:
1382 rAny >>= maGrabBag;
1383 break;
1384 case FIELD_PROP_TITLE:
1385 break;
1386 default:
1387 assert(false);
1388 }
1389 return true;
1390}
1391
1393void SwInputField::SetPar1(const OUString& rStr)
1394{
1395 maContent = rStr;
1396}
1397
1399{
1400 return getContent();
1401}
1402
1403void SwInputField::SetPar2(const OUString& rStr)
1404{
1405 maPText = rStr;
1406}
1407
1409{
1410 return maPText;
1411}
1412
1413void SwInputField::SetHelp(const OUString & rStr)
1414{
1415 maHelp = rStr;
1416}
1417
1418const OUString& SwInputField::GetHelp() const
1419{
1420 return maHelp;
1421}
1422
1423void SwInputField::SetToolTip(const OUString & rStr)
1424{
1425 maToolTip = rStr;
1426}
1427
1428const OUString& SwInputField::GetToolTip() const
1429{
1430 return maToolTip;
1431}
1432
1434{
1435 return mnSubType;
1436}
1437
1438void SwInputField::SetSubType(sal_uInt16 nSub)
1439{
1440 mnSubType = nSub;
1441}
1442
1443/* 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:3053
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:34
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:84
Definition: calc.hxx:199
SwSbxValue Calculate(const OUString &rStr)
Definition: calc.cxx:362
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
Definition: doc.hxx:194
SwNodes & GetNodes()
Definition: doc.hxx:417
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:363
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1326
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
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
FlyAnchors.
Definition: fmtanchr.hxx:37
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:74
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:148
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
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:62
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:1706
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:272
SwGetExpFieldType(SwDoc *pDoc)
Definition: expfld.cxx:262
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:267
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:295
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:325
virtual OUString GetPar2() const override
Change formula.
Definition: expfld.cxx:399
sal_uInt16 m_nSubType
Definition: expfld.hxx:92
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: expfld.cxx:307
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:427
SwGetExpField(SwGetExpFieldType *, const OUString &rFormel, sal_uInt16 nSubType, sal_uLong nFormat)
Definition: expfld.cxx:283
virtual void SetSubType(sal_uInt16 nType) override
Definition: expfld.cxx:414
void ChangeExpansion(const SwFrame &, const SwTextField &)
For fields in header/footer/footnotes/flys: Only called by formatting!!
Definition: expfld.cxx:342
OUString m_sExpandRLHidden
hidden redlines
Definition: expfld.hxx:90
bool m_bIsInBodyText
Definition: expfld.hxx:91
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:409
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:461
bool m_bLateInitialization
Definition: expfld.hxx:94
virtual OUString GetFieldName() const override
get name or content
Definition: expfld.cxx:315
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: expfld.cxx:419
OUString m_sExpand
Definition: expfld.hxx:89
double m_fValueRLHidden
SwValueField; hidden redlines.
Definition: expfld.hxx:88
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:971
virtual void SetValue(const double &rVal) override
Definition: expfld.cxx:938
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:404
T should be a subclass of SwHash.
Definition: calc.hxx:154
SwInputFieldType(SwDoc *pDoc)
Definition: expfld.cxx:1206
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:1212
SwDoc * mpDoc
Definition: expfld.hxx:277
OUString maContent
Definition: expfld.hxx:288
sal_uInt16 mnSubType
Definition: expfld.hxx:292
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: expfld.cxx:1313
bool isFormField() const
Definition: expfld.cxx:1331
bool mbIsFormField
Definition: expfld.hxx:293
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:1365
SwFormatField * mpFormatField
Definition: expfld.hxx:296
const OUString & GetHelp() const
Definition: expfld.cxx:1418
css::uno::Sequence< css::beans::PropertyValue > maGrabBag
Definition: expfld.hxx:294
void SetToolTip(const OUString &rStr)
Definition: expfld.cxx:1423
virtual void SetSubType(sal_uInt16 nSub) override
Definition: expfld.cxx:1438
void SetHelp(const OUString &rStr)
Definition: expfld.cxx:1413
const OUString & GetToolTip() const
Definition: expfld.cxx:1428
virtual void SetPar1(const OUString &rStr) override
set condition
Definition: expfld.cxx:1393
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:1338
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:1294
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:1236
void applyFieldContent(const OUString &rNewFieldContent)
Definition: expfld.cxx:1242
const OUString & getContent() const
Definition: expfld.hxx:302
OUString maPText
Definition: expfld.hxx:289
virtual OUString GetFieldName() const override
get name or content
Definition: expfld.cxx:1284
OUString maHelp
Definition: expfld.hxx:290
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:1403
OUString maToolTip
Definition: expfld.hxx:291
SwFormatField * GetFormatField()
Definition: expfld.hxx:316
virtual ~SwInputField() override
Definition: expfld.cxx:1232
virtual OUString GetPar2() const override
aPromptText
Definition: expfld.cxx:1408
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:1433
SwInputField(SwInputFieldType *pFieldType, OUString aContent, OUString aPrompt, sal_uInt16 nSubType, sal_uLong nFormat=0, bool bIsFormField=true)
Direct input via dialog; delete old value.
Definition: expfld.cxx:1217
virtual OUString GetPar1() const override
Content.
Definition: expfld.cxx:1398
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:1183
Base class of the Writer document model elements.
Definition: node.hxx:98
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
const SwTextNode * FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame const *pLayout=nullptr) const
Definition: node.cxx:793
SwDoc & GetDoc()
Definition: node.hxx:233
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:165
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1294
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:643
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:1393
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:70
bool SeekEntry(const SeqFieldLstElem &rNew, size_t *pPos) const
Definition: expfld.cxx:749
bool InsertSort(SeqFieldLstElem aNew)
Definition: expfld.cxx:729
size_t Count()
Definition: expfld.hxx:67
std::vector< SeqFieldLstElem > maData
Definition: expfld.hxx:62
const OUString & GetDelimiter() const
Number sequence fields chapterwise if required.
Definition: expfld.hxx:181
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: expfld.cxx:552
sal_uInt16 GetType() const
Definition: expfld.hxx:198
virtual OUString GetName() const override
Only in derived classes.
Definition: expfld.cxx:530
SwSetExpFieldType(SwDoc *pDoc, OUString aName, sal_uInt16 nType=nsSwGetSetExpType::GSE_EXPR)
Definition: expfld.cxx:509
void SetType(sal_uInt16 nTyp)
Definition: expfld.hxx:192
void SetOutlineLvl(sal_uInt8 n)
Definition: expfld.hxx:184
size_t GetSeqFieldList(SwSeqFieldList &rList, SwRootFrame const *pLayout)
Definition: expfld.cxx:617
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:669
OUString m_sDelim
Definition: expfld.hxx:151
void SetChapter(SwSetExpField &rField, const SwNode &rNd, SwRootFrame const *pLayout)
Definition: expfld.cxx:642
void SetSeqRefNo(SwSetExpField &rField)
Definition: expfld.cxx:575
sal_uInt8 m_nLevel
Definition: expfld.hxx:153
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:693
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:182
void SetSeqFormat(sal_uLong nFormat)
Definition: expfld.cxx:557
sal_uLong GetSeqFormat() const
Definition: expfld.cxx:565
sal_uInt16 m_nType
Definition: expfld.hxx:152
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:520
OUString m_sName
Definition: expfld.hxx:150
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:830
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
pool item to which the SwSetExpField belongs
Definition: expfld.cxx:835
virtual void SetValue(const double &rVal) override
Definition: expfld.cxx:901
OUString msExpandRLHidden
hidden redlines
Definition: expfld.hxx:208
SwSetExpField(SwSetExpFieldType *, const OUString &rFormel, sal_uLong nFormat=0)
Definition: expfld.cxx:808
virtual OUString GetPar1() const override
Query name only.
Definition: expfld.cxx:1023
SwFormatField * mpFormatField
Definition: expfld.hxx:213
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:1050
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:896
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:540
virtual OUString GetPar2() const override
Query formula.
Definition: expfld.cxx:1028
void SetInputFlag(bool bInp)
Definition: expfld.hxx:266
sal_uInt16 mnSeqNo
Definition: expfld.hxx:211
sal_uInt16 GetSeqNumber() const
Definition: expfld.hxx:248
sal_uInt16 mnSubType
Definition: expfld.hxx:212
virtual void SetSubType(sal_uInt16 nType) override
Definition: expfld.cxx:888
virtual OUString GetFieldName() const override
Definition: expfld.cxx:849
OUString maPText
Definition: expfld.hxx:209
bool mbInput
Definition: expfld.hxx:210
bool IsSequenceField() const
Definition: expfld.hxx:272
double m_fValueRLHidden
SwValueField; hidden redlines.
Definition: expfld.hxx:206
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:1151
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:870
void SetSeqNumber(sal_uInt16 n)
Logical number, sequence fields.
Definition: expfld.hxx:247
OUString msExpand
Definition: expfld.hxx:207
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:1037
const OUString & GetExpStr(SwRootFrame const *pLayout) const
Definition: expfld.cxx:535
bool GetInputFlag() const
Definition: expfld.hxx:269
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:199
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:165
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1246
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1293
void UnlockNotifyContentChange()
Definition: atrfld.cxx:673
bool LockNotifyContentChange()
Definition: atrfld.cxx:663
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
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|ExpandMode::HideFieldmarkCommands) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
Definition: ndtxt.cxx:3485
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:2133
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Definition: ndtxt.cxx:4075
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2907
const OUString & GetText() const
Definition: ndtxt.hxx:242
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 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:374
OUString m_sName
static SwTextNode * GetFirstTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwContentFrame *pCFrame, Point &rPt)
Definition: expfld.cxx:136
static sal_Int32 lcl_APIToSubType(const uno::Any &rAny)
Definition: expfld.cxx:87
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:66
OUString ReplacePoint(const OUString &rTmpName, bool bWithCommandType)
Definition: expfld.cxx:105
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:196
CharClass & GetAppCharClass()
Definition: init.cxx:705
CollatorWrapper & GetAppCaseCollator()
Definition: init.cxx:749
CollatorWrapper & GetAppCollator()
Definition: init.cxx:737
sal_Int32 nIndex
OUString aName
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:52
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:230
void AssignStartIndex(const SwContentNode &rNd)
Set nNode to rNd, and nContent to the beginning of rNd.
Definition: pam.cxx:271
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
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