27#include <osl/diagnose.h>
32#include <com/sun/star/text/SetVariableType.hpp>
33#include <unofield.hxx>
72 nRet = SetVariableType::VAR;
75 nRet = SetVariableType::SEQUENCE;
78 nRet = SetVariableType::FORMULA;
81 nRet = SetVariableType::STRING;
99 OSL_FAIL(
"wrong value");
105OUString
ReplacePoint(
const OUString& rTmpName,
bool bWithCommandType )
110 sal_Int32
nIndex = rTmpName.lastIndexOf(
'.');
116 OUString sRes = rTmpName.replaceAt(
nIndex, 1, rtl::OUStringChar(
DB_DELIM));
118 if (bWithCommandType)
128 nIndex = sRes.indexOf(
'.');
145 while(
nullptr != (pCNd = rNodes.
GoNext( &rPos ) ) &&
148 OSL_ENSURE( pTextNode,
"Where is the 1. TextNode?" );
175 OSL_ENSURE( pFlyFormat,
"Could not find FlyFormat, where is the field?" );
179 if( RndStdIds::FLY_AT_FLY == rAnchor.
GetAnchorId() )
185 else if ((RndStdIds::FLY_AT_PARA == rAnchor.
GetAnchorId()) ||
186 (RndStdIds::FLY_AT_CHAR == rAnchor.
GetAnchorId()) ||
192 if ( RndStdIds::FLY_AT_PARA == rAnchor.
GetAnchorId() )
198 pLayout =
static_cast<const SwFlyFrame*
>(pLayout)->GetAnchorFrame()
224 nullptr != (pTab = pContentFrame->
FindTabFrame()) && pTab->IsFollow() &&
269 return std::make_unique<SwGetExpFieldType>(
GetDoc());
280 , m_fValueRLHidden(0.0)
282 m_bIsInBodyText( true ),
284 m_bLateInitialization( false )
325 pTmp->SwValueField::SetValue(
GetValue());
331 pTmp->SetLateInitialization();
333 return std::unique_ptr<SwField>(pTmp.release());
341 OSL_ENSURE( !rFrame.
IsInDocBody(),
"Flag incorrect, frame is in DocBody" );
429 rAny <<= static_cast<sal_Int32>(
GetFormat());
470 m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp);
485 if(*o3tl::doAccess<bool>(rAny))
507 m_nType(nTyp),
m_nLevel( UCHAR_MAX ),
553 std::vector<SwFormatField*> vFields;
555 for(
auto pFormatField: vFields)
556 pFormatField->GetField()->ChangeFormat(nFormat);
561 if( !HasWriterListeners() )
564 std::vector<SwFormatField*> vFields;
566 return vFields.front()->GetField()->GetFormat();
574 std::vector<sal_uInt16>
aArr;
577 std::vector<SwFormatField*> vFields;
580 if(pF->GetField() != &rField)
585 if( USHRT_MAX != nNum )
587 std::vector<sal_uInt16>::size_type
n {0};
589 for(
n = 0;
n <
aArr.size(); ++
n )
590 if(
aArr[
n ] >= nNum )
598 std::vector<sal_uInt16>::size_type
n =
aArr.size();
599 OSL_ENSURE(
n <= std::numeric_limits<sal_uInt16>::max(),
"Array is too big for using a sal_uInt16 index" );
601 if (
n > 0 &&
aArr[
n-1 ] !=
n-1 )
603 for(
n = 0;
n <
aArr.size(); ++
n )
618 std::vector<SwFormatField*> vFields;
623 if(
nullptr != ( pNd = pF->GetTextField()->GetpTextNode() )
633 return rList.
Count();
654 if( !sNumber.isEmpty() )
659 OSL_ENSURE(pTextNd->
GetNum(
nullptr),
"<SwSetExpFieldType::SetChapter(..)> - text node with numbering rule, but without number. This is a serious defect");
695 SetType(o3tl::narrowing<sal_uInt16>(nSet));
702 if( !sTmp.isEmpty() )
726 const sal_Int32 nLen =
aBuf.getLength();
727 for (sal_Int32
i = 0;
i < nLen; ++
i)
745 size_t nO =
maData.size();
755 sal_Int32 nFndPos2 = 0;
756 const OUString sNum2( rTmp2.getToken( 0,
' ', nFndPos2 ));
758 sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.toInt32() : 0;
763 const size_t nM = nU + ( nO - nU ) / 2;
766 const OUString rTmp1 =
maData[nM].sDlgEntry;
767 sal_Int32 nFndPos1 = 0;
768 const OUString sNum1( rTmp1.getToken( 0,
' ', nFndPos1 ));
771 if( bIsNum2IsNumeric && rCC.
isNumeric( sNum1 ) )
773 sal_Int32 nNum1 = sNum1.toInt32();
774 nCmp = nNum2 - nNum1;
777 OUString aTmp1 = nFndPos1 != -1 ? rTmp1.copy(nFndPos1) : OUString();
778 OUString aTmp2 = nFndPos2 != -1 ? rTmp2.copy(nFndPos2) : OUString();
783 nCmp = rColl.compareString( rTmp2, rTmp1 );
805 , m_fValueRLHidden(0.0)
806 , mnSeqNo( USHRT_MAX )
808 , mpFormatField(nullptr)
817 if( rFormel.isEmpty() )
868 pTmp->SwValueField::SetValue(
GetValue());
879 return std::unique_ptr<SwField>(pTmp.release());
887 OSL_ENSURE( (nSub & 0xff) != 3,
"SubType is illegal!" );
971 sal_Int32 nRet = nHint ? nHint : pTextField->
GetStart() + 1;
972 OUString sNodeText = rTextNode.
GetText();
974 if(nRet<sNodeText.getLength())
976 sNodeText = sNodeText.copy(nRet);
993 if( RTL_TEXTENCODING_SYMBOL != aSet.
Get( nFontWhich ).GetCharSet() )
1001 (c0 ==
' ' || c0 ==
'\t'))
1005 const sal_Int32 nLen = sNodeText.getLength();
1006 for (sal_Int32
i = 1;
1007 i<nLen && (sNodeText[
i]==
' ' || sNodeText[
i]==
'\t');
1046 sal_Int32 nTmp32 = 0;
1047 sal_Int16 nTmp16 = 0;
1051 if(*o3tl::doAccess<bool>(rAny))
1063 if(nTmp16 <= css::style::NumberingType::NUMBER_NONE )
1110 if(*o3tl::doAccess<bool>(rAny))
1117 bool newInput(*o3tl::doAccess<bool>(rAny));
1153 rAny <<= static_cast<sal_Int32>(
GetFormat());
1156 rAny <<= static_cast<sal_Int16>(
GetFormat());
1159 rAny <<= static_cast<sal_Int16>(
mnSeqNo);
1170 rAny <<= sMyFormula;
1208 return std::make_unique<SwInputFieldType>(
mpDoc );
1218 , maContent(
std::move(aContent))
1219 , maPText(
std::move(aPrompt))
1221 , mbIsFormField( bIsFormField )
1222 , mpFormatField( nullptr )
1249 if (!pUserTyp->IsModifyLocked())
1253 bool bUnlock(
false);
1258 if (pTextInputField !=
nullptr)
1268 if (pTextInputField !=
nullptr)
1290 std::unique_ptr<SwInputField> pField(
1299 pField->SetHelp(
maHelp );
1304 return std::unique_ptr<SwField>(pField.release());
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
void InsertSort(std::vector< sal_uInt16 > &rArr, sal_uInt16 nIdx)
bool isNumeric(const OUString &rStr) const
static bool isAsciiNumeric(std::u16string_view rStr)
bool isAlphaNumeric(const OUString &rStr, sal_Int32 nPos) const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
virtual void FieldsToExpand(SwHashTable< HashStr > &rTable, const SetGetExpField &rToThisField, SwRootFrame const &rLayout)=0
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
virtual void FieldsToCalc(SwCalc &rCalc, SwNodeOffset nLastNd, sal_Int32 nLastCnt)=0
tools::Long AdjustY(tools::Long nVertMove)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
SwSbxValue Calculate(const OUString &rStr)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
const SwAttrPool & GetAttrPool() const
Instances of SwFields and those derived from it occur 0 to n times.
virtual void UpdateFields()
virtual OUString GetName() const
Only in derived classes.
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Base class of all fields.
virtual void SetLanguage(LanguageType nLng)
virtual void SetPar1(const OUString &rStr)
bool IsAutomaticLanguage() const
void SetFormat(sal_uInt32 const nSet)
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
virtual OUString GetFieldName() const
get name or content
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
SwFieldType * GetTyp() const
LanguageType GetLanguage() const
Language at field position.
general base class for all free-flowing frames
const SwRect & getFrameArea() const
bool isFrameAreaDefinitionValid() const
Base class of the Writer layout elements.
SwTabFrame * FindTabFrame()
bool IsHeaderFrame() const
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
bool IsFooterFrame() const
bool IsFootnoteFrame() const
SwLayoutFrame * GetUpper()
SwRootFrame * getRootFrame()
SwPageFrame * FindPageFrame()
sal_uInt16 GetPhyPageNum() const
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Overlay, because get-field cannot be changed and therefore does not need to be updated.
SwGetExpFieldType(SwDoc *pDoc)
virtual std::unique_ptr< SwFieldType > Copy() const override
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
virtual std::unique_ptr< SwField > Copy() const override
virtual OUString GetPar2() const override
Change formula.
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
SwGetExpField(SwGetExpFieldType *, const OUString &rFormel, sal_uInt16 nSubType, sal_uLong nFormat)
virtual void SetSubType(sal_uInt16 nType) override
void ChangeExpansion(const SwFrame &, const SwTextField &)
For fields in header/footer/footnotes/flys: Only called by formatting!!
OUString m_sExpandRLHidden
hidden redlines
virtual sal_uInt16 GetSubType() const override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
bool m_bLateInitialization
virtual OUString GetFieldName() const override
get name or content
virtual void SetLanguage(LanguageType nLng) override
set language of the format
double m_fValueRLHidden
SwValueField; hidden redlines.
static sal_Int32 GetReferenceTextPos(const SwFormatField &rFormat, SwDoc &rDoc, sal_Int32 nHint=0)
Find the index of the reference text following the current field.
virtual void SetValue(const double &rVal) override
virtual void SetPar2(const OUString &rStr) override
T should be a subclass of SwHash.
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
const SwContentFrame * GetContentPos(Point &rPoint, const bool bDontLeave, const bool bBodyOnly=false, SwCursorMoveState *pCMS=nullptr, const bool bDefaultExpand=true) const
Finds the closest Content for the SPoint Is used for Pages, Flys and Cells if GetModelPositionForView...
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
const SwTextNode * FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame const *pLayout=nullptr) const
const SwStartNode * StartOfSectionNode() const
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwContentNode * GoNext(SwNodeIndex *) const
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
A page of the document layout.
SwContentFrame * FindLastBodyContent()
Searches the last ContentFrame in BodyText below the page.
SwContentFrame * FindFirstBodyContent()
void GetContentPosition(const Point &rPt, SwPosition &rPos) const
Same as SwLayoutFrame::GetContentPos().
void Pos(const Point &rNew)
The root element of a Writer document layout.
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
bool SeekEntry(const SeqFieldLstElem &rNew, size_t *pPos) const
bool InsertSort(SeqFieldLstElem aNew)
std::vector< SeqFieldLstElem > maData
const OUString & GetDelimiter() const
Number sequence fields chapterwise if required.
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
sal_uInt16 GetType() const
virtual OUString GetName() const override
Only in derived classes.
SwSetExpFieldType(SwDoc *pDoc, OUString aName, sal_uInt16 nType=nsSwGetSetExpType::GSE_EXPR)
void SetType(sal_uInt16 nTyp)
void SetOutlineLvl(sal_uInt8 n)
size_t GetSeqFieldList(SwSeqFieldList &rList, SwRootFrame const *pLayout)
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
void SetChapter(SwSetExpField &rField, const SwNode &rNd, SwRootFrame const *pLayout)
void SetSeqRefNo(SwSetExpField &rField)
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
void SetDelimiter(const OUString &s)
void SetSeqFormat(sal_uLong nFormat)
sal_uLong GetSeqFormat() const
virtual std::unique_ptr< SwFieldType > Copy() const override
void SetFormatField(SwFormatField &rFormatField)
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
pool item to which the SwSetExpField belongs
virtual void SetValue(const double &rVal) override
OUString msExpandRLHidden
hidden redlines
SwSetExpField(SwSetExpFieldType *, const OUString &rFormel, sal_uLong nFormat=0)
virtual OUString GetPar1() const override
Query name only.
SwFormatField * mpFormatField
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
virtual sal_uInt16 GetSubType() const override
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
virtual OUString GetPar2() const override
Query formula.
void SetInputFlag(bool bInp)
sal_uInt16 GetSeqNumber() const
virtual void SetSubType(sal_uInt16 nType) override
virtual OUString GetFieldName() const override
bool IsSequenceField() const
double m_fValueRLHidden
SwValueField; hidden redlines.
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
virtual std::unique_ptr< SwField > Copy() const override
void SetSeqNumber(sal_uInt16 n)
Logical number, sequence fields.
virtual void SetPar2(const OUString &rStr) override
const OUString & GetExpStr(SwRootFrame const *pLayout) const
bool GetInputFlag() const
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
SwTabFrame is one table in the document layout, containing rows (which contain cells).
SwRowFrame * GetFirstNonHeadlineRow() const
const SwTable * GetTable() const
bool IsInHeadline(const SwFrame &rFrame) const
sal_uInt16 GetRowsToRepeat() const
sal_Int32 GetStart() const
SwTextNode & GetTextNode() const
Represents the visualization of a paragraph.
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
void UnlockNotifyContentChange()
bool LockNotifyContentChange()
SwTextNode is a paragraph in the document model.
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote|ExpandMode::HideFieldmarkCommands) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
bool GetParaAttr(SfxItemSet &rSet, sal_Int32 nStt, sal_Int32 nEnd, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true, const bool bMergeIndentValuesOfNumRule=false, SwRootFrame const *pLayout=nullptr) const
Query the attributes of textnode over the range.
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
const OUString & GetText() const
The shared part of a user field.
OUString GetContent(sal_uInt32 nFormat=0) const
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Fields containing values that have to be formatted via number formatter.
void EnableFormat(bool bFormat=true)
virtual void SetLanguage(LanguageType nLng) override
set language of the format
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
virtual double GetValue() const
virtual void SetValue(const double &rVal)
static OUString LocalizeFormula(const SwSetExpField &rField, const OUString &rFormula, bool bQuery)
static void TransmuteLeadToInputField(SwSetExpField &rField)
Convert between SwSetExpField with InputFlag false and InputFlag true.
virtual OUString GetName() const override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
OUString LookString(SwHashTable< HashStr > const &rTable, const OUString &rName)
Look up the Name, if it is present, return its String, otherwise return an empty String.
static SwTextNode * GetFirstTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwContentFrame *pCFrame, Point &rPt)
static sal_Int32 lcl_APIToSubType(const uno::Any &rAny)
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
static sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType)
OUString ReplacePoint(const OUString &rTmpName, bool bWithCommandType)
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
expand numbering
SwFieldTypesEnum
List of FieldTypes at UI.
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
CharClass & GetAppCharClass()
CollatorWrapper & GetAppCaseCollator()
CollatorWrapper & GetAppCollator()
const SwExtendedSubType SUB_CMD
Show command.
const SwExtendedSubType SUB_INVISIBLE
Invisible.
const SwGetSetExpType GSE_SEQ
Sequence.
const SwGetSetExpType GSE_EXPR
Expression.
const SwGetSetExpType GSE_FORMULA
Formula.
const SwGetSetExpType GSE_STRING
String.
static constexpr auto Items
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
Marks a position in the document model.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
void AssignStartIndex(const SwContentNode &rNd)
Set nNode to rNd, and nContent to the beginning of rNd.
sal_Int32 GetContentIndex() const
constexpr sal_uInt8 MAXLEVEL
#define FIELD_PROP_GRABBAG
#define FIELD_PROP_SUBTYPE
#define FIELD_PROP_USHORT1
#define FIELD_PROP_USHORT2
#define FIELD_PROP_FORMAT
#define FIELD_PROP_DOUBLE
#define FIELD_PROP_SHORT1