LibreOffice Module sw (master) 1
docufld.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 <config_features.h>
21#include <config_fuzzers.h>
22
23#include <textapi.hxx>
24
25#include <hintids.hxx>
26#include <com/sun/star/frame/XModel.hpp>
27#include <com/sun/star/text/XText.hpp>
28#include <com/sun/star/script/Converter.hpp>
29#include <com/sun/star/text/PlaceholderType.hpp>
30#include <com/sun/star/text/TemplateDisplayFormat.hpp>
31#include <com/sun/star/text/PageNumberType.hpp>
32#include <com/sun/star/text/FilenameDisplayFormat.hpp>
33#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
34#include <com/sun/star/document/XDocumentProperties.hpp>
35#include <com/sun/star/util/Date.hpp>
36#include <com/sun/star/util/Duration.hpp>
37#include <o3tl/any.hxx>
40#include <comphelper/string.hxx>
41#include <tools/urlobj.hxx>
42#include <svl/numformat.hxx>
43#include <svl/urihelper.hxx>
46#include <libxml/xmlstring.h>
47#include <libxml/xmlwriter.h>
48
49#include <tools/time.hxx>
50#include <tools/datetime.hxx>
51
52#include <com/sun/star/util/DateTime.hpp>
53
54#include <swmodule.hxx>
55#include <sfx2/docfile.hxx>
56#include <sfx2/doctempl.hxx>
57#include <fmtfld.hxx>
58#include <txtfld.hxx>
59#include <charfmt.hxx>
60#include <docstat.hxx>
61#include <pagedesc.hxx>
62#include <fmtpdsc.hxx>
63#include <doc.hxx>
68#include <rootfrm.hxx>
69#include <pagefrm.hxx>
70#include <cntfrm.hxx>
71#include <pam.hxx>
72#include <utility>
73#include <viewsh.hxx>
74#include <dbmgr.hxx>
75#include <shellres.hxx>
76#include <docufld.hxx>
77#include <flddat.hxx>
78#include <docfld.hxx>
79#include <ndtxt.hxx>
80#include <expfld.hxx>
81#include <poolfmt.hxx>
82#include <docsh.hxx>
83#include <unofldmid.h>
84#include <swunohelper.hxx>
85#include <strings.hrc>
86
87#include <editeng/outlobj.hxx>
88#include <calbck.hxx>
89#include <hints.hxx>
90
91#define URL_DECODE INetURLObject::DecodeMechanism::Unambiguous
92
93using namespace ::com::sun::star;
94using namespace ::com::sun::star::uno;
95using namespace nsSwDocInfoSubType;
96
99 m_nNumberingType( SVX_NUM_ARABIC ),
100 m_bVirtual( false )
101{
102}
103
104OUString SwPageNumberFieldType::Expand( SvxNumType nFormat, short nOff,
105 sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage,
106 const OUString& rUserStr, LanguageType nLang ) const
107{
108 SvxNumType nTmpFormat = (SVX_NUM_PAGEDESC == nFormat) ? m_nNumberingType : nFormat;
109 int const nTmp = nPageNumber + nOff;
110
111 if (0 > nTmp || SVX_NUM_NUMBER_NONE == nTmpFormat || (!m_bVirtual && nTmp > nMaxPage))
112 return OUString();
113
114 if( SVX_NUM_CHAR_SPECIAL == nTmpFormat )
115 return rUserStr;
116
117 return FormatNumber( nTmp, nTmpFormat, nLang );
118}
119
120std::unique_ptr<SwFieldType> SwPageNumberFieldType::Copy() const
121{
122 std::unique_ptr<SwPageNumberFieldType> pTmp(new SwPageNumberFieldType());
123
124 pTmp->m_nNumberingType = m_nNumberingType;
125 pTmp->m_bVirtual = m_bVirtual;
126
127 return pTmp;
128}
129
131 bool bVirt,
132 const SvxNumType* pNumFormat )
133{
134 if( pNumFormat )
135 m_nNumberingType = *pNumFormat;
136
137 m_bVirtual = false;
138 if (!(bVirt && pDoc))
139 return;
140
141 // check the flag since the layout NEVER sets it back
142 const SfxItemPool &rPool = pDoc->GetAttrPool();
143 for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_PAGEDESC))
144 {
145 auto pDesc = dynamic_cast<const SwFormatPageDesc*>(pItem);
146 if( pDesc && pDesc->GetNumOffset() && pDesc->GetDefinedIn() )
147 {
148 const SwContentNode* pNd = dynamic_cast<const SwContentNode*>( pDesc->GetDefinedIn() );
149 if( pNd )
150 {
152 // sw_redlinehide: not sure if this should happen only if
153 // it's the first node, because that's where RES_PAGEDESC
154 // is effective?
155 m_bVirtual = true;
156 }
157 else if( dynamic_cast< const SwFormat* >(pDesc->GetDefinedIn()) != nullptr)
158 {
159 SwAutoFormatGetDocNode aGetHt( &pDoc->GetNodes() );
160 m_bVirtual = !pDesc->GetDefinedIn()->GetInfo( aGetHt );
161 break;
162 }
163 }
164 }
165}
166
168 sal_uInt16 nSub, sal_uInt32 nFormat, short nOff,
169 sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage)
170 : SwField(pTyp, nFormat), m_nSubType(nSub), m_nOffset(nOff)
171 , m_nPageNumber(nPageNumber)
172 , m_nMaxPage(nMaxPage)
173{
174}
175
176void SwPageNumberField::ChangeExpansion(sal_uInt16 const nPageNumber,
177 sal_uInt16 const nMaxPage)
178{
179 m_nPageNumber = nPageNumber;
180 m_nMaxPage = nMaxPage;
181}
182
184{
185 OUString sRet;
186 SwPageNumberFieldType* pFieldType = static_cast<SwPageNumberFieldType*>(GetTyp());
187
188 if( PG_NEXT == m_nSubType && 1 != m_nOffset )
189 {
190 sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), 1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
191 if (!sRet.isEmpty())
192 {
193 sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
194 }
195 }
196 else if( PG_PREV == m_nSubType && -1 != m_nOffset )
197 {
198 sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), -1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
199 if (!sRet.isEmpty())
200 {
201 sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
202 }
203 }
204 else
205 sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage());
206 return sRet;
207}
208
209std::unique_ptr<SwField> SwPageNumberField::Copy() const
210{
211 std::unique_ptr<SwPageNumberField> pTmp(new SwPageNumberField(
212 static_cast<SwPageNumberFieldType*>(GetTyp()), m_nSubType,
214 pTmp->SetLanguage( GetLanguage() );
215 pTmp->SetUserString( m_sUserStr );
216 return std::unique_ptr<SwField>(pTmp.release());
217}
218
220{
221 return OUString::number(m_nOffset);
222}
223
224void SwPageNumberField::SetPar2(const OUString& rStr)
225{
226 m_nOffset = static_cast<short>(rStr.toInt32());
227}
228
230{
231 return m_nSubType;
232}
233
234bool SwPageNumberField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
235{
236 switch( nWhichId )
237 {
239 rAny <<= static_cast<sal_Int16>(GetFormat());
240 break;
242 rAny <<= m_nOffset;
243 break;
245 {
246 text::PageNumberType eType;
247 eType = text::PageNumberType_CURRENT;
248 if(m_nSubType == PG_PREV)
249 eType = text::PageNumberType_PREV;
250 else if(m_nSubType == PG_NEXT)
251 eType = text::PageNumberType_NEXT;
252 rAny <<= eType;
253 }
254 break;
255 case FIELD_PROP_PAR1:
256 rAny <<= m_sUserStr;
257 break;
258
259 default:
260 assert(false);
261 }
262 return true;
263}
264
265bool SwPageNumberField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
266{
267 bool bRet = true;
268 sal_Int16 nSet = 0;
269 switch( nWhichId )
270 {
272 rAny >>= nSet;
273
274 // TODO: where do the defines come from?
275 if(nSet <= SVX_NUM_PAGEDESC )
276 SetFormat(nSet);
277 break;
279 rAny >>= nSet;
280 m_nOffset = nSet;
281 break;
283 switch( static_cast<text::PageNumberType>(SWUnoHelper::GetEnumAsInt32( rAny )) )
284 {
285 case text::PageNumberType_CURRENT:
287 break;
288 case text::PageNumberType_PREV:
290 break;
291 case text::PageNumberType_NEXT:
293 break;
294 default:
295 bRet = false;
296 }
297 break;
298 case FIELD_PROP_PAR1:
299 rAny >>= m_sUserStr;
300 break;
301
302 default:
303 assert(false);
304 }
305 return bRet;
306}
307
310{
311}
312
314{
315 SvtUserOptions& rOpt = SW_MOD()->GetUserOptions();
316 if((nFormat & 0xff) == AF_NAME)
317 return rOpt.GetFullName();
318
319 return rOpt.GetID();
320}
321
322std::unique_ptr<SwFieldType> SwAuthorFieldType::Copy() const
323{
324 return std::make_unique<SwAuthorFieldType>();
325}
326
328 : SwField(pTyp, nFormat)
329{
331}
332
333OUString SwAuthorField::ExpandImpl(SwRootFrame const*const) const
334{
335 if (!IsFixed())
336 const_cast<SwAuthorField*>(this)->m_aContent =
338
339 return m_aContent;
340}
341
342std::unique_ptr<SwField> SwAuthorField::Copy() const
343{
344 std::unique_ptr<SwAuthorField> pTmp(new SwAuthorField( static_cast<SwAuthorFieldType*>(GetTyp()),
345 GetFormat()));
346 pTmp->SetExpansion(m_aContent);
347 return std::unique_ptr<SwField>(pTmp.release());
348}
349
350bool SwAuthorField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
351{
352 switch( nWhichId )
353 {
354 case FIELD_PROP_BOOL1:
355 rAny <<= (GetFormat() & 0xff) == AF_NAME;
356 break;
357
358 case FIELD_PROP_BOOL2:
359 rAny <<= IsFixed();
360 break;
361
362 case FIELD_PROP_PAR1:
363 rAny <<= m_aContent;
364 break;
365
366 case FIELD_PROP_TITLE:
367 break;
368
369 default:
370 assert(false);
371 }
372 return true;
373}
374
375bool SwAuthorField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
376{
377 switch( nWhichId )
378 {
379 case FIELD_PROP_BOOL1:
380 SetFormat( *o3tl::doAccess<bool>(rAny) ? AF_NAME : AF_SHORTCUT );
381 break;
382
383 case FIELD_PROP_BOOL2:
384 if( *o3tl::doAccess<bool>(rAny) )
386 else
388 break;
389
390 case FIELD_PROP_PAR1:
391 rAny >>= m_aContent;
392 break;
393
394 case FIELD_PROP_TITLE:
395 break;
396
397 default:
398 assert(false);
399 }
400 return true;
401}
402
405 , m_rDoc(rDocument)
406{
407}
408
410{
411 OUString aRet;
412 const SwDocShell* pDShell = m_rDoc.GetDocShell();
413 if( pDShell && pDShell->HasName() )
414 {
415 const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
416 switch( nFormat & ~FF_FIXED )
417 {
418 case FF_PATH:
419 {
420 if( INetProtocol::File == rURLObj.GetProtocol() )
421 {
422 INetURLObject aTemp(rURLObj);
423 aTemp.removeSegment();
424 // last slash should belong to the pathname
425 aRet = aTemp.PathToFileName();
426 }
427 else
428 {
432 const sal_Int32 nPos = aRet.indexOf(rURLObj.GetLastName( URL_DECODE ));
433 if (nPos>=0)
434 {
435 aRet = aRet.copy(0, nPos);
436 }
437 }
438 }
439 break;
440
441 case FF_NAME:
443 break;
444
445 case FF_NAME_NOEXT:
446 aRet = rURLObj.GetBase();
447 break;
448
449 default:
450 if( INetProtocol::File == rURLObj.GetProtocol() )
451 aRet = rURLObj.GetFull();
452 else
456 }
457 }
458 return aRet;
459}
460
461std::unique_ptr<SwFieldType> SwFileNameFieldType::Copy() const
462{
463 return std::make_unique<SwFileNameFieldType>(m_rDoc);
464}
465
467 : SwField(pTyp, nFormat)
468{
470}
471
472OUString SwFileNameField::ExpandImpl(SwRootFrame const*const) const
473{
474 if (!IsFixed())
475 const_cast<SwFileNameField*>(this)->m_aContent = static_cast<SwFileNameFieldType*>(GetTyp())->Expand(GetFormat());
476
477 return m_aContent;
478}
479
480std::unique_ptr<SwField> SwFileNameField::Copy() const
481{
482 std::unique_ptr<SwFileNameField> pTmp(
483 new SwFileNameField(static_cast<SwFileNameFieldType*>(GetTyp()), GetFormat()));
484 pTmp->SetExpansion(m_aContent);
485
486 return std::unique_ptr<SwField>(pTmp.release());
487}
488
489bool SwFileNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
490{
491 switch( nWhichId )
492 {
494 {
495 sal_Int16 nRet;
496 switch( GetFormat() &(~FF_FIXED) )
497 {
498 case FF_PATH:
499 nRet = text::FilenameDisplayFormat::PATH;
500 break;
501 case FF_NAME_NOEXT:
503 break;
504 case FF_NAME:
505 nRet = text::FilenameDisplayFormat::NAME_AND_EXT;
506 break;
507 default: nRet = text::FilenameDisplayFormat::FULL;
508 }
509 rAny <<= nRet;
510 }
511 break;
512
513 case FIELD_PROP_BOOL2:
514 rAny <<= IsFixed();
515 break;
516
517 case FIELD_PROP_PAR3:
518 rAny <<= m_aContent;
519 break;
520
521 default:
522 assert(false);
523 }
524 return true;
525}
526
527bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
528{
529 switch( nWhichId )
530 {
532 {
533 //JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
534 // called with a int32 value! But normally we need
535 // here only a int16
536 sal_Int32 nType = 0;
537 rAny >>= nType;
538 bool bFixed = IsFixed();
539 switch( nType )
540 {
541 case text::FilenameDisplayFormat::PATH:
542 nType = FF_PATH;
543 break;
546 break;
547 case text::FilenameDisplayFormat::NAME_AND_EXT:
548 nType = FF_NAME;
549 break;
550 default: nType = FF_PATHNAME;
551 }
552 if(bFixed)
553 nType |= FF_FIXED;
555 }
556 break;
557
558 case FIELD_PROP_BOOL2:
559 if( *o3tl::doAccess<bool>(rAny) )
561 else
563 break;
564
565 case FIELD_PROP_PAR3:
566 rAny >>= m_aContent;
567 break;
568
569 default:
570 assert(false);
571 }
572 return true;
573}
574
577 , m_rDoc(rDocument)
578{
579}
580
582{
583 OSL_ENSURE( nFormat < FF_END, "Expand: no valid Format!" );
584
585 OUString aRet;
586 SwDocShell *pDocShell(m_rDoc.GetDocShell());
587 OSL_ENSURE(pDocShell, "no SwDocShell");
588 if (pDocShell) {
589 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
590 pDocShell->GetModel(), uno::UNO_QUERY_THROW);
591 uno::Reference<document::XDocumentProperties> xDocProps(
592 xDPS->getDocumentProperties());
593 OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties");
594
595 if( FF_UI_NAME == nFormat )
596 aRet = xDocProps->getTemplateName();
597 else if( !xDocProps->getTemplateURL().isEmpty() )
598 {
599 if( FF_UI_RANGE == nFormat )
600 {
601 // for getting region names!
603 OUString sTmp;
604 OUString sRegion;
605 aFac.GetLogicNames( xDocProps->getTemplateURL(), sRegion, sTmp );
606 aRet = sRegion;
607 }
608 else
609 {
610 INetURLObject aPathName( xDocProps->getTemplateURL() );
611 if( FF_NAME == nFormat )
612 aRet = aPathName.GetLastName(URL_DECODE);
613 else if( FF_NAME_NOEXT == nFormat )
614 aRet = aPathName.GetBase();
615 else
616 {
617 if( FF_PATH == nFormat )
618 {
619 aPathName.removeSegment();
620 aRet = aPathName.GetFull();
621 }
622 else
623 aRet = aPathName.GetFull();
624 }
625 }
626 }
627 }
628 return aRet;
629}
630
631std::unique_ptr<SwFieldType> SwTemplNameFieldType::Copy() const
632{
633 return std::make_unique<SwTemplNameFieldType>(m_rDoc);
634}
635
637 : SwField(pTyp, nFormat)
638{}
639
640OUString SwTemplNameField::ExpandImpl(SwRootFrame const*const) const
641{
642 return static_cast<SwTemplNameFieldType*>(GetTyp())->Expand(GetFormat());
643}
644
645std::unique_ptr<SwField> SwTemplNameField::Copy() const
646{
647 return std::make_unique<SwTemplNameField>(static_cast<SwTemplNameFieldType*>(GetTyp()), GetFormat());
648}
649
650bool SwTemplNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
651{
652 switch ( nWhichId )
653 {
655 {
656 sal_Int16 nRet;
657 switch( GetFormat() )
658 {
659 case FF_PATH: nRet = text::FilenameDisplayFormat::PATH; break;
661 case FF_NAME: nRet = text::FilenameDisplayFormat::NAME_AND_EXT; break;
662 case FF_UI_RANGE: nRet = text::TemplateDisplayFormat::AREA; break;
663 case FF_UI_NAME: nRet = text::TemplateDisplayFormat::TITLE; break;
664 default: nRet = text::FilenameDisplayFormat::FULL;
665
666 }
667 rAny <<= nRet;
668 }
669 break;
670
671 default:
672 assert(false);
673 }
674 return true;
675}
676
677bool SwTemplNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
678{
679 switch ( nWhichId )
680 {
682 {
683 //JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
684 // called with a int32 value! But normally we need
685 // here only a int16
686 sal_Int32 nType = 0;
687 rAny >>= nType;
688 switch( nType )
689 {
690 case text::FilenameDisplayFormat::PATH:
692 break;
695 break;
696 case text::FilenameDisplayFormat::NAME_AND_EXT:
698 break;
699 case text::TemplateDisplayFormat::AREA :
701 break;
702 case text::TemplateDisplayFormat::TITLE :
704 break;
705 default: SetFormat(FF_PATHNAME);
706 }
707 }
708 break;
709
710 default:
711 assert(false);
712 }
713 return true;
714}
715
718 , m_rDoc(rDocument)
719 , m_nNumberingType(SVX_NUM_ARABIC)
720{
721}
722
723OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, SvxNumType nFormat) const
724{
725 sal_uInt32 nVal = 0;
727 switch( nSubType )
728 {
729 case DS_TBL: nVal = rDStat.nTable; break;
730 case DS_GRF: nVal = rDStat.nGrf; break;
731 case DS_OLE: nVal = rDStat.nOLE; break;
732 case DS_PARA: nVal = rDStat.nPara; break;
733 case DS_WORD: nVal = rDStat.nWord; break;
734 case DS_CHAR: nVal = rDStat.nChar; break;
735 case DS_PAGE:
737 const_cast<SwDocStat &>(rDStat).nPage = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->GetPageNum();
738 nVal = rDStat.nPage;
739 if( SVX_NUM_PAGEDESC == nFormat )
740 nFormat = m_nNumberingType;
741 break;
742 default:
743 OSL_FAIL( "SwDocStatFieldType::Expand: unknown SubType" );
744 }
745
746 if( nVal <= SHRT_MAX )
747 return FormatNumber( nVal, nFormat );
748
749 return OUString::number( nVal );
750}
751
752std::unique_ptr<SwFieldType> SwDocStatFieldType::Copy() const
753{
754 return std::make_unique<SwDocStatFieldType>(m_rDoc);
755}
756
762SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, sal_uInt16 nSub, sal_uInt32 nFormat)
763 : SwField(pTyp, nFormat),
764 m_nSubType(nSub)
765{}
766
767OUString SwDocStatField::ExpandImpl(SwRootFrame const*const) const
768{
769 return static_cast<SwDocStatFieldType*>(GetTyp())->Expand(m_nSubType, static_cast<SvxNumType>(GetFormat()));
770}
771
772std::unique_ptr<SwField> SwDocStatField::Copy() const
773{
774 return std::make_unique<SwDocStatField>(
775 static_cast<SwDocStatFieldType*>(GetTyp()), m_nSubType, GetFormat() );
776}
777
779{
780 return m_nSubType;
781}
782
783void SwDocStatField::SetSubType(sal_uInt16 nSub)
784{
785 m_nSubType = nSub;
786}
787
789{
791 static_cast<SwDocStatFieldType*>(GetTyp())->SetNumFormat(
793}
794
795bool SwDocStatField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
796{
797 switch ( nWhichId )
798 {
800 rAny <<= static_cast<sal_Int16>(GetFormat());
801 break;
802
803 default:
804 assert(false);
805 }
806 return true;
807}
808
809bool SwDocStatField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
810{
811 bool bRet = false;
812 switch ( nWhichId )
813 {
815 {
816 sal_Int16 nSet = 0;
817 rAny >>= nSet;
818 if(nSet <= SVX_NUM_CHARS_LOWER_LETTER_N &&
819 nSet != SVX_NUM_CHAR_SPECIAL &&
820 nSet != SVX_NUM_BITMAP)
821 {
822 SetFormat(nSet);
823 bRet = true;
824 }
825 }
826 break;
827
828 default:
829 assert(false);
830 }
831 return bRet;
832}
833
834// Document info field type
835
838{
839}
840
841std::unique_ptr<SwFieldType> SwDocInfoFieldType::Copy() const
842{
843 return std::make_unique<SwDocInfoFieldType>(GetDoc());
844}
845
847 const LocaleDataWrapper **ppAppLocalData,
848 const LocaleDataWrapper **ppLocalData )
849{
850 SvtSysLocale aLocale;
851 *ppAppLocalData = &aLocale.GetLocaleData();
852 *ppLocalData = *ppAppLocalData;
853 if( nLang != (*ppLocalData)->getLanguageTag().getLanguageType() )
854 *ppLocalData = new LocaleDataWrapper(LanguageTag( nLang ));
855}
856
857OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
858 LanguageType nLang, const OUString& rName ) const
859{
860 const LocaleDataWrapper *pAppLocalData = nullptr, *pLocalData = nullptr;
861 SwDocShell *pDocShell(GetDoc()->GetDocShell());
862 OSL_ENSURE(pDocShell, "no SwDocShell");
863 if (!pDocShell) { return OUString(); }
864
865 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
866 pDocShell->GetModel(), uno::UNO_QUERY_THROW);
867 uno::Reference<document::XDocumentProperties> xDocProps(
868 xDPS->getDocumentProperties());
869 OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties");
870
871 sal_uInt16 nExtSub = nSub & 0xff00;
872 nSub &= 0xff; // do not consider extended SubTypes
873
874 OUString aStr;
875 switch(nSub)
876 {
877 case DI_TITLE: aStr = xDocProps->getTitle(); break;
878 case DI_SUBJECT:aStr = xDocProps->getSubject(); break;
879 case DI_KEYS: aStr = ::comphelper::string::convertCommaSeparated(
880 xDocProps->getKeywords());
881 break;
882 case DI_COMMENT:aStr = xDocProps->getDescription(); break;
883 case DI_DOCNO: aStr = OUString::number(
884 xDocProps->getEditingCycles() );
885 break;
886 case DI_EDIT:
887 if ( !nFormat )
888 {
889 lcl_GetLocalDataWrapper( nLang, &pAppLocalData, &pLocalData );
890 sal_Int32 dur = xDocProps->getEditingDuration();
891 // If Seconds > 0 then bSec should be TRUE otherwise Seconds
892 // information will be lost if file has EditTime in Seconds format.
893 aStr = pLocalData->getTime( tools::Time(dur/3600, (dur%3600)/60, dur%60),
894 dur%60 > 0);
895 }
896 else
897 {
898 sal_Int32 dur = xDocProps->getEditingDuration();
899 double fVal = tools::Time(dur/3600, (dur%3600)/60, dur%60).GetTimeInDays();
900 aStr = ExpandValue(fVal, nFormat, nLang);
901 }
902 break;
903 case DI_CUSTOM:
904 {
905 OUString sVal;
906 try
907 {
908 uno::Any aAny;
909 uno::Reference < beans::XPropertySet > xSet(
910 xDocProps->getUserDefinedProperties(),
911 uno::UNO_QUERY_THROW);
912 aAny = xSet->getPropertyValue( rName );
913
914 uno::Reference < script::XTypeConverter > xConverter( script::Converter::create(comphelper::getProcessComponentContext()) );
915 uno::Any aNew = xConverter->convertToSimpleType( aAny, uno::TypeClass_STRING );
916 aNew >>= sVal;
917 }
918 catch (uno::Exception&) {}
919 return sVal;
920 }
921
922 default:
923 {
924 OUString aName( xDocProps->getAuthor() );
925 util::DateTime uDT( xDocProps->getCreationDate() );
926 DateTime aDate(uDT);
927 if( nSub == DI_CREATE )
928 ; // that's it !!
929 else if( nSub == DI_CHANGE )
930 {
931 aName = xDocProps->getModifiedBy();
932 uDT = xDocProps->getModificationDate();
933 aDate = DateTime(uDT);
934 }
935 else if( nSub == DI_PRINT )
936 {
937 aName = xDocProps->getPrintedBy();
938 uDT = xDocProps->getPrintDate();
939 aDate = DateTime(uDT);
940 }
941 else
942 break;
943
944 if (aDate.IsValidAndGregorian())
945 {
946 switch (nExtSub & ~DI_SUB_FIXED)
947 {
948 case DI_SUB_AUTHOR:
949 aStr = aName;
950 break;
951
952 case DI_SUB_TIME:
953 if (!nFormat)
954 {
955 lcl_GetLocalDataWrapper( nLang, &pAppLocalData,
956 &pLocalData );
957 aStr = pLocalData->getTime( aDate,
958 false);
959 }
960 else
961 {
962 // start the number formatter
963 double fVal = SwDateTimeField::GetDateTime( *GetDoc(),
964 aDate);
965 aStr = ExpandValue(fVal, nFormat, nLang);
966 }
967 break;
968
969 case DI_SUB_DATE:
970 if (!nFormat)
971 {
972 lcl_GetLocalDataWrapper( nLang, &pAppLocalData,
973 &pLocalData );
974 aStr = pLocalData->getDate( aDate );
975 }
976 else
977 {
978 // start the number formatter
979 double fVal = SwDateTimeField::GetDateTime( *GetDoc(),
980 aDate);
981 aStr = ExpandValue(fVal, nFormat, nLang);
982 }
983 break;
984 }
985 }
986 }
987 break;
988 }
989
990 if( pAppLocalData != pLocalData )
991 delete pLocalData;
992
993 return aStr;
994}
995
996// document info field
997
998SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFormat) :
999 SwValueField(pTyp, nFormat), m_nSubType(nSub)
1000{
1001 m_aName = rName;
1002 m_aContent = static_cast<SwDocInfoFieldType*>(GetTyp())->Expand(m_nSubType, nFormat, GetLanguage(), m_aName);
1003}
1004
1005SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat) :
1006 SwValueField(pTyp, nFormat), m_nSubType(nSub)
1007{
1008 m_aName = rName;
1009 m_aContent = rValue;
1010}
1011
1012template<class T>
1013static double lcl_TimeToDouble( const T& rTime )
1014{
1015 const double fNanoSecondsPerDay = 86400000000000.0;
1016 return ( (rTime.Hours * SAL_CONST_INT64(3600000000000))
1017 + (rTime.Minutes * SAL_CONST_INT64( 60000000000))
1018 + (rTime.Seconds * SAL_CONST_INT64( 1000000000))
1019 + (rTime.NanoSeconds))
1020 / fNanoSecondsPerDay;
1021}
1022
1023template<class D>
1024static double lcl_DateToDouble( const D& rDate, const Date& rNullDate )
1025{
1026 tools::Long nDate = Date::DateToDays( rDate.Day, rDate.Month, rDate.Year );
1027 tools::Long nNullDate = Date::DateToDays( rNullDate.GetDay(), rNullDate.GetMonth(), rNullDate.GetYear() );
1028 return double( nDate - nNullDate );
1029}
1030
1031OUString SwDocInfoField::ExpandImpl(SwRootFrame const*const) const
1032{
1033 if ( ( m_nSubType & 0xFF ) == DI_CUSTOM )
1034 {
1035 // custom properties currently need special treatment
1036 // We don't have a secure way to detect "real" custom properties in Word import of text
1037 // fields, so we treat *every* unknown property as a custom property, even the "built-in"
1038 // section in Word's document summary information stream as these properties have not been
1039 // inserted when the document summary information was imported, we do it here.
1040 // This approach is still a lot better than the old one to import such fields as
1041 // "user fields" and simple text
1042 SwDocShell* pDocShell = GetDoc()->GetDocShell();
1043 if( !pDocShell )
1044 return m_aContent;
1045 try
1046 {
1047 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW);
1048 uno::Reference<document::XDocumentProperties> xDocProps( xDPS->getDocumentProperties());
1049 uno::Reference < beans::XPropertySet > xSet( xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
1050 uno::Reference < beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
1051
1052 uno::Any aAny;
1053 if( xSetInfo->hasPropertyByName( m_aName ) )
1054 aAny = xSet->getPropertyValue( m_aName );
1055 if ( aAny.getValueType() != cppu::UnoType<void>::get() )
1056 {
1057 // "void" type means that the property has not been inserted until now
1058 if ( !IsFixed() )
1059 {
1060 // if the field is "fixed" we don't update it from the property
1061 OUString sVal;
1062 uno::Reference < script::XTypeConverter > xConverter( script::Converter::create(comphelper::getProcessComponentContext()) );
1063 util::Date aDate;
1064 util::DateTime aDateTime;
1065 util::Duration aDuration;
1066 if( aAny >>= aDate)
1067 {
1068 SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter();
1069 const Date& rNullDate = pFormatter->GetNullDate();
1070 sVal = ExpandValue( lcl_DateToDouble<util::Date>( aDate, rNullDate ), GetFormat(), GetLanguage());
1071 }
1072 else if( aAny >>= aDateTime )
1073 {
1074 double fDateTime = lcl_TimeToDouble<util::DateTime>( aDateTime );
1075 SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter();
1076 const Date& rNullDate = pFormatter->GetNullDate();
1077 fDateTime += lcl_DateToDouble<util::DateTime>( aDateTime, rNullDate );
1078 sVal = ExpandValue( fDateTime, GetFormat(), GetLanguage());
1079 }
1080 else if( aAny >>= aDuration )
1081 {
1082 sVal = OUStringChar(aDuration.Negative ? '-' : '+')
1084 sVal = sVal.replaceFirst("%1", OUString::number( aDuration.Years ) );
1085 sVal = sVal.replaceFirst("%2", OUString::number( aDuration.Months ) );
1086 sVal = sVal.replaceFirst("%3", OUString::number( aDuration.Days ) );
1087 sVal = sVal.replaceFirst("%4", OUString::number( aDuration.Hours ) );
1088 sVal = sVal.replaceFirst("%5", OUString::number( aDuration.Minutes) );
1089 sVal = sVal.replaceFirst("%6", OUString::number( aDuration.Seconds) );
1090 }
1091 else
1092 {
1093 uno::Any aNew = xConverter->convertToSimpleType( aAny, uno::TypeClass_STRING );
1094 aNew >>= sVal;
1095 }
1096 const_cast<SwDocInfoField*>(this)->m_aContent = sVal;
1097 }
1098 }
1099 }
1100 catch (uno::Exception&) {}
1101 }
1102 else if ( !IsFixed() )
1103 const_cast<SwDocInfoField*>(this)->m_aContent = static_cast<SwDocInfoFieldType*>(GetTyp())->Expand(m_nSubType, GetFormat(), GetLanguage(), m_aName);
1104
1105 return m_aContent;
1106}
1107
1109{
1110 OUString aStr(SwFieldType::GetTypeStr(GetTypeId()) + ":");
1111
1112 sal_uInt16 const nSub = m_nSubType & 0xff;
1113
1114 switch (nSub)
1115 {
1116 case DI_CUSTOM:
1117 aStr += m_aName;
1118 break;
1119
1120 default:
1122 ->aDocInfoLst[ nSub - DI_SUBTYPE_BEGIN ];
1123 break;
1124 }
1125 if (IsFixed())
1126 {
1128 }
1129 return aStr;
1130}
1131
1132std::unique_ptr<SwField> SwDocInfoField::Copy() const
1133{
1134 std::unique_ptr<SwDocInfoField> pField(new SwDocInfoField(static_cast<SwDocInfoFieldType*>(GetTyp()), m_nSubType, m_aName, GetFormat()));
1135 pField->SetAutomaticLanguage(IsAutomaticLanguage());
1136 pField->m_aContent = m_aContent;
1137
1138 return std::unique_ptr<SwField>(pField.release());
1139}
1140
1142{
1143 return m_nSubType;
1144}
1145
1146void SwDocInfoField::SetSubType(sal_uInt16 nSub)
1147{
1148 m_nSubType = nSub;
1149}
1150
1152{
1153 if (!GetFormat())
1155 else
1157}
1158
1159bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1160{
1161 switch( nWhichId )
1162 {
1163 case FIELD_PROP_PAR1:
1164 rAny <<= m_aContent;
1165 break;
1166
1167 case FIELD_PROP_PAR4:
1168 rAny <<= m_aName;
1169 break;
1170
1171 case FIELD_PROP_USHORT1:
1172 rAny <<= static_cast<sal_Int16>(m_aContent.toInt32());
1173 break;
1174
1175 case FIELD_PROP_BOOL1:
1176 rAny <<= 0 != (m_nSubType & DI_SUB_FIXED);
1177 break;
1178
1179 case FIELD_PROP_FORMAT:
1180 rAny <<= static_cast<sal_Int32>(GetFormat());
1181 break;
1182
1183 case FIELD_PROP_DOUBLE:
1184 {
1185 double fVal = GetValue();
1186 rAny <<= fVal;
1187 }
1188 break;
1189 case FIELD_PROP_PAR3:
1190 rAny <<= ExpandImpl(nullptr);
1191 break;
1192 case FIELD_PROP_BOOL2:
1193 {
1194 sal_uInt16 nExtSub = (m_nSubType & 0xff00) & ~DI_SUB_FIXED;
1195 rAny <<= nExtSub == DI_SUB_DATE;
1196 }
1197 break;
1198 default:
1199 return SwField::QueryValue(rAny, nWhichId);
1200 }
1201 return true;
1202}
1203
1204bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1205{
1206 sal_Int32 nValue = 0;
1207 switch( nWhichId )
1208 {
1209 case FIELD_PROP_PAR1:
1210 if( m_nSubType & DI_SUB_FIXED )
1211 rAny >>= m_aContent;
1212 break;
1213
1214 case FIELD_PROP_USHORT1:
1215 if( m_nSubType & DI_SUB_FIXED )
1216 {
1217 rAny >>= nValue;
1218 m_aContent = OUString::number(nValue);
1219 }
1220 break;
1221
1222 case FIELD_PROP_BOOL1:
1223 if(*o3tl::doAccess<bool>(rAny))
1225 else
1226 m_nSubType &= ~DI_SUB_FIXED;
1227 break;
1228 case FIELD_PROP_FORMAT:
1229 {
1230 rAny >>= nValue;
1231 if( nValue >= 0)
1233 }
1234 break;
1235
1236 case FIELD_PROP_PAR3:
1237 rAny >>= m_aContent;
1238 break;
1239 case FIELD_PROP_BOOL2:
1240 m_nSubType &= 0xf0ff;
1241 if(*o3tl::doAccess<bool>(rAny))
1243 else
1245 break;
1246 default:
1247 return SwField::PutValue(rAny, nWhichId);
1248 }
1249 return true;
1250}
1251
1253 : SwFieldType( SwFieldIds::HiddenText ), m_bHidden( bSetHidden )
1254{
1255}
1256
1257std::unique_ptr<SwFieldType> SwHiddenTextFieldType::Copy() const
1258{
1259 return std::make_unique<SwHiddenTextFieldType>( m_bHidden );
1260}
1261
1263{
1264 if( m_bHidden != bSetHidden )
1265 {
1266 m_bHidden = bSetHidden;
1267 UpdateFields(); // notify all HiddenTexts
1268 }
1269}
1270
1272 bool bConditional,
1273 OUString aCond,
1274 const OUString& rStr,
1275 bool bHidden,
1276 SwFieldTypesEnum nSub) :
1277 SwField( pFieldType ), m_aCond(std::move(aCond)), m_nSubType(nSub),
1278 m_bCanToggle(bConditional), m_bIsHidden(bHidden), m_bValid(false)
1279{
1281 {
1282 sal_Int32 nPos = 0;
1283 m_aTRUEText = rStr.getToken(0, '|', nPos);
1284
1285 if(nPos != -1)
1286 {
1287 m_aFALSEText = rStr.getToken(0, '|', nPos);
1288 if(nPos != -1)
1289 {
1290 m_aContent = rStr.getToken(0, '|', nPos);
1291 m_bValid = true;
1292 }
1293 }
1294 }
1295 else
1296 m_aTRUEText = rStr;
1297}
1298
1300 OUString aCond,
1301 OUString aTrue,
1302 OUString aFalse,
1303 SwFieldTypesEnum nSub)
1304 : SwField( pFieldType ), m_aTRUEText(std::move(aTrue)), m_aFALSEText(std::move(aFalse)), m_aCond(std::move(aCond)), m_nSubType(nSub),
1305 m_bIsHidden(true), m_bValid(false)
1306{
1307 m_bCanToggle = !m_aCond.isEmpty();
1308}
1309
1311{
1312 // Type: !Hidden -> show always
1313 // Hide -> evaluate condition
1314
1316 {
1317 if( m_bValid )
1318 return m_aContent;
1319
1320 if( m_bCanToggle && !m_bIsHidden )
1321 return m_aTRUEText;
1322 }
1323 else if( !static_cast<SwHiddenTextFieldType*>(GetTyp())->GetHiddenFlag() ||
1325 return m_aTRUEText;
1326
1327 return m_aFALSEText;
1328}
1329
1332{
1334 return;
1335
1336#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS
1337 (void) rDoc;
1338#else
1339 SwDBManager* pMgr = rDoc.GetDBManager();
1340#endif
1341 m_bValid = false;
1342 OUString sTmpName = (m_bCanToggle && !m_bIsHidden) ? m_aTRUEText : m_aFALSEText;
1343
1344 // Database expressions need to be different from normal text. Therefore, normal text is set
1345 // in quotes. If the latter exist they will be removed. If not, check if potential DB name.
1346 // Only if there are two or more dots and no quotes, we assume a database.
1347 if (sTmpName.getLength()>1 &&
1348 sTmpName.startsWith("\"") &&
1349 sTmpName.endsWith("\""))
1350 {
1351 m_aContent = sTmpName.copy(1, sTmpName.getLength() - 2);
1352 m_bValid = true;
1353 }
1354 else if(sTmpName.indexOf('\"')<0 &&
1355 comphelper::string::getTokenCount(sTmpName, '.') > 2)
1356 {
1357 sTmpName = ::ReplacePoint(sTmpName);
1358 if(sTmpName.startsWith("[") && sTmpName.endsWith("]"))
1359 { // remove brackets
1360 sTmpName = sTmpName.copy(1, sTmpName.getLength() - 2);
1361 }
1362#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
1363 if( pMgr)
1364 {
1365 sal_Int32 nIdx{ 0 };
1366 OUString sDBName( GetDBName( sTmpName, rDoc ));
1367 OUString sDataSource(sDBName.getToken(0, DB_DELIM, nIdx));
1368 OUString sDataTableOrQuery(sDBName.getToken(0, DB_DELIM, nIdx));
1369 if( pMgr->IsInMerge() && !sDBName.isEmpty() &&
1370 pMgr->IsDataSourceOpen( sDataSource,
1371 sDataTableOrQuery, false))
1372 {
1373 double fNumber;
1374 pMgr->GetMergeColumnCnt(GetColumnName( sTmpName ),
1375 GetLanguage(), m_aContent, &fNumber );
1376 m_bValid = true;
1377 }
1378 else if( !sDBName.isEmpty() && !sDataSource.isEmpty() &&
1379 !sDataTableOrQuery.isEmpty() )
1380 m_bValid = true;
1381 }
1382#endif
1383 }
1384}
1385
1387{
1389 " " + m_aCond + " " + m_aTRUEText;
1390
1392 {
1393 aStr += " : " + m_aFALSEText;
1394 }
1395 return aStr;
1396}
1397
1398std::unique_ptr<SwField> SwHiddenTextField::Copy() const
1399{
1400 std::unique_ptr<SwHiddenTextField> pField(
1403 pField->m_bIsHidden = m_bIsHidden;
1404 pField->m_bValid = m_bValid;
1405 pField->m_aContent = m_aContent;
1406 pField->SetFormat(GetFormat());
1407 pField->m_nSubType = m_nSubType;
1408 return std::unique_ptr<SwField>(pField.release());
1409}
1410
1412void SwHiddenTextField::SetPar1(const OUString& rStr)
1413{
1414 m_aCond = rStr;
1415 m_bCanToggle = !m_aCond.isEmpty();
1416}
1417
1419{
1420 return m_aCond;
1421}
1422
1424void SwHiddenTextField::SetPar2(const OUString& rStr)
1425{
1427 {
1428 sal_Int32 nPos = rStr.indexOf('|');
1429 if (nPos == -1)
1430 m_aTRUEText = rStr;
1431 else
1432 {
1433 m_aTRUEText = rStr.copy(0, nPos);
1434 m_aFALSEText = rStr.copy(nPos + 1);
1435 }
1436 }
1437 else
1438 m_aTRUEText = rStr;
1439}
1440
1443{
1445 {
1446 return m_aTRUEText;
1447 }
1448 return m_aTRUEText + "|" + m_aFALSEText;
1449}
1450
1452{
1453 return static_cast<sal_uInt16>(m_nSubType);
1454}
1455
1456bool SwHiddenTextField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1457{
1458 switch( nWhichId )
1459 {
1460 case FIELD_PROP_PAR1:
1461 rAny <<= m_aCond;
1462 break;
1463 case FIELD_PROP_PAR2:
1464 rAny <<= m_aTRUEText;
1465 break;
1466 case FIELD_PROP_PAR3:
1467 rAny <<= m_aFALSEText;
1468 break;
1469 case FIELD_PROP_PAR4 :
1470 rAny <<= m_aContent;
1471 break;
1472 case FIELD_PROP_BOOL1:
1473 rAny <<= m_bIsHidden;
1474 break;
1475 default:
1476 assert(false);
1477 }
1478 return true;
1479}
1480
1481bool SwHiddenTextField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1482{
1483 switch( nWhichId )
1484 {
1485 case FIELD_PROP_PAR1:
1486 {
1487 OUString sVal;
1488 rAny >>= sVal;
1489 SetPar1(sVal);
1490 }
1491 break;
1492 case FIELD_PROP_PAR2:
1493 rAny >>= m_aTRUEText;
1494 break;
1495 case FIELD_PROP_PAR3:
1496 rAny >>= m_aFALSEText;
1497 break;
1498 case FIELD_PROP_BOOL1:
1499 m_bIsHidden = *o3tl::doAccess<bool>(rAny);
1500 break;
1501 case FIELD_PROP_PAR4:
1502 rAny >>= m_aContent;
1503 m_bValid = true;
1504 break;
1505 default:
1506 assert(false);
1507 }
1508 return true;
1509}
1510
1511OUString SwHiddenTextField::GetColumnName(const OUString& rName)
1512{
1513 sal_Int32 nPos = rName.indexOf(DB_DELIM);
1514 if( nPos>=0 )
1515 {
1516 nPos = rName.indexOf(DB_DELIM, nPos + 1);
1517
1518 if( nPos>=0 )
1519 return rName.copy(nPos + 1);
1520 }
1521 return rName;
1522}
1523
1524OUString SwHiddenTextField::GetDBName(std::u16string_view rName, SwDoc& rDoc)
1525{
1526 size_t nPos = rName.find(DB_DELIM);
1527 if( nPos != std::u16string_view::npos )
1528 {
1529 nPos = rName.find(DB_DELIM, nPos + 1);
1530
1531 if( nPos != std::u16string_view::npos )
1532 return OUString(rName.substr(0, nPos));
1533 }
1534
1535 SwDBData aData = rDoc.GetDBData();
1536 return aData.sDataSource + OUStringChar(DB_DELIM) + aData.sCommand;
1537}
1538
1539// [aFieldDefinition] value sample : " IF A == B \"TrueText\" \"FalseText\""
1540void SwHiddenTextField::ParseIfFieldDefinition(const OUString& aFieldDefinition,
1541 OUString& rCondition,
1542 OUString& rTrue,
1543 OUString& rFalse)
1544{
1545 // get all positions inside the input string where words are started
1546 //
1547 // In: " IF A == B \"TrueText\" \"FalseText\""
1548 // 0 1 2 3
1549 // 01234567890 123456789 01 2345678901 2
1550 //
1551 // result:
1552 // [1, 4, 6, 9, 11, 22]
1553 std::vector<sal_Int32> wordPosition;
1554 {
1555 bool quoted = false;
1556 bool insideWord = false;
1557 for (sal_Int32 i = 0; i < aFieldDefinition.getLength(); i++)
1558 {
1559 if (quoted)
1560 {
1561 if (aFieldDefinition[i] == '\"')
1562 {
1563 quoted = false;
1564 insideWord = false;
1565 }
1566 }
1567 else
1568 {
1569 if (aFieldDefinition[i] == ' ')
1570 {
1571 // word delimiter
1572 insideWord = false;
1573 }
1574 else
1575 {
1576 if (insideWord)
1577 {
1578 quoted = (aFieldDefinition[i] == '\"');
1579 }
1580 else
1581 {
1582 insideWord = true;
1583 wordPosition.push_back(i);
1584 quoted = (aFieldDefinition[i] == '\"');
1585 }
1586 }
1587 }
1588 }
1589 }
1590
1591 // first word is always "IF"
1592 // last two words are: true-case and false-case,
1593 // everything before is treated as condition expression
1594 // => we need at least 4 words to be inside the input string
1595 if (wordPosition.size() < 4)
1596 {
1597 return;
1598 }
1599
1600
1601 const sal_Int32 conditionBegin = wordPosition[1];
1602 const sal_Int32 trueBegin = wordPosition[wordPosition.size() - 2];
1603 const sal_Int32 falseBegin = wordPosition[wordPosition.size() - 1];
1604
1605 const sal_Int32 conditionLength = trueBegin - conditionBegin;
1606 const sal_Int32 trueLength = falseBegin - trueBegin;
1607
1608 // Syntax
1609 // OUString::copy( sal_Int32 beginIndex, sal_Int32 count )
1610 rCondition = aFieldDefinition.copy(conditionBegin, conditionLength);
1611 rTrue = aFieldDefinition.copy(trueBegin, trueLength);
1612 rFalse = aFieldDefinition.copy(falseBegin);
1613
1614 // trim
1615 rCondition = rCondition.trim();
1616 rTrue = rTrue.trim();
1617 rFalse = rFalse.trim();
1618
1619 // remove quotes
1620 if (rCondition.getLength() >= 2)
1621 {
1622 if (rCondition[0] == '\"' && rCondition[rCondition.getLength() - 1] == '\"')
1623 rCondition = rCondition.copy(1, rCondition.getLength() - 2);
1624 }
1625 if (rTrue.getLength() >= 2)
1626 {
1627 if (rTrue[0] == '\"' && rTrue[rTrue.getLength() - 1] == '\"')
1628 rTrue = rTrue.copy(1, rTrue.getLength() - 2);
1629 }
1630 if (rFalse.getLength() >= 2)
1631 {
1632 if (rFalse[0] == '\"' && rFalse[rFalse.getLength() - 1] == '\"')
1633 rFalse = rFalse.copy(1, rFalse.getLength() - 2);
1634 }
1635
1636 // Note: do not make trim once again, while this is a user defined data
1637}
1638
1639// field type for line height 0
1640
1643{
1644}
1645
1646std::unique_ptr<SwFieldType> SwHiddenParaFieldType::Copy() const
1647{
1648 return std::make_unique<SwHiddenParaFieldType>();
1649}
1650
1651// field for line height 0
1652
1654 : SwField(pTyp), m_aCond(std::move(aStr))
1655{
1656 m_bIsHidden = false;
1657}
1658
1660{
1661 return OUString();
1662}
1663
1664std::unique_ptr<SwField> SwHiddenParaField::Copy() const
1665{
1666 std::unique_ptr<SwHiddenParaField> pField(new SwHiddenParaField(static_cast<SwHiddenParaFieldType*>(GetTyp()), m_aCond));
1667 pField->m_bIsHidden = m_bIsHidden;
1668 return std::unique_ptr<SwField>(pField.release());
1669}
1670
1671bool SwHiddenParaField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1672{
1673 switch ( nWhichId )
1674 {
1675 case FIELD_PROP_PAR1:
1676 rAny <<= m_aCond;
1677 break;
1678 case FIELD_PROP_BOOL1:
1679 rAny <<= m_bIsHidden;
1680 break;
1681
1682 default:
1683 assert(false);
1684 }
1685 return true;
1686}
1687
1688bool SwHiddenParaField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1689{
1690 switch ( nWhichId )
1691 {
1692 case FIELD_PROP_PAR1:
1693 rAny >>= m_aCond;
1694 break;
1695 case FIELD_PROP_BOOL1:
1696 m_bIsHidden = *o3tl::doAccess<bool>(rAny);
1697 break;
1698
1699 default:
1700 assert(false);
1701 }
1702 return true;
1703}
1704
1706void SwHiddenParaField::SetPar1(const OUString& rStr)
1707{
1708 m_aCond = rStr;
1709}
1710
1712{
1713 return m_aCond;
1714}
1715
1716// PostIt field type
1717
1720 , mrDoc(rDoc)
1721{}
1722
1723std::unique_ptr<SwFieldType> SwPostItFieldType::Copy() const
1724{
1725 return std::make_unique<SwPostItFieldType>(mrDoc);
1726}
1727
1728// PostIt field
1729
1730sal_uInt32 SwPostItField::s_nLastPostItId = 1;
1731
1733 OUString aAuthor,
1734 OUString aText,
1735 OUString aInitials,
1736 OUString aName,
1737 const DateTime& rDateTime,
1738 const bool bResolved,
1739 const sal_uInt32 nPostItId
1740)
1741 : SwField( pT )
1742 , m_sText( std::move(aText) )
1743 , m_sAuthor( std::move(aAuthor) )
1744 , m_sInitials( std::move(aInitials) )
1745 , m_sName( std::move(aName) )
1746 , m_aDateTime( rDateTime )
1747 , m_bResolved( bResolved )
1748{
1749 m_nPostItId = nPostItId == 0 ? s_nLastPostItId++ : nPostItId;
1750}
1751
1753{
1754 if ( m_xTextObject.is() )
1755 {
1756 m_xTextObject->DisposeEditSource();
1757 }
1758
1759 mpText.reset();
1760}
1761
1762OUString SwPostItField::ExpandImpl(SwRootFrame const*const) const
1763{
1764 return OUString();
1765}
1766
1768{
1769 return SwResId(STR_NOTE);
1770}
1771
1772void SwPostItField::SetResolved(bool bNewState)
1773{
1774 m_bResolved = bNewState;
1775}
1776
1778{
1780}
1781
1783{
1784 return m_bResolved;
1785}
1786
1787std::unique_ptr<SwField> SwPostItField::Copy() const
1788{
1789 std::unique_ptr<SwPostItField> pRet(new SwPostItField( static_cast<SwPostItFieldType*>(GetTyp()), m_sAuthor, m_sText, m_sInitials, m_sName,
1791 if (mpText)
1792 pRet->SetTextObject( *mpText );
1793
1794 // Note: member <m_xTextObject> not copied.
1795
1796 return std::unique_ptr<SwField>(pRet.release());
1797}
1798
1800void SwPostItField::SetPar1(const OUString& rStr)
1801{
1802 m_sAuthor = rStr;
1803}
1804
1807{
1808 return m_sAuthor;
1809}
1810
1812void SwPostItField::SetPar2(const OUString& rStr)
1813{
1814 m_sText = rStr;
1815}
1816
1819{
1820 return m_sText;
1821}
1822
1823
1824void SwPostItField::SetName(const OUString& rName)
1825{
1826 m_sName = rName;
1827}
1828
1829
1831{
1832 mpText = std::move(pText);
1833}
1834
1836{
1837 return mpText ? mpText->Count() : 1;
1838}
1839
1840void SwPostItField::SetPostItId(const sal_uInt32 nPostItId)
1841{
1842 m_nPostItId = nPostItId == 0 ? s_nLastPostItId++ : nPostItId;
1843}
1844
1845bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
1846{
1847 switch( nWhichId )
1848 {
1849 case FIELD_PROP_PAR1:
1850 rAny <<= m_sAuthor;
1851 break;
1852 case FIELD_PROP_PAR2:
1853 {
1854 rAny <<= m_sText;
1855 break;
1856 }
1857 case FIELD_PROP_PAR3:
1858 rAny <<= m_sInitials;
1859 break;
1860 case FIELD_PROP_PAR4:
1861 rAny <<= m_sName;
1862 break;
1863 case FIELD_PROP_BOOL1:
1864 rAny <<= m_bResolved;
1865 break;
1866 case FIELD_PROP_TEXT:
1867 {
1868 if ( !m_xTextObject.is() )
1869 {
1870 SwPostItFieldType* pGetType = static_cast<SwPostItFieldType*>(GetTyp());
1871 SwDoc& rDoc = pGetType->GetDoc();
1872 auto pObj = std::make_unique<SwTextAPIEditSource>( &rDoc );
1873 const_cast <SwPostItField*> (this)->m_xTextObject = new SwTextAPIObject( std::move(pObj) );
1874 }
1875
1876 if ( mpText )
1877 m_xTextObject->SetText( *mpText );
1878 else
1879 m_xTextObject->SetString( m_sText );
1880
1881 uno::Reference < text::XText > xText( m_xTextObject );
1882 rAny <<= xText;
1883 break;
1884 }
1885 case FIELD_PROP_DATE:
1886 {
1887 rAny <<= m_aDateTime.GetUNODate();
1888 }
1889 break;
1891 {
1892 rAny <<= m_aDateTime.GetUNODateTime();
1893 }
1894 break;
1895 default:
1896 assert(false);
1897 }
1898 return true;
1899}
1900
1901bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
1902{
1903 switch( nWhichId )
1904 {
1905 case FIELD_PROP_PAR1:
1906 rAny >>= m_sAuthor;
1907 break;
1908 case FIELD_PROP_PAR2:
1909 rAny >>= m_sText;
1910 //#i100374# new string via api, delete complex text object so SwPostItNote picks up the new string
1911 mpText.reset();
1912 break;
1913 case FIELD_PROP_PAR3:
1914 rAny >>= m_sInitials;
1915 break;
1916 case FIELD_PROP_PAR4:
1917 rAny >>= m_sName;
1918 break;
1919 case FIELD_PROP_BOOL1:
1920 rAny >>= m_bResolved;
1921 break;
1922 case FIELD_PROP_TEXT:
1923 OSL_FAIL("Not implemented!");
1924 break;
1925 case FIELD_PROP_DATE:
1926 if( auto aSetDate = o3tl::tryAccess<util::Date>(rAny) )
1927 {
1928 m_aDateTime = Date(aSetDate->Day, aSetDate->Month, aSetDate->Year);
1929 }
1930 break;
1932 {
1933 util::DateTime aDateTimeValue;
1934 if(!(rAny >>= aDateTimeValue))
1935 return false;
1936 m_aDateTime = DateTime(aDateTimeValue);
1937 }
1938 break;
1939 default:
1940 assert(false);
1941 }
1942 return true;
1943}
1944
1946{
1947 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPostItField"));
1948 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
1949
1950 SwField::dumpAsXml(pWriter);
1951
1952 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mpText"));
1953 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", mpText ? &*mpText : nullptr);
1954 if (mpText)
1955 mpText->dumpAsXml(pWriter);
1956 (void)xmlTextWriterEndElement(pWriter);
1957
1958 (void)xmlTextWriterEndElement(pWriter);
1959}
1960
1961// extended user information field type
1962
1965{
1966}
1967
1968std::unique_ptr<SwFieldType> SwExtUserFieldType::Copy() const
1969{
1970 return std::make_unique<SwExtUserFieldType>();
1971}
1972
1973OUString SwExtUserFieldType::Expand(sal_uInt16 nSub )
1974{
1975 UserOptToken nRet = static_cast<UserOptToken>(USHRT_MAX);
1976 switch(nSub)
1977 {
1978 case EU_FIRSTNAME: nRet = UserOptToken::FirstName; break;
1979 case EU_NAME: nRet = UserOptToken::LastName; break;
1980 case EU_SHORTCUT: nRet = UserOptToken::ID; break;
1981
1982 case EU_COMPANY: nRet = UserOptToken::Company; break;
1983 case EU_STREET: nRet = UserOptToken::Street; break;
1984 case EU_TITLE: nRet = UserOptToken::Title; break;
1985 case EU_POSITION: nRet = UserOptToken::Position; break;
1986 case EU_PHONE_PRIVATE: nRet = UserOptToken::TelephoneHome; break;
1987 case EU_PHONE_COMPANY: nRet = UserOptToken::TelephoneWork; break;
1988 case EU_FAX: nRet = UserOptToken::Fax; break;
1989 case EU_EMAIL: nRet = UserOptToken::Email; break;
1990 case EU_COUNTRY: nRet = UserOptToken::Country; break;
1991 case EU_ZIP: nRet = UserOptToken::Zip; break;
1992 case EU_CITY: nRet = UserOptToken::City; break;
1993 case EU_STATE: nRet = UserOptToken::State; break;
1994 case EU_FATHERSNAME: nRet = UserOptToken::FathersName; break;
1995 case EU_APARTMENT: nRet = UserOptToken::Apartment; break;
1996 default: OSL_ENSURE( false, "Field unknown");
1997 }
1998 if( static_cast<UserOptToken>(USHRT_MAX) != nRet )
1999 {
2000 SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
2001 return rUserOpt.GetToken( nRet );
2002 }
2003 return OUString();
2004}
2005
2006// extended user information field
2007
2008SwExtUserField::SwExtUserField(SwExtUserFieldType* pTyp, sal_uInt16 nSubTyp, sal_uInt32 nFormat) :
2009 SwField(pTyp, nFormat), m_nType(nSubTyp)
2010{
2012}
2013
2014OUString SwExtUserField::ExpandImpl(SwRootFrame const*const) const
2015{
2016 if (!IsFixed())
2018
2019 return m_aContent;
2020}
2021
2022std::unique_ptr<SwField> SwExtUserField::Copy() const
2023{
2024 std::unique_ptr<SwExtUserField> pField(new SwExtUserField(static_cast<SwExtUserFieldType*>(GetTyp()), m_nType, GetFormat()));
2025 pField->SetExpansion(m_aContent);
2026
2027 return std::unique_ptr<SwField>(pField.release());
2028}
2029
2031{
2032 return m_nType;
2033}
2034
2035void SwExtUserField::SetSubType(sal_uInt16 nSub)
2036{
2037 m_nType = nSub;
2038}
2039
2040bool SwExtUserField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
2041{
2042 switch( nWhichId )
2043 {
2044 case FIELD_PROP_PAR1:
2045 rAny <<= m_aContent;
2046 break;
2047
2048 case FIELD_PROP_USHORT1:
2049 {
2050 sal_Int16 nTmp = m_nType;
2051 rAny <<= nTmp;
2052 }
2053 break;
2054 case FIELD_PROP_BOOL1:
2055 rAny <<= IsFixed();
2056 break;
2057 default:
2058 assert(false);
2059 }
2060 return true;
2061}
2062
2063bool SwExtUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
2064{
2065 switch( nWhichId )
2066 {
2067 case FIELD_PROP_PAR1:
2068 rAny >>= m_aContent;
2069 break;
2070
2071 case FIELD_PROP_USHORT1:
2072 {
2073 sal_Int16 nTmp = 0;
2074 rAny >>= nTmp;
2075 m_nType = nTmp;
2076 }
2077 break;
2078 case FIELD_PROP_BOOL1:
2079 if( *o3tl::doAccess<bool>(rAny) )
2081 else
2083 break;
2084 default:
2085 assert(false);
2086 }
2087 return true;
2088}
2089
2090// field type for relative page numbers
2091
2094{
2095}
2096
2097std::unique_ptr<SwFieldType> SwRefPageSetFieldType::Copy() const
2098{
2099 return std::make_unique<SwRefPageSetFieldType>();
2100}
2101
2102// overridden since there is nothing to update
2104{
2105}
2106
2107// field for relative page numbers
2108
2110 short nOff, bool bFlag )
2111 : SwField( pTyp ), m_nOffset( nOff ), m_bOn( bFlag )
2112{
2113}
2114
2116{
2117 return OUString();
2118}
2119
2120std::unique_ptr<SwField> SwRefPageSetField::Copy() const
2121{
2122 return std::make_unique<SwRefPageSetField>( static_cast<SwRefPageSetFieldType*>(GetTyp()), m_nOffset, m_bOn );
2123}
2124
2126{
2127 return OUString::number(GetOffset());
2128}
2129
2130void SwRefPageSetField::SetPar2(const OUString& rStr)
2131{
2132 SetOffset( static_cast<short>(rStr.toInt32()) );
2133}
2134
2135bool SwRefPageSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
2136{
2137 switch( nWhichId )
2138 {
2139 case FIELD_PROP_BOOL1:
2140 rAny <<= m_bOn;
2141 break;
2142 case FIELD_PROP_USHORT1:
2143 rAny <<= static_cast<sal_Int16>(m_nOffset);
2144 break;
2145 default:
2146 assert(false);
2147 }
2148 return true;
2149}
2150
2151bool SwRefPageSetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
2152{
2153 switch( nWhichId )
2154 {
2155 case FIELD_PROP_BOOL1:
2156 m_bOn = *o3tl::doAccess<bool>(rAny);
2157 break;
2158 case FIELD_PROP_USHORT1:
2159 rAny >>=m_nOffset;
2160 break;
2161 default:
2162 assert(false);
2163 }
2164 return true;
2165}
2166
2167// relative page numbers - query field
2168
2170 : SwFieldType( SwFieldIds::RefPageGet ), m_rDoc( rDc ), m_nNumberingType( SVX_NUM_ARABIC )
2171{
2172}
2173
2174std::unique_ptr<SwFieldType> SwRefPageGetFieldType::Copy() const
2175{
2176 std::unique_ptr<SwRefPageGetFieldType> pNew(new SwRefPageGetFieldType( m_rDoc ));
2177 pNew->m_nNumberingType = m_nNumberingType;
2178 return pNew;
2179}
2180
2182{
2183 if (rHint.GetId() != SfxHintId::SwLegacyModify)
2184 return;
2185 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
2186 auto const ModifyImpl = [this](SwRootFrame const*const pLayout)
2187 {
2188 // first collect all SetPageRefFields
2189 SetGetExpFields aTmpLst;
2190 if (MakeSetList(aTmpLst, pLayout))
2191 {
2192 std::vector<SwFormatField*> vFields;
2193 GatherFields(vFields);
2194 for(auto pFormatField: vFields)
2195 UpdateField(pFormatField->GetTextField(), aTmpLst, pLayout);
2196 }
2197 };
2198
2199 // update all GetReference fields
2200 if( !pLegacy->m_pNew && !pLegacy->m_pOld && HasWriterListeners() )
2201 {
2202 SwRootFrame const* pLayout(nullptr);
2203 SwRootFrame const* pLayoutRLHidden(nullptr);
2204 for (SwRootFrame const*const pLay : m_rDoc.GetAllLayouts())
2205 {
2206 if (pLay->IsHideRedlines())
2207 {
2208 pLayoutRLHidden = pLay;
2209 }
2210 else
2211 {
2212 pLayout = pLay;
2213 }
2214 }
2215 ModifyImpl(pLayout);
2216 if (pLayoutRLHidden)
2217 {
2218 ModifyImpl(pLayoutRLHidden);
2219 }
2220 }
2221
2222 // forward to text fields, they "expand" the text
2223 CallSwClientNotify(rHint);
2224}
2225
2227 SwRootFrame const*const pLayout)
2228{
2230 std::vector<SwFormatField*> vFields;
2231 GatherFields(vFields);
2232 for(auto pFormatField: vFields)
2233 {
2234 // update only the GetRef fields
2235 const SwTextField* pTField = pFormatField->GetTextField();
2236 if (!pLayout || !pLayout->IsHideRedlines() || !sw::IsFieldDeletedInModel(rIDRA, *pTField))
2237 {
2238 const SwTextNode& rTextNd = pTField->GetTextNode();
2239
2240 // Always the first! (in Tab-Headline, header/footer )
2241 Point aPt;
2242 std::pair<Point, bool> const tmp(aPt, false);
2243 const SwContentFrame *const pFrame = rTextNd.getLayoutFrame(
2244 pLayout, nullptr, &tmp);
2245
2246 std::unique_ptr<SetGetExpField> pNew;
2247
2248 if( !pFrame ||
2249 pFrame->IsInDocBody() ||
2250 // #i31868#
2251 // Check if pFrame is not yet connected to the layout.
2252 !pFrame->FindPageFrame() )
2253 {
2254 pNew.reset( new SetGetExpField( rTextNd, pTField ) );
2255 }
2256 else
2257 {
2258 // create index for determination of the TextNode
2260 bool const bResult = GetBodyTextNode( m_rDoc, aPos, *pFrame );
2261 OSL_ENSURE(bResult, "where is the Field?");
2262 pNew.reset( new SetGetExpField( aPos.GetNode(), pTField,
2263 aPos.GetContentIndex() ) );
2264 }
2265
2266 rTmpLst.insert( std::move(pNew) );
2267 }
2268 }
2269 return !rTmpLst.empty();
2270}
2271
2273 SetGetExpFields const & rSetList,
2274 SwRootFrame const*const pLayout)
2275{
2276 SwRefPageGetField* pGetField = const_cast<SwRefPageGetField*>(static_cast<const SwRefPageGetField*>(pTextField->GetFormatField().GetField()));
2277 pGetField->SetText( OUString(), pLayout );
2278
2279 // then search the correct RefPageSet field
2280 SwTextNode* pTextNode = &pTextField->GetTextNode();
2281 if( pTextNode->StartOfSectionIndex() >
2283 {
2284 SetGetExpField aEndField( *pTextNode, pTextField );
2285
2286 SetGetExpFields::const_iterator itLast = rSetList.lower_bound( &aEndField );
2287
2288 if( itLast != rSetList.begin() )
2289 {
2290 --itLast;
2291 const SwTextField* pRefTextField = (*itLast)->GetTextField();
2292 const SwRefPageSetField* pSetField =
2293 static_cast<const SwRefPageSetField*>(pRefTextField->GetFormatField().GetField());
2294 if( pSetField->IsOn() )
2295 {
2296 // determine the correct offset
2297 Point aPt;
2298 std::pair<Point, bool> const tmp(aPt, false);
2299 const SwContentFrame *const pFrame = pTextNode->getLayoutFrame(
2300 pLayout, nullptr, &tmp);
2301 const SwContentFrame *const pRefFrame = pRefTextField->GetTextNode().getLayoutFrame(
2302 pLayout, nullptr, &tmp);
2303 const SwPageFrame* pPgFrame = nullptr;
2304 short nDiff = 1;
2305 if ( pFrame && pRefFrame )
2306 {
2307 pPgFrame = pFrame->FindPageFrame();
2308 nDiff = pPgFrame->GetPhyPageNum() -
2309 pRefFrame->FindPageFrame()->GetPhyPageNum() + 1;
2310 }
2311
2312 SvxNumType nTmpFormat = SVX_NUM_PAGEDESC == static_cast<SvxNumType>(pGetField->GetFormat())
2313 ? ( !pPgFrame
2315 : pPgFrame->GetPageDesc()->GetNumType().GetNumberingType() )
2316 : static_cast<SvxNumType>(pGetField->GetFormat());
2317 const short nPageNum = std::max<short>(0, pSetField->GetOffset() + nDiff);
2318 pGetField->SetText(FormatNumber(nPageNum, nTmpFormat), pLayout);
2319 }
2320 }
2321 }
2322 // start formatting
2323 const_cast<SwFormatField&>(pTextField->GetFormatField()).UpdateTextNode(nullptr, nullptr);
2324}
2325
2326// queries for relative page numbering
2327
2329 sal_uInt32 nFormat )
2330 : SwField( pTyp, nFormat )
2331{
2332}
2333
2334void SwRefPageGetField::SetText(const OUString& rText,
2335 SwRootFrame const*const pLayout)
2336{
2337 if (!pLayout || !pLayout->IsHideRedlines())
2338 {
2339 m_sText = rText;
2340 }
2341 if (!pLayout || pLayout->IsHideRedlines())
2342 {
2343 m_sTextRLHidden = rText;
2344 }
2345}
2346
2347OUString SwRefPageGetField::ExpandImpl(SwRootFrame const*const pLayout) const
2348{
2349 return pLayout && pLayout->IsHideRedlines() ? m_sTextRLHidden : m_sText;
2350}
2351
2352std::unique_ptr<SwField> SwRefPageGetField::Copy() const
2353{
2354 std::unique_ptr<SwRefPageGetField> pCpy(new SwRefPageGetField(
2355 static_cast<SwRefPageGetFieldType*>(GetTyp()), GetFormat() ));
2356 pCpy->m_sText = m_sText;
2357 pCpy->m_sTextRLHidden = m_sTextRLHidden;
2358 return std::unique_ptr<SwField>(pCpy.release());
2359}
2360
2362 const SwTextField* pField )
2363{
2364 // only fields in Footer, Header, FootNote, Flys
2365 SwRefPageGetFieldType* pGetType = static_cast<SwRefPageGetFieldType*>(GetTyp());
2366 SwDoc& rDoc = pGetType->GetDoc();
2367 if( pField->GetTextNode().StartOfSectionIndex() >
2368 rDoc.GetNodes().GetEndOfExtras().GetIndex() )
2369 return;
2370
2371 SwRootFrame const& rLayout(*rFrame.getRootFrame());
2372 OUString & rText(rLayout.IsHideRedlines() ? m_sTextRLHidden : m_sText);
2373 rText.clear();
2374
2375 OSL_ENSURE(!rFrame.IsInDocBody(), "Flag incorrect, frame is in DocBody");
2376
2377 // collect all SetPageRefFields
2378 SetGetExpFields aTmpLst;
2379 if (!pGetType->MakeSetList(aTmpLst, &rLayout))
2380 return ;
2381
2382 // create index for determination of the TextNode
2383 SwPosition aPos( rDoc.GetNodes() );
2384 SwTextNode* pTextNode = const_cast<SwTextNode*>(GetBodyTextNode(rDoc, aPos, rFrame));
2385
2386 // If no layout exists, ChangeExpansion is called for header and
2387 // footer lines via layout formatting without existing TextNode.
2388 if(!pTextNode)
2389 return;
2390
2391 SetGetExpField aEndField( aPos.GetNode(), pField, aPos.GetContentIndex() );
2392
2393 SetGetExpFields::const_iterator itLast = aTmpLst.lower_bound( &aEndField );
2394
2395 if( itLast == aTmpLst.begin() )
2396 return; // there is no corresponding set-field in front
2397 --itLast;
2398
2399 const SwTextField* pRefTextField = (*itLast)->GetTextField();
2400 const SwRefPageSetField* pSetField =
2401 static_cast<const SwRefPageSetField*>(pRefTextField->GetFormatField().GetField());
2402 Point aPt;
2403 std::pair<Point, bool> const tmp(aPt, false);
2404 const SwContentFrame *const pRefFrame = pRefTextField->GetTextNode().getLayoutFrame(
2405 &rLayout, nullptr, &tmp);
2406 if( !(pSetField->IsOn() && pRefFrame) )
2407 return;
2408
2409 // determine the correct offset
2410 const SwPageFrame* pPgFrame = rFrame.FindPageFrame();
2411 const short nDiff = pPgFrame->GetPhyPageNum() -
2412 pRefFrame->FindPageFrame()->GetPhyPageNum() + 1;
2413
2414 SwRefPageGetField* pGetField = const_cast<SwRefPageGetField*>(static_cast<const SwRefPageGetField*>(pField->GetFormatField().GetField()));
2415 SvxNumType nTmpFormat = SVX_NUM_PAGEDESC == pGetField->GetFormat()
2416 ? pPgFrame->GetPageDesc()->GetNumType().GetNumberingType()
2417 : static_cast<SvxNumType>(pGetField->GetFormat());
2418 const short nPageNum = std::max<short>(0, pSetField->GetOffset() + nDiff);
2419 pGetField->SetText(FormatNumber(nPageNum, nTmpFormat), &rLayout);
2420}
2421
2422bool SwRefPageGetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
2423{
2424 switch( nWhichId )
2425 {
2426 case FIELD_PROP_USHORT1:
2427 rAny <<= static_cast<sal_Int16>(GetFormat());
2428 break;
2429 case FIELD_PROP_PAR1:
2430 rAny <<= m_sText;
2431 break;
2432 default:
2433 assert(false);
2434 }
2435 return true;
2436}
2437
2438bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
2439{
2440 switch( nWhichId )
2441 {
2442 case FIELD_PROP_USHORT1:
2443 {
2444 sal_Int16 nSet = 0;
2445 rAny >>= nSet;
2446 if(nSet <= SVX_NUM_PAGEDESC )
2447 SetFormat(nSet);
2448 }
2449 break;
2450 case FIELD_PROP_PAR1:
2451 rAny >>= m_sText;
2453 break;
2454 default:
2455 assert(false);
2456 }
2457 return true;
2458}
2459
2460// field type to jump to and edit
2461
2463 : SwFieldType( SwFieldIds::JumpEdit ), m_rDoc( rD ), m_aDep( *this )
2464{
2465}
2466
2467std::unique_ptr<SwFieldType> SwJumpEditFieldType::Copy() const
2468{
2469 return std::make_unique<SwJumpEditFieldType>( m_rDoc );
2470}
2471
2473{
2475 m_aDep.StartListening(pFormat);
2476 return pFormat;
2477}
2478
2480 OUString aText, OUString aHelp )
2481 : SwField( pTyp, nForm ), m_sText( std::move(aText) ), m_sHelp( std::move(aHelp) )
2482{
2483}
2484
2485OUString SwJumpEditField::ExpandImpl(SwRootFrame const*const) const
2486{
2487 return "<" + m_sText + ">";
2488}
2489
2490std::unique_ptr<SwField> SwJumpEditField::Copy() const
2491{
2492 return std::make_unique<SwJumpEditField>( static_cast<SwJumpEditFieldType*>(GetTyp()), GetFormat(),
2493 m_sText, m_sHelp );
2494}
2495
2498{
2499 return m_sText;
2500}
2501
2503void SwJumpEditField::SetPar1(const OUString& rStr)
2504{
2505 m_sText = rStr;
2506}
2507
2510{
2511 return m_sHelp;
2512}
2513
2515void SwJumpEditField::SetPar2(const OUString& rStr)
2516{
2517 m_sHelp = rStr;
2518}
2519
2520bool SwJumpEditField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
2521{
2522 switch( nWhichId )
2523 {
2524 case FIELD_PROP_USHORT1:
2525 {
2526 sal_Int16 nRet;
2527 switch( GetFormat() )
2528 {
2529 case JE_FMT_TABLE: nRet = text::PlaceholderType::TABLE; break;
2530 case JE_FMT_FRAME: nRet = text::PlaceholderType::TEXTFRAME; break;
2531 case JE_FMT_GRAPHIC:nRet = text::PlaceholderType::GRAPHIC; break;
2532 case JE_FMT_OLE: nRet = text::PlaceholderType::OBJECT; break;
2533 default:
2534 nRet = text::PlaceholderType::TEXT; break;
2535 }
2536 rAny <<= nRet;
2537 }
2538 break;
2539 case FIELD_PROP_PAR1 :
2540 rAny <<= m_sHelp;
2541 break;
2542 case FIELD_PROP_PAR2 :
2543 rAny <<= m_sText;
2544 break;
2545 default:
2546 assert(false);
2547 }
2548 return true;
2549}
2550
2551bool SwJumpEditField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
2552{
2553 switch( nWhichId )
2554 {
2555 case FIELD_PROP_USHORT1:
2556 {
2557 //JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
2558 // called with a int32 value! But normally we need
2559 // here only a int16
2560 sal_Int32 nSet = 0;
2561 rAny >>= nSet;
2562 switch( nSet )
2563 {
2564 case text::PlaceholderType::TEXT : SetFormat(JE_FMT_TEXT); break;
2565 case text::PlaceholderType::TABLE : SetFormat(JE_FMT_TABLE); break;
2566 case text::PlaceholderType::TEXTFRAME: SetFormat(JE_FMT_FRAME); break;
2567 case text::PlaceholderType::GRAPHIC : SetFormat(JE_FMT_GRAPHIC); break;
2568 case text::PlaceholderType::OBJECT : SetFormat(JE_FMT_OLE); break;
2569 }
2570 }
2571 break;
2572 case FIELD_PROP_PAR1 :
2573 rAny >>= m_sHelp;
2574 break;
2575 case FIELD_PROP_PAR2 :
2576 rAny >>= m_sText;
2577 break;
2578 default:
2579 assert(false);
2580 }
2581 return true;
2582}
2583
2584// combined character field type
2585
2588{
2589}
2590
2591std::unique_ptr<SwFieldType> SwCombinedCharFieldType::Copy() const
2592{
2593 return std::make_unique<SwCombinedCharFieldType>();
2594}
2595
2596// combined character field
2597
2599 const OUString& rChars )
2600 : SwField( pFTyp, 0 ),
2601 m_sCharacters( rChars.copy( 0, std::min<sal_Int32>(rChars.getLength(), MAX_COMBINED_CHARACTERS) ))
2602{
2603}
2604
2606{
2607 return m_sCharacters;
2608}
2609
2610std::unique_ptr<SwField> SwCombinedCharField::Copy() const
2611{
2612 return std::make_unique<SwCombinedCharField>( static_cast<SwCombinedCharFieldType*>(GetTyp()),
2613 m_sCharacters );
2614}
2615
2617{
2618 return m_sCharacters;
2619}
2620
2621void SwCombinedCharField::SetPar1(const OUString& rStr)
2622{
2623 m_sCharacters = rStr.copy(0, std::min<sal_Int32>(rStr.getLength(), MAX_COMBINED_CHARACTERS));
2624}
2625
2627 sal_uInt16 nWhichId ) const
2628{
2629 switch( nWhichId )
2630 {
2631 case FIELD_PROP_PAR1:
2632 rAny <<= m_sCharacters;
2633 break;
2634 default:
2635 assert(false);
2636 }
2637 return true;
2638}
2639
2641 sal_uInt16 nWhichId )
2642{
2643 switch( nWhichId )
2644 {
2645 case FIELD_PROP_PAR1:
2646 {
2647 OUString sTmp;
2648 rAny >>= sTmp;
2649 SetPar1(sTmp);
2650 }
2651 break;
2652 default:
2653 assert(false);
2654 }
2655 return true;
2656}
2657
2658/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
css::util::DateTime GetUNODateTime() const
css::util::Date GetUNODate() const
bool IsValidAndGregorian() const
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
static sal_Int32 DateToDays(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
sal_uInt16 GetMonth() const
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual const SwDocStat & GetDocStat() const =0
Document - Statistics.
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetBase() const
OUString PathToFileName() const
INetProtocol GetProtocol() const
OUString GetFull() const
sal_Int32 Count() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
bool GetLogicNames(std::u16string_view rPath, OUString &rRegion, OUString &rName) const
SfxHintId GetId() const
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
const INetURLObject & GetURLObject() const
bool HasName() const
SfxMedium * GetMedium() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
const Date & GetNullDate() const
const LocaleDataWrapper & GetLocaleData() const
OUString GetFullName() const
OUString GetID() const
OUString GetToken(UserOptToken nToken) const
SvxNumType GetNumberingType() const
static OUString Expand(sal_uLong)
Definition: docufld.cxx:313
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:322
OUString m_aContent
Definition: docufld.hxx:190
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:333
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:342
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:350
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:375
SwAuthorField(SwAuthorFieldType *, sal_uInt32 nFormat)
Definition: docufld.cxx:327
Represents the style of a text portion.
Definition: charfmt.hxx:27
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:2591
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:2640
virtual void SetPar1(const OUString &rStr) override
Definition: docufld.cxx:2621
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:2610
OUString m_sCharacters
combine these characters
Definition: docufld.hxx:742
virtual OUString GetPar1() const override
Characters.
Definition: docufld.cxx:2616
SwCombinedCharField(SwCombinedCharFieldType *, const OUString &rChars)
Definition: docufld.cxx:2598
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:2626
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:2605
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1224
bool IsInMerge() const
Definition: dbmgr.hxx:343
bool IsDataSourceOpen(const OUString &rDataSource, const OUString &rTableOrQuery, bool bMergeShell)
check if a data source is open
Definition: dbmgr.cxx:2010
bool GetMergeColumnCnt(const OUString &rColumnName, LanguageType nLanguage, OUString &rResult, double *pNumber)
Definition: dbmgr.cxx:2094
static double GetDateTime(SwDoc &rDoc, const DateTime &rDT)
Definition: flddat.cxx:122
SwDocInfoFieldType(SwDoc *pDc)
Definition: docufld.cxx:836
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:841
OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFormat, LanguageType nLang, const OUString &rName) const
Definition: docufld.cxx:857
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:1132
virtual OUString GetFieldName() const override
get name or content
Definition: docufld.cxx:1108
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: docufld.cxx:1151
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:1204
virtual void SetSubType(sal_uInt16) override
Definition: docufld.cxx:1146
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:1031
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:1159
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:1141
OUString m_aName
Definition: docufld.hxx:526
OUString m_aContent
Definition: docufld.hxx:525
sal_uInt16 m_nSubType
Definition: docufld.hxx:524
SwDocInfoField(SwDocInfoFieldType *, sal_uInt16 nSub, const OUString &rName, sal_uInt32 nFormat=0)
Definition: docufld.cxx:998
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:204
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:752
SwDocStatFieldType(SwDoc &)
Definition: docufld.cxx:716
SvxNumType m_nNumberingType
Definition: docufld.hxx:255
OUString Expand(sal_uInt16 nSubType, SvxNumType nFormat) const
Definition: docufld.cxx:723
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:809
sal_uInt16 m_nSubType
Definition: docufld.hxx:267
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:778
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:795
void ChangeExpansion(const SwFrame *pFrame)
Definition: docufld.cxx:788
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:767
SwDocStatField(SwDocStatFieldType *, sal_uInt16 nSubType, sal_uInt32 nFormat)
Definition: docufld.cxx:762
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:772
virtual void SetSubType(sal_uInt16 nSub) override
Definition: docufld.cxx:783
Definition: doc.hxx:192
SwDBData const & GetDBData()
Definition: docfld.cxx:383
o3tl::sorted_vector< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1667
SwDBManager * GetDBManager() const
Definition: doc.hxx:674
SwNodes & GetNodes()
Definition: doc.hxx:413
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:336
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:406
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:427
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1322
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1414
SwDocShell * GetDocShell()
Definition: doc.hxx:1355
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:374
static OUString Expand(sal_uInt16 nSubType)
Definition: docufld.cxx:1973
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:1968
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:2030
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:2014
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:2022
SwExtUserField(SwExtUserFieldType *, sal_uInt16 nSub, sal_uInt32 nFormat)
Definition: docufld.cxx:2008
OUString m_aContent
Definition: docufld.hxx:558
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:2063
sal_uInt16 m_nType
Definition: docufld.hxx:559
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:2040
virtual void SetSubType(sal_uInt16 nSub) override
Definition: docufld.cxx:2035
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
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
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:257
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:853
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 bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
Definition: fldbas.cxx:369
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:408
bool IsFixed() const
Definition: fldbas.cxx:452
OUString Expand(sal_uLong) const
Definition: docufld.cxx:409
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:461
SwFileNameFieldType(SwDoc &)
Definition: docufld.cxx:403
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:489
SwFileNameField(SwFileNameFieldType *, sal_uInt32 nFormat)
Definition: docufld.cxx:466
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:472
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:527
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:480
OUString m_aContent
Definition: docufld.hxx:216
const SwField * GetField() const
Definition: fmtfld.hxx:130
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:36
Base class for various Writer styles.
Definition: format.hxx:47
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsInDocBody() const
Definition: frame.hxx:943
SwRootFrame * getRootFrame()
Definition: frame.hxx:679
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:1646
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:1664
SwHiddenParaField(SwHiddenParaFieldType *, OUString aCond)
Direct input, delete old value.
Definition: docufld.cxx:1653
virtual void SetPar1(const OUString &rStr) override
set condition
Definition: docufld.cxx:1706
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:1671
OUString m_aCond
Definition: docufld.hxx:366
virtual OUString GetPar1() const override
Query, set condition.
Definition: docufld.cxx:1711
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:1659
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:1688
virtual void UpdateFields() override
Definition: docufld.hxx:291
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:1257
SwHiddenTextFieldType(bool bSetHidden=true)
Definition: docufld.cxx:1252
void SetHiddenFlag(bool bSetHidden)
Definition: docufld.cxx:1262
void Evaluate(SwDoc &rDoc)
get current field value and cache it
Definition: docufld.cxx:1331
static OUString GetDBName(std::u16string_view rName, SwDoc &rDoc)
Definition: docufld.cxx:1524
OUString m_aContent
Evaluated DB-text.
Definition: docufld.hxx:301
bool m_bValid
Is DB-field evaluated?
Definition: docufld.hxx:308
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:1451
OUString m_aTRUEText
Text if condition true.
Definition: docufld.hxx:299
OUString m_aFALSEText
If condition false.
Definition: docufld.hxx:300
static OUString GetColumnName(const OUString &rName)
Definition: docufld.cxx:1511
SwFieldTypesEnum m_nSubType
Definition: docufld.hxx:304
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:1398
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:1481
bool m_bIsHidden
Is it not visible?
Definition: docufld.hxx:307
bool m_bCanToggle
Can field be toggled alone?
Definition: docufld.hxx:306
virtual OUString GetFieldName() const override
get name or content
Definition: docufld.cxx:1386
OUString m_aCond
Condition.
Definition: docufld.hxx:303
static void ParseIfFieldDefinition(const OUString &aFieldDefinition, OUString &rCondition, OUString &rTrue, OUString &rFalse)
Definition: docufld.cxx:1540
virtual void SetPar1(const OUString &rStr) override
Condition.
Definition: docufld.cxx:1412
virtual void SetPar2(const OUString &rStr) override
True/False - String.
Definition: docufld.cxx:1424
virtual OUString GetPar1() const override
Definition: docufld.cxx:1418
virtual OUString GetPar2() const override
get True/False text
Definition: docufld.cxx:1442
SwHiddenTextField(SwHiddenTextFieldType *, bool bConditional, OUString aCond, const OUString &rText, bool bHidden, SwFieldTypesEnum nSubType=SwFieldTypesEnum::HiddenText)
Definition: docufld.cxx:1271
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:1456
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:1310
TElementType * First()
Definition: calbck.hxx:356
SwCharFormat * GetCharFormat()
Definition: docufld.cxx:2472
sw::WriterMultiListener m_aDep
Definition: docufld.hxx:654
SwJumpEditFieldType(SwDoc &rDoc)
Definition: docufld.cxx:2462
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:2467
OUString m_sText
Definition: docufld.hxx:666
virtual void SetPar2(const OUString &rStr) override
set hint text
Definition: docufld.cxx:2515
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:2490
virtual OUString GetPar1() const override
Placeholder-Text.
Definition: docufld.cxx:2497
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:2485
SwJumpEditField(SwJumpEditFieldType *, sal_uInt32 nFormat, OUString sText, OUString sHelp)
Definition: docufld.cxx:2479
virtual void SetPar1(const OUString &rStr) override
set place holder text
Definition: docufld.cxx:2503
OUString m_sHelp
Definition: docufld.hxx:667
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:2551
virtual OUString GetPar2() const override
Hint-Text.
Definition: docufld.cxx:2509
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:2520
bool HasWriterListeners() const
Definition: calbck.hxx:202
SwNodeOffset GetIndex() const
Definition: node.hxx:296
SwNodeOffset StartOfSectionIndex() const
Definition: node.hxx:702
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:154
const SvxNumberType & GetNumType() const
Definition: pagedesc.hxx:202
A page of the document layout.
Definition: pagefrm.hxx:58
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:120
SvxNumType m_nNumberingType
Definition: docufld.hxx:133
OUString Expand(SvxNumType nFormat, short nOff, sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage, const OUString &, LanguageType=LANGUAGE_NONE) const
Definition: docufld.cxx:104
void ChangeExpansion(SwDoc *pDoc, bool bVirtPageNum, const SvxNumType *pNumFormat)
Definition: docufld.cxx:130
sal_uInt16 m_nMaxPage
Definition: docufld.hxx:154
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:209
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:265
OUString m_sUserStr
Definition: docufld.hxx:149
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:183
void ChangeExpansion(sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage)
Definition: docufld.cxx:176
virtual OUString GetPar2() const override
Definition: docufld.cxx:219
SwPageNumberField(SwPageNumberFieldType *, sal_uInt16 nSub, sal_uInt32 nFormat, short nOff=0, sal_uInt16 const nPageNumber=0, sal_uInt16 const nMaxPage=0)
Definition: docufld.cxx:167
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:229
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:234
sal_uInt16 m_nSubType
Definition: docufld.hxx:150
sal_uInt16 m_nPageNumber
Definition: docufld.hxx:153
virtual void SetPar2(const OUString &rStr) override
Definition: docufld.cxx:224
SwDoc & GetDoc() const
Definition: docufld.hxx:442
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:1723
SwPostItFieldType(SwDoc &rDoc)
Definition: docufld.cxx:1718
virtual ~SwPostItField() override
Definition: docufld.cxx:1752
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:1845
bool GetResolved() const
Definition: docufld.cxx:1782
virtual OUString GetPar1() const override
Author.
Definition: docufld.cxx:1806
virtual OUString GetDescription() const override
Definition: docufld.cxx:1767
void SetName(const OUString &rStr)
Definition: docufld.cxx:1824
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:1787
const OUString & GetName() const
Definition: docufld.hxx:496
OUString m_sAuthor
Definition: docufld.hxx:451
rtl::Reference< SwTextAPIObject > m_xTextObject
Definition: docufld.hxx:457
OUString m_sInitials
Initials of the author.
Definition: docufld.hxx:452
void SetPostItId(const sal_uInt32 nPostItId=0)
Definition: docufld.cxx:1840
OUString m_sText
Definition: docufld.hxx:450
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: docufld.cxx:1945
virtual void SetPar1(const OUString &rStr) override
set author
Definition: docufld.cxx:1800
SwPostItField(SwPostItFieldType *, OUString aAuthor, OUString aText, OUString aInitials, OUString aName, const DateTime &rDate, const bool bResolved=false, const sal_uInt32 nPostItId=0)
Definition: docufld.cxx:1732
bool m_bResolved
Definition: docufld.hxx:455
static sal_uInt32 s_nLastPostItId
Definition: docufld.hxx:461
sal_uInt32 m_nPostItId
Definition: docufld.hxx:458
DateTime m_aDateTime
Definition: docufld.hxx:454
sal_Int32 GetNumberOfParagraphs() const
Definition: docufld.cxx:1835
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:1901
void SetTextObject(std::optional< OutlinerParaObject > pText)
Definition: docufld.cxx:1830
virtual void SetPar2(const OUString &rStr) override
set the PostIt's text
Definition: docufld.cxx:1812
void ToggleResolved()
Definition: docufld.cxx:1777
void SetResolved(bool bNewState)
Definition: docufld.cxx:1772
virtual OUString GetPar2() const override
Text.
Definition: docufld.cxx:1818
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:1762
std::optional< OutlinerParaObject > mpText
Definition: docufld.hxx:456
OUString m_sName
Name of the comment.
Definition: docufld.hxx:453
SwDoc & GetDoc() const
Definition: docufld.hxx:628
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:2174
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
overwritten to update all RefPageGet fields
Definition: docufld.cxx:2181
sal_Int16 m_nNumberingType
Definition: docufld.hxx:617
SwRefPageGetFieldType(SwDoc &rDoc)
Definition: docufld.cxx:2169
bool MakeSetList(SetGetExpFields &rTmpLst, SwRootFrame const *pLayout)
Definition: docufld.cxx:2226
void UpdateField(SwTextField const *pTextField, SetGetExpFields const &rSetList, SwRootFrame const *pLayout)
Definition: docufld.cxx:2272
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:2422
void ChangeExpansion(const SwFrame &rFrame, const SwTextField *pField)
Definition: docufld.cxx:2361
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:2438
OUString m_sText
Definition: docufld.hxx:634
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:2352
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:2347
void SetText(const OUString &rText, SwRootFrame const *pLayout)
Definition: docufld.cxx:2334
OUString m_sTextRLHidden
hidden redlines
Definition: docufld.hxx:635
SwRefPageGetField(SwRefPageGetFieldType *, sal_uInt32 nFormat)
Definition: docufld.cxx:2328
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
noop, there is nothing to update!
Definition: docufld.cxx:2103
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:2097
void SetOffset(short nOff)
Definition: docufld.hxx:608
SwRefPageSetField(SwRefPageSetFieldType *, short nOff, bool bOn)
Definition: docufld.cxx:2109
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:2115
bool IsOn() const
Definition: docufld.hxx:605
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:2151
virtual OUString GetPar2() const override
Definition: docufld.cxx:2125
virtual void SetPar2(const OUString &rStr) override
Definition: docufld.cxx:2130
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:2135
short GetOffset() const
Definition: docufld.hxx:607
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:2120
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:312
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
Definition: rootfrm.hxx:421
OUString Expand(sal_uLong) const
Definition: docufld.cxx:581
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: docufld.cxx:631
SwTemplNameFieldType(SwDoc &)
Definition: docufld.cxx:575
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: docufld.cxx:640
SwTemplNameField(SwTemplNameFieldType *, sal_uInt32 nFormat)
Definition: docufld.cxx:636
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: docufld.cxx:677
virtual std::unique_ptr< SwField > Copy() const override
Definition: docufld.cxx:645
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: docufld.cxx:650
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:199
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:89
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:415
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
return value formatted as string
Definition: fldbas.cxx:547
SwDoc * GetDoc() const
Definition: fldbas.hxx:425
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
SwDoc * GetDoc() const
Definition: fldbas.hxx:459
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2662
const_iterator begin() const
bool empty() const
std::pair< const_iterator, bool > insert(Value &&x)
const_iterator lower_bound(const Value &x) const
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
void StartListening(SwModify *pDepend)
Definition: calbck.cxx:269
double GetTimeInDays() const
SwDoc & m_rDoc
Definition: docbm.cxx:1201
static void lcl_GetLocalDataWrapper(LanguageType nLang, const LocaleDataWrapper **ppAppLocalData, const LocaleDataWrapper **ppLocalData)
Definition: docufld.cxx:846
static double lcl_TimeToDouble(const T &rTime)
Definition: docufld.cxx:1013
#define URL_DECODE
Definition: docufld.cxx:91
static double lcl_DateToDouble(const D &rDate, const Date &rNullDate)
Definition: docufld.cxx:1024
#define MAX_COMBINED_CHARACTERS
Definition: docufld.hxx:738
@ EU_APARTMENT
Definition: docufld.hxx:119
@ EU_PHONE_PRIVATE
Definition: docufld.hxx:113
@ EU_TITLE
Definition: docufld.hxx:111
@ EU_PHONE_COMPANY
Definition: docufld.hxx:114
@ EU_FIRSTNAME
Definition: docufld.hxx:104
@ EU_FAX
Definition: docufld.hxx:115
@ EU_NAME
Definition: docufld.hxx:105
@ EU_EMAIL
Definition: docufld.hxx:116
@ EU_STREET
Definition: docufld.hxx:107
@ EU_COMPANY
Definition: docufld.hxx:103
@ EU_FATHERSNAME
Definition: docufld.hxx:118
@ EU_POSITION
Definition: docufld.hxx:112
@ EU_ZIP
Definition: docufld.hxx:109
@ EU_SHORTCUT
Definition: docufld.hxx:106
@ EU_CITY
Definition: docufld.hxx:110
@ EU_COUNTRY
Definition: docufld.hxx:108
@ EU_STATE
Definition: docufld.hxx:117
@ JE_FMT_TEXT
Definition: docufld.hxx:124
@ JE_FMT_GRAPHIC
Definition: docufld.hxx:127
@ JE_FMT_TABLE
Definition: docufld.hxx:125
@ JE_FMT_OLE
Definition: docufld.hxx:128
@ JE_FMT_FRAME
Definition: docufld.hxx:126
@ PG_NEXT
Definition: docufld.hxx:93
@ PG_RANDOM
Definition: docufld.hxx:92
@ PG_PREV
Definition: docufld.hxx:94
@ DS_CHAR
Definition: docufld.hxx:57
@ DS_GRF
Definition: docufld.hxx:59
@ DS_TBL
Definition: docufld.hxx:58
@ DS_OLE
Definition: docufld.hxx:60
@ DS_PAGE
Definition: docufld.hxx:54
@ DS_WORD
Definition: docufld.hxx:56
@ DS_PARA
Definition: docufld.hxx:55
@ AF_SHORTCUT
Definition: docufld.hxx:46
@ AF_NAME
Definition: docufld.hxx:45
@ AF_FIXED
Definition: docufld.hxx:47
OUString m_sName
Reference< XTypeConverter > xConverter
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
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
@ FF_UI_RANGE
Definition: fldbas.hxx:160
@ FF_UI_NAME
Definition: fldbas.hxx:159
@ FF_FIXED
Definition: fldbas.hxx:162
@ FF_NAME_NOEXT
Definition: fldbas.hxx:158
@ FF_PATH
Definition: fldbas.hxx:157
@ FF_END
Definition: fldbas.hxx:161
@ FF_NAME
Definition: fldbas.hxx:155
@ FF_PATHNAME
Definition: fldbas.hxx:156
SwFieldIds
Definition: fldbas.hxx:45
DocumentType eType
sal_Int16 nValue
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
OUString aName
sal_uInt16 nPos
aStr
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
sal_Int32 GetEnumAsInt32(const css::uno::Any &rVal)
Definition: swunohelper.cxx:50
SVL_DLLPUBLIC OUString removePassword(OUString const &rURI, INetURLObject::EncodeMechanism eEncodeMechanism, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
double getLength(const B2DPolygon &rCandidate)
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
Reference< XComponentContext > getProcessComponentContext()
void copy(const fs::path &src, const fs::path &dest)
int i
const SwDocInfoSubType DI_DOCNO
Definition: docufld.hxx:78
const SwDocInfoSubType DI_SUB_AUTHOR
Definition: docufld.hxx:83
const SwDocInfoSubType DI_CUSTOM
Definition: docufld.hxx:80
const SwDocInfoSubType DI_CHANGE
Definition: docufld.hxx:76
const SwDocInfoSubType DI_COMMENT
Definition: docufld.hxx:74
const SwDocInfoSubType DI_SUBTYPE_BEGIN
NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward ...
Definition: docufld.hxx:70
const SwDocInfoSubType DI_SUB_FIXED
Definition: docufld.hxx:86
const SwDocInfoSubType DI_PRINT
Definition: docufld.hxx:77
const SwDocInfoSubType DI_SUB_DATE
Definition: docufld.hxx:85
const SwDocInfoSubType DI_KEYS
Definition: docufld.hxx:73
const SwDocInfoSubType DI_EDIT
Definition: docufld.hxx:79
const SwDocInfoSubType DI_SUBJECT
Definition: docufld.hxx:72
const SwDocInfoSubType DI_TITLE
Definition: docufld.hxx:71
const SwDocInfoSubType DI_SUB_TIME
Definition: docufld.hxx:84
const SwDocInfoSubType DI_CREATE
Definition: docufld.hxx:75
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
@ RES_POOLCHR_JUMPEDIT
Placeholder.
Definition: poolfmt.hxx:122
QPRO_FUNC_TYPE nType
sal_uIntPtr sal_uLong
static LanguageType nLang
Definition: srtdlg.cxx:51
OUString sDurationFormat
Definition: shellres.hxx:50
OUString aFixedStr
Definition: shellres.hxx:48
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:62
sal_uLong nWord
Definition: docstat.hxx:35
sal_uInt16 nOLE
Definition: docstat.hxx:29
sal_uInt16 nTable
Definition: docstat.hxx:27
sal_uInt16 nGrf
Definition: docstat.hxx:28
sal_uLong nPara
paragraphs for document statistic: non-empty and non-hidden ones
Definition: docstat.hxx:32
sal_uLong nPage
Definition: docstat.hxx:30
sal_uLong nChar
Definition: docstat.hxx:37
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
SvxNumType
SVX_NUM_NUMBER_NONE
SVX_NUM_CHARS_LOWER_LETTER_N
SVX_NUM_ARABIC
SVX_NUM_BITMAP
SVX_NUM_CHAR_SPECIAL
SVX_NUM_PAGEDESC
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
#define SW_MOD()
Definition: swmodule.hxx:256
#define DB_DELIM
Definition: swtypes.hxx:130
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
#define FIELD_PROP_DATE_TIME
Definition: unofldmid.h:38
#define FIELD_PROP_DATE
Definition: unofldmid.h:30
#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_TEXT
Definition: unofldmid.h:49
#define FIELD_PROP_TITLE
Definition: unofldmid.h:50
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
#define FIELD_PROP_PAR4
Definition: unofldmid.h:36
#define FIELD_PROP_PAR2
Definition: unofldmid.h:24
UserOptToken