27#include <unonames.hxx>
36#include <editeng/editeng.hxx>
42#include <com/sun/star/beans/PropertyAttribute.hpp>
43#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
44#include <com/sun/star/text/TextContentAnchorType.hpp>
45#include <com/sun/star/text/WrapTextMode.hpp>
46#include <com/sun/star/text/FilenameDisplayFormat.hpp>
47#include <com/sun/star/text/textfield/Type.hpp>
86 return &aURLPropertySet_Impl;
97 static SfxItemPropertySet aHeaderFieldPropertySet_Impl( aHeaderFieldPropertyMap_Impl );
98 return &aHeaderFieldPropertySet_Impl;
111 return &aFileFieldPropertySet_Impl;
118 case text::FilenameDisplayFormat::FULL:
return SvxFileFormat::PathFull;
119 case text::FilenameDisplayFormat::PATH:
return SvxFileFormat::PathOnly;
120 case text::FilenameDisplayFormat::NAME:
return SvxFileFormat::NameOnly;
122 return SvxFileFormat::NameAndExt;
130 case SvxFileFormat::NameAndExt:
return text::FilenameDisplayFormat::NAME_AND_EXT;
131 case SvxFileFormat::PathFull:
return text::FilenameDisplayFormat::FULL;
132 case SvxFileFormat::PathOnly:
return text::FilenameDisplayFormat::PATH;
134 return text::FilenameDisplayFormat::NAME;
148 SC_UNO_COLLECT_COUNT,
149 SC_UNO_COLLECT_FINDINDEX,
150 SC_UNO_COLLECT_FINDPOS
160 ScUnoCollectMode
eMode;
161 sal_uInt16 nFieldCount;
162 sal_Int32 mnFieldType;
163 std::unique_ptr<SvxFieldData>
167 sal_uInt16 nFieldIndex;
173 std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle )
override;
175 sal_uInt16 CountFields();
179 sal_Int32 GetFieldPar()
const {
return nFieldPar; }
180 sal_Int32 GetFieldPos()
const {
return nFieldPos; }
187 ,
eMode(SC_UNO_COLLECT_NONE)
195 SetTextCurrentDefaults( *pData );
198OUString ScUnoEditEngine::CalcFieldValue(
const SvxFieldItem& rField,
199 sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle )
202 if (eMode != SC_UNO_COLLECT_NONE)
207 if (mnFieldType == text::textfield::Type::UNSPECIFIED || pFieldData->
GetClassId() == mnFieldType)
209 if ( eMode == SC_UNO_COLLECT_FINDINDEX && !pFound && nFieldCount == nFieldIndex )
211 pFound = pFieldData->
Clone();
215 if ( eMode == SC_UNO_COLLECT_FINDPOS && !pFound &&
216 nPara == nFieldPar && nPos == nFieldPos )
218 pFound = pFieldData->
Clone();
219 nFieldIndex = nFieldCount;
228sal_uInt16 ScUnoEditEngine::CountFields()
230 eMode = SC_UNO_COLLECT_COUNT;
231 mnFieldType = text::textfield::Type::UNSPECIFIED;
234 eMode = SC_UNO_COLLECT_NONE;
239SvxFieldData* ScUnoEditEngine::FindByIndex(sal_uInt16 nIndex)
241 eMode = SC_UNO_COLLECT_FINDINDEX;
243 mnFieldType = text::textfield::Type::UNSPECIFIED;
246 eMode = SC_UNO_COLLECT_NONE;
251SvxFieldData* ScUnoEditEngine::FindByPos(sal_Int32 nPar, sal_Int32 nPos, sal_Int32
nType)
253 eMode = SC_UNO_COLLECT_FINDPOS;
259 mnFieldType = text::textfield::Type::UNSPECIFIED;
260 eMode = SC_UNO_COLLECT_NONE;
266 uno::Reference<text::XTextRange> xContent,
268 mxContent(
std::move(xContent)),
291 std::unique_lock g(
aMutex);
295 aEvent.Source.set(getXWeak());
306 else if ( rHint.
GetId() == SfxHintId::Dying )
320 ScUnoEditEngine aTempEngine(pEditEngine);
323 return uno::Reference<text::XTextField>();
325 sal_Int32 nPar = aTempEngine.GetFieldPar();
326 sal_Int32
nPos = aTempEngine.GetFieldPos();
330 uno::Reference<text::XTextField> xRet(
341 ScUnoEditEngine aTempEngine(pEditEngine);
343 return aTempEngine.CountFields();
351 throw lang::IndexOutOfBoundsException();
374 const uno::Reference<container::XContainerListener>& )
376 OSL_FAIL(
"not implemented");
380 const uno::Reference<container::XContainerListener>& )
382 OSL_FAIL(
"not implemented");
388 std::unique_lock g(
aMutex);
393 aEvent.Source.set(uno::Reference< util::XRefreshable >(
this));
402 std::unique_lock g(
aMutex);
411 std::unique_lock g(
aMutex);
429 std::unique_lock g(
aMutex);
433 aEvent.Source = getXWeak();
444 ScUnoEditEngine aTempEngine(pEditEngine);
451 uno::Reference<text::XTextRange> xTextRange;
453 if (!xContentObj.is())
454 throw uno::RuntimeException(
"");
457 uno::Reference<text::XText> xText;
462 xText = pContentObj->getLeftText();
465 xText = pContentObj->getCenterText();
468 xText = pContentObj->getRightText();
474 sal_Int32 nPar = aTempEngine.GetFieldPar();
475 sal_Int32
nPos = aTempEngine.GetFieldPos();
478 sal_Int32 eRealType =
pData->GetClassId();
479 uno::Reference<text::XTextField> xRet(
480 new ScEditFieldObj(xTextRange, std::make_unique<ScHeaderFooterEditSource>(
mrData), eRealType, aSelection));
490 ScUnoEditEngine aTempEngine(pEditEngine);
491 return aTempEngine.CountFields();
499 throw lang::IndexOutOfBoundsException();
522 const uno::Reference<container::XContainerListener>& )
524 OSL_FAIL(
"not implemented");
528 const uno::Reference<container::XContainerListener>& )
530 OSL_FAIL(
"not implemented");
536 std::unique_lock g(
aMutex);
541 aEvent.Source.set(uno::Reference< util::XRefreshable >(
this));
550 std::unique_lock g(
aMutex);
559 std::unique_lock g(
aMutex);
573 case text::textfield::Type::EXTENDED_FILE:
575 new SvxExtFileField(OUString(), SvxFileType::Var, SvxFileFormat::NameAndExt));
577 case text::textfield::Type::PAGE:
580 case text::textfield::Type::PAGES:
586 case text::textfield::Type::TIME:
589 case text::textfield::Type::EXTENDED_TIME:
597 case text::textfield::Type::DOCINFO_TITLE:
600 case text::textfield::Type::URL:
602 new SvxURLField(OUString(), OUString(), SvxURLFormat::AppDefault));
618 ScUnoEditEngine aTempEngine(pEditEngine);
623 OSL_ENSURE(pField,
"setPropertyValue: Field not found");
627 if (pField->
GetClassId() != text::textfield::Type::URL)
635 if (rVal >>= aStrVal)
640 if (rVal >>= aStrVal)
645 if (rVal >>= aStrVal)
649 throw beans::UnknownPropertyException(rName);
660 if (rVal >>= aStrVal)
665 if (rVal >>= aStrVal)
670 if (rVal >>= aStrVal)
674 throw beans::UnknownPropertyException(rName);
687 ScUnoEditEngine aTempEngine(pEditEngine);
692 OSL_ENSURE(pField,
"getPropertyValue: Field not found");
694 throw uno::RuntimeException();
696 if (pField->
GetClassId() != text::textfield::Type::URL)
697 throw uno::RuntimeException();
708 throw beans::UnknownPropertyException(rName);
721 throw beans::UnknownPropertyException(rName);
729 throw beans::UnknownPropertyException(rName);
731 sal_Int16 nIntVal = 0;
732 if (!(rVal >>= nIntVal))
739 ScUnoEditEngine aTempEngine(pEditEngine);
742 OSL_ENSURE(pField,
"setPropertyValueFile: Field not found");
763 throw beans::UnknownPropertyException(rName);
770 ScUnoEditEngine aTempEngine(pEditEngine);
771 pField = aTempEngine.FindByPos(
777 OSL_ENSURE(pField,
"setPropertyValueFile: Field not found");
779 throw uno::RuntimeException();
783 sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
795 ScUnoEditEngine aTempEngine(pEditEngine);
818 p->SetFixDate(aDate);
826 throw beans::UnknownPropertyException(rName);
829 case text::textfield::Type::TIME:
834 throw beans::UnknownPropertyException(rName);
837 case text::textfield::Type::EXTENDED_TIME:
853 p->SetFixTime(aTime);
861 throw beans::UnknownPropertyException(rName);
865 throw beans::UnknownPropertyException(rName);
879 throw beans::UnknownPropertyException(rName);
889 ScUnoEditEngine aTempEngine(pEditEngine);
892 throw uno::RuntimeException();
903 return uno::Any(
p->GetType() == SvxDateType::Fix);
907 Date aD(
p->GetFixDate());
919 return uno::Any(
static_cast<sal_Int32
>(
p->GetFormat()));
922 case text::textfield::Type::TIME:
940 case text::textfield::Type::EXTENDED_TIME:
947 return uno::Any(
p->GetType() == SvxTimeType::Fix);
963 return uno::Any(
static_cast<sal_Int32
>(
p->GetFormat()));
985 throw beans::UnknownPropertyException(rName);
994 ScUnoEditEngine aTempEngine(pEditEngine);
999 OSL_ENSURE(pField,
"setPropertyValue: Field not found");
1010 throw beans::UnknownPropertyException(rName);
1012 sal_Int32 nTab = rVal.get<sal_Int32>();
1024 throw beans::UnknownPropertyException(rName);
1026 sal_Int32 nTab = rVal.get<sal_Int32>();
1031 uno::Reference<text::XTextRange> xContent,
1032 std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType,
const ESelection& rSel) :
1034 mpEditSource(
std::move(pEditSrc)),
1036 meType(
eType), mpContent(
std::move(xContent)), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
1040 case text::textfield::Type::DOCINFO_TITLE:
1043 case text::textfield::Type::EXTENDED_FILE:
1044 pPropSet = lcl_GetFileFieldPropertySet();
1046 case text::textfield::Type::URL:
1047 pPropSet = lcl_GetURLPropertySet();
1050 case text::textfield::Type::TIME:
1051 case text::textfield::Type::EXTENDED_TIME:
1052 pPropSet = getDateTimePropertySet();
1055 pPropSet = lcl_GetHeaderFieldPropertySet();
1063 const uno::Reference<text::XTextRange>& rContent, std::unique_ptr<ScEditSource> pEditSrc,
const ESelection& rSel)
1081 OSL_ENSURE( !
mpEditSource,
"CreateFieldItem with inserted field" );
1117 ScUnoEditEngine aTempEngine(pEditEngine);
1122 OSL_ENSURE(pField,
"getPresentation: Field not found");
1128 case text::textfield::Type::URL:
1130 if (pField->
GetClassId() != text::textfield::Type::URL)
1132 throw uno::RuntimeException();
1149 if (xTextRange.is())
1151 uno::Reference<text::XText> xText(xTextRange->getText());
1154 xText->insertTextContent( xTextRange,
this,
true );
1175 const OUString& aPropertyName,
const uno::Any& aValue )
1186 case text::textfield::Type::URL:
1189 case text::textfield::Type::EXTENDED_FILE:
1193 case text::textfield::Type::TIME:
1194 case text::textfield::Type::EXTENDED_TIME:
1200 case text::textfield::Type::DOCINFO_TITLE:
1202 throw beans::UnknownPropertyException(OUString::number(
meType));
1218 aRet <<= text::TextContentAnchorType_AS_CHARACTER;
1224 uno::Sequence<text::TextContentAnchorType>
aSeq { text::TextContentAnchorType_AS_CHARACTER };
1231 aRet <<= text::WrapTextMode_NONE;
1237 case text::textfield::Type::URL:
1239 case text::textfield::Type::EXTENDED_FILE:
1242 case text::textfield::Type::TIME:
1243 case text::textfield::Type::EXTENDED_TIME:
1245 case text::textfield::Type::DOCINFO_TITLE:
1247 throw beans::UnknownPropertyException(OUString::number(
meType));
1257 return "ScEditFieldObj";
1267 return {
"com.sun.star.text.TextField",
1268 "com.sun.star.text.TextContent"};
1275 uno::Sequence<uno::Type>
1286 return css::uno::Sequence<sal_Int8>();
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor, std::optional< FontLineStyle > &rFldLineStyle)
std::unique_ptr< EditTextObject > CreateTextObject()
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
virtual ~ScCellFieldsObj() override
virtual void SAL_CALL refresh() override
css::uno::Reference< css::text::XTextField > GetObjectByIndex_Impl(sal_Int32 Index) const
comphelper::OInterfaceContainerHelper4< css::util::XRefreshListener > maRefreshListeners
List of refresh listeners.
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
std::unique_ptr< ScEditSource > mpEditSource
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
ScCellFieldsObj(css::uno::Reference< css::text::XTextRange > xContent, ScDocShell *pDocSh, const ScAddress &rPos)
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
css::uno::Reference< css::text::XTextRange > mxContent
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
virtual sal_Int32 SAL_CALL getCount() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
std::mutex aMutex
mutex to lock the InterfaceContainerHelper
const ScDocument & GetDocument() const
void AddUnoObject(SfxListener &rObject)
void RemoveUnoObject(SfxListener &rObject)
std::unique_ptr< ScEditSource > mpEditSource
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
const SfxItemPropertySet * pPropSet
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Any getPropertyValueDateTime(const OUString &rName)
void InitDoc(const css::uno::Reference< css::text::XTextRange > &rContent, std::unique_ptr< ScEditSource > pEditSrc, const ESelection &rSel)
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
css::uno::Reference< css::text::XTextRange > mpContent
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
css::util::DateTime maDateTime
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
std::unique_ptr< SvxFieldData > mpData
void setPropertyValueDateTime(const OUString &rName, const css::uno::Any &rVal)
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
css::uno::Any getPropertyValueURL(const OUString &rName)
css::uno::Any getPropertyValueFile(const OUString &rName)
void setPropertyValueSheet(const OUString &rName, const css::uno::Any &rVal)
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void setPropertyValueURL(const OUString &rName, const css::uno::Any &rVal)
SvxFieldItem CreateFieldItem()
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual ~ScEditFieldObj() override
void setPropertyValueFile(const OUString &rName, const css::uno::Any &rVal)
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
SvxFileFormat GetFormat() const
void SetFormat(SvxFileFormat eFmt)
virtual std::unique_ptr< SvxFieldData > Clone() const
virtual sal_Int32 GetClassId() const
const SvxFieldData * GetField() const
virtual void QuickInsertText(const OUString &rText, const ESelection &rSel)=0
const OUString & GetRepresentation() const
void SetTargetFrame(const OUString &rFrm)
const OUString & GetTargetFrame() const
void SetURL(const OUString &rURL)
const OUString & GetURL() const
void SetRepresentation(const OUString &rRep)
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) const
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
css::uno::Type const & get()
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
HashMap_OWString_Interface aMap
constexpr OUStringLiteral SC_UNONAME_TABLEPOS
constexpr OUStringLiteral SC_UNONAME_NUMFMT
constexpr OUStringLiteral SC_UNONAME_FILEFORM
constexpr OUStringLiteral SC_UNONAME_REPR
constexpr OUStringLiteral SC_UNONAME_ANCHOR
constexpr OUStringLiteral SC_UNONAME_ANCTYPES
constexpr OUStringLiteral SC_UNONAME_ANCTYPE
constexpr OUStringLiteral SC_UNONAME_URL
constexpr OUStringLiteral SC_UNONAME_TARGET
constexpr OUStringLiteral SC_UNONAME_ISDATE
constexpr OUStringLiteral SC_UNONAME_TEXTFIELD_TYPE
constexpr OUStringLiteral SC_UNONAME_ISFIXED
constexpr OUStringLiteral SC_UNONAME_TEXTWRAP
constexpr OUStringLiteral SC_UNONAME_DATETIME