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 // do not expand anything (else)
275}
276
277SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const OUString& rFormel,
278 sal_uInt16 nSub, sal_uLong nFormat)
279 : SwFormulaField( pTyp, nFormat, 0.0 )
280 , m_fValueRLHidden(0.0)
281 ,
282 m_bIsInBodyText( true ),
283 m_nSubType(nSub),
284 m_bLateInitialization( false )
285{
286 SetFormula( rFormel );
287}
288
289void SwGetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const pLayout)
290{
291 if (!pLayout || pLayout->IsHideRedlines())
292 {
293 m_sExpandRLHidden = rExpand;
294 }
295 if (!pLayout || !pLayout->IsHideRedlines())
296 {
297 m_sExpand = rExpand;
298 }
299}
300
301OUString SwGetExpField::ExpandImpl(SwRootFrame const*const pLayout) const
302{
304 return GetFormula();
305
306 return (pLayout && pLayout->IsHideRedlines()) ? m_sExpandRLHidden : m_sExpand;
307}
308
310{
311 const SwFieldTypesEnum nType =
315
316 return SwFieldType::GetTypeStr(nType) + " " + GetFormula();
317}
318
319std::unique_ptr<SwField> SwGetExpField::Copy() const
320{
321 std::unique_ptr<SwGetExpField> pTmp(new SwGetExpField(static_cast<SwGetExpFieldType*>(GetTyp()),
323 pTmp->SetLanguage(GetLanguage());
324 pTmp->m_fValueRLHidden = m_fValueRLHidden;
325 pTmp->SwValueField::SetValue(GetValue());
326 pTmp->m_sExpand = m_sExpand;
327 pTmp->m_sExpandRLHidden = m_sExpandRLHidden;
328 pTmp->m_bIsInBodyText = m_bIsInBodyText;
329 pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
331 pTmp->SetLateInitialization();
332
333 return std::unique_ptr<SwField>(pTmp.release());
334}
335
336void SwGetExpField::ChangeExpansion( const SwFrame& rFrame, const SwTextField& rField )
337{
338 if( m_bIsInBodyText ) // only fields in Footer, Header, FootNote, Flys
339 return;
340
341 OSL_ENSURE( !rFrame.IsInDocBody(), "Flag incorrect, frame is in DocBody" );
342
343 // determine document (or is there an easier way?)
344 const SwTextNode* pTextNode = &rField.GetTextNode();
345 SwDoc& rDoc = const_cast<SwDoc&>(pTextNode->GetDoc());
346
347 // create index for determination of the TextNode
348 SwPosition aPos( rDoc.GetNodes() );
349 pTextNode = GetBodyTextNode( rDoc, aPos, rFrame );
350
351 // If no layout exists, ChangeExpansion is called for header and
352 // footer lines via layout formatting without existing TextNode.
353 if(!pTextNode)
354 return;
355 // #i82544#
357 {
359 if( pSetExpField )
360 {
361 m_bLateInitialization = false;
363 static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING )
365 }
366 }
367
368 SwRootFrame const& rLayout(*rFrame.getRootFrame());
369 OUString & rExpand(rLayout.IsHideRedlines() ? m_sExpandRLHidden : m_sExpand);
370 // here a page number is needed to sort correctly
371 SetGetExpField aEndField(aPos.GetNode(), &rField, aPos.GetContentIndex(), rFrame.GetPhyPageNum());
373 {
374 SwHashTable<HashStr> aHashTable(0);
375 rDoc.getIDocumentFieldsAccess().FieldsToExpand(aHashTable, aEndField, rLayout);
376 rExpand = LookString( aHashTable, GetFormula() );
377 }
378 else
379 {
380 // fill calculator with values
381 SwCalc aCalc( rDoc );
382 rDoc.getIDocumentFieldsAccess().FieldsToCalc(aCalc, aEndField, &rLayout);
383
384 // calculate value
385 SetValue(aCalc.Calculate(GetFormula()).GetDouble(), &rLayout);
386
387 // analyse based on format
388 rExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue(
389 GetValue(&rLayout), GetFormat(), GetLanguage());
390 }
391}
392
394{
395 return GetFormula();
396}
397
398void SwGetExpField::SetPar2(const OUString& rStr)
399{
400 SetFormula(rStr);
401}
402
404{
405 return m_nSubType;
406}
407
408void SwGetExpField::SetSubType(sal_uInt16 nType)
409{
411}
412
414{
417 else
419}
420
421bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
422{
423 switch( nWhichId )
424 {
426 rAny <<= GetValue();
427 break;
429 rAny <<= static_cast<sal_Int32>(GetFormat());
430 break;
432 rAny <<= static_cast<sal_Int16>(m_nSubType);
433 break;
434 case FIELD_PROP_PAR1:
435 rAny <<= GetFormula();
436 break;
438 {
439 sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
440 rAny <<= nRet;
441 }
442 break;
443 case FIELD_PROP_BOOL2:
445 break;
446 case FIELD_PROP_PAR4:
447 rAny <<= m_sExpand;
448 break;
449 default:
450 return SwField::QueryValue(rAny, nWhichId);
451 }
452 return true;
453}
454
455bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
456{
457 sal_Int32 nTmp = 0;
458 switch( nWhichId )
459 {
461 SwValueField::SetValue(*o3tl::doAccess<double>(rAny));
462 m_fValueRLHidden = *o3tl::doAccess<double>(rAny);
463 break;
465 rAny >>= nTmp;
466 SetFormat(nTmp);
467 break;
469 rAny >>= nTmp;
470 m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp);
471 break;
472 case FIELD_PROP_PAR1:
473 {
474 OUString sTmp;
475 rAny >>= sTmp;
476 SetFormula(sTmp);
477 break;
478 }
480 nTmp = lcl_APIToSubType(rAny);
481 if( nTmp >=0 )
482 SetSubType( o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
483 break;
484 case FIELD_PROP_BOOL2:
485 if(*o3tl::doAccess<bool>(rAny))
487 else
489 break;
490 case FIELD_PROP_PAR4:
491 {
492 OUString sTmp;
493 rAny >>= sTmp;
494 ChgExpStr(sTmp, nullptr);
495 break;
496 }
497 default:
498 return SwField::PutValue(rAny, nWhichId);
499 }
500 return true;
501}
502
503SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, OUString aName, sal_uInt16 nTyp )
505 m_sName( std::move(aName) ),
506 m_sDelim( "." ),
507 m_nType(nTyp), m_nLevel( UCHAR_MAX ),
508 m_bDeleted( false )
509{
511 EnableFormat(false); // do not use Numberformatter
512}
513
514std::unique_ptr<SwFieldType> SwSetExpFieldType::Copy() const
515{
516 std::unique_ptr<SwSetExpFieldType> pNew(new SwSetExpFieldType(GetDoc(), m_sName, m_nType));
517 pNew->m_bDeleted = m_bDeleted;
518 pNew->m_sDelim = m_sDelim;
519 pNew->m_nLevel = m_nLevel;
520
521 return pNew;
522}
523
525{
526 return m_sName;
527}
528
529const OUString& SwSetExpField::GetExpStr(SwRootFrame const*const pLayout) const
530{
531 return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand;
532}
533
534void SwSetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const pLayout)
535{
536 if (!pLayout || pLayout->IsHideRedlines())
537 {
538 msExpandRLHidden = rExpand;
539 }
540 if (!pLayout || !pLayout->IsHideRedlines())
541 {
542 msExpand = rExpand;
543 }
544}
545
547{
548 // do not expand further
549}
550
552{
553 std::vector<SwFormatField*> vFields;
554 GatherFields(vFields, false);
555 for(auto pFormatField: vFields)
556 pFormatField->GetField()->ChangeFormat(nFormat);
557}
558
560{
561 if( !HasWriterListeners() )
562 return SVX_NUM_ARABIC;
563
564 std::vector<SwFormatField*> vFields;
565 GatherFields(vFields, false);
566 return vFields.front()->GetField()->GetFormat();
567}
568
570{
571 if( !HasWriterListeners() || !(nsSwGetSetExpType::GSE_SEQ & m_nType) )
572 return;
573
574 std::vector<sal_uInt16> aArr;
575
576 // check if number is already used and if a new one needs to be created
577 std::vector<SwFormatField*> vFields;
578 GatherFields(vFields);
579 for(SwFormatField* pF: vFields)
580 if(pF->GetField() != &rField)
581 InsertSort(aArr, static_cast<SwSetExpField*>(pF->GetField())->GetSeqNumber());
582
583 // check first if number already exists
584 sal_uInt16 nNum = rField.GetSeqNumber();
585 if( USHRT_MAX != nNum )
586 {
587 std::vector<sal_uInt16>::size_type n {0};
588
589 for( n = 0; n < aArr.size(); ++n )
590 if( aArr[ n ] >= nNum )
591 break;
592
593 if( n == aArr.size() || aArr[ n ] > nNum )
594 return; // no -> use it
595 }
596
597 // flagged all numbers, so determine the right number
598 std::vector<sal_uInt16>::size_type n = aArr.size();
599 OSL_ENSURE( n <= std::numeric_limits<sal_uInt16>::max(), "Array is too big for using a sal_uInt16 index" );
600
601 if ( n > 0 && aArr[ n-1 ] != n-1 )
602 {
603 for( n = 0; n < aArr.size(); ++n )
604 if( n != aArr[ n ] )
605 break;
606 }
607
608 rField.SetSeqNumber( n );
609}
610
612 SwRootFrame const*const pLayout)
613{
614 rList.Clear();
615
616 IDocumentRedlineAccess const& rIDRA(GetDoc()->getIDocumentRedlineAccess());
617
618 std::vector<SwFormatField*> vFields;
619 GatherFields(vFields);
620 for(SwFormatField* pF: vFields)
621 {
622 const SwTextNode* pNd;
623 if( nullptr != ( pNd = pF->GetTextField()->GetpTextNode() )
624 && (!pLayout || !pLayout->IsHideRedlines()
625 || !sw::IsFieldDeletedInModel(rIDRA, *pF->GetTextField())))
626 {
627 SeqFieldLstElem aNew(
628 pNd->GetExpandText(pLayout),
629 static_cast<SwSetExpField*>(pF->GetField())->GetSeqNumber() );
630 rList.InsertSort( std::move(aNew) );
631 }
632 }
633 return rList.Count();
634}
635
637 SwRootFrame const*const pLayout)
638{
639 const SwTextNode* pTextNd = rNd.FindOutlineNodeOfLevel(m_nLevel, pLayout);
640 if( !pTextNd )
641 return;
642
643 SwNumRule * pRule = pTextNd->GetNumRule();
644
645 if (!pRule)
646 return;
647
648 // --> OD 2005-11-02 #i51089 - TUNING#
649 if (SwNodeNum const*const pNum = pTextNd->GetNum(pLayout))
650 {
651 // only get the number, without pre-/post-fixstrings
652 OUString const sNumber(pRule->MakeNumString(*pNum, false));
653
654 if( !sNumber.isEmpty() )
655 rField.ChgExpStr(sNumber + m_sDelim + rField.GetExpStr(pLayout), pLayout);
656 }
657 else
658 {
659 OSL_ENSURE(pTextNd->GetNum(nullptr), "<SwSetExpFieldType::SetChapter(..)> - text node with numbering rule, but without number. This is a serious defect");
660 }
661}
662
663void SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
664{
665 switch( nWhichId )
666 {
668 {
669 sal_Int16 nRet = lcl_SubTypeToAPI(GetType());
670 rAny <<= nRet;
671 }
672 break;
673 case FIELD_PROP_PAR2:
674 rAny <<= GetDelimiter();
675 break;
677 {
678 sal_Int8 nRet = m_nLevel < MAXLEVEL? m_nLevel : -1;
679 rAny <<= nRet;
680 }
681 break;
682 default:
683 assert(false);
684 }
685}
686
687void SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
688{
689 switch( nWhichId )
690 {
692 {
693 sal_Int32 nSet = lcl_APIToSubType(rAny);
694 if(nSet >=0)
695 SetType(o3tl::narrowing<sal_uInt16>(nSet));
696 }
697 break;
698 case FIELD_PROP_PAR2:
699 {
700 OUString sTmp;
701 rAny >>= sTmp;
702 if( !sTmp.isEmpty() )
703 SetDelimiter( sTmp );
704 else
705 SetDelimiter( " " );
706 }
707 break;
709 {
710 sal_Int8 nLvl = 0;
711 rAny >>= nLvl;
712 if(nLvl < 0 || nLvl >= MAXLEVEL)
713 SetOutlineLvl(UCHAR_MAX);
714 else
715 SetOutlineLvl(nLvl);
716 }
717 break;
718 default:
719 assert(false);
720 }
721}
722
724{
725 OUStringBuffer aBuf(aNew.sDlgEntry);
726 const sal_Int32 nLen = aBuf.getLength();
727 for (sal_Int32 i = 0; i < nLen; ++i)
728 {
729 if (aBuf[i]<' ')
730 {
731 aBuf[i]=' ';
732 }
733 }
734 aNew.sDlgEntry = aBuf.makeStringAndClear();
735
736 size_t nPos = 0;
737 bool bRet = SeekEntry( aNew, &nPos );
738 if( !bRet )
739 maData.insert( maData.begin() + nPos, aNew );
740 return bRet;
741}
742
743bool SwSeqFieldList::SeekEntry( const SeqFieldLstElem& rNew, size_t* pP ) const
744{
745 size_t nO = maData.size();
746 size_t nU = 0;
747 if( nO > 0 )
748 {
750 & rColl = ::GetAppCollator();
751 const CharClass& rCC = GetAppCharClass();
752
753 //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1")
754 const OUString rTmp2 = rNew.sDlgEntry;
755 sal_Int32 nFndPos2 = 0;
756 const OUString sNum2( rTmp2.getToken( 0, ' ', nFndPos2 ));
757 bool bIsNum2IsNumeric = CharClass::isAsciiNumeric( sNum2 );
758 sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.toInt32() : 0;
759
760 nO--;
761 while( nU <= nO )
762 {
763 const size_t nM = nU + ( nO - nU ) / 2;
764
765 //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1")
766 const OUString rTmp1 = maData[nM].sDlgEntry;
767 sal_Int32 nFndPos1 = 0;
768 const OUString sNum1( rTmp1.getToken( 0, ' ', nFndPos1 ));
769 sal_Int32 nCmp;
770
771 if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) )
772 {
773 sal_Int32 nNum1 = sNum1.toInt32();
774 nCmp = nNum2 - nNum1;
775 if( 0 == nCmp )
776 {
777 OUString aTmp1 = nFndPos1 != -1 ? rTmp1.copy(nFndPos1) : OUString();
778 OUString aTmp2 = nFndPos2 != -1 ? rTmp2.copy(nFndPos2) : OUString();
779 nCmp = rCaseColl.compareString(aTmp2, aTmp1);
780 }
781 }
782 else
783 nCmp = rColl.compareString( rTmp2, rTmp1 );
784
785 if( 0 == nCmp )
786 {
787 if( pP ) *pP = nM;
788 return true;
789 }
790 else if( 0 < nCmp )
791 nU = nM + 1;
792 else if( nM == 0 )
793 break;
794 else
795 nO = nM - 1;
796 }
797 }
798 if( pP ) *pP = nU;
799 return false;
800}
801
802SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const OUString& rFormel,
803 sal_uLong nFormat)
804 : SwFormulaField( pTyp, nFormat, 0.0 )
805 , m_fValueRLHidden(0.0)
806 , mnSeqNo( USHRT_MAX )
807 , mnSubType(0)
808 , mpFormatField(nullptr)
809{
810 SetFormula(rFormel);
811 // ignore SubType
812 mbInput = false;
813 if( IsSequenceField() )
814 {
816 m_fValueRLHidden = 1.0;
817 if( rFormel.isEmpty() )
818 {
819 SetFormula(pTyp->GetName() + "+1");
820 }
821 }
822}
823
825{
826 mpFormatField = &rFormatField;
827}
828
829OUString SwSetExpField::ExpandImpl(SwRootFrame const*const pLayout) const
830{
832 { // we need the CommandString
833 return GetTyp()->GetName() + " = " + GetFormula();
834 }
836 { // value is visible
837 return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand;
838 }
839 return OUString();
840}
841
844{
845 SwFieldTypesEnum const nStrType( (IsSequenceField())
847 : mbInput
850
851 OUString aStr(
852 SwFieldType::GetTypeStr( nStrType )
853 + " "
854 + GetTyp()->GetName() );
855
856 // Sequence: without formula
857 if (SwFieldTypesEnum::Sequence != nStrType)
858 {
859 aStr += " = " + GetFormula();
860 }
861 return aStr;
862}
863
864std::unique_ptr<SwField> SwSetExpField::Copy() const
865{
866 std::unique_ptr<SwSetExpField> pTmp(new SwSetExpField(static_cast<SwSetExpFieldType*>(GetTyp()),
867 GetFormula(), GetFormat()));
868 pTmp->SwValueField::SetValue(GetValue());
869 pTmp->m_fValueRLHidden = m_fValueRLHidden;
870 pTmp->msExpand = msExpand;
871 pTmp->msExpandRLHidden = msExpandRLHidden;
872 pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
873 pTmp->SetLanguage(GetLanguage());
874 pTmp->maPText = maPText;
875 pTmp->mbInput = mbInput;
876 pTmp->mnSeqNo = mnSeqNo;
877 pTmp->SetSubType(GetSubType());
878
879 return std::unique_ptr<SwField>(pTmp.release());
880}
881
882void SwSetExpField::SetSubType(sal_uInt16 nSub)
883{
884 static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & 0xff);
885 mnSubType = nSub & 0xff00;
886
887 OSL_ENSURE( (nSub & 0xff) != 3, "SubType is illegal!" );
888}
889
891{
892 return static_cast<SwSetExpFieldType*>(GetTyp())->GetType() | mnSubType;
893}
894
895void SwSetExpField::SetValue( const double& rAny )
896{
898
899 if( IsSequenceField() )
901 else
902 msExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue( rAny,
904}
905
906void SwSetExpField::SetValue(const double& rValue, SwRootFrame const*const pLayout)
907{
908 if (!pLayout || !pLayout->IsHideRedlines())
909 {
910 SetValue(rValue);
911 }
912 if (pLayout && !pLayout->IsHideRedlines())
913 return;
914
915 m_fValueRLHidden = rValue;
916 if (IsSequenceField())
917 {
918 msExpandRLHidden = FormatNumber(rValue, static_cast<SvxNumType>(GetFormat()), GetLanguage());
919 }
920 else
921 {
923 rValue, GetFormat(), GetLanguage());
924 }
925}
926
927double SwSetExpField::GetValue(SwRootFrame const* pLayout) const
928{
929 return (pLayout && pLayout->IsHideRedlines()) ? m_fValueRLHidden : GetValue();
930}
931
932void SwGetExpField::SetValue( const double& rAny )
933{
935 m_sExpand = static_cast<SwValueFieldType*>(GetTyp())->ExpandValue( rAny, GetFormat(),
936 GetLanguage());
937}
938
939void SwGetExpField::SetValue(const double& rValue, SwRootFrame const*const pLayout)
940{
941 if (!pLayout || !pLayout->IsHideRedlines())
942 {
943 SetValue(rValue);
944 }
945 if (!pLayout || pLayout->IsHideRedlines())
946 {
947 m_fValueRLHidden = rValue;
949 rValue, GetFormat(), GetLanguage());
950 }
951}
952
953double SwGetExpField::GetValue(SwRootFrame const* pLayout) const
954{
955 return (pLayout && pLayout->IsHideRedlines()) ? m_fValueRLHidden : GetValue();
956}
957
965sal_Int32 SwGetExpField::GetReferenceTextPos( const SwFormatField& rFormat, SwDoc& rDoc, sal_Int32 nHint)
966{
967
968 const SwTextField* pTextField = rFormat.GetTextField();
969 const SwTextNode& rTextNode = pTextField->GetTextNode();
970
971 sal_Int32 nRet = nHint ? nHint : pTextField->GetStart() + 1;
972 OUString sNodeText = rTextNode.GetText();
973
974 if(nRet<sNodeText.getLength())
975 {
976 sNodeText = sNodeText.copy(nRet);
977
978 // now check if sNodeText starts with a non-alphanumeric character plus blanks
979 sal_uInt16 nSrcpt = g_pBreakIt->GetRealScriptOfText( sNodeText, 0 );
980
981 static const WhichRangesContainer nIds(svl::Items<
988 >);
989 SwAttrSet aSet(rDoc.GetAttrPool(), nIds);
990 rTextNode.GetParaAttr(aSet, nRet, nRet+1);
991
993 if( RTL_TEXTENCODING_SYMBOL != aSet.Get( nFontWhich ).GetCharSet() )
994 {
996 LanguageType eLang = aSet.Get(nLangWhich).GetLanguage();
997 CharClass aCC(( LanguageTag(eLang) ));
998 sal_Unicode c0 = sNodeText[0];
999 bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 );
1000 if( !bIsAlphaNum ||
1001 (c0 == ' ' || c0 == '\t'))
1002 {
1003 // ignoring blanks
1004 nRet++;
1005 const sal_Int32 nLen = sNodeText.getLength();
1006 for (sal_Int32 i = 1;
1007 i<nLen && (sNodeText[i]==' ' || sNodeText[i]=='\t');
1008 ++i
1009 )
1010 ++nRet;
1011 }
1012 }
1013 }
1014 return nRet;
1015}
1016
1018{
1019 return static_cast<const SwSetExpFieldType*>(GetTyp())->GetName();
1020}
1021
1023{
1024 sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType();
1025
1027 return GetFormula();
1028 return GetExpandedFormula();
1029}
1030
1031void SwSetExpField::SetPar2(const OUString& rStr)
1032{
1033 sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType();
1034
1035 if( !(nType & nsSwGetSetExpType::GSE_SEQ) || !rStr.isEmpty() )
1036 {
1038 SetFormula(rStr);
1039 else
1040 SetExpandedFormula(rStr);
1041 }
1042}
1043
1044bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1045{
1046 sal_Int32 nTmp32 = 0;
1047 sal_Int16 nTmp16 = 0;
1048 switch( nWhichId )
1049 {
1050 case FIELD_PROP_BOOL2:
1051 if(*o3tl::doAccess<bool>(rAny))
1053 else
1055 break;
1056 case FIELD_PROP_FORMAT:
1057 rAny >>= nTmp32;
1058 SetFormat(nTmp32);
1059 break;
1060 case FIELD_PROP_USHORT2:
1061 {
1062 rAny >>= nTmp16;
1063 if(nTmp16 <= css::style::NumberingType::NUMBER_NONE )
1064 SetFormat(nTmp16);
1065 else {
1066 //exception(wrong_value)
1067 ;
1068 }
1069 }
1070 break;
1071 case FIELD_PROP_USHORT1:
1072 rAny >>= nTmp16;
1073 mnSeqNo = nTmp16;
1074 break;
1075 case FIELD_PROP_PAR1:
1076 {
1077 OUString sTmp;
1078 rAny >>= sTmp;
1080 }
1081 break;
1082 case FIELD_PROP_PAR2:
1083 {
1084 OUString uTmp;
1085 rAny >>= uTmp;
1086 //I18N - if the formula contains only "TypeName+1"
1087 //and it's one of the initially created sequence fields
1088 //then the localized names has to be replaced by a programmatic name
1089 OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, false);
1090 SetFormula( sMyFormula );
1091 }
1092 break;
1093 case FIELD_PROP_DOUBLE:
1094 {
1095 double fVal = 0.0;
1096 rAny >>= fVal;
1097 SetValue(fVal);
1098 m_fValueRLHidden = fVal;
1099 }
1100 break;
1101 case FIELD_PROP_SUBTYPE:
1102 nTmp32 = lcl_APIToSubType(rAny);
1103 if(nTmp32 >= 0)
1104 SetSubType(o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
1105 break;
1106 case FIELD_PROP_PAR3:
1107 rAny >>= maPText;
1108 break;
1109 case FIELD_PROP_BOOL3:
1110 if(*o3tl::doAccess<bool>(rAny))
1112 else
1114 break;
1115 case FIELD_PROP_BOOL1:
1116 {
1117 bool newInput(*o3tl::doAccess<bool>(rAny));
1118 if (newInput != GetInputFlag())
1119 {
1120 if (static_cast<SwSetExpFieldType*>(GetTyp())->GetType()
1122 {
1124 }
1125 else
1126 {
1127 SetInputFlag(newInput);
1128 }
1129 }
1130 }
1131 break;
1132 case FIELD_PROP_PAR4:
1133 {
1134 OUString sTmp;
1135 rAny >>= sTmp;
1136 ChgExpStr(sTmp, nullptr);
1137 }
1138 break;
1139 default:
1140 return SwField::PutValue(rAny, nWhichId);
1141 }
1142 return true;
1143}
1144
1145bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1146{
1147 switch( nWhichId )
1148 {
1149 case FIELD_PROP_BOOL2:
1151 break;
1152 case FIELD_PROP_FORMAT:
1153 rAny <<= static_cast<sal_Int32>(GetFormat());
1154 break;
1155 case FIELD_PROP_USHORT2:
1156 rAny <<= static_cast<sal_Int16>(GetFormat());
1157 break;
1158 case FIELD_PROP_USHORT1:
1159 rAny <<= static_cast<sal_Int16>(mnSeqNo);
1160 break;
1161 case FIELD_PROP_PAR1:
1163 break;
1164 case FIELD_PROP_PAR2:
1165 {
1166 //I18N - if the formula contains only "TypeName+1"
1167 //and it's one of the initially created sequence fields
1168 //then the localized names has to be replaced by a programmatic name
1169 OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), true);
1170 rAny <<= sMyFormula;
1171 }
1172 break;
1173 case FIELD_PROP_DOUBLE:
1174 rAny <<= GetValue();
1175 break;
1176 case FIELD_PROP_SUBTYPE:
1177 {
1178 sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
1179 rAny <<= nRet;
1180 }
1181 break;
1182 case FIELD_PROP_PAR3:
1183 rAny <<= maPText;
1184 break;
1185 case FIELD_PROP_BOOL3:
1186 rAny <<= 0 != (mnSubType & nsSwExtendedSubType::SUB_CMD);
1187 break;
1188 case FIELD_PROP_BOOL1:
1189 rAny <<= GetInputFlag();
1190 break;
1191 case FIELD_PROP_PAR4:
1192 rAny <<= GetExpStr(nullptr);
1193 break;
1194 default:
1195 return SwField::QueryValue(rAny, nWhichId);
1196 }
1197 return true;
1198}
1199
1202 , mpDoc( pD )
1203{
1204}
1205
1206std::unique_ptr<SwFieldType> SwInputFieldType::Copy() const
1207{
1208 return std::make_unique<SwInputFieldType>( mpDoc );
1209}
1210
1212 OUString aContent,
1213 OUString aPrompt,
1214 sal_uInt16 nSub,
1215 sal_uLong nFormat,
1216 bool bIsFormField )
1217 : SwField( pFieldType, nFormat, LANGUAGE_SYSTEM, false )
1218 , maContent(std::move(aContent))
1219 , maPText(std::move(aPrompt))
1220 , mnSubType(nSub)
1221 , mbIsFormField( bIsFormField )
1222 , mpFormatField( nullptr )
1223{
1224}
1225
1227{
1228}
1229
1231{
1232 mpFormatField = &rFormatField;
1233}
1234
1235
1236void SwInputField::applyFieldContent( const OUString& rNewFieldContent )
1237{
1238 if ( (mnSubType & 0x00ff) == INP_TXT )
1239 {
1240 maContent = rNewFieldContent;
1241 }
1242 else if( (mnSubType & 0x00ff) == INP_USR )
1243 {
1244 SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
1245 static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::User, getContent(), false ) );
1246 if( pUserTyp )
1247 {
1248 pUserTyp->SetContent( rNewFieldContent );
1249 if (!pUserTyp->IsModifyLocked())
1250 {
1251 // trigger update of the corresponding User Fields and other
1252 // related Input Fields
1253 bool bUnlock(false);
1254 if (GetFormatField() != nullptr)
1255 {
1256 SwTextInputField *const pTextInputField =
1257 dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
1258 if (pTextInputField != nullptr)
1259 {
1260 bUnlock = pTextInputField->LockNotifyContentChange();
1261 }
1262 }
1263 pUserTyp->UpdateFields();
1264 if (bUnlock)
1265 {
1266 SwTextInputField *const pTextInputField =
1267 dynamic_cast<SwTextInputField*>(GetFormatField()->GetTextField());
1268 if (pTextInputField != nullptr)
1269 {
1270 pTextInputField->UnlockNotifyContentChange();
1271 }
1272 }
1273 }
1274 }
1275 }
1276}
1277
1279{
1280 OUString aStr(SwField::GetFieldName());
1281 if ((mnSubType & 0x00ff) == INP_USR)
1282 {
1283 aStr += GetTyp()->GetName() + " " + getContent();
1284 }
1285 return aStr;
1286}
1287
1288std::unique_ptr<SwField> SwInputField::Copy() const
1289{
1290 std::unique_ptr<SwInputField> pField(
1291 new SwInputField(
1292 static_cast<SwInputFieldType*>(GetTyp()),
1293 getContent(),
1294 maPText,
1295 GetSubType(),
1296 GetFormat(),
1297 mbIsFormField ));
1298
1299 pField->SetHelp( maHelp );
1300 pField->SetToolTip( maToolTip );
1301 pField->maGrabBag = maGrabBag;
1302
1303 pField->SetAutomaticLanguage(IsAutomaticLanguage());
1304 return std::unique_ptr<SwField>(pField.release());
1305}
1306
1307OUString SwInputField::ExpandImpl(SwRootFrame const*const) const
1308{
1309 if((mnSubType & 0x00ff) == INP_TXT)
1310 {
1311 return getContent();
1312 }
1313
1314 if( (mnSubType & 0x00ff) == INP_USR )
1315 {
1316 SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
1317 static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::User, getContent(), false ) );
1318 if( pUserTyp )
1319 return pUserTyp->GetContent();
1320 }
1321
1322 return OUString();
1323}
1324
1326{
1327 return mbIsFormField
1328 || !maHelp.isEmpty()
1329 || !maToolTip.isEmpty();
1330}
1331
1332bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1333{
1334 switch( nWhichId )
1335 {
1336 case FIELD_PROP_PAR1:
1337 rAny <<= getContent();
1338 break;
1339 case FIELD_PROP_PAR2:
1340 rAny <<= maPText;
1341 break;
1342 case FIELD_PROP_PAR3:
1343 rAny <<= maHelp;
1344 break;
1345 case FIELD_PROP_PAR4:
1346 rAny <<= maToolTip;
1347 break;
1348 case FIELD_PROP_GRABBAG:
1349 rAny <<= maGrabBag;
1350 break;
1351 case FIELD_PROP_TITLE:
1352 break;
1353 default:
1354 assert(false);
1355 }
1356 return true;
1357}
1358
1359bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1360{
1361 switch( nWhichId )
1362 {
1363 case FIELD_PROP_PAR1:
1364 rAny >>= maContent;
1365 break;
1366 case FIELD_PROP_PAR2:
1367 rAny >>= maPText;
1368 break;
1369 case FIELD_PROP_PAR3:
1370 rAny >>= maHelp;
1371 break;
1372 case FIELD_PROP_PAR4:
1373 rAny >>= maToolTip;
1374 break;
1375 case FIELD_PROP_GRABBAG:
1376 rAny >>= maGrabBag;
1377 break;
1378 case FIELD_PROP_TITLE:
1379 break;
1380 default:
1381 assert(false);
1382 }
1383 return true;
1384}
1385
1387void SwInputField::SetPar1(const OUString& rStr)
1388{
1389 maContent = rStr;
1390}
1391
1393{
1394 return getContent();
1395}
1396
1397void SwInputField::SetPar2(const OUString& rStr)
1398{
1399 maPText = rStr;
1400}
1401
1403{
1404 return maPText;
1405}
1406
1407void SwInputField::SetHelp(const OUString & rStr)
1408{
1409 maHelp = rStr;
1410}
1411
1412const OUString& SwInputField::GetHelp() const
1413{
1414 return maHelp;
1415}
1416
1417void SwInputField::SetToolTip(const OUString & rStr)
1418{
1419 maToolTip = rStr;
1420}
1421
1422const OUString& SwInputField::GetToolTip() const
1423{
1424 return maToolTip;
1425}
1426
1428{
1429 return mnSubType;
1430}
1431
1432void SwInputField::SetSubType(sal_uInt16 nSub)
1433{
1434 mnSubType = nSub;
1435}
1436
1437/* 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:3044
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
tools::Long AdjustY(tools::Long nVertMove)
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:200
SwSbxValue Calculate(const OUString &rStr)
Definition: calc.cxx:363
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:59
Definition: doc.hxx:197
SwNodes & GetNodes()
Definition: doc.hxx:422
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
virtual void UpdateFields()
Definition: fldbas.cxx:219
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:139
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:124
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:205
Base class of all fields.
Definition: fldbas.hxx:296
virtual void SetLanguage(LanguageType nLng)
Definition: fldbas.cxx:449
virtual void SetPar1(const OUString &rStr)
Definition: fldbas.cxx:349
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:387
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:311
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:407
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
Definition: fldbas.cxx:364
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:318
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
Definition: fldbas.cxx:382
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:412
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
Represents one footnote or endnote in the layout.
Definition: ftnfrm.hxx:84
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:149
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
OUString GetExpandedFormula() const
Definition: fldbas.cxx:863
void SetExpandedFormula(const OUString &rStr)
Definition: fldbas.cxx:841
void SetFormula(const OUString &rStr)
Definition: fldbas.cxx:825
virtual OUString GetFormula() const override
Definition: fldbas.cxx:820
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:171
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
bool IsInDocBody() const
Definition: frame.hxx:949
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1105
bool IsHeaderFrame() const
Definition: frame.hxx:1196
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
bool IsFooterFrame() const
Definition: frame.hxx:1200
bool IsFootnoteFrame() const
Definition: frame.hxx:1208
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
SwRootFrame * getRootFrame()
Definition: frame.hxx:685
bool IsFlyFrame() const
Definition: frame.hxx:1216
SwPageFrame * FindPageFrame()
Definition: frame.hxx:686
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:289
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:319
virtual OUString GetPar2() const override
Change formula.
Definition: expfld.cxx:393
sal_uInt16 m_nSubType
Definition: expfld.hxx:92
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: expfld.cxx:301
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:421
SwGetExpField(SwGetExpFieldType *, const OUString &rFormel, sal_uInt16 nSubType, sal_uLong nFormat)
Definition: expfld.cxx:277
virtual void SetSubType(sal_uInt16 nType) override
Definition: expfld.cxx:408
void ChangeExpansion(const SwFrame &, const SwTextField &)
For fields in header/footer/footnotes/flys: Only called by formatting!!
Definition: expfld.cxx:336
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:403
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:455
bool m_bLateInitialization
Definition: expfld.hxx:94
virtual OUString GetFieldName() const override
get name or content
Definition: expfld.cxx:309
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: expfld.cxx:413
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:965
virtual void SetValue(const double &rVal) override
Definition: expfld.cxx:932
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:398
T should be a subclass of SwHash.
Definition: calc.hxx:155
SwInputFieldType(SwDoc *pDoc)
Definition: expfld.cxx:1200
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:1206
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:1307
bool isFormField() const
Definition: expfld.cxx:1325
bool mbIsFormField
Definition: expfld.hxx:293
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:1359
SwFormatField * mpFormatField
Definition: expfld.hxx:296
const OUString & GetHelp() const
Definition: expfld.cxx:1412
css::uno::Sequence< css::beans::PropertyValue > maGrabBag
Definition: expfld.hxx:294
void SetToolTip(const OUString &rStr)
Definition: expfld.cxx:1417
virtual void SetSubType(sal_uInt16 nSub) override
Definition: expfld.cxx:1432
void SetHelp(const OUString &rStr)
Definition: expfld.cxx:1407
const OUString & GetToolTip() const
Definition: expfld.cxx:1422
virtual void SetPar1(const OUString &rStr) override
set condition
Definition: expfld.cxx:1387
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:1332
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:1288
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:1230
void applyFieldContent(const OUString &rNewFieldContent)
Definition: expfld.cxx:1236
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:1278
OUString maHelp
Definition: expfld.hxx:290
virtual void SetPar2(const OUString &rStr) override
Definition: expfld.cxx:1397
OUString maToolTip
Definition: expfld.hxx:291
SwFormatField * GetFormatField()
Definition: expfld.hxx:316
virtual ~SwInputField() override
Definition: expfld.cxx:1226
virtual OUString GetPar2() const override
aPromptText
Definition: expfld.cxx:1402
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:1427
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:1211
virtual OUString GetPar1() const override
Content.
Definition: expfld.cxx:1392
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:72
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:901
const SwTextNode * FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame const *pLayout=nullptr) const
Definition: node.cxx:791
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:1299
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
Definition: number.cxx:643
A page of the document layout.
Definition: pagefrm.hxx:60
SwContentFrame * FindLastBodyContent()
Searches the last ContentFrame in BodyText below the page.
Definition: findfrm.cxx:57
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:359
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:85
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
Definition: rootfrm.hxx:434
void Clear()
Definition: expfld.hxx:70
bool SeekEntry(const SeqFieldLstElem &rNew, size_t *pPos) const
Definition: expfld.cxx:743
bool InsertSort(SeqFieldLstElem aNew)
Definition: expfld.cxx:723
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:546
sal_uInt16 GetType() const
Definition: expfld.hxx:198
virtual OUString GetName() const override
Only in derived classes.
Definition: expfld.cxx:524
SwSetExpFieldType(SwDoc *pDoc, OUString aName, sal_uInt16 nType=nsSwGetSetExpType::GSE_EXPR)
Definition: expfld.cxx:503
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:611
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: expfld.cxx:663
OUString m_sDelim
Definition: expfld.hxx:151
void SetChapter(SwSetExpField &rField, const SwNode &rNd, SwRootFrame const *pLayout)
Definition: expfld.cxx:636
void SetSeqRefNo(SwSetExpField &rField)
Definition: expfld.cxx:569
sal_uInt8 m_nLevel
Definition: expfld.hxx:153
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:687
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:182
void SetSeqFormat(sal_uLong nFormat)
Definition: expfld.cxx:551
sal_uLong GetSeqFormat() const
Definition: expfld.cxx:559
sal_uInt16 m_nType
Definition: expfld.hxx:152
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: expfld.cxx:514
OUString m_sName
Definition: expfld.hxx:150
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:824
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
pool item to which the SwSetExpField belongs
Definition: expfld.cxx:829
virtual void SetValue(const double &rVal) override
Definition: expfld.cxx:895
OUString msExpandRLHidden
hidden redlines
Definition: expfld.hxx:208
SwSetExpField(SwSetExpFieldType *, const OUString &rFormel, sal_uLong nFormat=0)
Definition: expfld.cxx:802
virtual OUString GetPar1() const override
Query name only.
Definition: expfld.cxx:1017
SwFormatField * mpFormatField
Definition: expfld.hxx:213
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: expfld.cxx:1044
virtual sal_uInt16 GetSubType() const override
Definition: expfld.cxx:890
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:534
virtual OUString GetPar2() const override
Query formula.
Definition: expfld.cxx:1022
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:882
virtual OUString GetFieldName() const override
Definition: expfld.cxx:843
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:1145
virtual std::unique_ptr< SwField > Copy() const override
Definition: expfld.cxx:864
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:1031
const OUString & GetExpStr(SwRootFrame const *pLayout) const
Definition: expfld.cxx:529
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:49
SwRowFrame * GetFirstNonHeadlineRow() const
Definition: tabfrm.cxx:5985
const SwTable * GetTable() const
Definition: tabfrm.hxx:162
bool IsInHeadline(const SwFrame &rFrame) const
Definition: tabfrm.cxx:5966
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:201
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:72
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1333
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1380
void UnlockNotifyContentChange()
Definition: atrfld.cxx:699
bool LockNotifyContentChange()
Definition: atrfld.cxx:689
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
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:3505
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:2140
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Definition: ndtxt.cxx:4095
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2921
const OUString & GetText() const
Definition: ndtxt.hxx:244
The shared part of a user field.
Definition: usrfld.hxx:35
OUString GetContent(sal_uInt32 nFormat=0) const
Definition: usrfld.cxx:283
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:299
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:419
SwDoc * GetDoc() const
Definition: fldbas.hxx:429
void EnableFormat(bool bFormat=true)
Definition: fldbas.hxx:439
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: fldbas.cxx:757
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
Definition: fldbas.hxx:472
virtual double GetValue() const
Definition: fldbas.cxx:799
virtual void SetValue(const double &rVal)
Definition: fldbas.cxx:804
static OUString LocalizeFormula(const SwSetExpField &rField, const OUString &rFormula, bool bQuery)
Definition: unofield.cxx:1005
static void TransmuteLeadToInputField(SwSetExpField &rField)
Convert between SwSetExpField with InputFlag false and InputFlag true.
Definition: unofield.cxx:1238
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:377
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:523
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:98
@ INP_USR
Definition: fldbas.hxx:223
@ INP_TXT
Definition: fldbas.hxx:222
SwFieldIds
Definition: fldbas.hxx:49
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< SvxFontItem > RES_CHRATR_FONT(7)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:184
CharClass & GetAppCharClass()
Definition: init.cxx:721
CollatorWrapper & GetAppCaseCollator()
Definition: init.cxx:765
CollatorWrapper & GetAppCollator()
Definition: init.cxx:753
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:216
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:217
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:209
const SwGetSetExpType GSE_EXPR
Expression.
Definition: fldbas.hxx:208
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:210
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:207
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:38
SwNode & GetNode() const
Definition: pam.hxx:81
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:231
void AssignStartIndex(const SwContentNode &rNd)
Set nNode to rNd, and nContent to the beginning of rNd.
Definition: pam.cxx:272
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
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