34 #include <osl/diagnose.h>
36 #include <com/sun/star/text/textfield/Type.hpp>
37 #include <com/sun/star/document/XDocumentProperties.hpp>
42 #include <document.hxx>
47 #include <compiler.hxx>
54 const Point& rCellPos,
57 pDoc(pDocument),nCol(nX),nRow(nY),nTab(nZ),
58 aCellPos(rCellPos),pDev(pDevice),
59 nPPTX(nScaleX),
nPPTY(nScaleY),aZoomX(rX),aZoomY(rY),
60 bInPrintTwips(bPrintTwips) {}
65 OUString aRet = rOld.replaceAll(
"_",
"") +
74 OUStringBuffer aRet( nParCount * 80 );
75 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
79 aRet.append( rEngine.
GetText( nPar ));
81 return aRet.makeStringAndClear();
87 OUStringBuffer aRet( nParCount * 80 );
88 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
92 aRet.append( rEdit.
GetText( nPar ));
94 return aRet.makeStringAndClear();
117 osl::MutexGuard aGuard( aMutex);
138 SvxURLField aUrlField( rURL, rText, SvxURLFormat::AppDefault);
149 static const struct {
150 sal_uInt16 nAttrType;
151 sal_uInt16 nCharType;
163 if ( rSet.
GetItemState(AttrTypeMap[
i].nAttrType,
false, &pItem) == SfxItemState::SET )
170 std::unique_ptr<EditTextObject> pNew;
176 const EEControlBits nSpellControl = EEControlBits::ONLINESPELLING | EEControlBits::ALLOWBIGOBJS;
177 bool bNewControl = ( (nControl & nSpellControl) != nSpellControl );
200 case text::textfield::Type::URL:
207 case SvxURLFormat::AppDefault:
208 case SvxURLFormat::Repr:
211 case SvxURLFormat::Url:
222 *ppTextColor =
SC_MOD()->GetColorConfig().GetColorValue(eEntry).nColor;
225 case text::textfield::Type::EXTENDED_TIME:
244 case text::textfield::Type::DOCINFO_TITLE:
265 if (pDoc && pDoc->
GetName(nTab, aName))
320 sal_uInt16 nIndent = 0;
322 SvxCellHorJustify::Left )
327 aStartPos.AdjustX(nDifX * nLayoutSign );
343 if ( eJust == SvxCellVerJustify::Top ||
344 ( bForceToTop && (
SC_MOD()->GetInputOptions().GetTextWysiwyg() || bAsianVertical ) ) )
367 if ( nTextHeight > nCellY + nTopMargin || bForceToTop )
371 if ( eJust == SvxCellVerJustify::Center )
372 nDifY = nTopMargin + ( nCellY - nTextHeight ) / 2;
374 nDifY = nCellY - nTextHeight + nTopMargin;
378 aStartPos.AdjustY(nDifY );
382 aStartPos.AdjustX( -(nCellX - 2) );
389 bNeedsObject( false ),
390 bNeedsCellAttr( false )
406 if (eState == SfxItemState::DONTCARE)
408 else if (eState == SfxItemState::SET)
418 if ( *pItem != rEditDefaults.
Get(
nId) )
423 if ( *pItem != rEditDefaults.
Get(
nId) )
432 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
438 if ( eConvState == SfxItemState::DONTCARE || eConvState == SfxItemState::SET )
448 bool bDeleteEnginePoolP )
450 pEnginePool( pEnginePoolP ),
451 pDefaults( nullptr ),
452 bDeleteEnginePool( bDeleteEnginePoolP ),
453 bDeleteDefaults( false )
459 pEnginePool( rOrg.bDeleteEnginePool ? rOrg.pEnginePool->
Clone() : rOrg.pEnginePool ),
460 pDefaults( nullptr ),
461 bDeleteEnginePool( rOrg.bDeleteEnginePool ),
462 bDeleteDefaults( false )
475 bool bDeleteEnginePoolP )
514 for ( sal_Int32 j=0; j<nPara; j++ )
580 std::unique_ptr<SfxItemSet> pSet )
616 std::unique_ptr<SfxItemSet> pSet )
632 for ( sal_Int32 j=0; j<nPara; j++ )
639 std::unique_ptr<SfxItemSet> pCharItems;
644 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
651 if ( rParaAttribs.
GetItemState( nWhich,
false, &pParaItem ) == SfxItemState::SET )
658 pCharItems->Put( *pParaItem );
665 std::vector<sal_Int32> aPortions;
671 sal_Int32 nStart = 0;
672 for (
const sal_Int32 nEnd : aPortions )
682 if ( aNewCharAttrs.
GetItemState( nWhich,
false, &pItem ) == SfxItemState::SET &&
683 *pItem != aOldCharAttrs.
Get(nWhich) )
688 if ( aNewCharAttrs.
Count() )
697 if ( rParaAttribs.
Count() )
720 if ( pTextObjectPool )
728 auto pEditDefaults = std::make_unique<SfxItemSet>(
GetEmptyItemSet() );
741 OSL_ENSURE( nNo,
"0 is an invalid number !!" );
744 const sal_Int32 coDiff =
'Z' -
'A' +1;
748 nCalc = nNo % coDiff;
751 aStr = OUStringChar(
sal_Unicode(
'a' - 1 + nCalc) ) + aStr;
752 nNo = sal::static_int_cast<sal_Int32>( nNo - nCalc );
761 OUString aTmpStr(
'0');
766 case css::style::NumberingType::CHARS_UPPER_LETTER:
767 case css::style::NumberingType::CHARS_LOWER_LETTER:
771 case css::style::NumberingType::ROMAN_UPPER:
772 case css::style::NumberingType::ROMAN_LOWER:
779 case css::style::NumberingType::NUMBER_NONE:
788 aTmpStr = OUString::number(nNo);
792 if( css::style::NumberingType::CHARS_UPPER_LETTER == eType )
793 aTmpStr = aTmpStr.toAsciiUpperCase();
811 sal_Int32 , sal_Int32 ,
812 std::optional<Color>& , std::optional<Color>& )
822 case text::textfield::Type::PAGE:
825 case text::textfield::Type::PAGES:
828 case text::textfield::Type::EXTENDED_TIME:
829 case text::textfield::Type::TIME:
833 case text::textfield::Type::DOCINFO_TITLE:
836 case text::textfield::Type::EXTENDED_FILE:
838 switch (static_cast<const SvxExtFileField*>(pFieldData)->GetFormat())
840 case SvxFileFormat::PathFull :
865 SfxItemPool* pTextObjectPool,
bool bDeleteEnginePoolP) :
867 mpDoc(pDoc), bExecuteURL(true)
869 if ( pTextObjectPool )
875 sal_Int32 , sal_Int32 ,
876 std::optional<Color>& rTxtColor, std::optional<Color>& )
900 if ( pTextObjectPool )
tools::Rectangle GetEditArea(const ScPatternAttr *pPattern, bool bForceToTop)
std::unique_ptr< SfxItemSet > pEditAttrs
virtual ~ScEditEngineDefaulter() override
SCCOL GetColMerge() const
OUString GetText(LineEnd eEnd=LINEEND_LF) const
EEControlBits GetControlWord() const
void SetDefaults(const SfxItemSet &rDefaults, bool bRememberCopy=true)
Creates a copy of SfxItemSet if bRememberCopy set.
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
const SfxItemSet & GetEmptyItemSet() const
void SetUpdateMode(bool bUpdate, bool bRestoring=false)
constexpr TypedWhichId< SfxBoolItem > ATTR_VERTICAL_ASIAN(137)
ScEditEngineDefaulter(SfxItemPool *pEnginePool, bool bDeleteEnginePool=false)
bDeleteEnginePool: Engine becomes the owner of the pool and deletes it on destruction ...
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor) override
static void OpenURL(const OUString &rURL, const OUString &rTarget, bool bIgnoreSettings=false)
Open the specified URL.
const SfxItemSet & GetItemSet() const
const MapMode & GetMapMode() const
ScFieldEditEngine(ScDocument *pDoc, SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool=nullptr, bool bDeleteEnginePool=false)
sal_Int16 GetRightMargin() const
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
static std::unique_ptr< EditTextObject > CreateURLObjectFromURL(ScDocument &rDoc, const OUString &rURL, const OUString &rText)
bool HasOnlineSpellErrors() const
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
constexpr TypedWhichId< ScIndentItem > ATTR_INDENT(131)
SC_DLLPUBLIC ScDocumentPool * GetPool()
virtual ~ScEnginePoolHelper()
ScNoteEditEngine(SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool)
void SetText(const OUString &rStr)
void SetControlWord(EEControlBits nWord)
void Init(const ScPatternAttr &rPattern)
ScEditAttrTester(ScEditEngineDefaulter *pEng)
static OUString lcl_GetDelimitedString(const EditEngine &rEngine, const char c)
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
OUString GetText(sal_Int32 nPara) const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
#define SAL_N_ELEMENTS(arr)
bool IsUndoEnabled() const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool RemoveCharAttribs(sal_uInt16 nWhich)
static void GetFont(vcl::Font &rFont, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Static helper function to fill a font object from the passed item set.
bool HasField(sal_Int32 nType=css::text::textfield::Type::UNSPECIFIED) const
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
static ScFieldEditEngine & GetStaticFieldEditEngine()
A static instance of ScFieldEditEngine not capable of resolving document specific fields...
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetDefaultItem(const SfxPoolItem &rItem)
Set the item in the default ItemSet which is created if it doesn't exist yet.
static INetURLHistory * GetOrCreate()
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
sal_uInt32 GetTextLen() const
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
sal_uLong GetScaledRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale, const sal_uLong *pnMaxHeight=nullptr) const
void RepeatDefaults()
Re-apply existing defaults if set, same as in SetText, but without EnableUndo/SetUpdateMode.
std::unique_ptr< EditTextObject > CreateTextObject()
constexpr sal_uInt16 EE_CHAR_START(EE_PARA_END+1)
OUString GetFormatted(SvNumberFormatter &rFormatter, LanguageType eLanguage) const
const OUString & GetRepresentation() const
constexpr TypedWhichId< ScVerticalStackCell > ATTR_STACKED(134)
constexpr sal_uInt16 EE_CHAR_END(EE_CHAR_START+32)
static OUString lcl_GetNumStr(sal_Int32 nNo, SvxNumType eType)
static SC_DLLPUBLIC LanguageType eLnge
void SetDefaultLanguage(LanguageType eLang)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
sal_Int16 GetBottomMargin() const
static LanguageType GetEditDefaultLanguage()
sal_Int32 GetParagraphCount() const
static OUString GetCellFieldValue(const SvxFieldData &rFieldData, const ScDocument *pDoc, std::optional< Color > *ppTextColor)
ScEditUtil(ScDocument *pDocument, SCCOL nX, SCROW nY, SCTAB nZ, const Point &rCellPos, OutputDevice *pDevice, double nScaleX, double nScaleY, const Fraction &rX, const Fraction &rY, bool bPrintTwips=false)
const OUString & GetURL() const
virtual sal_Int32 GetClassId() const
bool QueryUrl(const INetURLObject &rUrl)
sal_Int32 GetParagraphCount() const
static SC_DLLPUBLIC const LocaleDataWrapper * getLocaleDataPtr()
constexpr sal_uInt16 EE_FEATURE_NOTCONV(EE_FEATURE_LINEBR+1)
OUString getDate(const Date &rDate) const
void SetRefMapMode(const MapMode &rMapMode)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static void Free(SfxItemPool *pPool)
tools::Long const nTopMargin
SfxItemPool * pEnginePool
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
void SetFont(const vcl::Font &rNewFont)
bool GetUpdateMode() const
virtual void FieldClicked(const SvxFieldItem &rField) override
tools::Long GetTextHeight() const
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
void EnableUndo(bool bEnable)
void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList)
static OUString ModifyDelimiters(const OUString &rOld)
sal_Int16 GetLeftMargin() const
const SfxItemSet & GetDefaults()
Returns the stored defaults, used to find non-default character attributes.
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
ScEnginePoolHelper(SfxItemPool *pEnginePool, bool bDeleteEnginePool)
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
tools::Long GetNeededSize(SCCOL nCol, SCROW nRow, SCTAB nTab, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bWidth, bool bTotalSize=false, bool bInPrintTwips=false)
Reference< XComponentContext > getProcessComponentContext()
#define EE_TEXTPOS_MAX_COUNT
ScTabEditEngine(ScDocument *pDoc)
static OUString lcl_GetCharStr(sal_Int32 nNo)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
static OUString GetSpaceDelimitedString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by spaces.
static void RemoveCharAttribs(EditTextObject &rEditText, const ScPatternAttr &rAttr)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
const sal_uInt16 * GetRanges() const
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet)
SfxObjectShell * GetDocumentShell() const
static std::unique_ptr< EditTextObject > Clone(const EditTextObject &rSrc, ScDocument &rDestDoc)
VclPtr< OutputDevice > pDev
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
SCROW GetRowMerge() const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
#define EE_PARA_MAX_COUNT
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
void SetTextNewDefaults(const EditTextObject &rTextObject, const SfxItemSet &rDefaults, bool bRememberCopy=true)
Current defaults are not applied, new defaults are applied.
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
void RemoveParaAttribs()
Paragraph attributes that are not defaults are copied to character attributes and all paragraph attri...
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
void SetEditTextObjectPool(SfxItemPool *pPool)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_CHAR_XMLATTRIBS(EE_CHAR_START+28)
constexpr TypedWhichId< SvxMarginItem > ATTR_MARGIN(143)
const SvxFieldData * GetField() const
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
SvxURLFormat GetFormat() const
sal_Int16 GetTopMargin() const